/* Auth shell and forms: Welcome, Log in, Create account, Forgot password, and the
   #/connect page's frame (design §14.4, docs/monarch-reference/welcome-and-login.md).
   Organic tokens only. The shell is left-aligned and asymmetric: content in the left
   column, a washed photograph in the right one, hidden below 900px.
   C's .app.is-bare gives #page no padding, so .auth owns its gutters. */

.auth {
  --auth-muted: color-mix(in srgb, var(--color-text) 70%, transparent);
  min-height: 100vh;
  display: flex; flex-direction: column; gap: var(--space-4);
  padding: var(--space-4) var(--space-6) var(--space-6);
}

/* ── top row: mark + wordmark, one ghost link ─────────────────────────── */
.auth-top { display: flex; align-items: center; justify-content: space-between; gap: var(--space-3); min-height: 44px; }
.auth-brand { display: inline-flex; align-items: center; gap: var(--space-2); }
.auth-mark {
  width: 38px; height: 38px; flex: none; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--color-accent); color: var(--color-bg);
}
.auth-wordmark {
  font-family: var(--font-heading); font-weight: var(--font-heading-weight);
  font-size: 22px; line-height: 1; letter-spacing: -0.01em;
}
.auth-top-link { display: flex; align-items: center; }
.auth-top-btn { padding-inline: var(--space-4); min-height: 40px; }

/* Accent on body-size text uses the deep step (contrast). */
.auth .btn-ghost { color: var(--color-accent-700); }

/* ── split: content left, washed photo right ──────────────────────────── */
.auth-split {
  flex: 1; display: grid; gap: var(--space-8);
  grid-template-columns: minmax(420px, 45fr) minmax(0, 55fr);
}
.auth.no-photo .auth-split { grid-template-columns: minmax(0, 1fr); }
.auth-col {
  min-width: 0; display: flex; flex-direction: column; justify-content: center; gap: var(--space-6);
  padding: var(--space-6) var(--space-4) var(--space-8) var(--space-6);
}
.auth-content { width: 100%; max-width: 440px; }
.auth-content:has(> .connect-page) { max-width: 600px; }
.auth-photo {
  position: sticky; top: var(--space-4); align-self: start;
  height: calc(100vh - var(--space-8) * 3); min-height: 420px;
  border-radius: var(--radius-lg); overflow: hidden; background: var(--color-surface);
}
.auth-photo img { width: 100%; height: 100%; object-fit: cover; }

/* ── progress (Step 2 of 2) ───────────────────────────────────────────── */
.auth-progress { display: flex; align-items: center; gap: var(--space-3); width: 100%; max-width: 440px; }
.auth-progress-track { flex: 1; display: flex; gap: var(--space-1); }
.auth-progress-seg { flex: 1; height: 8px; border-radius: 999px; background: var(--color-neutral-300); }
.auth-progress-seg.is-done { background: var(--color-accent-2-500); }
.auth-progress-seg.is-current { background: var(--color-accent-2-300); }
.auth-progress-label { font-size: 13px; color: var(--auth-muted); white-space: nowrap; }

/* ── type ─────────────────────────────────────────────────────────────── */
.auth-title { font-size: 34px; margin: 0 0 var(--space-2); }
/* A page's h1 takes focus (tabindex=-1) when the part of the page around it changes (§21.7). */
.auth-title:focus { outline: none; }
.auth-title:focus-visible { outline: 2px solid var(--color-accent); outline-offset: 2px; border-radius: var(--radius-sm); }
.auth-title-xl { font-size: 50px; line-height: 1.04; margin-bottom: var(--space-3); max-width: 12ch; }
.auth-lede { font-size: 17px; line-height: 1.5; color: var(--auth-muted); margin: 0 0 var(--space-4); max-width: 40ch; }
.auth-small { font-size: 14px; }
.auth code {
  font-family: var(--font-body); font-weight: 600; font-size: 0.92em;
  padding: 0 var(--space-1); border-radius: var(--radius-sm);
  background: color-mix(in srgb, var(--color-text) 7%, transparent);
}
.auth-link {
  color: var(--color-accent-700); font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: from-font;
  border-radius: var(--radius-sm);
}
.auth-link:hover { color: var(--color-accent-800); }
.auth-link:active { color: var(--color-accent-900); }
.auth-alt { margin: var(--space-3) 0 0; font-size: 14px; color: var(--auth-muted); }

