/* Sign-in and registration pages. Reuses the tokens and .key-input/.btn
 * classes from styles.css; only the layout and states specific to these
 * forms live here. */

.auth {
  display: flex;
  justify-content: center;
  padding: clamp(32px, 8vw, 80px) 0 clamp(48px, 10vw, 96px);
}

.auth-card {
  width: 100%;
  max-width: 440px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: clamp(22px, 5vw, 36px);
}

.auth-card h1 {
  font-size: clamp(1.6rem, 4vw, 2rem);
  margin-bottom: 8px;
}

.auth-lede {
  margin-bottom: 26px;
  color: var(--text-muted);
}

.auth-field {
  margin-bottom: 18px;
}

/* Account fields are not key entry: undo the monospace/tracking of .key-input. */
.auth .key-input {
  font-family: var(--font-sans);
  letter-spacing: normal;
}

.auth-hint {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--text-muted);
}

.auth-show {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 10px;
  font-size: 0.85rem;
  color: var(--text-muted);
  cursor: pointer;
}

.auth-show input {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.auth-show input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-error {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--danger);
  border-radius: var(--radius);
  background: var(--danger-soft);
  color: var(--text);
  font-size: 0.9rem;
  overflow-wrap: anywhere;
}

.auth-error[hidden] {
  display: none;
}

.auth-success {
  margin-bottom: 18px;
  padding: 12px 14px;
  border: 1px solid var(--accent-3);
  border-radius: var(--radius);
  background: var(--accent-soft);
  color: var(--text);
  font-size: 0.9rem;
}

.auth-success[hidden] {
  display: none;
}

.btn-block {
  width: 100%;
}

.auth-alt {
  margin-top: 22px;
  text-align: center;
  font-size: 0.92rem;
}

.auth-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 0 2.5rem;
  color: var(--text-muted);
  font-size: 0.9rem;
}

.auth-footer .wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem 1.5rem;
}

.auth-footer a {
  color: var(--text-muted);
}

.auth-footer a:hover,
.auth-footer a:focus-visible {
  color: var(--accent);
}

/* Email verification step. Injected after the credentials form by /js/auth.js,
 * so it only ever exists on the two auth pages. */
.auth-step[hidden],
#authForm[hidden] {
  display: none;
}

.auth .auth-code {
  text-align: center;
  letter-spacing: 0.38em;
  text-indent: 0.38em; /* keeps the digits optically centred despite tracking */
  font-family: var(--font-mono, ui-monospace, SFMono-Regular, Menlo, monospace);
  font-variant-numeric: tabular-nums;
  font-size: 1.25rem;
}

/* A link that performs an action (resend) must stay a button for keyboard and
 * screen-reader users; only its looks are borrowed from an anchor. */
.auth-link {
  -webkit-appearance: none;
  appearance: none;
  background: none;
  border: 0;
  padding: 0;
  font: inherit;
  color: var(--accent);
  cursor: pointer;
  text-decoration: underline;
}

.auth-link:hover:not(:disabled) {
  color: var(--text);
}

.auth-link:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
  border-radius: 4px;
}

.auth-link:disabled {
  color: var(--text-muted);
  cursor: default;
  text-decoration: none;
}

@media (max-width: 640px) {
  .auth {
    padding-top: 24px;
  }

  .auth .auth-code {
    letter-spacing: 0.28em;
    text-indent: 0.28em;
  }
}

/* ========================================================================== */
/* Registration layout: the form card plus a supporting panel.                */
/* The card comes FIRST in the document — it is the reason the page exists —   */
/* and is placed in the right-hand column on wide screens with explicit grid   */
/* positions, so the visual order never contradicts the reading order.         */
/* ========================================================================== */

.auth-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
  gap: clamp(28px, 5vw, 64px);
  align-items: start;
  width: 100%;
  max-width: 1000px;
}

.auth-split > .auth-card {
  grid-column: 2;
  grid-row: 1;
  max-width: none;
}

.auth-split > .auth-aside {
  grid-column: 1;
  grid-row: 1;
  padding-top: clamp(4px, 2vw, 22px);
}

.auth-eyebrow {
  margin-bottom: 10px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.auth-aside h2 {
  font-size: clamp(1.5rem, 3.4vw, 2.1rem);
  line-height: 1.2;
  margin-bottom: 22px;
  max-width: 22ch;
}

.auth-benefits {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 18px;
}

.auth-benefits li {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  color: var(--text-muted);
  font-size: 0.95rem;
  line-height: 1.5;
}

.auth-benefits strong {
  color: var(--text);
  font-weight: 600;
}

.auth-benefits svg {
  width: 22px;
  height: 22px;
  margin-top: 1px;
  color: var(--accent);
  flex: none;
}

.auth-trust {
  margin-top: 26px;
  padding-top: 20px;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
  max-width: 44ch;
}

/* Label row that carries a secondary action, e.g. "Forgot password?". */
.auth-field-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
}

