/* Home base (DS piece): reset, page defaults, the typography ladder, focus rings, safe areas, the 12-column page
   grid and a few layout helpers. No raw px except outline widths (tests/test_grid_tokens.py). Classes here: t-*, u-*,
   g12, span-*, sr-only. */

*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  background: var(--bg);
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: var(--fs-16);
  line-height: var(--lh-24);
  font-weight: var(--fw-regular);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  overflow-wrap: break-word;       /* long values wrap, never cut off (her accessibility rule) */
  padding-left: var(--safe-left);  /* landscape iPad/iPhone notch; the shell's own bars add the top/bottom insets */
  padding-right: var(--safe-right);
}

h1, h2, h3, h4, h5, h6, p, ul, ol, dl, dd, figure, blockquote, fieldset { margin: 0; padding: 0; }
ul, ol { list-style: none; }
fieldset { border: 0; min-width: 0; }
legend { padding: 0; }

/* Headings default to her ladder; the .t-* classes below set the same values on any element. */
h1 { font-size: var(--fs-34); line-height: var(--lh-40); font-weight: var(--fw-heavy); }
h2 { font-size: var(--fs-20); line-height: var(--lh-28); font-weight: var(--fw-heavy); }
h3 { font-size: var(--fs-17); line-height: var(--lh-24); font-weight: var(--fw-heavy); }
h4 { font-size: var(--fs-15); line-height: var(--lh-20); font-weight: var(--fw-heavy); }
small { font-size: var(--fs-13); line-height: var(--lh-16); }
b, strong { font-weight: var(--fw-heavy); }

a { color: var(--brand); text-decoration: none; }
p a { text-decoration: underline; text-underline-offset: 0.2em; }
@media (hover: hover) {
  a:hover { color: var(--brand-hover); }
}

button, input, select, textarea {
  font: inherit;
  color: inherit;
  margin: 0;
}
button { background: none; border: 0; padding: 0; cursor: pointer; touch-action: manipulation; text-align: inherit; }
button:disabled, [aria-disabled="true"] { cursor: not-allowed; }
/* Phone: input text is 16 px or larger or iOS zooms the page (her accessibility rule; also holds on iPad). */
input, select, textarea { font-size: var(--fs-16); }

img { display: block; max-width: 100%; }
svg { flex-shrink: 0; }

[hidden] { display: none !important; }

/* Focus: a visible ring for keyboard users (hers draws none). White on the dark lock screens: put .on-dark there. */
:focus { outline: none; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }
.on-dark { --focus: var(--white); }

::placeholder { color: var(--placeholder); opacity: 1; }
::selection { background: var(--brand-tint); color: var(--ink); }

