/* Instrument skin. Existing tokens live in home.css, gym.css, today.css and
   design-tokens.css. This opt-in layer leaves those fallback declarations intact.
   Remove data-skin from html to restore the existing cascade. */

/* ==========================================================================
   Eccentryx design system: the ONE canonical token layer (2026-11-19).
   Every page already loads this file under html[data-skin="instrument"], so the
   scale lives here instead of in a fifth token file. New pages and redesigned
   pages read only --ds-* names; design_tokens_contract_test.js pins the scale,
   the four theme mappings and the AA contrast of every text-on-surface pair.

   Legacy names (--bg, --text, --muted, --accent, --r, ... and --instrument-*)
   stay wired to the theme-invariant instrument palette further down, so pages
   that have not adopted the roles yet render exactly as before. A page adopts
   the system by styling with --ds-* only; its [data-theme] then works.

   Roles, not colours:
     --ds-surface-0/1/2  page, card, raised/inset
     --ds-text-1/2       primary text, secondary text (both AA 4.5 on every surface)
     --ds-border         decorative hairline (no contrast duty)
     --ds-border-strong  component boundary (inputs, ghost buttons): 3:1 on every surface
     --ds-accent         fill for the one primary action; --ds-accent-ink is text on it
     --ds-accent-text    accent-coloured text and links on surfaces
     --ds-accent-soft    tinted background for a selected state
     --ds-positive/--ds-caution/--ds-danger  status text on surfaces
     --ds-focus          focus ring colour (3:1 on every surface)
   ========================================================================== */
html[data-skin="instrument"] {
  /* Type families: sans for reading, display for headings, mono for numbers,
     labels and data only. Fallback faces are metric-matched in the page sheet. */
  --ds-font-text: 'Inter','Inter Fallback',ui-sans-serif,system-ui,-apple-system,'Segoe UI',sans-serif;
  --ds-font-display: 'Space Grotesk','Space Grotesk Fallback','Inter',ui-sans-serif,system-ui,sans-serif;
  --ds-font-data: 'JetBrains Mono','JetBrains Mono Fallback',ui-monospace,'SF Mono',Menlo,Consolas,monospace;
  /* Modular scale, ratio ~1.25, fluid between 320px and 1440px. */
  --ds-text-xs: 0.8125rem;
  --ds-text-sm: 0.9375rem;
  --ds-text-md: clamp(1rem, 0.96rem + 0.2vw, 1.0625rem);
  --ds-text-lg: clamp(1.125rem, 1.06rem + 0.32vw, 1.3125rem);
  --ds-text-xl: clamp(1.3125rem, 1.18rem + 0.66vw, 1.75rem);
  --ds-text-2xl: clamp(1.625rem, 1.38rem + 1.22vw, 2.375rem);
  --ds-text-3xl: clamp(2.125rem, 1.7rem + 2.1vw, 3.375rem);
  --ds-text-4xl: clamp(2.5rem, 1.86rem + 3.2vw, 4.5rem);
  --ds-leading-tight: 1.05;
  --ds-leading-snug: 1.25;
  --ds-leading-body: 1.6;
  --ds-tracking-display: -0.025em;
  --ds-tracking-label: 0.08em;
  --ds-weight-regular: 400;
  --ds-weight-medium: 500;
  --ds-weight-semibold: 600;
  --ds-weight-bold: 700;
  --ds-measure: 62ch;
  /* Spacing on a 4/8 rhythm. */
  --ds-space-1: 4px;
  --ds-space-2: 8px;
  --ds-space-3: 12px;
  --ds-space-4: 16px;
  --ds-space-5: 24px;
  --ds-space-6: 32px;
  --ds-space-7: 48px;
  --ds-space-8: 64px;
  --ds-space-9: 96px;
  --ds-space-10: 128px;
  --ds-container: 1120px;
  --ds-gutter: clamp(16px, 4vw, 32px);
  --ds-tap: 44px;
  /* Shape. */
  --ds-radius-sm: 6px;
  --ds-radius-md: 10px;
  --ds-radius-lg: 16px;
  --ds-radius-pill: 999px;
  --ds-border-width: 1px;
  /* Elevation: three steps, tinted per theme through --ds-shadow-color. */
  --ds-elev-1: 0 1px 2px var(--ds-shadow-color);
  --ds-elev-2: 0 8px 24px var(--ds-shadow-color);
  --ds-elev-3: 0 24px 64px var(--ds-shadow-color);
  /* Focus. */
  --ds-focus-width: 2px;
  --ds-focus-offset: 3px;
  /* Motion. Durations collapse to 0 under prefers-reduced-motion (below). */
  --ds-dur-fast: 120ms;
  --ds-dur-base: 200ms;
  --ds-dur-slow: 320ms;
  --ds-ease-out: cubic-bezier(0.2, 0.7, 0.2, 1);
  --ds-ease-in-out: cubic-bezier(0.4, 0, 0.2, 1);
  /* Colour roles: dark (the default theme). */
  --ds-surface-0: #0e0f12;
  --ds-surface-1: #16181c;
  --ds-surface-2: #1f2126;
  --ds-text-1: #f4f4f6;
  --ds-text-2: #a9acb4;
  --ds-border: #26282e;
  --ds-border-strong: #6b6e76;
  --ds-accent: #ffba08;
  --ds-accent-ink: #141414;
  --ds-accent-text: #ffc94d;
  --ds-accent-soft: #2b2410;
  --ds-positive: #4ade80;
  --ds-caution: #fbbf24;
  --ds-danger: #f87171;
  --ds-focus: #ffc94d;
  --ds-shadow-color: rgba(0, 0, 0, 0.32);
}
html[data-skin="instrument"][data-theme="obsidian"] {
  --ds-surface-0: #050506;
  --ds-surface-1: #0d0d0f;
  --ds-surface-2: #141416;
  --ds-text-1: #f5f5f7;
  --ds-text-2: #a1a1aa;
  --ds-border: #1e1e22;
  --ds-border-strong: #63636b;
  --ds-accent: #ffba08;
  --ds-accent-ink: #050506;
  --ds-accent-text: #ffba08;
  --ds-accent-soft: #221c08;
  --ds-positive: #4ade80;
  --ds-caution: #fbbf24;
  --ds-danger: #f87171;
  --ds-focus: #ffba08;
  --ds-shadow-color: rgba(0, 0, 0, 0.5);
}
html[data-skin="instrument"][data-theme="light"] {
  --ds-surface-0: #f6f5f1;
  --ds-surface-1: #ffffff;
  --ds-surface-2: #ebe9e3;
  --ds-text-1: #141416;
  --ds-text-2: #55565d;
  --ds-border: #e0ded7;
  --ds-border-strong: #7c7d83;
  --ds-accent: #141416;
  --ds-accent-ink: #ffc94d;
  --ds-accent-text: #7a4f00;
  --ds-accent-soft: #faf0d4;
  --ds-positive: #166534;
  --ds-caution: #8a4b00;
  --ds-danger: #b42318;
  --ds-focus: #7a4f00;
  --ds-shadow-color: rgba(20, 20, 22, 0.08);
}
html[data-skin="instrument"][data-theme="clinical"] {
  --ds-surface-0: #f7faf9;
  --ds-surface-1: #ffffff;
  --ds-surface-2: #eaf2ef;
  --ds-text-1: #0d1512;
  --ds-text-2: #3f4f49;
  --ds-border: #d6e3de;
  --ds-border-strong: #7c8b85;
  --ds-accent: #047857;
  --ds-accent-ink: #ffffff;
  --ds-accent-text: #046a4e;
  --ds-accent-soft: #e1f2ea;
  --ds-positive: #166534;
  --ds-caution: #8a4b00;
  --ds-danger: #b42318;
  --ds-focus: #046a4e;
  --ds-shadow-color: rgba(13, 21, 18, 0.08);
}
@media (prefers-reduced-motion: reduce) {
  html[data-skin="instrument"] {
    --ds-dur-fast: 0ms;
    --ds-dur-base: 0ms;
    --ds-dur-slow: 0ms;
  }
}