.auth-aside-link {
  font-size: 0.85rem;
  white-space: nowrap;
}

.auth-fineprint {
  margin-top: 16px;
  font-size: 0.78rem;
  line-height: 1.5;
  color: var(--text-muted);
  text-align: center;
}

.auth-error-inline {
  margin-top: 8px;
  font-size: 0.82rem;
  color: var(--danger);
}

.auth-error-inline[hidden] {
  display: none;
}

/* ------------------------------ strength meter ---------------------------- */
/* Mirrors lib/validate.js as a hint only; the server is the authority. */

.pw-meter {
  margin-top: 12px;
}

.pw-meter-track {
  display: flex;
  gap: 6px;
}

.pw-meter-bar {
  flex: 1 1 0;
  height: 5px;
  border-radius: 999px;
  background: var(--border);
  transition: background-color 0.18s ease;
}

.pw-meter[data-score="1"] .pw-meter-bar.is-on {
  background: var(--danger);
}

.pw-meter[data-score="2"] .pw-meter-bar.is-on {
  background: var(--warning, #f0b429);
}

.pw-meter[data-score="3"] .pw-meter-bar.is-on {
  background: var(--accent);
}

.pw-meter[data-score="4"] .pw-meter-bar.is-on {
  background: var(--accent-3, var(--accent));
}

.pw-meter-label {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pw-rules {
  list-style: none;
  margin: 12px 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px 16px;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.pw-rules li {
  display: flex;
  align-items: center;
  gap: 8px;
}

.pw-rules li::before {
  content: "";
  width: 12px;
  height: 12px;
  flex: none;
  border: 1px solid currentColor;
  border-radius: 50%;
  opacity: 0.6;
}

.pw-rules li.is-met {
  color: var(--text);
}

.pw-rules li.is-met::before {
  border-color: var(--accent-3, var(--accent));
  background: var(--accent-3, var(--accent));
  opacity: 1;
}

/* ------------------------ "keep me signed in" box ------------------------- */
/* A plain checkbox with a two-line label: the explanation matters here, since
 * the choice is about whether the session survives closing the browser. */

.auth-remember {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 18px 0 20px;
  cursor: pointer;
}

.auth-remember input[type="checkbox"] {
  flex: 0 0 auto;
  width: 18px;
  height: 18px;
  margin-top: 2px;
  accent-color: var(--accent);
  cursor: pointer;
}

.auth-remember input[type="checkbox"]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.auth-remember-text {
  display: block;
  min-width: 0;
  font-size: 0.9rem;
  line-height: 1.35;
  color: var(--text);
  overflow-wrap: anywhere;
}

.auth-remember-note {
  display: block;
  margin-top: 4px;
  font-size: 0.78rem;
  line-height: 1.45;
  color: var(--text-muted);
}

@media (max-width: 640px) {
  .auth-remember {
    margin: 16px 0 18px;
  }

  .auth-remember-note {
    font-size: 0.75rem;
  }
}

/* ------------------------- "show password" switch ------------------------- */
/* Still a real checkbox: only its painting changes, so the label, keyboard
 * behaviour and /js/auth.js binding are untouched. */

.auth .auth-show input[type="checkbox"] {
  -webkit-appearance: none;
  appearance: none;
  position: relative;
  width: 36px;
  height: 20px;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--surface);
  transition: background-color 0.18s ease, border-color 0.18s ease;
}

.auth .auth-show input[type="checkbox"]::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.18s ease, background-color 0.18s ease;
}

.auth .auth-show input[type="checkbox"]:checked {
  background: var(--accent-soft);
  border-color: var(--accent);
}

.auth .auth-show input[type="checkbox"]:checked::after {
  transform: translateX(16px);
  background: var(--accent);
}

@media (max-width: 900px) {
  .auth-split {
    grid-template-columns: minmax(0, 1fr);
    max-width: 480px;
  }

  .auth-split > .auth-card {
    grid-column: 1;
    grid-row: 1;
  }

  .auth-split > .auth-aside {
    grid-column: 1;
    grid-row: 2;
  }
}

@media (max-width: 420px) {
  .pw-rules {
    grid-template-columns: minmax(0, 1fr);
  }
}

@media (prefers-reduced-motion: reduce) {
  .pw-meter-bar,
  .auth .auth-show input[type="checkbox"],
  .auth .auth-show input[type="checkbox"]::after {
    transition: none;
  }
}