/* ==========================================================================
   Sign-in and sign-up screens (/login, /start).
   The screens load tokens.css, base.css and components.css first, so every
   value here comes from the design system: one type family, the 4pt grid,
   the monochrome surface ramp and the shared button states.
   ========================================================================== */

[hidden] { display: none !important; }
html { min-width: 280px; scroll-padding-top: var(--ml-sp-6); }

body.ml-auth {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  background: var(--ml-bg);
  color: var(--ml-text);
  font-family: var(--ml-font);
  font-size: var(--ml-fs-3);
  line-height: var(--ml-lh-body);
}

/* skip link: out of sight until a keyboard user reaches it */
.auth-skip {
  position: fixed;
  inset-block-start: calc(var(--ml-sp-16) * -2);
  inset-inline-start: var(--ml-sp-4);
  z-index: var(--ml-z-toast);
  background: var(--ml-surface);
  box-shadow: var(--ml-elev-2);
}
.auth-skip:focus { inset-block-start: var(--ml-sp-3); }
.ml-auth :is(a, button, input, select, textarea):focus-visible { outline: 3px solid var(--ml-accent); outline-offset: 3px; }

/* ---------------------------------------------------------------- header */
.auth-header {
  box-sizing: border-box;
  width: min(var(--ml-container), 100%);
  min-height: var(--ml-header-h);
  margin-inline: auto;
  padding: var(--ml-sp-3) var(--ml-gutter);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--ml-sp-4);
}
.auth-brand {
  display: inline-flex;
  align-items: center;
  gap: var(--ml-sp-2);
  min-height: var(--ml-tap);
  color: var(--ml-ink);
  text-decoration: none;
}
.auth-brand-mark { display: block; width: 32px; height: 36px; object-fit: contain; flex: none; }
.auth-brand .ml-wordmark {
  display: block;
  height: 20px;
  aspect-ratio: 9360 / 951;
  background: url("wordmark-light.svg") center / contain no-repeat;
}
html[data-ml-theme="dark"] .auth-brand .ml-wordmark { background-image: url("wordmark-dark.svg"); }
.auth-header-actions { display: flex; align-items: center; gap: var(--ml-sp-2); flex: none; }
/* On a phone the brand and the two actions share one row: the wordmark
   steps down like the site header does, may give way, and leaves the logo
   mark alone on the narrowest screens. */
.auth-brand { min-width: 0; }
.auth-brand .ml-wordmark { flex: 0 1 auto; min-width: 0; }
@media (max-width: 440px) {
  .auth-brand .ml-wordmark { height: 16px; }
  .auth-back { padding: 0 var(--ml-sp-2); }
}
@media (max-width: 359px) {
  .auth-brand .ml-wordmark { display: none; }
}
.auth-back {
  display: inline-flex;
  align-items: center;
  gap: var(--ml-sp-2);
  min-height: var(--ml-tap);
  padding: 0 var(--ml-sp-3);
  border-radius: var(--ml-r-md);
  color: var(--ml-muted);
  font-size: var(--ml-fs-2);
  font-weight: var(--ml-fw-medium);
  white-space: nowrap;
  text-decoration: none;
  transition: background-color var(--ml-dur-1) var(--ml-ease), color var(--ml-dur-1) var(--ml-ease);
}
.auth-back:hover { background: var(--ml-tint); color: var(--ml-ink); text-decoration: none; }
.auth-back:active { background: var(--ml-tint-2); }
.auth-theme svg { width: 20px; height: 20px; }

/* ------------------------------------------------------------------ layout */
.auth-main {
  box-sizing: border-box;
  flex: 1;
  width: min(var(--ml-container), 100%);
  margin: 0 auto;
  padding: var(--ml-sp-4) var(--ml-gutter) var(--ml-sp-12);
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas: "card" "story";
  gap: var(--ml-sp-10);
  align-content: start;
}
@media (min-width: 900px) {
  .auth-main {
    grid-template-columns: minmax(0, 1fr) minmax(0, 440px);
    grid-template-areas: "story card";
    gap: var(--ml-sp-16);
    align-content: center;
    align-items: center;
    padding-block: var(--ml-sp-10) var(--ml-sp-16);
  }
}

