/* auth.css (AUTHUI): the signed-out screens of auth.html (Welcome, Create your account, sign in, invite, Lock, Kid
   sign-in, notices) and the setup frame the signed-in setup steps share (stepper, heading, footer). Prefix .au-.
   Loaded by auth.html (tokens, base, components, grid-overlay, auth) and by index.html (every CSS file).
   Every spacing, size and radius is a token (CONTRACT 10.9). No-rail screens are placed with explicit 4 px offsets,
   never margin:auto (DESIGN 2.3): horizontal offsets are round(down, ..., 4px); vertical centring is done by
   steps.js centerOnGrid(), which sets --au-top (a top padding rounded down to 4 px). Fixed widths below keep centred
   rows on the 4 px grid at 1180 px (a centred row needs a width of 4 mod 8). */

.au-page { --au-top: var(--sp-12); min-height: 100vh; min-height: 100dvh; }
html:has(body.au-dark), body.au-dark { background: var(--lock-bg); }

.au-error {
  font-size: var(--fs-15); line-height: var(--lh-20); font-weight: var(--fw-bold); color: var(--alert);
}
.au-error--dark { color: var(--alert-tint); text-align: center; }
.au-chip-alert { --t-bg: var(--alert-tint); --t-fg: var(--alert); }

/* ---------- app icon (Welcome, invite): her 84 px blue tile with the white home mark ---------- */
.au-appicon {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  width: var(--h-84); height: var(--h-84); border-radius: var(--r-2xl); background: var(--brand); color: var(--white);
}

/* ---------- Welcome, sign in, invite (DESIGN 4.1): 440 + 80 + 440, centred on the 4 px grid ---------- */
.au-welcome { padding: var(--au-top) 0 var(--sp-12); }
.au-welcome__row {
  display: flex; align-items: flex-start; gap: var(--sp-20);     /* middled by steps.js middleOnGrid (4 px steps) */
  padding-left: round(down, calc((100% - var(--w-welcome) * 2 - var(--sp-20)) / 2), var(--h-4));
}
.au-welcome__intro { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-6); width: var(--w-welcome); flex-shrink: 0; }
.au-welcome__actions { display: flex; flex-direction: column; align-items: flex-start; gap: var(--sp-3); margin-top: var(--sp-2); }
.au-welcome__link { font-size: var(--fs-16); line-height: var(--lh-24); text-decoration: underline; text-underline-offset: 0.2em; }
.au-welcome__note { max-width: var(--w-welcome); }
.au-features {
  flex-shrink: 0; width: var(--w-welcome); gap: var(--sp-6); padding: var(--sp-8); border-radius: var(--r-3xl);
}
.au-feature__text { min-width: 0; }

/* ---------- the setup frame (her SetupFamily.html, the pattern for every setup step, DESIGN 4.2) ---------- */
.au-setup {
  display: flex; flex-direction: column; gap: var(--sp-6); min-height: 100vh; min-height: 100dvh;
  padding: calc(var(--sp-8) + var(--safe-top)) var(--sp-10) calc(var(--sp-8) + var(--safe-bottom));
}
.au-stepper { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.au-steps { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-8); }
.au-step {
  display: flex; align-items: center; gap: var(--sp-3);
  font-size: var(--fs-15); line-height: var(--lh-24); font-weight: var(--fw-heavy); color: var(--ink);   /* 24 in a 32 row: 4 px off the top */
}
/* The "(done)" word for screen readers carries .grid-exempt: it is clipped to nothing and never seen. */
.au-step__dot {
  display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: var(--h-32); height: var(--h-32);
  border-radius: var(--r-round); font-size: var(--fs-14); line-height: var(--lh-20); font-weight: var(--fw-heavy);
}
.au-step--done .au-step__dot    { background: var(--ok); color: var(--white); }
.au-step--current .au-step__dot { background: var(--brand); color: var(--white); }
.au-step--next .au-step__dot    { background: var(--surface); color: var(--muted); box-shadow: var(--ring-2); }
.au-step--next { color: var(--muted); }
.au-stepcount { font-size: var(--fs-14); line-height: var(--lh-24); font-weight: var(--fw-bold); color: var(--muted); }
.au-setup__head { display: flex; flex-direction: column; gap: var(--sp-2); }
.au-setup__body { display: flex; flex-direction: column; flex: 1 1 auto; gap: var(--sp-6); min-width: 0; }
.au-setup__card { width: calc(var(--w-panel-wide) - var(--h-80)); max-width: 100%; }
.au-foot { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-4); }
.au-foot__right { display: flex; align-items: center; gap: var(--sp-4); }
.au-foot__spacer { flex: 0 0 auto; }

/* Setup step 1: the Face ID note under the form */
.au-faceid-note { display: flex; align-items: center; gap: var(--sp-4); padding: var(--sp-4); border-radius: var(--r-lg); background: var(--bg); }
.au-faceid-note__text { min-width: 0; color: var(--muted); }

/* ---------- Lock (her Lock.html, DESIGN 4.6) ---------- */
.au-lock {
  position: relative; padding: var(--au-top) var(--margin) var(--sp-22); background: var(--lock-bg); color: var(--white);
  --au-parent-w: calc(var(--h-112) * 2 + var(--h-4));      /* 228: "Parent: Face ID"; with the 164 kid button and the 16 gap the row is 412 (4 mod 8) */
  --au-kid-w: calc(var(--h-80) * 2 + var(--h-4));          /* 164: "I'm a kid" */
  --au-em-w: calc(var(--h-112) * 2 - var(--h-4));          /* 220: "Emergency access" */
}
.au-lock__center { display: flex; flex-direction: column; gap: var(--sp-3); text-align: center; }
.au-lock__time, .au-lock__date { color: var(--white); }
.au-lock__buttons { display: flex; justify-content: center; gap: var(--sp-4); margin-top: calc(var(--sp-8) - var(--sp-1)); }
.au-lock__parent { width: var(--au-parent-w); }
.au-lock__kid { width: var(--au-kid-w); }
.au-lock__emergency { position: absolute; right: var(--sp-8); bottom: calc(var(--sp-8) + var(--safe-bottom)); width: var(--au-em-w); }

