/* ============================================================
   STAFF SIGN-IN SCREENS
   ============================================================
   Login, forgot password, reset password and two-step verification
   (app/view/auth/*.php). Linked by AuthController via addCSS(), so it
   loads on these screens only. Behaviour lives in /js/auth.js; the
   submit itself is form.js's job.

   Colours and fonts come from the theme tokens (--clr-*, --font-*),
   so the screens follow Admin Settings → Theme like every other
   section — nothing here names a brand colour.
   ============================================================ */

.auth-screen{
  --auth-ink:    var(--clr-bark, #0d1b2a);
  --auth-body:   var(--clr-earth, #334155);
  --auth-muted:  var(--clr-stone, #64748b);
  --auth-faint:  var(--clr-mist, #94a3b8);
  --auth-line:   #dde3ea;
  --auth-field:  #f8fafc;
  --auth-focus:  var(--clr-accent, #1582c7);
  --auth-danger: #c0362c;
  --auth-ok:     #15803d;
  --auth-radius: 10px;

  padding:clamp(1.75rem, 6vw, 4.5rem) 1rem;
  background:var(--clr-linen, #f8fafc);
  background:
    radial-gradient(1100px 480px at 12% -12%, color-mix(in srgb, var(--clr-accent) 9%, transparent), transparent 62%),
    radial-gradient(900px 420px at 100% 112%, color-mix(in srgb, var(--clr-secondary) 8%, transparent), transparent 62%),
    var(--clr-linen, #f8fafc);
  color:var(--auth-body);
  font-family:var(--font-sans);
}

/* ── Frame: one card, two panels on desktop ──────────────── */
.auth-frame{
  display:grid;
  grid-template-columns:1fr;
  max-width:28.5rem;
  margin:0 auto;
  background:#fff;
  border:1px solid rgba(15,23,42,.06);
  border-radius:20px;
  box-shadow:
    0 1px 2px rgba(15,23,42,.04),
    0 14px 34px -10px rgba(15,23,42,.14),
    0 36px 70px -30px rgba(15,23,42,.22);
  overflow:hidden;
  animation:auth-rise .45s var(--ease-out, ease-out) both;
}
@media (min-width:992px){
  .auth-frame{
    max-width:61rem;
    grid-template-columns:minmax(0, 5fr) minmax(0, 6fr);
    min-height:36rem;
  }
}
@keyframes auth-rise{
  from{opacity:0;transform:translateY(10px)}
  to{opacity:1;transform:none}
}

/* ── Brand panel (desktop only) ──────────────────────────── */
.auth-aside{display:none}
@media (min-width:992px){
  .auth-aside{
    position:relative;
    isolation:isolate;
    display:flex;
    flex-direction:column;
    gap:2.5rem;
    padding:2.75rem 2.75rem 2.25rem;
    color:var(--clr-on-primary, #fff);
    background:linear-gradient(155deg, var(--clr-primary) 0%, var(--clr-primary-lt) 100%);
  }
}
.auth-aside::before{
  /* Two soft glows in the theme's accent/secondary colours. */
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background:
    radial-gradient(520px 320px at 115% -5%, color-mix(in srgb, var(--clr-accent) 55%, transparent), transparent 70%),
    radial-gradient(420px 280px at -15% 105%, color-mix(in srgb, var(--clr-secondary) 40%, transparent), transparent 70%);
  opacity:.5;
}
.auth-aside::after{
  /* Faint grid texture, fading out towards the bottom. Drawn in
     currentColor so it works on light and dark primaries alike. */
  content:"";
  position:absolute;
  inset:0;
  z-index:-1;
  background-image:
    linear-gradient(currentColor 1px, transparent 1px),
    linear-gradient(90deg, currentColor 1px, transparent 1px);
  background-size:34px 34px;
  opacity:.045;
  -webkit-mask-image:linear-gradient(180deg, #000 0%, transparent 70%);
          mask-image:linear-gradient(180deg, #000 0%, transparent 70%);
}
.auth-eyebrow{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  align-self:flex-start;
  padding:.4rem .8rem;
  border-radius:var(--r-full, 50rem);
  font-size:.72rem;
  font-weight:600;
  letter-spacing:.08em;
  text-transform:uppercase;
  background:color-mix(in srgb, currentColor 10%, transparent);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, currentColor 18%, transparent);
}
.auth-eyebrow__dot{
  width:.45rem;
  height:.45rem;
  border-radius:50%;
  background:var(--clr-secondary, #5cb338);
  box-shadow:0 0 0 3px color-mix(in srgb, var(--clr-secondary) 30%, transparent);
}
.auth-aside__title{
  margin:0 0 .85rem;
  font-family:var(--font-serif);
  font-size:2rem;
  font-weight:700;
  line-height:1.15;
  letter-spacing:-.02em;
}
.auth-aside__text{
  margin:0;
  max-width:24rem;
  font-size:1rem;
  line-height:1.6;
  opacity:.78;
}
.auth-assurances{
  list-style:none;
  margin:auto 0 0;
  padding:0;
  display:grid;
  gap:1.1rem;
}
.auth-assurances li{
  display:flex;
  align-items:flex-start;
  gap:.9rem;
  font-size:.875rem;
  line-height:1.45;
}
.auth-assurances__icon{
  flex:none;
  display:grid;
  place-items:center;
  width:2.25rem;
  height:2.25rem;
  border-radius:9px;
  font-size:.85rem;
  background:color-mix(in srgb, currentColor 11%, transparent);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, currentColor 14%, transparent);
}
.auth-assurances strong{
  display:block;
  font-weight:600;
}
.auth-assurances__sub{opacity:.72}
.auth-aside__foot{
  margin:0;
  padding-top:1.5rem;
  border-top:1px solid color-mix(in srgb, currentColor 14%, transparent);
  font-size:.78rem;
  opacity:.6;
}

/* ── Form panel ──────────────────────────────────────────── */
.auth-main{
  display:flex;
  align-items:center;
  justify-content:center;
  padding:2.25rem 1.5rem 2rem;
}
@media (min-width:576px){
  .auth-main{padding:3rem 3rem 2.5rem}
}
.auth-form-wrap{
  width:100%;
  max-width:23rem;
}
.auth-badge{
  display:inline-grid;
  place-items:center;
  width:3rem;
  height:3rem;
  margin-bottom:1.35rem;
  border-radius:12px;
  font-size:1.1rem;
  color:var(--clr-primary);
  background:color-mix(in srgb, var(--clr-primary) 7%, #fff);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--clr-primary) 14%, transparent);
}
.auth-title{
  margin:0 0 .45rem;
  font-family:var(--font-serif);
  font-size:1.75rem;
  font-weight:700;
  line-height:1.2;
  letter-spacing:-.02em;
  color:var(--auth-ink);
}
.auth-lede{
  margin:0 0 1.85rem;
  font-size:.95rem;
  line-height:1.6;
  color:var(--auth-muted);
}
.auth-account{
  display:flex;
  align-items:center;
  gap:.6rem;
  margin:-.75rem 0 1.6rem;
  padding:.6rem .85rem;
  border-radius:var(--auth-radius);
  font-size:.875rem;
  font-weight:600;
  color:var(--auth-ink);
  background:#f1f5f9;
}
.auth-account i{color:var(--auth-muted);font-size:1rem}
.auth-account__email{min-width:0;overflow-wrap:anywhere}

/* ── Fields ──────────────────────────────────────────────── */
.auth-field{margin-bottom:1.15rem}
.auth-label{
  display:block;
  margin-bottom:.45rem;
  font-size:.85rem;
  font-weight:600;
  color:var(--auth-ink);
}
.auth-input{position:relative}
.auth-input__icon{
  position:absolute;
  top:50%;
  left:.95rem;
  transform:translateY(-50%);
  font-size:.875rem;
  color:var(--auth-faint);
  pointer-events:none;
  transition:color .15s ease;
}
.auth-control{
  display:block;
  width:100%;
  height:3rem;
  padding:0 1rem 0 2.65rem;
  font-size:.95rem;
  color:var(--auth-ink);
  background:var(--auth-field);
  border:1px solid var(--auth-line);
  border-radius:var(--auth-radius);
  transition:border-color .15s ease, box-shadow .15s ease, background-color .15s ease;
  -webkit-appearance:none;
          appearance:none;
}
.auth-control::placeholder{color:#a3afbf}
.auth-control:hover{border-color:#c5cfdb}
.auth-control:focus{
  outline:none;
  background:#fff;
  border-color:var(--auth-focus);
  box-shadow:0 0 0 4px color-mix(in srgb, var(--auth-focus) 15%, transparent);
}
.auth-input:focus-within .auth-input__icon{color:var(--auth-focus)}
.auth-control:-webkit-autofill,
.auth-control:-webkit-autofill:hover,
.auth-control:-webkit-autofill:focus{
  -webkit-text-fill-color:var(--auth-ink);
  -webkit-box-shadow:0 0 0 100px #fff inset;
  transition:background-color 9999s ease-out 0s;
}
/* Room for the icon buttons sitting inside the right edge. */
.auth-input--1 .auth-control{padding-right:3.1rem}
.auth-input--2 .auth-control{padding-right:5.5rem}
.auth-input__actions{
  position:absolute;
  top:50%;
  right:.35rem;
  transform:translateY(-50%);
  display:flex;
  gap:.1rem;
}
.auth-icon-btn{
  display:grid;
  place-items:center;
  width:2.35rem;
  height:2.35rem;
  padding:0;
  border:0;
  border-radius:8px;
  font-size:.875rem;
  color:var(--auth-muted);
  background:transparent;
  transition:background-color .15s ease, color .15s ease;
}
.auth-icon-btn:hover{
  color:var(--auth-ink);
  background:rgba(15,23,42,.06);
}
.auth-icon-btn:focus-visible{
  outline:2px solid var(--auth-focus);
  outline-offset:1px;
}

/* form.js adds .error to a field the server rejected and fills its
   .error-message; style.css hides that message until then. */
.auth-control.error{
  background:#fff;
  border-color:var(--auth-danger);
  box-shadow:0 0 0 4px color-mix(in srgb, var(--auth-danger) 12%, transparent);
}
.auth-screen .error-message{
  margin-top:.45rem;
  padding-left:0;
  font-size:.8rem;
  color:var(--auth-danger);
}

.auth-hint{
  display:flex;
  align-items:center;
  gap:.45rem;
  margin:.5rem 0 0;
  font-size:.8rem;
  color:var(--auth-muted);
}
.auth-hint[hidden]{display:none}
.auth-hint--warn{color:#a15c07}
.auth-hint--ok{color:var(--auth-ok)}
.auth-hint--bad{color:var(--auth-danger)}

/* ── Two-step code ───────────────────────────────────────── */
.auth-control.auth-code{
  height:3.85rem;
  padding:0 1rem;
  text-align:center;
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:1.55rem;
  font-weight:600;
  letter-spacing:.42em;
  text-indent:.42em; /* balances the trailing letter-space so digits sit centred */
}
.auth-control.auth-code::placeholder{color:#cdd5df}

/* ── Remember me / forgot row ────────────────────────────── */
.auth-row{
  display:flex;
  flex-wrap:wrap;
  align-items:center;
  justify-content:space-between;
  gap:.75rem 1rem;
  margin:.35rem 0 1.6rem;
  font-size:.875rem;
}
.auth-check{
  display:inline-flex;
  align-items:center;
  gap:.6rem;
  margin:0;
  color:var(--auth-body);
  cursor:pointer;
  user-select:none;
}
.auth-check input{
  width:1.05rem;
  height:1.05rem;
  margin:0;
  accent-color:var(--clr-primary);
  cursor:pointer;
}

/* ── Links and buttons ───────────────────────────────────── */
.auth-link{
  font-weight:600;
  color:var(--clr-primary);
  text-decoration:none;
}
.auth-link:hover,
.auth-link:focus-visible{
  text-decoration:underline;
  text-underline-offset:3px;
}
.auth-submit{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  gap:.6rem;
  width:100%;
  height:3rem;
  padding:0 1.25rem;
  border:0;
  border-radius:var(--auth-radius);
  font-size:.975rem;
  font-weight:600;
  letter-spacing:.005em;
  color:var(--clr-on-primary, #fff);
  background:var(--clr-primary);
  box-shadow:0 1px 2px rgba(15,23,42,.16), inset 0 1px 0 rgba(255,255,255,.08);
  transition:background-color .15s ease, box-shadow .15s ease, transform .15s ease;
}
a.auth-submit{text-decoration:none}
a.auth-submit:hover,
a.auth-submit:focus-visible{color:var(--clr-on-primary, #fff)}
.auth-submit:hover{
  background:var(--clr-primary-lt, var(--clr-primary));
  box-shadow:0 8px 20px -8px color-mix(in srgb, var(--clr-primary) 70%, transparent);
}
.auth-submit:active{transform:translateY(1px)}
.auth-submit:focus-visible{
  outline:none;
  box-shadow:0 0 0 4px color-mix(in srgb, var(--auth-focus) 30%, transparent);
}
.auth-submit:disabled{opacity:.78;cursor:progress}
.auth-submit i{transition:transform .15s ease}
.auth-submit:hover i{transform:translateX(3px)}

.auth-link-btn{
  display:inline-flex;
  align-items:center;
  gap:.5rem;
  padding:.35rem .5rem;
  border:0;
  border-radius:8px;
  font-size:.875rem;
  font-weight:600;
  color:var(--clr-primary);
  background:transparent;
}
.auth-link-btn:hover{background:color-mix(in srgb, var(--clr-primary) 6%, transparent)}
.auth-link-btn:focus-visible{outline:2px solid var(--auth-focus);outline-offset:1px}

.auth-divider{
  display:flex;
  align-items:center;
  gap:.85rem;
  margin:1.5rem 0 1rem;
  font-size:.72rem;
  font-weight:600;
  letter-spacing:.1em;
  text-transform:uppercase;
  color:var(--auth-faint);
}
.auth-divider::before,
.auth-divider::after{
  content:"";
  flex:1;
  height:1px;
  background:var(--auth-line);
}

.auth-note{
  display:flex;
  align-items:flex-start;
  gap:.65rem;
  margin:1.25rem 0 0;
  padding:.85rem 1rem;
  border-radius:var(--auth-radius);
  font-size:.825rem;
  line-height:1.5;
  color:var(--auth-body);
  background:#f1f5f9;
}
.auth-note i{margin-top:.2rem;color:var(--auth-muted)}

.auth-foot{
  margin-top:1.85rem;
  padding-top:1.25rem;
  border-top:1px solid #edf1f5;
  text-align:center;
  font-size:.875rem;
}
.auth-back{
  display:inline-flex;
  align-items:center;
  gap:.55rem;
  font-weight:500;
  color:var(--auth-muted);
  text-decoration:none;
  transition:color .15s ease;
}
.auth-back:hover,
.auth-back:focus-visible{color:var(--auth-ink)}
.auth-back i{transition:transform .15s ease}
.auth-back:hover i{transform:translateX(-3px)}

/* ── New-password strength ───────────────────────────────── */
.auth-meter{
  display:grid;
  grid-template-columns:repeat(4, 1fr);
  gap:.3rem;
  margin-top:.65rem;
}
.auth-meter span{
  height:4px;
  border-radius:2px;
  background:#e3e8ee;
  transition:background-color .2s ease;
}
.auth-meter[data-score="1"] span:nth-child(-n+1){background:#dc4c41}
.auth-meter[data-score="2"] span:nth-child(-n+2){background:#e0a106}
.auth-meter[data-score="3"] span:nth-child(-n+3){background:#3fa34d}
.auth-meter[data-score="4"] span{background:#15803d}
.auth-meter-label{
  display:flex;
  justify-content:space-between;
  margin-top:.4rem;
  font-size:.775rem;
  color:var(--auth-muted);
}
.auth-meter-label strong{font-weight:600;color:var(--auth-ink)}
.auth-rules{
  display:grid;
  gap:.35rem;
  margin:.8rem 0 0;
  padding:0;
  list-style:none;
  font-size:.8rem;
  color:var(--auth-muted);
}
.auth-rules li{
  display:flex;
  align-items:center;
  gap:.5rem;
  transition:color .15s ease;
}
.auth-rules i{width:1rem;text-align:center;font-size:.8rem}
.auth-rules li.is-met{color:var(--auth-ok)}

.auth-generated{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:.75rem;
  margin-top:.75rem;
  padding:.65rem .75rem .65rem .9rem;
  border-radius:var(--auth-radius);
  font-size:.8rem;
  line-height:1.45;
  color:var(--auth-ok);
  background:color-mix(in srgb, var(--auth-ok) 8%, #fff);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--auth-ok) 20%, transparent);
}
.auth-generated[hidden]{display:none}
.auth-generated .auth-link-btn{flex:none;color:var(--auth-ok);font-size:.8rem}

/* ── Two-step setup (first sign-in) ──────────────────────── */
/* One wide panel, no brand aside: the QR code and its instructions need
   the room, and must be the first thing on screen at every width. */
.auth-frame--setup{max-width:54rem}
@media (min-width:992px){
  .auth-frame--setup{grid-template-columns:1fr;min-height:0}
}
.auth-setup{padding:2rem 1.25rem 1.75rem}
@media (min-width:576px){
  .auth-setup{padding:2.75rem 3rem 2.25rem}
}
.auth-setup__head .auth-lede{max-width:38rem;margin-bottom:1.5rem}
/* Phones: a compact header so the QR code and step 1 show without scrolling. */
@media (max-width:575.98px){
  .auth-setup__head .auth-badge{display:none}
  .auth-setup__head .auth-title{font-size:1.4rem}
  .auth-setup__head .auth-lede{font-size:.875rem;margin-bottom:1rem}
  .auth-step{padding:1.15rem 0}
  .auth-step__title{font-size:1rem;margin-bottom:1rem}
  .auth-qr{padding:1rem}
  .auth-qr__img{max-width:190px}
}

.auth-step{
  padding:1.5rem 0;
  border-top:1px solid #edf1f5;
}
.auth-step__title{
  display:flex;
  align-items:center;
  gap:.75rem;
  margin:0 0 1.25rem;
  font-family:var(--font-serif);
  font-size:1.1rem;
  font-weight:700;
  line-height:1.3;
  color:var(--auth-ink);
}
.auth-step__num{
  flex:none;
  display:grid;
  place-items:center;
  width:1.85rem;
  height:1.85rem;
  border-radius:50%;
  font-family:var(--font-sans);
  font-size:.85rem;
  color:var(--clr-on-primary, #fff);
  background:var(--clr-primary);
}

.auth-setup__grid{
  display:grid;
  gap:1.5rem;
}
@media (min-width:768px){
  .auth-setup__grid{
    grid-template-columns:18.5rem minmax(0, 1fr);
    gap:2.25rem;
    align-items:start;
  }
}

.auth-qr{
  display:flex;
  flex-direction:column;
  align-items:center;
  gap:.75rem;
  padding:1.25rem;
  border:1px solid var(--auth-line);
  border-radius:14px;
  background:#fff;
  text-align:center;
}
.auth-qr__img{
  display:block;
  width:100%;
  max-width:220px;
  height:auto;
  border-radius:8px;
  image-rendering:pixelated;
}
.auth-qr__caption{
  margin:0;
  font-size:.8rem;
  line-height:1.45;
  color:var(--auth-muted);
}
.auth-qr__caption i{margin-right:.4rem}
.auth-qr .auth-link-btn{display:inline-block;line-height:1.45}

/* Only where the visitor is probably holding the phone they would scan
   with: touch-first, no hover. Desktops never see an otpauth:// button
   that would do nothing there. */
.auth-touch-only{display:none}
@media (hover:none) and (pointer:coarse){
  .auth-touch-only{display:block}
}
.auth-phone-box{
  width:100%;
  padding:.9rem;
  border-radius:var(--auth-radius);
  background:#f1f5f9;
  text-align:left;
  font-size:.85rem;
  line-height:1.5;
}
.auth-phone-box p{margin:0 0 .75rem}
.auth-phone-box .auth-submit{
  height:auto;
  min-height:3rem;
  padding:.7rem 1rem;
  text-align:center;
  line-height:1.3;
}

.auth-key{
  width:100%;
  text-align:left;
}
.auth-key__help{
  margin:0 0 .6rem;
  font-size:.8rem;
  line-height:1.5;
  color:var(--auth-muted);
}
.auth-key__row{
  display:flex;
  align-items:center;
  gap:.35rem;
  margin-bottom:.6rem;
  padding:.35rem .35rem .35rem .75rem;
  border:1px solid var(--auth-line);
  border-radius:var(--auth-radius);
  background:var(--auth-field);
}
.auth-key__code{
  flex:1;
  min-width:0;
  font-family:ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size:.9rem;
  font-weight:600;
  letter-spacing:.04em;
  color:var(--auth-ink);
  overflow-wrap:anywhere;
}

.auth-howto{
  counter-reset:howto;
  display:grid;
  gap:1.15rem;
  margin:0;
  padding:0;
  list-style:none;
  font-size:.9rem;
  line-height:1.55;
  color:var(--auth-body);
}
.auth-howto li{
  counter-increment:howto;
  position:relative;
  padding-left:2.4rem;
}
.auth-howto li::before{
  content:counter(howto);
  position:absolute;
  top:0;
  left:0;
  display:grid;
  place-items:center;
  width:1.6rem;
  height:1.6rem;
  border-radius:50%;
  font-size:.78rem;
  font-weight:700;
  color:var(--clr-primary);
  background:color-mix(in srgb, var(--clr-primary) 8%, #fff);
  box-shadow:inset 0 0 0 1px color-mix(in srgb, var(--clr-primary) 16%, transparent);
}
.auth-howto strong{color:var(--auth-ink)}
.auth-howto__lead{display:block}
.auth-kbd{
  display:inline-grid;
  place-items:center;
  min-width:1.4rem;
  height:1.4rem;
  padding:0 .3rem;
  border-radius:6px;
  font-weight:700;
  line-height:1;
  background:#eef2f6;
  box-shadow:inset 0 -1px 0 #d5dde6;
}
.auth-stores{
  display:flex;
  flex-wrap:wrap;
  gap:.5rem;
  margin-top:.7rem;
}
.auth-store{
  display:inline-flex;
  align-items:center;
  gap:.6rem;
  padding:.45rem .95rem .45rem .8rem;
  border-radius:9px;
  font-size:.9rem;
  font-weight:600;
  line-height:1.15;
  color:#fff;
  background:#111827;
  text-decoration:none;
  transition:background-color .15s ease, transform .15s ease;
}
.auth-store:hover,
.auth-store:focus-visible{color:#fff;background:#000;transform:translateY(-1px)}
.auth-store i{font-size:1.3rem}
.auth-store small{
  display:block;
  font-size:.65rem;
  font-weight:500;
  opacity:.75;
}

.auth-verify{
  display:grid;
  gap:.85rem;
}
@media (min-width:576px){
  .auth-verify{
    grid-template-columns:minmax(0, 17rem) auto;
    align-items:start;
  }
  .auth-verify .auth-submit{height:3.85rem;padding:0 1.75rem}
}

@media (prefers-reduced-motion:reduce){
  .auth-frame{animation:none}
  .auth-screen *{transition:none !important}
}