/* ── welcome ──────────────────────────────────────────────────────────── */
.auth-welcome { display: flex; flex-direction: column; }
.auth-doors { display: flex; flex-direction: column; gap: var(--space-2); max-width: 360px; }
.auth-door { min-height: 48px; font-size: 16px; margin-top: 0; }
.auth-footnote {
  display: flex; align-items: flex-start; gap: var(--space-2);
  margin: var(--space-6) 0 0; font-size: 13px; line-height: 1.5; color: var(--auth-muted); max-width: 44ch;
}
.auth-footnote-icon { flex: none; margin-top: 0.15em; color: var(--color-accent-2-700); }

/* ── cards (log in, forgot password) ──────────────────────────────────── */
.auth-card { padding: var(--space-6); gap: var(--space-3); }
.auth-card p { margin: 0; }
.auth-card .input { background: var(--color-bg); }
.auth-card .auth-title { margin: 0; }
.auth-card-head { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: var(--space-2) var(--space-3); margin-bottom: var(--space-1); }
.auth-remember {
  display: inline-flex; align-items: center; gap: var(--space-2);
  font-size: 14px; color: var(--auth-muted);
}
.auth-remember label { cursor: pointer; }
.auth-card .auth-footnote { margin-top: var(--space-2); }
.auth-card .auth-door { margin-top: var(--space-2); }

/* ── notice slot ──────────────────────────────────────────────────────── */
.auth-notice-slot:empty { display: none; }
.auth-notice-slot { margin-bottom: var(--space-1); }
.auth-signup .auth-notice-slot { margin-bottom: var(--space-4); }
.auth-notice {
  display: flex; align-items: flex-start; gap: var(--space-2);
  padding: var(--space-3) var(--space-4); border-radius: var(--radius-lg);
  font-size: 14px; line-height: 1.45;
}
.auth-notice-text { margin: 0; }
.auth-notice-icon { flex: none; margin-top: 0.1em; }
.auth-notice-sage { background: var(--color-accent-2-100); color: var(--color-accent-2-800); }
.auth-notice-sand { background: var(--color-neutral-100); color: var(--color-neutral-800); }
.auth-notice-terracotta { background: var(--color-accent-100); color: var(--color-accent-800); }

/* ── fields ───────────────────────────────────────────────────────────── */
.auth-form { display: flex; flex-direction: column; gap: var(--space-4); margin: 0; }
.auth-field { display: flex; flex-direction: column; min-width: 0; }
.auth-label-row { display: flex; align-items: baseline; justify-content: space-between; gap: var(--space-2); margin-bottom: var(--space-1); }
.auth-label-row label { font-size: 13px; font-weight: 600; color: color-mix(in srgb, var(--color-text) 78%, transparent); }
.auth-forgot { font-size: 13px; }
.auth .input { min-height: 46px; font-size: 15px; padding-inline: var(--space-4); }
.auth-field.is-invalid .input { border-color: var(--color-accent); }
.auth-field.is-invalid .input:focus-visible { border-color: var(--color-accent); }
.auth-field-err { margin: var(--space-1) 0 0 var(--space-4); font-size: 13px; color: var(--color-accent-700); }
.auth-field-err[hidden] { display: none; }

