/* Home design tokens (DS piece). The ONLY file in static/css that may hold raw px values (tests/test_grid_tokens.py).
   Source: docs/DESIGN.md sections 1 and 2 (her values, snapped to the 4 px grid), docs/CONTRACT.md 10.9 (names).
   Rules for every other CSS file:
   - padding, margin, gap, height, min/max-height, border-radius, top/right/bottom/left/inset: only var(--sp-*),
     var(--h-*), var(--w-*), var(--r-*), --gutter, --margin, --tabbar-h, 0, auto, %, or a calc() of those.
   - width, min/max-width, flex-basis, font-size, line-height, grid-template-*: tokens too (--w-*, --h-*, --fs-*, --lh-*).
   - Hairline borders are drawn with box-shadow: var(--ring*) (they add no size, so edges stay on the 4 px grid).
     A real `border` is only for 2 to 4 px rings on fixed-size boxes (avatar, swatch, PIN dot) and dashed tiles.
   - Colours only from the names below. Hex in other files is a review flag.
   Staying on the 4 px grid (tools/grid_check.py finds the misses):
   - A box centred in another needs (parent height - child height) to be a multiple of 8: a 44 button centres a 20, 28 or 36
     high box (not 24 or 32), a 48 avatar centres a 40 or 48 text block, a 52 bar centres a 20. Line heights are tokens
     (--lh-*) for that reason. To line up a 24 chip with 20 px text, top-align the row (.u-start) instead of centring it.
   - Fixed widths are multiples of 4 (--w-*, --h-*). A content-sized or window-sized box may have any width; the gap after
     it is what is checked.
   - No margin: auto or translate(-50%) centring of fixed boxes: 1180 is not an even 8. Use round(down, ..., var(--h-4)). */