/* Legacy instrument palette and aliases (theme-invariant; unchanged). */
html[data-skin="instrument"] {
  --instrument-bg: #050506;
  --instrument-surface: #0d0d0f;
  --instrument-raised: #141416;
  --instrument-text: #f5f5f7;
  --instrument-muted: #a1a1aa;
  --instrument-gold: #ffba08;
  --instrument-rule: rgba(255,255,255,.14);
  --instrument-grid: rgba(255,255,255,.024);
  --instrument-mono: 'JetBrains Mono',ui-monospace,'SF Mono',Menlo,Consolas,monospace;
  --instrument-display: 'Space Grotesk',ui-sans-serif,system-ui,sans-serif;
  --bg-2: var(--instrument-bg);
  --card: var(--instrument-surface);
  --elev: var(--instrument-raised);
  --line-2: var(--instrument-rule);
  --faint: var(--instrument-muted);
  --font-mono: var(--instrument-mono);
  --font-display: var(--instrument-display);
  --load: var(--instrument-gold);
  --good: var(--instrument-gold);
  --green: var(--instrument-gold);
  --green-light: var(--instrument-gold);
  --warn: var(--instrument-gold);
  --blue: var(--instrument-gold);
  --blue-strong: var(--instrument-gold);
  --acc: var(--instrument-gold);
  --amber: var(--instrument-gold);
  --shell-top: var(--instrument-bg);
  --shell-bot: var(--instrument-bg);
  --hud-top: var(--instrument-surface);
  --hud-bot: var(--instrument-surface);
  --bg: var(--instrument-bg);
  --bg-app: var(--instrument-bg);
  --paper: var(--instrument-bg);
  --surface: var(--instrument-surface);
  --surface-2: var(--instrument-raised);
  --bg-surface: var(--instrument-surface);
  --sheet-bg: var(--instrument-surface);
  --panel: var(--instrument-surface);
  --text: var(--instrument-text);
  --ink: var(--instrument-text);
  --navy: var(--instrument-text);
  --slate: var(--instrument-text);
  --muted: var(--instrument-muted);
  --line: var(--instrument-rule);
  --line-strong: var(--instrument-rule);
  --action: var(--instrument-gold);
  --action-hover: var(--instrument-gold);
  --on-action: var(--instrument-bg);
  --action-ink: var(--instrument-gold);
  --teal-ink: var(--instrument-gold);
  --accent: var(--instrument-gold);
  --accent-cyan: var(--instrument-gold);
  --accent-magenta: var(--instrument-gold);
  --cy: var(--instrument-gold);
  --cy-deep: var(--instrument-gold);
  --mono: var(--instrument-mono);
  --serif: var(--instrument-display);
  --r: 0px;
  --r-sm: 0px;
  color-scheme: dark;
}
html[data-skin="instrument"] body {
  background-color: var(--instrument-bg);
  background-image: linear-gradient(var(--instrument-grid) 1px,transparent 1px),linear-gradient(90deg,var(--instrument-grid) 1px,transparent 1px);
  background-size: 40px 40px;
  color: var(--instrument-text);
}
html[data-skin="instrument"] :is(h1,.wordmark) { font-family: var(--instrument-display); }
html[data-skin="instrument"] :is(nav,.topnav,.lab,label,button,.btn,.dv-tag,.dv-eyebrow,.readout-tag,.price,.price-amt,.v,.u,.dv-target,.readiness-badge,.s2-chip-num,.instrument-row-index) {
  font-family: var(--instrument-mono);
  font-variant-numeric: tabular-nums;
}
html[data-skin="instrument"] :is(nav,.topnav,.lab,label,.dv-tag,.dv-eyebrow,.readout-tag) { text-transform: uppercase; }
html[data-skin="instrument"] :is(.hero,.device-screen,.device-frame,.readout,.panel,.today-out,.price-card,.card,.num,.upnext,.sheet,.instrument-card) {
  background-color: var(--instrument-surface);
  background-image: linear-gradient(var(--instrument-gold),var(--instrument-gold)),linear-gradient(var(--instrument-gold),var(--instrument-gold)),linear-gradient(var(--instrument-gold),var(--instrument-gold)),linear-gradient(var(--instrument-gold),var(--instrument-gold));
  background-size: 12px 1px,1px 12px,12px 1px,1px 12px;
  background-position: left top,left top,right bottom,right bottom;
  background-repeat: no-repeat;
  border-color: var(--instrument-rule);
  border-radius: 0;
  box-shadow: none;
  color: var(--instrument-text);
}
html[data-skin="instrument"] :is(.btn-primary,.btn-buy,.dv-action,.log-btn) {
  background: var(--instrument-gold);
  color: var(--instrument-bg);
  border-color: var(--instrument-gold);
  box-shadow: none;
}
html[data-skin="instrument"] :is(.topbar,hr,.readout-rows li,.data-stream-chip,.instrument-row) { border-color: var(--instrument-rule); }
html[data-skin="instrument"] :is(.s2-chip-num,.instrument-row-index) { color: var(--instrument-gold); }
html[data-skin="instrument"] :is(.readiness-badge,.metabolic-tag,.instrument-readiness) {
  font-family: var(--instrument-mono);
  font-variant-numeric: tabular-nums;
  border-color: var(--instrument-rule);
  color: var(--instrument-text);
  border-radius: 0;
}
/* The reusable gauge occupies existing readout boxes; it creates no new fold. */
html[data-skin="instrument"] :is(.dv-target,.tachometer-wrap) { position: relative; }
.instrument-gauge { display: none; }
html[data-skin="instrument"] .instrument-gauge {
  display: block;
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: visible;
  pointer-events: none;
  color: var(--instrument-text);
}
html[data-skin="instrument"] .instrument-gauge-arc,
html[data-skin="instrument"] .instrument-gauge-tick { fill: none; stroke: var(--instrument-muted); stroke-width: 1; }
html[data-skin="instrument"] .instrument-gauge-needle { stroke: var(--instrument-gold); stroke-width: 2; stroke-linecap: round; }
html[data-skin="instrument"] .dv-target { color: var(--instrument-text); text-align: center; }
html[data-skin="instrument"] .instrument-gauge { opacity: .5; }
html[data-skin="instrument"] #nReps .tachometer-svg { visibility: hidden; }
html[data-skin="instrument"] .hero::before,
html[data-skin="instrument"] .device-frame::after { background: none; }
html[data-skin="instrument"] :is(.hero-sub,.hero-free,.hero-eyebrow,.dv-tag,.dv-step,.readout-k) { color: var(--instrument-text); }
html[data-skin="instrument"] :is(.ae-kicker,.eyebrow,.hero-kicker) { color: var(--instrument-muted); }
html[data-skin="instrument"] :is(.dot,.live-dot) { background-color: var(--instrument-gold); box-shadow: none; }

html[data-skin="instrument"] .dv-eff { color: var(--instrument-text); border-color: var(--instrument-rule); }
html[data-skin="instrument"] .dv-eff.on { color: var(--instrument-text); background: var(--instrument-raised); border-color: var(--instrument-gold); }
html[data-skin="instrument"] .free-banner strong { color: var(--instrument-text); }