/* ---------- Kid sign-in (her KidLogin.html, DESIGN 4.7): who (n tiles of 168) + 88 + the 284 PIN pad ---------- */
.au-kid {
  position: relative; padding: var(--au-top) var(--margin) var(--sp-8); background: var(--lock-bg); color: var(--white);
  --au-tile-w: calc(var(--h-84) * 2);                                   /* 120 avatar + 2 x 24 padding */
  --au-pad-w: calc(var(--h-84) * 3 + var(--sp-4) * 2);                  /* 284 */
}
.au-kid__back { position: absolute; left: var(--h-28); top: calc(var(--h-28) + var(--safe-top)); }
.au-kid__row { display: flex; justify-content: center; align-items: flex-start; gap: var(--sp-22); }
.au-kid__who { display: flex; flex-direction: column; gap: var(--sp-6); flex-shrink: 0; padding-top: var(--h-120); }
.au-kid__who--rows { padding-top: var(--sp-2); }
.au-kid__who--n1 { width: calc(var(--au-tile-w) * 2 + var(--sp-4)); }   /* as wide as two tiles so "Who's here?" stays on one line */
.au-kid__who--n2 { width: calc(var(--au-tile-w) * 2 + var(--sp-4)); }
.au-kid__who--n3 { width: calc(var(--au-tile-w) * 3 + var(--sp-4) * 2); }
.au-kid__who--n4 { width: calc(var(--au-tile-w) * 4 + var(--sp-4) * 3); }
.au-kid__title { color: var(--white); }
.au-kid__tiles .kid-tile { width: var(--au-tile-w); }
.au-kid__name { max-width: 100%; text-align: center; overflow-wrap: anywhere; }
.au-kid__pad { width: var(--au-pad-w); flex-shrink: 0; }
.au-kid .pin-help { color: var(--lock-muted); }

/* ---------- notices on the signed-out pages ---------- */
.au-notice .dialog__actions .btn { min-width: var(--h-96); }
.au-fatal { padding: calc(var(--sp-16) + var(--safe-top)) var(--margin) var(--sp-16); }
.au-fatal__card { width: var(--w-dialog); max-width: 100%; margin-left: round(down, calc((100% - var(--w-dialog)) / 2), var(--h-4)); }

/* ---------- phone (< 768 px) ---------- */
@media (max-width: 767.98px) {
  .au-welcome { padding: calc(var(--h-56) + var(--safe-top)) var(--margin) calc(var(--sp-6) + var(--safe-bottom)); }
  .au-welcome__row { flex-direction: column; align-items: stretch; gap: var(--sp-8); padding-left: 0; }
  .au-welcome__intro, .au-features { width: auto; }
  .au-welcome__title { font-size: var(--fs-34); line-height: var(--lh-40); }
  .au-welcome__lead { font-size: var(--fs-18); line-height: var(--lh-28); }
  .au-welcome__actions { align-self: stretch; align-items: stretch; }
  .au-welcome__hero { width: 100%; }
  .au-welcome__link { justify-content: center; }
  .au-features { padding: var(--sp-6); border-radius: var(--r-2xl); }

  .au-setup { gap: var(--sp-6); padding: calc(var(--sp-6) + var(--safe-top)) var(--margin) 0; }
  .au-steps { gap: var(--sp-3); }
  .au-step:not(.au-step--current) .au-step__label { display: none; }
  .au-setup__head .t-setup-title { font-size: var(--fs-30); line-height: var(--lh-36); }
  .au-setup__card { width: auto; }
  .au-foot {
    position: sticky; bottom: 0; z-index: var(--z-sticky); margin: 0 calc(var(--margin) * -1);
    padding: var(--sp-4) var(--margin) calc(var(--sp-4) + var(--safe-bottom)); background: var(--bg); box-shadow: var(--ring-top);
  }
  .au-foot__right { flex: 1 1 0; justify-content: flex-end; }
  .au-foot > .btn, .au-foot__right > .btn { flex: 1 1 0; padding: 0 var(--sp-3); }
  .au-foot > .au-foot__back { flex: 0 0 auto; padding: 0 var(--sp-6); }          /* Back sized by its word, the next step gets the room */
  .au-foot__right > .link { flex: 0 0 auto; white-space: nowrap; }
  .au-foot__spacer { display: none; }

  .au-lock { padding-bottom: calc(var(--sp-22) + var(--safe-bottom)); }
  .au-lock__buttons { flex-direction: column; align-items: stretch; }
  .au-lock__parent { width: 100%; }
  .au-lock__kid { display: none; }                                        /* kid sign-in is iPad-only (spec) */
  .au-lock__emergency { right: auto; left: round(down, calc(50% - var(--au-em-w) / 2), var(--h-4)); }

  .au-kid { padding-top: calc(var(--h-88) + var(--safe-top)); }
  .au-kid__row { flex-direction: column; align-items: flex-start; gap: var(--sp-8); }
  .au-kid__who, .au-kid__who--rows { width: 100%; padding-top: 0; }
  .au-kid__pad { margin-left: round(down, calc((100% - var(--au-pad-w)) / 2), var(--h-4)); }
}
