/* Auth - login, signup, forgot, reset, verify, setup (web/screens/auth.js) - 4.0, T5-015.

   Load order (web/index.html): tokens -> components -> shell -> per-screen, this
   file among the five 4.0 screens that load last - so a rule here may override
   shell.css and components.css (`.landing-card`, `.field`, `.btn`, `.error-text`),
   never the other way round. Every var() used here is defined in tokens.css
   (tests/test_web.py).

   One card per screen, centred in the public pane and at most 420px wide. The
   shared `.landing-card` is a centred-text, 520px card whose `form` is a flex
   ROW (the follow pane's tag field beside its button); an auth form is a
   COLUMN of labelled fields, so the form rules below out-rank it. Phone first:
   the pane gives the card 288px at a 320px viewport, the fields fill what the
   card's padding leaves, and nothing here has a width that can push the page
   sideways (the card breaks long words: `overflow-wrap` comes from
   .landing-card). */

.auth-card {
  max-width: 420px; margin: clamp(4px, 5vh, 48px) auto 0;
  text-align: left; padding: 28px 24px;
}
@media (max-width: 420px) {
  .auth-card { padding: 24px 20px; }
}

.auth-title {
  font-family: var(--display); font-weight: 800; font-size: 26px;
  letter-spacing: -0.02em; line-height: 1.1; margin: 0 0 6px;
}
.auth-card p { margin: 10px 0 0; }
.auth-card .auth-lede { color: var(--ink-2); font-size: 14px; line-height: 1.5; }
.auth-card .auth-wait { color: var(--ink-3); font-size: 14px; }
.auth-card .auth-lede.good { color: var(--good); font-weight: 700; }
/* `.landing-card p` and `.auth-card .auth-lede` set the muted ink; an error
   paragraph keeps the app-wide red. */
.auth-card p.error-text { color: var(--bad); margin-top: 10px; }
/* A result sentence the screen moves focus to (so a screen reader reads it: the
   forgot confirmation, a dead link, the verify outcome) is not a control - no
   ring around it, the same call components.css makes for the sheet panel. */
.auth-lede:focus, .auth-lede:focus-visible,
.auth-confirm:focus, .auth-confirm:focus-visible { outline: none; }

/* The expired-session notice above the sign-in form. */
.auth-notice {
  margin-top: 14px; padding: 10px 12px; border-radius: 12px;
  background: var(--s2); border: 1px solid var(--line-2);
  color: var(--ink-2); font-size: 13px; line-height: 1.45;
}

/* ---------- the form: a column of labelled fields ---------- */

.auth-card .auth-form { flex-direction: column; align-items: stretch; gap: 14px; margin-top: 16px; }
.auth-field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.auth-label { font-size: 12px; font-weight: 800; letter-spacing: .02em; color: var(--ink-2); }
.auth-card .auth-form .field, .auth-card .auth-input { flex: none; width: 100%; min-width: 0; }
/* The focus ring is the app-wide :focus-visible outline (components.css); a
   refused value turns the border red under it. */
.auth-input[aria-invalid="true"] { border-color: var(--bad); }
.auth-input.locked { color: var(--ink-2); background: var(--s1); border-style: dashed; }

.auth-card .auth-hint { color: var(--ink-3); font-size: 12px; line-height: 1.4; margin: 0; }
.auth-field > .auth-hint { margin-top: 0; }

/* An error line is always in the DOM (it is a live region), so an empty one
   must take no room. */
.auth-card .auth-error { margin: 0; font-size: 13px; line-height: 1.4; }
.auth-card .auth-error:empty { display: block; height: 0; overflow: hidden; }

/* The form's own status line: the 401 sentence, a lockout countdown, a network
   failure. Empty it takes no room; with text it carries the existing error
   colour (.error-text) or the muted "You can try again.". */
.auth-status { font-size: 13px; line-height: 1.4; margin: 0; }
.auth-status:empty { height: 0; overflow: hidden; }
.auth-status.error-text { margin-top: 0; }
.auth-status.muted { color: var(--ink-3); }

/* ---------- password field with its show/hide toggle ---------- */

.auth-pw { position: relative; display: flex; min-width: 0; }
.auth-pw .field { padding-right: 68px; }
.auth-pw-toggle {
  position: absolute; top: 4px; bottom: 4px; right: 4px;
  min-width: 56px; padding: 0 10px; border-radius: 9px;
  background: var(--s3); color: var(--ink-2);
  font-size: 12px; font-weight: 800;
}
.auth-pw-toggle:hover { color: var(--ink); }
.auth-pw-toggle:focus-visible { outline: 2px solid var(--gold); outline-offset: 1px; }

/* ---------- the terms checkbox ---------- */

.auth-check {
  display: flex; align-items: flex-start; gap: 12px;
  min-height: 44px; padding: 4px 0;
  color: var(--ink-2); font-size: 14px; line-height: 1.45; cursor: pointer;
}
.auth-check input[type="checkbox"] {
  flex: none; width: 22px; height: 22px; margin: 1px 0 0;
  accent-color: var(--gold); cursor: pointer;
}
.auth-check-text { min-width: 0; }
.auth-check-text a { text-decoration: underline; text-underline-offset: 2px; }

/* ---------- links and buttons ---------- */

.auth-aside { display: flex; justify-content: flex-end; margin-top: -6px; font-size: 13px; }
.auth-link, .auth-alt a, .auth-aside a { text-decoration: underline; text-underline-offset: 2px; }
.auth-link:focus-visible, .auth-alt a:focus-visible, .auth-aside a:focus-visible,
.auth-check-text a:focus-visible { outline: 2px solid var(--gold); outline-offset: 2px; border-radius: 4px; }
.auth-card .auth-alt { margin-top: 18px; text-align: center; color: var(--ink-3); font-size: 13px; }

.auth-submit { width: 100%; }
a.btn.auth-submit { text-decoration: none; margin-top: 16px; }
.auth-form .auth-submit { margin-top: 2px; }
.auth-submit:disabled, .auth-retry:disabled {
  opacity: .55; cursor: not-allowed;
}
.auth-submit.busy { cursor: progress; }
.auth-card .auth-retry { margin-top: 14px; width: 100%; }
.auth-card .auth-fail { margin-top: 10px; font-size: 14px; }

.auth-actions { display: flex; flex-direction: column; gap: 10px; margin-top: 16px; }
.auth-actions a.btn.auth-submit, .auth-actions .btn.auth-submit { margin-top: 0; }
.auth-actions .auth-hint { text-align: center; }

@media (prefers-reduced-motion: no-preference) {
  .auth-input, .auth-pw-toggle { transition: border-color .12s ease; }
}
