/* ==========================================================================
   Health Age Simulator v5 — tokens, rebased on Genomics v17 (9 Oct 2026, Mihir).
   Why: HS-08 Prototype v4 — Design System Audit vs Genomics v17 (D1, D2, D4, D6, D7).

   Three layers, in this order:
     A. Genomics v17 tokens.css — VERBATIM (Sahatna Genomics v17/tokens.css, 29 Sep 2026).
        Dark is :root; light is [data-theme="light"]. ui.js now always sets data-theme.
     B. Light-mode AA overrides — kept by Mihir's decision, 9 Oct 2026 ("keep readability fixes").
     C. Simulator extension — tokens Genomics does not have (slider, orb, status/tag colours,
        AI bubble, sheet, motion, demo stage + review panel), plus aliases so the v4 names
        used in app.css resolve to the Genomics tokens.
   ========================================================================== */

/* ========================== A. Genomics v17 (verbatim) ========================== */
/* ==========================================================================
   TAMM DLS tokens — Sahatna | Genomics. Dark is :root (product default); light is [data-theme=light], v15.
   Every value here was read off the Figma file
   WZ1L30ATWDq3uVq48fX4gO (App Sahatna | Genomics), page
   "EGP VIP1 Prototype 12 Aug", via the Plugin API. The comment after each
   custom property is the Figma variable it is bound to. Nothing in this file
   is invented; where the design used a raw hex with no variable, the comment
   says "raw".
   Reference: vault note NX-30 Build Spec — Foundations & Extraction Log.
   ========================================================================== */