/* Nunito, self-hosted (OFL, static/fonts/SOURCE.txt). 400 / 600 / 700 / 800 are her four weights. */
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 400; font-display: swap;
  src: url("/static/fonts/nunito-400.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 600; font-display: swap;
  src: url("/static/fonts/nunito-600.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 700; font-display: swap;
  src: url("/static/fonts/nunito-700.woff2") format("woff2");
}
@font-face {
  font-family: "Nunito"; font-style: normal; font-weight: 800; font-display: swap;
  src: url("/static/fonts/nunito-800.woff2") format("woff2");
}

:root {
  color-scheme: light;

  /* ---- colours (DESIGN 1.1, with the 5.1 fixes: teal #0F7769, placeholder #667085) ---- */
  --bg: #F6F7FA;              /* page, segmented trough, close-button fill */
  --surface: #FFFFFF;         /* cards, rail, tab bar, panels, inputs */
  --white: #FFFFFF;           /* text on brand / alert / dark; same value as --surface, a different job */
  --line: #E8EAF0;            /* hairlines, card and input borders, dashed tiles */
  --ink: #1E2330;             /* body text, selected segment, selected swatch ring */
  --muted: #596173;           /* secondary text */
  --placeholder: #667085;     /* ::placeholder (4.97:1 on white; Safari's default is 2.35) */
  --brand: #2F5BD3;
  --brand-hover: #1E43A8;
  --brand-tint: #DCE9FA;
  --ok: #0F7769;              /* her #0F7B6C darkened 3% so it passes 4.5:1 on its tint */
  --ok-tint: #D7F2EC;
  --warn: #8A5A00;
  --warn-tint: #FFF1C9;
  --alert: #8A2E07;
  --alert-tint: #FFE4D6;
  --scrim: rgba(30, 35, 48, 0.45);
  --panel-shadow: -8px 0 30px rgba(30, 35, 48, 0.18);
  --sheet-shadow: 0 -8px 30px rgba(30, 35, 48, 0.18);     /* [derived] the panel shadow turned for a bottom sheet */
  --dialog-shadow: 0 8px 30px rgba(30, 35, 48, 0.18);     /* [derived] the same shadow for a centred dialog */
  --lock-bg: #26354B;
  --lock-muted: #C9D2E0;
  --glass-12: rgba(255, 255, 255, 0.12);
  --glass-14: rgba(255, 255, 255, 0.14);
  --glass-16: rgba(255, 255, 255, 0.16);
  --glass-24: rgba(255, 255, 255, 0.24);   /* [derived] hover on glass buttons and keys */
  --photo-bg: #3B4A5E;
  --scan-box: #FFD25A;
  --swatch-blank: #D1CBC1;
  /* later screens (DESIGN-LATER 1.2) */
  --lit-room-bg: #FFE7A3;
  --lit-room-ink: #6B4500;
  --panel-well: #E9ECF2;

  /* ---- people: her 8 colours. Accent = text, dot, swatch. Tint = avatar and card fill. 6 to 8 tints are proposed. ---- */
  --p1-accent: #0F7769; --p1-tint: #D7F2EC;   /* teal   (default Parent 1) */
  --p2-accent: #6B4FA0; --p2-tint: #EAE3F7;   /* purple (default Parent 2) */
  --p3-accent: #B93E0B; --p3-tint: #FFE4D6;   /* rust   (default Kid 1) */
  --p4-accent: #2563A8; --p4-tint: #DCE9FA;   /* blue   (default Kid 2) */
  --p5-accent: #8A5A00; --p5-tint: #FFF1C9;   /* amber */
  --p6-accent: #B4235A; --p6-tint: #FCE4EC;   /* rose   [proposed tint] */
  --p7-accent: #3F6212; --p7-tint: #E8F2D6;   /* olive  [proposed tint] */
  --p8-accent: #475569; --p8-tint: #E3E8F0;   /* slate  [proposed tint] */
  /* decorative pastels, never people (DESIGN-LATER 1.2): gold, teal, orange, blue, purple */
  --tint-1-bg: #FFF1C9; --tint-1-fg: #8A5A00;
  --tint-2-bg: #D7F2EC; --tint-2-fg: #0F7769;
  --tint-3-bg: #FFE4D6; --tint-3-fg: #B93E0B;
  --tint-4-bg: #DCE9FA; --tint-4-fg: #2563A8;
  --tint-5-bg: #EAE3F7; --tint-5-fg: #6B4FA0;

  /* focus and the grid overlay */
  --focus: var(--brand);       /* 3 px ring, 2 px away (components.css); white on dark screens (.on-dark) */
  --grid-col: rgba(225, 29, 72, 0.08);
  --grid-line: rgba(30, 35, 48, 0.08);
  --grid-line-half: rgba(30, 35, 48, 0.04);

  /* ---- hairlines drawn as inset shadows: no layout size, so a 1 px edge never pushes a child off the 4 px grid ---- */
  --ring: inset 0 0 0 1px var(--line);
  --ring-top: inset 0 1px 0 var(--line);
  --ring-bottom: inset 0 -1px 0 var(--line);
  --ring-right: inset -1px 0 0 var(--line);
  --ring-left: inset 1px 0 0 var(--line);
  --ring-2: inset 0 0 0 2px var(--line);
  --ring-brand: inset 0 0 0 2px var(--brand);
  --ring-brand-1: inset 0 0 0 1px var(--brand);
  --ring-warn: inset 0 0 0 2px var(--warn);
  --ring-alert: inset 0 0 0 2px var(--alert);

  /* ---- spacing (4 px base, 8 px steps; --sp-1 inside a control only, --sp-3 inside a row, card or control only) ---- */
  --sp-0: 0;
  --sp-1: 4px;
  --sp-2: 8px;
  --sp-3: 12px;
  --sp-4: 16px;
  --sp-6: 24px;
  --sp-8: 32px;
  --sp-10: 40px;
  --sp-12: 48px;
  --sp-16: 64px;
  --sp-20: 80px;
  --sp-22: 88px;

  /* ---- sizes: every multiple of 4 up to 128 (heights, avatars, icons, touch targets), and the 420 scan photo ---- */
  --h-4: 4px;     --h-8: 8px;     --h-12: 12px;   --h-16: 16px;   --h-20: 20px;   --h-24: 24px;
  --h-28: 28px;   --h-32: 32px;   --h-36: 36px;   --h-40: 40px;   --h-44: 44px;   --h-48: 48px;
  --h-52: 52px;   --h-56: 56px;   --h-60: 60px;   --h-64: 64px;   --h-68: 68px;   --h-72: 72px;
  --h-76: 76px;   --h-80: 80px;   --h-84: 84px;   --h-88: 88px;   --h-92: 92px;   --h-96: 96px;
  --h-100: 100px; --h-104: 104px; --h-108: 108px; --h-112: 112px; --h-116: 116px; --h-120: 120px;
  --h-124: 124px; --h-128: 128px; --h-420: 420px;

  /* ---- fixed widths (multiples of 4; the 12-column page grid needs the rail at 100) ---- */
  --w-rail: 100px;
  --w-side: 240px;            /* room list, Settings sub-nav: 3 columns */
  --w-today-side: 248px;
  --w-panel: 520px;
  --w-panel-wide: 760px;
  --w-welcome: 440px;
  --w-scan: 328px;            /* scan photo column, setup member list: 4 columns */
  --w-dialog: 440px;

  /* ---- radii ---- */
  --r-xs: 4px;                /* progress bars */
  --r-sm: 8px;
  --r-md: 12px;
  --r-lg: 16px;
  --r-xl: 20px;
  --r-2xl: 24px;
  --r-3xl: 28px;
  --r-pill: 999px;
  --r-round: 50%;

  /* ---- layout ---- */
  --cols: 12;
  --gutter: 24px;
  --margin: 24px;
  --tabbar-h: 76px;           /* tab bar content height; the safe area is added on top of it */
  --bp: 768;                  /* phone below this CSS width (media queries cannot read it; the number is for scripts) */

  /* ---- type (DESIGN 1.2). Line heights are on the 4 px grid, so text boxes land on it. ---- */
  --font: Nunito, system-ui, sans-serif;
  --fw-regular: 400; --fw-semibold: 600; --fw-bold: 700; --fw-heavy: 800;
  --fs-11: 11px; --fs-12: 12px; --fs-13: 13px; --fs-14: 14px; --fs-15: 15px; --fs-16: 16px; --fs-17: 17px;
  --fs-18: 18px; --fs-19: 19px; --fs-20: 20px; --fs-21: 21px; --fs-22: 22px; --fs-24: 24px; --fs-26: 26px;
  --fs-30: 30px; --fs-32: 32px; --fs-34: 34px; --fs-36: 36px; --fs-40: 40px; --fs-46: 46px; --fs-132: 132px;
  --lh-16: 16px; --lh-20: 20px; --lh-24: 24px; --lh-28: 28px; --lh-32: 32px; --lh-36: 36px; --lh-40: 40px;
  --lh-44: 44px; --lh-48: 48px; --lh-52: 52px; --lh-132: 132px;

  /* ---- safe areas (installed PWA on iPhone/iPad): use these, never env() directly ---- */
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);

  /* ---- stacking ---- */
  --z-sticky: 20; --z-panel: 40; --z-dialog: 50; --z-toast: 60; --z-grid: 1000;

  /* ---- motion (DESIGN 5.4: only the toast countdown and the PIN shake move; both stop under reduced motion) ---- */
  --dur-shake: 360ms;
}