/* -------------------------------------------------------------------- card */
.auth-card {
  grid-area: card;
  box-sizing: border-box;
  min-width: 0;
  width: 100%;
  max-width: 480px;
  justify-self: center;
  padding: var(--ml-sp-8) var(--ml-sp-6) var(--ml-sp-4);
  border-radius: var(--ml-r-xl);
  background: var(--ml-surface);
  box-shadow: var(--ml-elev-2);
  outline: none;
}
@media (min-width: 900px) { .auth-card { padding: var(--ml-sp-10) var(--ml-sp-8) var(--ml-sp-6); } }

.auth-eyebrow {
  margin: 0 0 var(--ml-sp-2);
  color: var(--ml-accent-text);
  font-size: var(--ml-fs-2);
  font-weight: var(--ml-fw-bold);
  letter-spacing: var(--ml-ls-label);
  line-height: var(--ml-lh-ui);
}
.auth-card h1 {
  margin: 0;
  color: var(--ml-ink);
  font-size: var(--ml-fs-5);
  font-weight: var(--ml-fw-heavy);
  line-height: var(--ml-lh-display);
  letter-spacing: var(--ml-ls-display);
  text-wrap: balance;
}
@media (min-width: 900px) { .auth-card h1 { font-size: var(--ml-fs-6); } }
.auth-intro { margin: var(--ml-sp-3) 0 var(--ml-sp-6); color: var(--ml-muted); }

/* Google draws its own button inside this slot; it is never restyled. */
.auth-access { position: relative; min-height: var(--ml-control-lg); display: grid; place-items: center; }
.auth-google { min-width: 0; max-width: 100%; direction: ltr; display: flex; justify-content: center; }
.auth-google:empty { display: none; }
.auth-access[aria-busy="true"] .auth-google { visibility: hidden; pointer-events: none; }
.auth-loading {
  margin: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--ml-sp-2);
  color: var(--ml-muted);
  font-size: var(--ml-fs-2);
}
.auth-spinner {
  width: 16px;
  height: 16px;
  flex: none;
  border: 2px solid var(--ml-line-strong);
  border-top-color: var(--ml-accent);
  border-radius: var(--ml-r-full);
  animation: ml-spin 0.8s linear infinite;
}
.auth-google-note { margin: var(--ml-sp-3) 0 0; color: var(--ml-muted); font-size: var(--ml-fs-2); line-height: var(--ml-lh-ui); text-align: center; }

/* status: neutral well for progress, red for errors, always with text */
.auth-status {
  margin: var(--ml-sp-4) 0 0;
  padding: var(--ml-sp-3) var(--ml-sp-4);
  border-radius: var(--ml-r-md);
  background: var(--ml-sunken);
  color: var(--ml-text);
  font-size: var(--ml-fs-2);
  line-height: var(--ml-lh-ui);
  overflow-wrap: anywhere;
}
.auth-status:empty { display: none; }
.auth-status.is-error { background: var(--ml-danger-soft); color: var(--ml-danger); }
.auth-retry { margin-top: var(--ml-sp-2); }

.auth-terms { margin: var(--ml-sp-6) 0; color: var(--ml-muted); font-size: var(--ml-fs-2); line-height: var(--ml-lh-body); text-align: center; }
.auth-switch {
  padding-top: var(--ml-sp-4);
  border-top: 1px solid var(--ml-line);
  color: var(--ml-text);
  font-size: var(--ml-fs-2);
  text-align: center;
}
.auth-switch a, .auth-help a { display: inline-flex; align-items: center; min-height: var(--ml-tap); font-weight: var(--ml-fw-bold); }
.auth-switch a { margin-inline-start: var(--ml-sp-1); }
.auth-help { margin-top: var(--ml-sp-2); border-top: 1px solid var(--ml-line); color: var(--ml-muted); font-size: var(--ml-fs-2); }
.auth-help summary { display: flex; align-items: center; min-height: var(--ml-tap); cursor: pointer; }
.auth-help p { margin: 0 0 var(--ml-sp-2); line-height: var(--ml-lh-body); }

