/* ===== Stay Frosty — Frost Glass tokens (one look: always dark) ===== */
:root {
  color-scheme: dark;

  /* ---- grounds: navy-black ---- */
  --bg: #050A13;              /* page ground */
  --bg-top: #071226;          /* NEW: top of the page gradient (behind the brand) */
  --surface: #0B1626;         /* solid panel fill, inset groups, medium surfaces */
  --surface-2: #12223A;       /* chips (rest), fields, stepper, seg track (solid), pressed rows */
  --surface-3: #1A2E4C;       /* NEW: pressed on --surface-2, disabled fills */
  --panel-top: #0E1B2F;       /* NEW: panel gradient, top */
  --panel-bot: #0A1424;       /* NEW: panel gradient, bottom */
  --material: rgba(8, 16, 29, .68);   /* = --glass-regular (name kept for old rules) */
  --ink: #EEF5FC;
  --ink-2: #AFC0D4;
  --ink-3: #8A9DB6;           /* never on glass (see 1.3) */
  --rule: #1B2B44;            /* hairlines inside panels */
  --rule-strong: #2A4264;     /* double rules, tracks, ticks */
  --seg-thumb: #1A6BCD;       /* solid fallback of --accent-fill */
  --knob: #FFFFFF;

  /* ---- signals (one meaning each) ---- */
  --brass: #F6B12A;           /* amber: primary CTA, S tag, Max pointer, reached ticks */
  --brass-text: #F5C55E;
  --on-brass: #1A1205;
  --brass-fill: linear-gradient(180deg, #FFD45E 0%, #F6B12A 50%, #E58E0C 100%);   /* NEW */
  --blue: #5CC8FF;            /* frost: tappable text and glyphs, "yours" marks */
  --on-blue: #04212E;
  --accent-hi: #2580E0;       /* NEW: vivid frost fill, top */
  --accent-lo: #0E56BA;       /* NEW: vivid frost fill, bottom */
  --accent-fill: linear-gradient(180deg, var(--accent-hi), var(--accent-lo));    /* NEW */
  --on-accent: #FFFFFF;       /* NEW */
  --red: #FF7A6B;
  --green: #6FE0A6;
  --tag: #D2C49A;  --on-tag: #221C0E;  --tag-link: #0F3E5C;  --tag-red: #8A2E21;  /* B tier tag only */
  --toast-bg: rgba(8, 16, 29, .84);   /* = --glass-thick */
  --toast-text: #EEF5FC;
  --toast-ok: #6FE0A6;
  --scrim: rgba(2, 5, 10, .55);
  --scrim-strong: rgba(2, 5, 10, .68);
  --stage-under: #000000;
  --pdf-page: #FAFAF8;
  --pdf-ink3: #5F6569;

  /* ---- atmosphere (see §2) ---- */
  --aura: radial-gradient(70% 180px at 50% 0, rgba(46, 132, 255, .30), transparent 100%),
          radial-gradient(120% 60% at 50% 0, rgba(30, 90, 190, .20), transparent 70%);
  --frost-corners: radial-gradient(90% 50% at 0 100%, rgba(40, 110, 210, .16), transparent 70%),
                   radial-gradient(90% 50% at 100% 100%, rgba(40, 110, 210, .12), transparent 70%);   /* NEW */
  --frost-noise: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.8' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .80 0 0 0 0 .91 0 0 0 0 1 0 0 0 2.4 -1.25'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");   /* NEW */

  /* ---- glass (see §4) ---- NEW */
  --glass-thin: rgba(12, 24, 44, .42);      /* glyph buttons, lens base */
  --glass-regular: rgba(8, 16, 29, .68);    /* bars, tab bar, docked controls, column heads */
  --glass-thick: rgba(8, 16, 29, .84);      /* drawer, menus, toast, notices, PDF chrome, share sheet bars */
  --glass-faux: rgba(10, 20, 36, .72);      /* in-flow "glass look", no blur: seg track, secondary buttons */
  --blur-thin: blur(12px) saturate(180%);
  --blur-regular: blur(22px) saturate(180%) brightness(.9);
  --blur-thick: blur(30px) saturate(170%) brightness(.85);
  --spec: inset 0 1px 0 rgba(255, 255, 255, .20), inset 0 -1px 0 rgba(255, 255, 255, .05), inset 0 0 0 1px rgba(160, 215, 255, .12);
  --rim: linear-gradient(155deg, rgba(255, 255, 255, .50), rgba(255, 255, 255, .06) 30%, rgba(120, 190, 255, .04) 70%, rgba(150, 215, 255, .32));
  --lens-fill: radial-gradient(120% 90% at 50% 0, rgba(140, 210, 255, .28), rgba(60, 150, 255, .10) 70%);
  --sh-float: 0 10px 30px rgba(0, 0, 0, .50), 0 2px 8px rgba(0, 0, 0, .35);

  /* ---- frost edges and glows ---- NEW */
  --edge-frost: 0 0 0 1px rgba(110, 185, 255, .16), inset 0 1px 0 rgba(180, 225, 255, .10),
                0 12px 30px -14px rgba(0, 0, 0, .70), 0 0 28px -12px rgba(40, 140, 255, .30);
  --edge-frost-hi: linear-gradient(180deg, rgba(170, 225, 255, .60), rgba(120, 195, 255, .18) 45%, rgba(120, 195, 255, 0) 90%);
  --glow-accent: inset 0 1px 0 rgba(255, 255, 255, .35), inset 0 0 0 1px rgba(150, 215, 255, .45), 0 0 16px rgba(40, 140, 255, .50);
  --glow-amber: inset 0 1px 0 rgba(255, 255, 255, .45), inset 0 -1px 0 rgba(120, 60, 0, .35), 0 0 0 1px rgba(255, 205, 100, .30), 0 8px 22px -6px rgba(246, 177, 42, .55);
  --glow-glyph: drop-shadow(0 0 6px rgba(92, 200, 255, .55));   /* a filter value, for the active tab glyph */

  /* ---- hatches (unchanged: each encodes data) ---- */
  --hatch-gap: repeating-linear-gradient(38deg, var(--blue) 0 1.5px, transparent 1.5px 5px);
  --hatch-loss: repeating-linear-gradient(45deg, var(--red) 0 1.5px, transparent 1.5px 4px);
  --hatch-hidden: repeating-linear-gradient(38deg, transparent 0 6px, var(--rule) 6px 7px);

  /* ---- schematic plate (art.js and share.js read these) ---- */
  --a-paper: #0B1A30;         /* also the fill of cut-outs in the drawings: matches the plate's mid tone */
  --a-rule: rgba(92, 200, 255, .075);
  --a-margin: rgba(92, 200, 255, .28);   /* unused by the reskin; kept */
  --a-ink: #E2F4FF;
  --a-cap: #CDEBFF;
  --a-note: #93B4CC;
  --a-body: #2B4562;
  --a-dark: #172A42;
  --a-wood: #4A3F30;
  --a-steel: #55728F;
  --a-lens: #7CD6FF;
  --a-laser: #FF5A47;
  --a-hl: rgba(92, 200, 255, .42);
  --a-corner: rgba(140, 215, 255, .55);
  --a-spot: radial-gradient(70% 90% at 30% 20%, rgba(60, 150, 255, .26), transparent 62%);   /* NEW */
  --a-grad: linear-gradient(180deg, #0C1D35, #081323);                                       /* NEW */

  /* ---- type (families and scale unchanged) ---- */
  --font-ui: 'Archivo', -apple-system, 'SF Pro Text', system-ui, sans-serif;
  --font-data: 'Martian Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --font-hand: 'Archivo', -apple-system, 'SF Pro Text', system-ui, sans-serif;
  --wd-cond: 75%;  --wd-semi: 87.5%;
  --fs-hero: 2.353rem;    --lh-hero: 1.1;
  --fs-large: 2rem;       --lh-large: 1.206;
  --fs-title1: 1.647rem;  --lh-title1: 1.214;
  --fs-title2: 1.294rem;  --lh-title2: 1.273;
  --fs-title3: 1.176rem;  --lh-title3: 1.25;
  --fs-headline: 1rem;    --lh-headline: 1.294;
  --fs-body: 1rem;        --lh-body: 1.412;
  --fs-callout: .941rem;  --lh-callout: 1.3125;
  --fs-subhead: .882rem;  --lh-subhead: 1.333;
  --fs-footnote: .765rem; --lh-footnote: 1.385;
  --fs-caption: .706rem;  --lh-caption: 1.333;
  --fs-dxl: 2.588rem;     --lh-dxl: 1.09;
  --fs-dl: 1.647rem;      --lh-dl: 1.143;
  --fs-dm: 1rem;          --lh-dm: 1.294;
  --fs-ds: .765rem;       --lh-ds: 1.385;
  --fs-serial: .706rem;   --lh-serial: 1.333;
  --fs-nav: 17px;  --fs-seg: 14px;  --fs-tab: 10px;  --lh-tab: 12px;   /* --fs-seg 13 → 14 (mockup) */
  --fs-dxs: 11px;  --lh-dxs: 14px;
  --fs-hand-l: 15px; --fs-hand-m: 13px; --fs-hand-s: 12px;

  /* ---- spacing and geometry ---- */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  --s-8: 32px; --s-10: 40px; --s-12: 48px;
  --g: 16px;                  /* text gutter; 20px from 390px, 12px up to 340px */
  --panel-x: 6px;             /* NEW: panel outer inset from the screen edge (4px up to 340px) */
  --pad: calc(var(--g) - var(--panel-x));   /* NEW: panel inner padding, so panel text aligns with --g */
  --sec-gap: 12px;            /* was 32: panels now separate sections */
  --nav-h: 44px;              /* compact brand bar */
  --bar-h: 56px;              /* NEW: brand bar at rest */
  --tab-h: 62px;              /* was 49: floating capsule height */
  --tab-x: 10px;              /* NEW: capsule inset from the screen sides (8 ≤340, 12 ≥390, 16 ≥428) */
  --tab-bottom: max(8px, calc(var(--safe-b) - 12px));   /* NEW: 22pt on Face ID phones, 8pt on SE/iframe */
  --tab-space: calc(var(--tab-bottom) + var(--tab-h) + 16px);   /* NEW: scroller bottom padding */
  --mini: 52px;               /* NEW: minimised tab button */
  --sheet-bar: calc(52px + 10px + max(var(--safe-b), 12px));   /* NEW: sheet bottom bar height */
  --tap: 44px;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);    /* NEW */
  --safe-r: env(safe-area-inset-right, 0px);   /* NEW */
  --stick: calc(var(--safe-t) + var(--nav-h));
  --brand-m: 48px;            /* NEW: mascot height at rest (width = height × 1.16); assets/brand is exported at 2x and 3x of this */
  --brand-w: 50px;            /* NEW: wordmark height at rest (width = height × 2.38); the box is 54pt in the 56pt bar */

  /* ---- radii (complete list) ---- */
  --r-plate: 14px;  --r-tile: 12px;  --r-thumb: 8px;  --r-control: 14px;
  --r-seg: 18px;  --r-seg-thumb: 15px;  --r-stepper: 12px;  --r-group: 18px;  --r-panel: 20px;
  --r-menu: 20px;  --r-sheet: 38px;  --r-stage: 38px;  --r-pill: 999px;
  --r-tabbar: 31px;  --r-lens: 27px;  --r-drawer: 30px;  --r-hero: 24px;   /* NEW: last four, plus --r-tile, --r-panel */

  --hair: 1px;

  /* ---- elevation (complete list) ---- */
  --sh-plate: inset 0 0 0 1px rgba(120, 200, 255, .36), inset 0 1px 0 rgba(200, 235, 255, .22), 0 0 22px -8px rgba(40, 140, 255, .50);
  --sh-sheet: 0 -1px 0 rgba(150, 215, 255, .14), 0 -12px 40px rgba(0, 0, 0, .55);
  --sh-menu: 0 0 0 1px rgba(150, 215, 255, .14), 0 18px 48px rgba(0, 0, 0, .60);
  --sh-thumb: var(--glow-accent);
  --sh-knob: 0 .5px 4px rgba(0, 0, 0, .25), 0 6px 13px rgba(0, 0, 0, .25);
  --edge-brass: var(--glow-amber);

  /* ---- motion ---- */
  --dur-press: 100ms; --dur-state: 200ms; --dur-present: 560ms; --dur-dismiss: 300ms;
  --dur-data: 400ms; --dur-chart: 500ms;
  --dur-tab: 340ms; --dur-tab-out: 180ms; --dur-lens: 520ms; --dur-menu: 420ms; --dur-mini: 420ms;   /* NEW */
  --ease-ios: cubic-bezier(.32, .72, 0, 1);
  --ease-out: cubic-bezier(.2, 0, 0, 1);
  --ease-in: cubic-bezier(.4, 0, 1, 1);
  --ease-stamp: cubic-bezier(.3, 1.4, .5, 1);
  /* springs: cubic fallbacks here, linear() springs in the @supports block below */
  --spring-sheet: cubic-bezier(.32, .72, 0, 1);   /* NEW */
  --spring-lens: cubic-bezier(.34, 1.36, .64, 1); /* NEW */
  --spring-pop: cubic-bezier(.34, 1.56, .64, 1);  /* NEW */

  /* ---- z-index scale ---- */
  --z-sticky: 8; --z-dock: 9; --z-nav: 10; --z-sheet: 20; --z-ghost: 36; --z-xsheet: 40; --z-drawer: 42;
  --z-menu: 45; --z-levelup: 50; --z-flash: 55; --z-toast: 60;
}

@supports (transition-timing-function: linear(0, 1)) {
  :root {
    /* critically damped-ish, 0.5% overshoot (response .42s, damping .86), settles in 560ms */
    --spring-sheet: linear(0, 0.058, 0.188, 0.34, 0.489, 0.62, 0.728, 0.812, 0.876, 0.922, 0.954, 0.976, 0.99, 0.998, 1.002, 1.004, 1.005, 1.005, 1.004, 1.003, 1.003, 1.002, 1);
    /* liquid, 4.6% overshoot (response .38s, damping .70), 600ms */
    --spring-lens: linear(0, 0.07, 0.228, 0.416, 0.596, 0.748, 0.866, 0.949, 1.002, 1.032, 1.044, 1.046, 1.04, 1.032, 1.024, 1.016, 1.009, 1.005, 1.001, 0.999, 0.998, 0.998, 0.998, 0.998, 1);
    /* pop, 8% overshoot (response .30s, damping .62), 500ms: menus, mini tab, pressed release */
    --spring-pop: linear(0, 0.109, 0.342, 0.593, 0.805, 0.954, 1.041, 1.078, 1.082, 1.068, 1.047, 1.027, 1.011, 1.001, 0.995, 0.993, 0.993, 0.995, 0.997, 0.998, 1);
  }
}

@media (max-width: 340px) { :root { --g: 12px; --panel-x: 4px; --tab-x: 8px; --brand-m: 38px; --brand-w: 40px; } }
@media (min-width: 390px) { :root { --g: 20px; --tab-x: 12px; } }
@media (min-width: 428px) { :root { --tab-x: 16px; } }
@media (min-resolution: 2dppx) { :root { --hair: .5px; } }

:root[data-theme] { color-scheme: dark; }

/* Reduce motion (system, or Intel › Reduce motion) */
:root[data-motion="reduce"] {
  --dur-press: 0ms; --dur-state: 0ms; --dur-present: 200ms; --dur-dismiss: 200ms; --dur-data: 0ms; --dur-chart: 0ms;
  --dur-tab: 0ms; --dur-tab-out: 0ms; --dur-lens: 0ms; --dur-menu: 150ms; --dur-mini: 0ms;
}
@media (prefers-reduced-motion: reduce) {
  :root { --dur-press: 0ms; --dur-state: 0ms; --dur-present: 200ms; --dur-dismiss: 200ms; --dur-data: 0ms; --dur-chart: 0ms;
          --dur-tab: 0ms; --dur-tab-out: 0ms; --dur-lens: 0ms; --dur-menu: 150ms; --dur-mini: 0ms; }
}

/* Reduce transparency (system, or Intel › Reduce transparency → :root[data-glass="solid"]), and engines without
   backdrop-filter: every glass becomes an opaque fill of the same family; rims and glows stay. */
@media (prefers-reduced-transparency: reduce) {
  :root { --glass-thin: #12223A; --glass-regular: #0B1626; --glass-thick: #0E1A2C; --glass-faux: #12223A;
          --material: #0B1626; --toast-bg: #0E1A2C; --blur-thin: none; --blur-regular: none; --blur-thick: none; }
}
:root[data-glass="solid"] {
  --glass-thin: #12223A; --glass-regular: #0B1626; --glass-thick: #0E1A2C; --glass-faux: #12223A;
  --material: #0B1626; --toast-bg: #0E1A2C; --blur-thin: none; --blur-regular: none; --blur-thick: none;
}
@supports not ((backdrop-filter: blur(1px)) or (-webkit-backdrop-filter: blur(1px))) {
  :root { --glass-thin: #12223A; --glass-regular: #0B1626; --glass-thick: #0E1A2C; --material: #0B1626; --toast-bg: #0E1A2C; }
}
/* Increase Contrast: quiet ink steps up, hairlines firm up, glass goes opaque */
@media (prefers-contrast: more) {
  :root:not([data-hc]) { --ink-3: var(--ink-2); --rule: var(--rule-strong);
    --glass-thin: #12223A; --glass-regular: #0B1626; --glass-thick: #0E1A2C; --material: #0B1626; --toast-bg: #0E1A2C;
    --blur-thin: none; --blur-regular: none; --blur-thick: none; }
}

/* Landscape and short screens (§8.4): the brand bar starts compact and never expands, the tab capsule is 50 tall
   (glyphs only) and sits closer to the edge; no minimised tab bar (app.js) */
@media (max-height: 500px) {
  :root { --bar-h: 44px; --tab-h: 50px; --tab-bottom: max(6px, var(--safe-b)); }
}
/* Short portrait phones (SE 2/3, Display Zoom minis: 501–700pt tall, no home indicator): the docked 49pt bar they
   had cost less than a 62pt capsule, so the capsule tightens to 54 (glyphs 24) and column heads to 28. Taller phones
   keep the spec's 62 (SPEC §8.2 measures 393×852). */
@media (min-height: 501px) and (max-height: 700px) {
  :root { --tab-h: 54px; --colhead-h: 28px; }
}

/* Landscape on a notched iPhone: #app is a centred 560pt column that only reaches the notch or Dynamic Island inset
   below 560 + 2 × 62 = 684pt of width, so from there the side insets don't apply inside it (SPEC §8.4: safe areas pad
   the bar and capsule only when the column reaches the edge) */
@media (min-width: 684px) { #app { --safe-l: 0px; --safe-r: 0px; } }