/* Phone (< 768 CSS px): 16 px gutter and side margin */
@media (max-width: 767.98px) {
  :root {
    --gutter: 16px;
    --margin: 16px;
  }
}

/* A person's colours for a subtree: .p-c3 sets --m-accent and --m-tint for everything inside (avatar, chip, card, dot). */
.p-c1 { --m-accent: var(--p1-accent); --m-tint: var(--p1-tint); }
.p-c2 { --m-accent: var(--p2-accent); --m-tint: var(--p2-tint); }
.p-c3 { --m-accent: var(--p3-accent); --m-tint: var(--p3-tint); }
.p-c4 { --m-accent: var(--p4-accent); --m-tint: var(--p4-tint); }
.p-c5 { --m-accent: var(--p5-accent); --m-tint: var(--p5-tint); }
.p-c6 { --m-accent: var(--p6-accent); --m-tint: var(--p6-tint); }
.p-c7 { --m-accent: var(--p7-accent); --m-tint: var(--p7-tint); }
.p-c8 { --m-accent: var(--p8-accent); --m-tint: var(--p8-tint); }

/* Decorative pastel for a subtree (never a person): .tint-2 sets --t-bg and --t-fg (feature chips, zones, list cards). */
.tint-1 { --t-bg: var(--tint-1-bg); --t-fg: var(--tint-1-fg); }
.tint-2 { --t-bg: var(--tint-2-bg); --t-fg: var(--tint-2-fg); }
.tint-3 { --t-bg: var(--tint-3-bg); --t-fg: var(--tint-3-fg); }
.tint-4 { --t-bg: var(--tint-4-bg); --t-fg: var(--tint-4-fg); }
.tint-5 { --t-bg: var(--tint-5-bg); --t-fg: var(--tint-5-fg); }