/* password show / hide inside the pill */
.auth-pw { position: relative; }
.auth-pw .input { padding-right: calc(var(--space-8) + var(--space-4)); }
.auth-pw-toggle {
  position: absolute; top: 50%; right: var(--space-1); transform: translateY(-50%);
  width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  color: color-mix(in srgb, var(--color-text) 65%, transparent);
}
.auth-pw-toggle:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); color: var(--color-text); }
.auth-pw-toggle:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }
.auth-pw-toggle:disabled { opacity: 0.45; cursor: not-allowed; }
.auth-pw-toggle .auth-pw-hide { display: none; }
.auth-pw-toggle[aria-pressed='true'] .auth-pw-show { display: none; }
.auth-pw-toggle[aria-pressed='true'] .auth-pw-hide { display: block; }

/* live password checklist: neutral circle → sage check */
.auth-rules { list-style: none; margin: var(--space-3) 0 0 var(--space-2); padding: 0; display: flex; flex-direction: column; gap: var(--space-1); font-size: 14px; }
.auth-rule { display: flex; align-items: center; gap: var(--space-2); color: var(--auth-muted); transition: color 0.15s; }
.auth-rule-icon { display: inline-grid; flex: none; }
.auth-rule-icon > * { grid-area: 1 / 1; }
.auth-rule .auth-rule-off { color: var(--color-neutral-500); }
.auth-rule .auth-rule-on { display: none; color: var(--color-accent-2-700); }
.auth-rule.is-met { color: var(--color-accent-2-700); }
.auth-rule.is-met .auth-rule-off { display: none; }
.auth-rule.is-met .auth-rule-on { display: block; }

/* submit: while busy a spinner sits before the label, which reads "Logging in…" and so on
   (the label is the button's own text, so its name always matches what it shows) */
.auth-submit { min-height: 48px; font-size: 16px; margin-top: var(--space-1); gap: var(--space-2); }
.auth-submit .auth-spinner { display: none; }
.auth-form.is-busy .auth-submit .auth-spinner { display: block; animation: auth-spin 0.9s linear infinite; }
.auth-form.is-busy .auth-submit:disabled { opacity: 1; cursor: progress; }
@keyframes auth-spin { to { transform: rotate(360deg); } }

/* ── forgot password: the command box ─────────────────────────────────── */
.auth-cmd {
  display: flex; align-items: center; gap: var(--space-2);
  padding: var(--space-1) var(--space-1) var(--space-1) var(--space-4);
  border-radius: var(--radius-lg); background: var(--color-bg);
}
.auth-cmd code.auth-cmd-text {
  flex: 1; min-width: 0; white-space: normal; overflow-wrap: anywhere;
  padding: var(--space-2) 0; background: none; font-size: 14px; line-height: 1.4;
}
.auth-muted { color: var(--auth-muted); }
.auth-cmd-copy {
  flex: none; width: 38px; height: 38px; display: grid; place-items: center;
  border: 0; border-radius: 50%; background: transparent; cursor: pointer;
  color: color-mix(in srgb, var(--color-text) 70%, transparent);
}
.auth-cmd-copy:hover { background: color-mix(in srgb, var(--color-accent) 10%, transparent); color: var(--color-text); }
.auth-cmd-copy:active { background: color-mix(in srgb, var(--color-accent) 18%, transparent); }

/* screen-reader-only text */
.auth-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── phones and narrow windows ────────────────────────────────────────── */
@media (max-width: 900px) {
  .auth { padding: var(--space-4); gap: var(--space-2); }
  .auth-split { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .auth-photo { display: none; }
  .auth-col { justify-content: flex-start; padding: var(--space-6) 0 var(--space-8); }
  .auth-content { max-width: 560px; }
}
@media (max-width: 480px) {
  .auth-title { font-size: 28px; }
  .auth-title-xl { font-size: 38px; }
  .auth-lede { font-size: 16px; }
  .auth-card { padding: var(--space-4); }
  .auth-doors { max-width: none; }
  .auth-wordmark { font-size: 20px; }
}
@media (prefers-reduced-motion: reduce) {
  .auth-form.is-busy .auth-submit .auth-spinner { animation-duration: 2.4s; }
  .auth-rule { transition: none; }
}