.sr-only {
  position: absolute; width: var(--h-4); height: var(--h-4); margin: calc(var(--h-4) * -1); padding: 0; overflow: hidden;
  clip: rect(0, 0, 0, 0); clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ---- the typography ladder (DESIGN 1.2, line heights on the 4 px grid) ---- */
.t-clock       { font-size: var(--fs-132); line-height: var(--lh-132); font-weight: var(--fw-heavy); letter-spacing: -2px; }  /* lock clock */
.t-hero        { font-size: var(--fs-46); line-height: var(--lh-52); font-weight: var(--fw-heavy); }   /* Welcome h1 */
.t-display     { font-size: var(--fs-40); line-height: var(--lh-48); font-weight: var(--fw-heavy); }   /* kid sign-in h1, kid initials */
.t-setup-title { font-size: var(--fs-36); line-height: var(--lh-44); font-weight: var(--fw-heavy); }   /* setup h1 */
.t-title       { font-size: var(--fs-34); line-height: var(--lh-40); font-weight: var(--fw-heavy); }   /* page title (top bar h1) */
.t-pin         { font-size: var(--fs-32); line-height: var(--lh-40); font-weight: var(--fw-bold); }    /* PIN digits */
.t-title-phone { font-size: var(--fs-30); line-height: var(--lh-36); font-weight: var(--fw-heavy); }   /* phone title */
.t-lock-date   { font-size: var(--fs-26); line-height: var(--lh-32); font-weight: var(--fw-heavy); }   /* lock date line */
.t-panel-title { font-size: var(--fs-24); line-height: var(--lh-32); font-weight: var(--fw-heavy); }   /* side panel, dialog title */
.t-name-lg     { font-size: var(--fs-22); line-height: var(--lh-28); font-weight: var(--fw-heavy); }   /* kid name under avatar */
.t-card-title-lg { font-size: var(--fs-21); line-height: var(--lh-28); font-weight: var(--fw-heavy); } /* setup card title */
.t-card-title  { font-size: var(--fs-20); line-height: var(--lh-28); font-weight: var(--fw-heavy); }   /* card h2 */
.t-lead        { font-size: var(--fs-20); line-height: var(--lh-32); font-weight: var(--fw-regular); color: var(--muted); } /* Welcome paragraph */
.t-prompt      { font-size: var(--fs-20); line-height: var(--lh-28); font-weight: var(--fw-heavy); }   /* PIN prompt */
.t-btn-hero    { font-size: var(--fs-19); line-height: var(--lh-24); font-weight: var(--fw-heavy); }   /* Welcome main button */
.t-date        { font-size: var(--fs-18); line-height: var(--lh-24); font-weight: var(--fw-bold); color: var(--muted); } /* top-bar date */
.t-event       { font-size: var(--fs-18); line-height: var(--lh-24); font-weight: var(--fw-heavy); }   /* event title */
.t-row-title   { font-size: var(--fs-17); line-height: var(--lh-24); font-weight: var(--fw-heavy); }   /* list name, feature title, Settings name */
.t-row-sub     { font-size: var(--fs-17); line-height: var(--lh-24); font-weight: var(--fw-regular); color: var(--muted); } /* setup description */
.t-body        { font-size: var(--fs-16); line-height: var(--lh-24); font-weight: var(--fw-regular); }
.t-body-strong { font-size: var(--fs-16); line-height: var(--lh-24); font-weight: var(--fw-bold); }
.t-label       { font-size: var(--fs-15); line-height: var(--lh-20); font-weight: var(--fw-heavy); }   /* field label */
.t-value       { font-size: var(--fs-15); line-height: var(--lh-20); font-weight: var(--fw-bold); }    /* kv value, button text */
.t-sub         { font-size: var(--fs-14); line-height: var(--lh-20); font-weight: var(--fw-regular); color: var(--muted); } /* sub-lines */
.t-kv-label    { font-size: var(--fs-14); line-height: var(--lh-20); font-weight: var(--fw-semibold); color: var(--muted); }
.t-help        { font-size: var(--fs-13); line-height: var(--lh-16); font-weight: var(--fw-regular); color: var(--muted); } /* helper text */
.t-caption     { font-size: var(--fs-12); line-height: var(--lh-16); font-weight: var(--fw-heavy); }   /* rail labels, chips */
.t-tab         { font-size: var(--fs-11); line-height: var(--lh-16); font-weight: var(--fw-heavy); }   /* phone tab labels */

.t-muted  { color: var(--muted); }
.t-ink    { color: var(--ink); }
.t-brand  { color: var(--brand); }
.t-white  { color: var(--white); }
.t-center { text-align: center; }
.t-right  { text-align: right; }
.t-nums   { font-variant-numeric: tabular-nums; }

/* ---- the 12-column page grid: gutter 24 iPad / 16 phone (tokens.css). Children say how many columns they span. ---- */
.g12 {
  display: grid;
  grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
  column-gap: var(--gutter);
  row-gap: var(--gutter);
  align-items: start;
}
.g12 > .span-1  { grid-column: span 1; }
.g12 > .span-2  { grid-column: span 2; }
.g12 > .span-3  { grid-column: span 3; }
.g12 > .span-4  { grid-column: span 4; }
.g12 > .span-5  { grid-column: span 5; }
.g12 > .span-6  { grid-column: span 6; }
.g12 > .span-7  { grid-column: span 7; }
.g12 > .span-8  { grid-column: span 8; }
.g12 > .span-9  { grid-column: span 9; }
.g12 > .span-10 { grid-column: span 10; }
.g12 > .span-11 { grid-column: span 11; }
.g12 > .span-12 { grid-column: span 12; }
@media (max-width: 767.98px) {
  .g12 > [class*="span-"] { grid-column: span 12; }   /* phone: one column; give a child .span-p-6 to keep two */
  .g12 > .span-p-6 { grid-column: span 6; }
}

/* ---- layout helpers, all on the spacing tokens (u- prefix: no other piece defines u-* classes) ---- */
.u-stack-1 { display: flex; flex-direction: column; gap: var(--sp-1); }
.u-stack-2 { display: flex; flex-direction: column; gap: var(--sp-2); }
.u-stack-3 { display: flex; flex-direction: column; gap: var(--sp-3); }
.u-stack-4 { display: flex; flex-direction: column; gap: var(--sp-4); }
.u-stack-6 { display: flex; flex-direction: column; gap: var(--sp-6); }
.u-stack-8 { display: flex; flex-direction: column; gap: var(--sp-8); }
.u-row-2   { display: flex; align-items: center; gap: var(--sp-2); }
.u-row-3   { display: flex; align-items: center; gap: var(--sp-3); }
.u-row-4   { display: flex; align-items: center; gap: var(--sp-4); }
.u-start    { align-items: flex-start; }           /* a row of mixed heights: tops line up (centring a 24 chip beside 20 px text lands on a 2 px offset) */
.u-row-wrap-2 { display: flex; flex-wrap: wrap; gap: var(--sp-2); }
.u-row-wrap-4 { display: flex; flex-wrap: wrap; gap: var(--sp-4); }
.u-grow    { flex-grow: 1; min-width: 0; }
.u-spacer  { flex-grow: 1; }
.u-between { justify-content: space-between; }
.u-end     { justify-content: flex-end; }
.u-wrap-anywhere { overflow-wrap: anywhere; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