:root {
  /* ---- surface ------------------------------------------------------- */
  --bg-primary:            #000000;   /* color/background/primary            */
  --bg-secondary:          #282931;   /* color/background/secondary          */
  --neutral-primary:       #000000;   /* color/neutral/primary               */
  --neutral-secondary:     #ffffff;   /* color/neutral/secondary             */
  --header-bg:             #000000;   /* color/header/default-background     */
  --page-grad-end:         #000000;   /* …/tamm-by-you-dark-grad-end         */

  /* ---- card ---------------------------------------------------------- */
  --card-bg:               rgba(255,255,255,.10); /* color/card/filled/background/default */
  --card-stroke:           rgba(255,255,255,.10); /* color/card/filled/stroke/default     */
  --card-stroke-outline:   rgba(255,255,255,.10); /* card/stroke-outline                 */
  --opacity-primary:       rgba(255,255,255,.10); /* color/opacity/primary               */
  --opacity-secondary:     rgba(255,255,255,.15); /* color/opacity/secondary             */
  --opacity-disable:       rgba(255,255,255,.05); /* color/opacity/disable               */
  --skeleton-primary:      rgba(255,255,255,.05); /* color/skeleton/primary              */
  --opacity-septenary:     rgba(18,18,27,.50);    /* color/opacity/septenary             */
  --outline-secondary:     #464650;   /* color/outline/secondary             */
  --table-stroke:          rgba(255,255,255,.10); /* color/table-readonly/stroke/default */

  /* ---- text ---------------------------------------------------------- */
  --text-primary:          #ffffff;   /* color/text/primary, color/text/white */
  --text-secondary:        #d0d0d1;   /* color/text/secondary, color/text/body */
  --text-tertiary:         #a0a0a4;   /* color/text/tertiary                 */
  --text-quarternary:      #83838e;   /* color/text/quarternary              */
  --pill-text:             #ffffff;   /* color/pill/text/default             */

  /* ---- brand / action ------------------------------------------------ */
  --accent:                #0eecda;   /* color/button/primary/default,
                                         color/link/primary/default,
                                         color/brand-footer/text/selected     */
  --button-secondary:      rgba(255,255,255,.15); /* color/button/secondary/default */
  --button-secondary-on:   #ffffff;   /* color/button/secondary/active       */
  --button-text-active:    #12121b;   /* color/button/text/primary/default — v15: was #ffffff, wrong in dark (ink on teal) */
  --segmented-on:          rgba(255,255,255,.20); /* color/segmented-control/selected */
  --segmented-bg:          rgba(255,255,255,.10); /* color/segmented-control/default */
  --pill-bg:               rgba(255,255,255,.15); /* color/pill/background/default */
  --action-required-bg:    rgba(255,255,255,.20); /* color/action-required/background/default */
  --checkbox-focus:        #12b6ad;   /* color/checkbox/default/focus        */

  /* ---- input --------------------------------------------------------- */
  --input-bg:              rgba(255,255,255,.10); /* color/input/background/default */
  --input-border:          rgba(255,255,255,.10); /* color/input/border/default     */
  --input-border-active:   #0eecda;   /* color/input/border/active           */

  /* ---- status -------------------------------------------------------- */
  --success:               #70e17b;   /* color/highlighter/default/success   */
  --success-primary:       #00a91c;   /* color/notification/success/primary  */
  --success-tertiary:      #99ffaa;   /* color/notification/success/tertiary */
  --error-secondary:       #f45d79;   /* color/notification/error/secondary  */
  --warning-tertiary:      #fce2c5;   /* color/notification/warning/tertiary */
  --info-quarternary:      rgba(88,180,255,.15); /* color/notification/informational/quarternary */
  --info-primary:          #2491ff;   /* informational glyph — Book empty state 28232:176078 */

  /* ---- tag / gene pills --------------------------------------------- */
  /* Read off `Clinical Trait Details` 28232:188241, where every one of these
     is variable-bound: the DETECTED row is color/tag/{text,background}/error
     and the NON-DETECTED row is color/tag/{text,background}/neutral.
     Note the neutral pair is used INVERTED in the frame — the pill's fill is
     the "text" token and its label is the "background" token. Reproduced as
     drawn; the names below say what each value DOES here, not what the DLS
     calls it, so the inversion cannot be mistaken for a bug. */
  --tag-error-ink:         #b21d38;   /* color/tag/text/error        */
  --tag-error-surface:     #f8dfe2;   /* color/tag/background/error  */
  --tag-neutral-surface:   #5d5e68;   /* color/tag/text/neutral   (used as fill)  */
  --tag-neutral-ink:       #e7e7e8;   /* color/tag/background/neutral (used as ink) */
  --tag-neutral-dot:       #5d5e68;   /* the row bullet — see the light note below */
  --tag-informational:     #345d96;   /* color/tag/text/informational        */
  --warning-text:          #fa9441;   /* color/status-text/warning/primary   */
  --link-text:             #0eecda;   /* accent as text — light uses teal/60 */

  /* ---- static (never flip — text on fixed-colour surfaces) ----------- */
  --static-white:          #ffffff;   /* color/text/white                    */
  --static-black:          #000000;
  --shadow-s:              0 2px 8px rgba(255,255,255,.16);  /* shadow/S    */
  --shadow-m:              0 4px 16px rgba(255,255,255,.20); /* shadow/M    */
  --ai-footer:             #1f3d3f;   /* color/ai/input-footer/primary       */
  --ai-outline-start:      #169f9f;   /* color/ai/card/outline-start         */
  --static-ink:            #12121b;   /* text on paper / on pale level tints */
  --figure-muted:          #5d5e68;   /* pop-people inactive figures (raw)   */
  --grad-ai-card:          linear-gradient(90deg, #051b1b 0%, #072c2c 100%);   /* AI card, raw */
  --grad-ai-pill:          linear-gradient(315deg, #004747 0%, #00615b 100%); /* Smart Prompt pill, raw */

  /* ---- gradients (stops read from the bound paints) ------------------ */
  --grad-a3:      linear-gradient(180deg, #0077b5 0%, rgba(0,0,0,0) 100%);
  --grad-genes:   radial-gradient(120% 90% at 50% 0%, rgba(33,200,52,.15) 0%, rgba(18,18,27,0) 100%);
  /* Status Card Widget 20555:21366 — gradientTransform gives 155deg, not 135. */
  --grad-status:  linear-gradient(155deg, #020b2a 0%, #004ab2 100%);
  --grad-ai:      linear-gradient(135deg, rgba(14,236,218,.15) 0%, rgba(80,235,226,0) 100%);
  --grad-prompts: linear-gradient(180deg, #051b1b 0%, #072c2c 100%);
  --card-tint-op: 1;                 /* v15 — light may halve category washes */

  /* ---- spacing — Channel → Mobile ------------------------------------ */
  --sp-xxs: 2px;   --sp-xs: 4px;   --sp-s: 8px;   --sp-m: 12px;
  --sp-l: 16px;    --sp-xl: 20px;  --sp-2xl: 24px; --sp-3xl: 32px;

  /* ---- radius -------------------------------------------------------- */
  --r-s: 12px;     /* radius/S                       */
  --r-m: 16px;     /* radius/M, radius/component/Card Small */
  --r-l: 20px;     /* radius/L, radius/component/Card Large */
  --r-xl: 24px;    /* radius/XL                      */
  --r-full: 999px; /* radius/Full, component/Button, component/Search */

  /* ---- blur ---------------------------------------------------------- */
  --blur-30: 30px; --blur-35: 35px; --blur-40: 40px; --blur-120: 120px;

  /* ---- device -------------------------------------------------------- */
  --device-w: 402px;   /* v6.6: iPhone 17 Pro */
  --gutter: 20px;         /* every screen's horizontal padding */
  --col: 350px;           /* 390 − 2×20                        */
}


/* ==========================================================================
   v15 — LIGHT THEME.  [data-theme="light"] on <html>. Every value below is
   the TAMM Light mode of the same Figma variable, resolved from the live
   Theme library on 10 Sep 2026 (NX-60 §4). Anything not redefined here is
   static across modes by design: category tints, status-widget gradient,
   consult hero, --static-*.
   ========================================================================== */
[data-theme="light"] {
  --bg-primary:            #ffffff;
  --bg-secondary:          #e7e7e8;
  --neutral-primary:       #ffffff;
  --neutral-secondary:     #000000;
  --header-bg:             #ffffff;
  --page-grad-end:         #ffffff;

  --card-bg:               rgba(18,18,27,.05);
  --card-stroke:           rgba(18,18,27,.10);
  --card-stroke-outline:   rgba(18,18,27,.10);
  --opacity-primary:       rgba(18,18,27,.05);
  --opacity-secondary:     rgba(18,18,27,.10);
  --opacity-disable:       rgba(18,18,27,.05);
  --skeleton-primary:      rgba(0,0,0,.05);
  --opacity-septenary:     rgba(255,255,255,.50);   /* inverts */
  --outline-secondary:     #e7e7e8;
  --table-stroke:          rgba(18,18,27,.10);

  --text-primary:          #12121b;
  --text-secondary:        #282931;
  --text-tertiary:         #83838e;
  --text-quarternary:      #a0a0a4;                 /* lighter in light */
  --pill-text:             #12121b;

  --accent:                #169f9f;
  --button-secondary:      rgba(18,18,27,.05);
  --button-secondary-on:   #12121b;
  --button-text-active:    #ffffff;
  --segmented-bg:          rgba(18,18,27,.05);
  --segmented-on:          rgba(18,18,27,.15);
  --pill-bg:               rgba(0,0,0,.05);
  --action-required-bg:    rgba(18,18,27,.05);
  --checkbox-focus:        #238281;

  --input-bg:              rgba(18,18,27,.05);
  --input-border:          rgba(18,18,27,.05);
  --input-border-active:   #169f9f;

  --success:               #00a91c;
  --success-primary:       #00a91c;
  --success-tertiary:      #00a91c;
  --error-secondary:       #f45d79;
  --warning-tertiary:      #cf4900;                 /* inverts pale → deep */
  --info-quarternary:      rgba(88,180,255,.15);
  --info-primary:          #0057b8;                 /* darkened for the pale wash — 4.6:1 */

  /* The error pair is a pale surface with a dark ink, so it carries over to a
     white page unchanged — that is what makes it a semantic marker rather than
     a dark-mode colour. The neutral pair DOES have to flip: #5d5e68 is a
     dark-mode fill and reads as a heavy slab on white. */
  --tag-error-ink:         #b21d38;
  --tag-error-surface:     #f8dfe2;
  --tag-neutral-surface:   #e7e7e8;
  --tag-neutral-ink:       #414250;
  /* The bullet does NOT follow the pill fill into light mode. In the frame the
     two share color/tag/text/neutral, but that only works because the dark
     fill is also a legible dot; on white the pale fill would be an invisible
     dot. It keeps the dark value, which reads on either ground. */
  --tag-neutral-dot:       #5d5e68;
  --tag-informational:     #d0ebff;                 /* inverts */
  --warning-text:          #ef5e25;
  --link-text:             #006d6d;                 /* teal/60 — 4.5:1 on white */

  --shadow-s:              0 2px 8px rgba(18,18,27,.16);
  --shadow-m:              0 4px 16px rgba(18,18,27,.20);
  --ai-footer:             #dcf3ee;
  --ai-outline-start:      #37fbe4;                 /* counter-intuitive, per library */
  --grad-prompts:          linear-gradient(180deg, #dcf3ee 0%, #eaf8f5 100%);
  --figure-muted:          #d0d0d1;
  --grad-ai-card:          linear-gradient(90deg, #dcf3ee 0%, #eaf8f5 100%);   /* ai/input-footer/primary light pair */
  --grad-ai-pill:          linear-gradient(315deg, #c4ebe4 0%, #d6f1ec 100%);
}

/* --------------------------------------------------------------------------
   Type ramp. CircularXX; Book is weight 450, Medium 500 (Fonts/Font Weight).
   Letter-spacing −2 in the DLS is −2 PERCENT, not −2px — writing it as px
   welds characters together ("Yourdetails"). Every ls below is em-based.
   -------------------------------------------------------------------------- */
:root {
  --f: 'CircularXX', 'Circular Std', system-ui, -apple-system, sans-serif;
}

.t-display  { font: 500 48px/1.2 var(--f); letter-spacing: -.02em; }  /* orb age      */
.t-h1       { font: 500 32px/1.2 var(--f); letter-spacing: -.02em; }  /* "Sahatna"    */
.t-h2       { font: 500 28px/1.2 var(--f); letter-spacing: -.02em; }  /* greeting     */
.t-h3       { font: 500 26px/1.2 var(--f); letter-spacing: -.02em; }  /* genes guide  */
.t-h3s      { font: 500 24px/1.2 var(--f); letter-spacing: -.02em; }  /* C7 explore   */
.t-h4       { font: 500 20px/1.2 var(--f); letter-spacing: -.02em; }  /* section head */
.t-h5       { font: 500 16px/1.2 var(--f); letter-spacing: -.02em; }  /* AI title     */
.t-title    { font: 500 16px/1.4 var(--f); }                          /* app header   */
.t-label-m  { font: 500 14px/1.2 var(--f); }                          /* filter label */
.t-body-l   { font: 450 16px/1.4 var(--f); }
.t-body     { font: 450 14px/1.4 var(--f); }
.t-small    { font: 450 12px/1.4 var(--f); }


/* ========================== B. Light-mode AA overrides ========================== */
/* Mihir, 9 Oct 2026: keep the Simulator's readability fixes over the DLS light values.
   Genomics keeps the DLS values and logs the failures (NX-86); the Simulator runs on a
   public event screen, so legibility wins. Each is an AA override, not a DLS value. */
[data-theme="light"] {
  --text-tertiary:      #6b6b76;   /* AA override — DLS color/text/tertiary #83838e is 3.4:1 on white   */
  --text-quarternary:   #6b6b76;   /* AA override — DLS color/text/quarternary #a0a0a4 fails on white */
  --btn-primary-bg:     #006d6d;   /* AA override — teal/60 + white 6.2:1; DLS button/primary #169f9f + white is 3.2:1 */
}


/* ========================== C. Simulator extension ========================== */
:root {
  /* aliases — v4 names → Genomics tokens (do not give these their own values) */
  --bg-page:            var(--bg-primary);
  --link:               var(--link-text);
  --pill-bg-on:         var(--neutral-secondary);  /* selected pill inverts, as Genomics .pill.is-on */
  --pill-text-on:       var(--neutral-primary);
  --ai-input-bg:        var(--ai-footer);
  --sp-2: var(--sp-xxs); --sp-4: var(--sp-xs); --sp-8: var(--sp-s); --sp-12: var(--sp-m);
  --sp-16: var(--sp-l); --sp-20: var(--sp-xl); --sp-24: var(--sp-2xl); --sp-32: var(--sp-3xl);
  --r-card-s:           var(--r-m);
  --r-card-l:           var(--r-l);
  --r-xxs:              4px;                       /* radius/XXS — tag, slider value tooltip */
  --blur-l:             var(--blur-40);
  --blur-m:             var(--blur-30);

  /* accent tints — follow the theme (v4 hard-coded the dark teal rgba(14,236,218,…)) */
  --btn-primary-bg:     var(--accent);         /* dark: DLS color/button/primary/default #0eecda; light: AA override (layer B) */
  --accent-a12:         color-mix(in srgb, var(--accent) 12%, transparent);
  --accent-a20:         color-mix(in srgb, var(--accent) 20%, transparent);
  --accent-a35:         color-mix(in srgb, var(--accent) 35%, transparent);
  --accent-a40:         color-mix(in srgb, var(--accent) 40%, transparent);
  --accent-a70:         color-mix(in srgb, var(--accent) 70%, transparent);

  /* ---- dark values (Genomics :root is dark) — read from the Wellness frames, 30 Sep ---- */
  --bg-tertiary:        #464650;               /* color/background/tertiary (slider tooltip) */
  --slider-fill:        var(--accent);         /* Selector Bar — #0eecda dark / #169f9f light */
  --slider-thumb:       #12121b;               /* raw — Selector Marquee fill */
  --slider-tick:        #169f9f;               /* raw — Divider stroke (teal/40) */
  --slider-track:       rgba(255,255,255,.10); /* raw — Underlay fill white 10% */
  --alert:              #ffba1b;
  --alert-strong:       #fc9224;               /* raw — stroke of Health_orb_older8 (ASSUMED threshold) */
  --tag-error-bg:       rgba(228,29,61,.15);   /* color/notification/error/quarternary */
  --tag-error-text:     #f45d79;               /* color/notification/error/secondary */
  --tag-success-bg:     rgba(0,169,28,.15);    /* color/notification/success/quarternary */
  --tag-success-text:   #21c834;               /* color/notification/success/secondary */
  --tag-warn-bg:        rgba(255,188,120,.15); /* color/notification/warning/quarternary */
  --tag-warn-text:      #fa9441;               /* color/notification/warning/secondary */
  --ai-bubble-user:     #ffffff;               /* color/ai/chat-bubble/user */
  --ai-bubble-user-ink: #12121b;
  --orb-amber-stroke:   #f0cf2b; --orb-amber-fill: #fac941; --orb-inner: #60766f;  /* Orb Wrapper 21349:17523 */
  --orb-green-stroke:   #3ee07a;               /* ASSUMED: "Lower than actual age" state is not drawn */
  --orb-green-fill:     #21c834;
  --orb-steady-stroke:  #9fb7b0;               /* ASSUMED: "In Range" state is not drawn */
  --sheet-bg:           #16161d;               /* raw */
  --scrim:              rgba(0,0,0,.6);
  --grab:               rgba(255,255,255,.25);
  --press:              rgba(255,255,255,.05);
  --shadow-push:        -20px 0 40px rgba(0,0,0,.5);
  --seg-on-shadow:      none;
  --lrow-text:          var(--text-secondary);
  /* demo stage + review panel — outside the phone, not app UI */
  --stage-bg:           #0c0c11;
  --stage-ink:          #ffffff;
  --stage-ink-2:        #a0a0aa;
  --panel-bg:           #15151c; --panel-line: #2a2a33; --panel-ink: #c9c9d1; --panel-ink-strong: #ffffff; --panel-muted: #8a8a96;
  --panel-ctrl:         #22222b; --panel-ctrl-on: #3a3a46; --panel-ctrl-ink: #b8b8c2; --panel-row: #24242d;
  --panel-warn-bg:      rgba(255,186,27,.1); --panel-warn-line: rgba(255,186,27,.35); --panel-warn-ink: #ffd98a;
  --panel-pos:          #ffba1b; --panel-neg: #52d66a;

  /* motion — PROPOSED in HS-01 §5 (the DLS has no motion tokens) */
  --m-fast:   140ms cubic-bezier(.2,0,0,1);
  --m-base:   280ms cubic-bezier(.2,0,0,1);
  --m-push:   380ms cubic-bezier(.32,.72,0,1);
  --m-spring: 440ms cubic-bezier(.34,1.4,.64,1);
  --ease-out: cubic-bezier(.2,0,0,1);
}

/* ---- light values (TAMM Light; the event build's primary theme since 6 Oct) ---- */
[data-theme="light"] {
  --btn-primary-bg:     #006d6d;               /* AA override (see layer B) */
  --bg-tertiary:        #282931;               /* raw — slider tooltip stays dark for legibility */
  --slider-thumb:       #ffffff;
  --slider-tick:        #006d6d;               /* teal/60 */
  --slider-track:       rgba(18,18,27,.12);
  --alert:              #a86b00;               /* AA override — "Higher than actual age"; #ffba1b fails on white */
  --alert-strong:       #c4580a;               /* AA override — "Much older", orb orange darkened */
  --tag-error-bg:       rgba(228,29,61,.10);
  --tag-error-text:     #c8102e;               /* AA override */
  --tag-success-bg:     rgba(0,169,28,.10);
  --tag-success-text:   #00801a;               /* AA override */
  --tag-warn-bg:        rgba(255,188,120,.30); /* color/tag/background/warning-opacity hover (light) */
  --tag-warn-text:      #a84300;               /* AA override — DLS #ef5e25 pairing is 3.1:1 */
  --ai-bubble-user:     #2d494a;               /* color/ai/chat-bubble/user (light) */
  --ai-bubble-user-ink: #ffffff;
  --orb-green-stroke:   #15c18f; --orb-green-fill: #15c18f;
  --sheet-bg:           #ffffff;
  --scrim:              rgba(18,18,27,.35);
  --grab:               rgba(18,18,27,.2);
  --press:              rgba(18,18,27,.05);
  --shadow-push:        -16px 0 32px rgba(18,18,27,.12);
  --stage-bg:           #eef0f2;
  --stage-ink:          #12121b;
  --stage-ink-2:        #5d6068;
  --panel-bg:           #ffffff; --panel-line: #e3e5e8; --panel-ink: #3a3c44; --panel-ink-strong: #12121b; --panel-muted: #6b6e78;
  --panel-ctrl:         #f1f2f4; --panel-ctrl-on: #12121b; --panel-ctrl-ink: #3a3c44; --panel-row: #eceef1;
  --panel-warn-bg:      #fff6e0; --panel-warn-line: #f0d48a; --panel-warn-ink: #6b4a00;
  --panel-pos:          #a86b00; --panel-neg: #00801a;
}