/* ------------------------------------------------------------------- story */
.auth-story { grid-area: story; min-width: 0; }
.auth-kicker {
  display: flex;
  align-items: center;
  gap: var(--ml-sp-2);
  margin: 0 0 var(--ml-sp-4);
  color: var(--ml-accent-text);
  font-size: var(--ml-fs-2);
  font-weight: var(--ml-fw-bold);
  letter-spacing: var(--ml-ls-label);
}
.auth-kicker span { width: 8px; height: 8px; border-radius: var(--ml-r-full); background: var(--ml-accent); }
.auth-story h2 {
  margin: 0;
  color: var(--ml-ink);
  font-size: var(--ml-fs-hero);
  font-weight: var(--ml-fw-heavy);
  line-height: var(--ml-lh-display);
  letter-spacing: var(--ml-ls-display);
  text-wrap: balance;
}
.auth-story em { font-style: normal; color: var(--ml-accent-text); }
.auth-story-intro { margin: var(--ml-sp-4) 0 var(--ml-sp-8); color: var(--ml-muted); font-size: var(--ml-fs-4); line-height: var(--ml-lh-body); }
.auth-features { margin: 0; padding: 0; list-style: none; display: grid; gap: var(--ml-sp-5); }
.auth-features li { display: flex; align-items: center; gap: var(--ml-sp-4); }
/* the step number sits in a sunken icon container, not a bordered box */
.auth-feature-icon {
  width: var(--ml-tap);
  height: var(--ml-tap);
  flex: none;
  display: grid;
  place-items: center;
  border-radius: var(--ml-r-md);
  background: var(--ml-accent-soft);
  color: var(--ml-accent-text);
  font-size: var(--ml-fs-2);
  font-weight: var(--ml-fw-bold);
  font-variant-numeric: tabular-nums;
}
.auth-features strong { display: block; color: var(--ml-ink); font-size: var(--ml-fs-3); font-weight: var(--ml-fw-bold); line-height: var(--ml-lh-ui); }
.auth-features div > span { display: block; color: var(--ml-muted); font-size: var(--ml-fs-2); line-height: var(--ml-lh-ui); }
.auth-plans { margin-top: var(--ml-sp-6); margin-inline-start: calc(var(--ml-sp-4) * -1); }
.auth-signature {
  margin: var(--ml-sp-8) 0 0;
  padding-top: var(--ml-sp-5);
  border-top: 1px solid var(--ml-line);
  color: var(--ml-muted);
  font-size: var(--ml-fs-2);
}
.auth-signature span { white-space: nowrap; }

/* ------------------------------------------------------------------ footer */
.auth-footer {
  box-sizing: border-box;
  width: min(var(--ml-container), 100%);
  margin-inline: auto;
  padding: var(--ml-sp-4) var(--ml-gutter) calc(var(--ml-sp-4) + env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--ml-sp-1);
  border-top: 1px solid var(--ml-line);
  color: var(--ml-muted);
  font-size: var(--ml-fs-2);
  text-align: center;
}
.auth-footer nav { display: flex; gap: var(--ml-sp-4); }
.auth-footer a { display: inline-flex; align-items: center; justify-content: center; min-height: var(--ml-tap); min-width: var(--ml-tap); color: var(--ml-muted); }
.auth-footer a:hover { color: var(--ml-ink); }
@media (min-width: 900px) {
  .auth-footer { flex-direction: row; justify-content: space-between; }
}

@media (prefers-reduced-motion: reduce) { .auth-spinner { animation-duration: 2.4s; } }
@media (forced-colors: active) { .auth-card, .auth-feature-icon { border: 1px solid CanvasText; } }

/* 1.6.0: the privacy notice at sign-in (Privacy Protection Law s.11) */
.auth-terms { margin-bottom: var(--ml-sp-2); }
.auth-privacy { margin: 0 0 var(--ml-sp-6); color: var(--ml-muted); font-size: var(--ml-fs-1); line-height: 1.7; text-align: center; }
.auth-privacy a { color: var(--ml-accent-text); text-decoration: underline; text-underline-offset: 2px; }
