/*
 * Lumina Health · design tokens
 *
 * The single source for every colour, size, radius, shadow and duration in the
 * app. Components read semantic tokens (--text, --surface, --status-*), never
 * the ramps directly, so Increase Contrast can remap meaning in one place.
 * Rationale and the verified contrast table: docs/design-system.md. The table
 * is checked by scripts/verify-contrast.mjs; change a value, re-run it.
 */

:root {
  /* ── Ramps ─────────────────────────────────────────────────────────────
     Navy is the brand (the wireframe's Deep Trust Blue, #1E3A8A, kept).
     Teal is the brand's second voice (#0D9488, kept) but it is 3.74:1 on
     white, so it never sets text: teal TEXT is teal-700. */
  --navy-50: #eef2ff;
  --navy-100: #e0e7ff;
  --navy-200: #c7d2fe;
  --navy-300: #a5b4fc;
  --navy-400: #6d84e3;
  --navy-500: #3e5cc8;
  --navy-600: #2547a8;
  --navy-700: #1e3a8a; /* brand */
  --navy-800: #1a2f6e;
  --navy-900: #13224f;
  --navy-950: #0b1533;

  --teal-50: #f0fdfa;
  --teal-100: #ccfbf1;
  --teal-200: #99f6e4;
  --teal-300: #5eead4;
  --teal-400: #2dd4bf;
  --teal-500: #14b8a6;
  --teal-600: #0d9488; /* brand */
  --teal-700: #0f766e;
  --teal-800: #115e59;
  --teal-900: #134e4a;

  --slate-0: #ffffff;
  --slate-25: #f8fafc;
  --slate-50: #f4f6fa; /* the page */
  --slate-100: #eceff5;
  --slate-200: #e2e8f0;
  --slate-300: #cbd5e1;
  --slate-400: #94a3b8;
  --slate-500: #64748b;
  --slate-600: #475569;
  --slate-700: #334155;
  --slate-800: #1e293b;
  --slate-900: #0f172a;

  /* Semantic hues, deliberately NOT the brand. The wireframe's success was
     the brand teal, so every "Normal" pill read like a button. Success is a
     green you cannot confuse with the CTA; red is reserved (see --danger). */
  --green-50: #f0fdf4;
  --green-100: #dcfce7;
  --green-600: #16a34a;
  --green-700: #15803d;
  --green-800: #166534;
  --amber-50: #fffbeb;
  --amber-100: #fef3c7;
  --amber-600: #d97706;
  --amber-700: #b45309;
  --amber-800: #92400e;
  --red-50: #fef2f2;
  --red-100: #fee2e2;
  --red-600: #dc2626;
  --red-700: #b91c1c;
  --red-800: #991b1b;

  /* ── Semantic: surfaces and text ──────────────────────────────────────
     The owner's Figma (2026-11-07) sets the surface model: a white page with
     soft grey, flat containers, not white cards on a grey page. Everything
     below follows it, so a screen never mixes the two. */
  --bg: #ffffff; /* the page */
  --card: #f6f6f6; /* grouped lists, cards, tiles: the Figma's container grey */
  --surface: #ffffff; /* raised and floating: sheets, the tab bar, a segment's thumb */
  --surface-2: #ffffff; /* a well inside a grey card */
  --surface-sunken: #eceef2; /* tracks, placeholders, a pressed row */
  --field: #f8f8f8; /* a text field on the page (white inside a card) */
  --overlay: rgba(11, 21, 51, 0.42); /* sheet scrim: navy-950 at 42% */

  --text: var(--slate-900); /* 17.85:1 on white */
  --text-2: var(--slate-600); /* 7.58:1 on white, 7.00:1 on --bg */
  --text-3: #5f6b7d; /* 5.00:1 on --card, 5.40:1 on white (slate-500 fell to 4.40 on the card grey) */
  --text-on-brand: #ffffff;
  --text-link: var(--navy-600); /* 8.25:1 */

  --line: var(--slate-200); /* hairlines between rows: decorative */
  --line-strong: #7c8aa0; /* control outlines: 3.4:1, meets 1.4.11 */
  --focus: var(--navy-500);

  /* ── Semantic: brand and status ─────────────────────────────────────── */
  --brand: var(--navy-700);
  --brand-hover: var(--navy-800);
  --brand-tint: var(--navy-50);
  --brand-ink: var(--navy-700); /* brand-coloured text */
  --accent: var(--teal-600); /* fills, charts, brand moments */
  --accent-ink: var(--teal-700); /* teal text: 5.47:1 */
  --accent-tint: var(--teal-50);

  --ok: var(--green-700); /* in range, done, sent */
  --ok-icon: var(--green-600);
  --ok-tint: var(--green-50);
  --attn: var(--amber-700); /* outside range, needs a look */
  --attn-icon: var(--amber-600);
  --attn-tint: var(--amber-50);
  /* Red is reserved for emergencies and destructive actions. An out-of-range
     lab is "attention", never red: a result is not an alarm. (The rule is
     CareBridge's, carried over.) */
  --danger: var(--red-700);
  --danger-tint: var(--red-50);
  --info: var(--navy-700);
  --info-tint: var(--navy-50);

  /* Categories: the Figma's tinted icon tiles (notifications, quick actions,
     list rows). Decorative: a row's words carry its meaning. Each icon ink
     meets 4.5:1 on its own tint. They are never status colours. */
  --cat-visit: #7e22ce;
  --cat-visit-tint: #f3e8ff;
  --cat-result: var(--teal-700);
  --cat-result-tint: #e2f3f1;
  --cat-med: #0369a1;
  --cat-med-tint: #e0f2fe;
  --cat-message: #1d4ed8;
  --cat-message-tint: #e3e9fd;
  --cat-refill: #c2410c;
  --cat-refill-tint: #ffedd5;
  --cat-file: #9a5b04;
  --cat-file-tint: #fef3c7;
  --cat-goal: var(--green-700);
  --cat-goal-tint: #dcfce7;

  /* The mark's own colours (Figma): its navy is lighter than the UI navy. */
  --mark-navy: #314b95;
  --mark-teal: var(--teal-600);
  --tab-active: #bfdbfe; /* the tab bar's active disc */

  /* Data colours: one per measure, so a chart and its card always match. */
  --data-bp: var(--navy-500);
  --data-hr: #c2416b; /* rose, 4.9:1, never used for status */
  --data-sleep: #5b54c9;
  --data-activity: var(--teal-600);
  --data-ref: rgba(13, 148, 136, 0.12); /* the reference band */

  /* ── Type: iOS Dynamic Type roles ──────────────────────────────────────
     --ts is the user's text size (1 = default). Body roles scale fully;
     title roles scale at half rate, as iOS does, so a large title never
     crowds the content it heads. Nothing goes below 12px. */
  --ts: 1;
  --tt: calc(1 + (var(--ts) - 1) * 0.5);
  --font: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Inter", system-ui, sans-serif;
  --font-round: ui-rounded, -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "Inter", system-ui, sans-serif;

  --fs-large: calc(34px * var(--tt));
  --fs-t1: calc(28px * var(--tt));
  --fs-t2: calc(22px * var(--tt));
  --fs-t3: calc(20px * var(--tt));
  --fs-head: calc(17px * var(--ts));
  --fs-body: calc(17px * var(--ts));
  --fs-callout: calc(16px * var(--ts));
  --fs-sub: calc(15px * var(--ts));
  --fs-foot: calc(13px * var(--ts));
  --fs-cap: calc(12px * var(--ts));
  --fs-metric: calc(34px * var(--tt)); /* a reading, set in rounded */
  --fs-metric-xl: calc(56px * var(--tt));

  /* ── Space (4pt grid), shape, elevation ─────────────────────────────── */
  --s1: 4px;
  --s2: 8px;
  --s3: 12px;
  --s4: 16px;
  --s5: 20px;
  --s6: 24px;
  --s8: 32px;
  --s10: 40px;
  --s12: 48px;
  --gutter: 20px;

  --r-sm: 8px; /* the wireframe's four radii, kept */
  --r-field: 10px; /* text fields and their icon tiles, as the Figma draws them */
  --r: 14px;
  --r-lg: 22px;
  --r-xl: 28px;
  --r-pill: 999px;

  --e1: 0 0 0 0 transparent; /* flat grey on white (Figma). Not `none`: it is used inside shadow lists, where none is invalid */
  --e2: 0 10px 28px -12px rgba(15, 23, 42, 0.22), 0 2px 6px rgba(15, 23, 42, 0.06);
  --e3: 0 -8px 40px -12px rgba(11, 21, 51, 0.28);

  --tap: 44px; /* minimum touch target, everywhere */

  /* ── Motion ─────────────────────────────────────────────────────────── */
  --d-press: 120ms;
  --d-fast: 180ms;
  --d-base: 260ms;
  --d-push: 380ms;
  --ease-out: cubic-bezier(0.2, 0.8, 0.2, 1);
  --ease-in: cubic-bezier(0.4, 0, 1, 1);
  --ease-ios: cubic-bezier(0.32, 0.72, 0, 1); /* sheets and pushes */
}

/* ── The type scale, re-declared where the text size is set ───────────────
   Custom properties inherit as COMPUTED values. Declared only on :root, every
   --fs-* would be computed once against --ts: 1 and inherited frozen, so the
   text-size setting (which the shell writes to .ios) would change nothing.
   Re-declaring the scale on .ios computes it against the live --ts. */
.ios {
  --tt: calc(1 + (var(--ts) - 1) * 0.5);
  --fs-large: calc(34px * var(--tt));
  --fs-t1: calc(28px * var(--tt));
  --fs-t2: calc(22px * var(--tt));
  --fs-t3: calc(20px * var(--tt));
  --fs-head: calc(17px * var(--ts));
  --fs-body: calc(17px * var(--ts));
  --fs-callout: calc(16px * var(--ts));
  --fs-sub: calc(15px * var(--ts));
  --fs-foot: calc(13px * var(--ts));
  --fs-cap: calc(12px * var(--ts));
  --fs-metric: calc(34px * var(--tt));
  --fs-metric-xl: calc(56px * var(--tt));
}

/* ── Increase Contrast ───────────────────────────────────────────────────
   One class on the app root remaps meaning, not components: darker text,
   firmer lines, deeper status inks, and no translucency anywhere. */
.hc {
  --bg: #ffffff;
  --card: #eef0f3;
  --field: #ffffff;
  --text-2: var(--slate-700); /* 10.35:1 */
  --text-3: var(--slate-600);
  --line: var(--slate-300);
  --line-strong: var(--slate-600);
  --brand: var(--navy-800);
  --brand-ink: var(--navy-800);
  --text-link: var(--navy-700);
  --accent-ink: var(--teal-800);
  --ok: var(--green-800);
  --ok-icon: var(--green-700); /* 4.39:1 on the Increase Contrast card */
  --attn: var(--amber-800);
  --danger: var(--red-800);
  --focus: var(--navy-800);
  --e1: 0 0 0 1px var(--slate-300);
}

@media (prefers-reduced-motion: reduce) {
  :root {
    --d-fast: 1ms;
    --d-base: 1ms;
    --d-push: 1ms;
  }
}
