/* ==========================================================================
   THEME TOKENS — layered colour and personality tokens.
   Primitives are raw values; components consume ONLY the semantic layer.
   Loaded after the legacy sheets so the semantic layer wins without changing
   the existing palette blocks yet (Part B owns extra themes).
   ========================================================================== */

:root {
  /* --- Primitive palette (raw, never used by components) --- */
  --p-ink-950: #060606;
  --p-ink-900: #1b1b1b;
  --p-ink-850: #252525;
  --p-ink-800: #2d2d2d;
  --p-grey-100: #f2f2f2;
  --p-grey-300: #b0b0b0;
  --p-grey-500: #969696;
  --p-cyan-400: #22d3ee;
  --p-cyan-500: #06b6d4;
  --p-green-400: #34d399;
  --p-amber-400: #fbbf24;
  --p-red-400: #f87171;
  --p-blue-400: #60a5fa;
  --p-indigo-400: #7c8cff;
  --p-orange-400: #ff9f5a;
  --p-blue-500: #4c8df6;
  --p-green-500: #34c77b;
  --p-orange-500: #f59a3d;
  --p-red-500: #ef5a6f;
  --p-purple-500: #9b7bf2;
  --p-pink-500: #e873b9;
  --p-teal-500: #2bb8b0;
  --p-grey-400: #8a8a8a;

  /* --- Semantic colour: Midnight --- */
  --bg: var(--p-ink-950);
  --surface-1: var(--p-ink-900);
  --surface-2: var(--p-ink-850);
  --surface-3: var(--p-ink-800);
  --divider: rgba(255, 255, 255, 0.08);
  --border-strong: rgba(255, 255, 255, 0.14);
  --text: var(--p-grey-100);
  --text-2: var(--p-grey-300);
  --text-3: var(--p-grey-500);
  --text-inverse: #04202a;
  --accent: var(--p-cyan-400);
  --accent-pressed: var(--p-cyan-500);
  --accent-rgb: 34, 211, 238;
  --accent-subtle: rgba(34, 211, 238, 0.14);
  --on-accent: #04202a;
  --accent-text: var(--p-cyan-400);
  --success: var(--p-green-400);
  --success-subtle: rgba(52, 211, 153, 0.14);
  --warning: var(--p-amber-400);
  --warning-subtle: rgba(251, 191, 36, 0.14);
  --danger: var(--p-red-400);
  --danger-subtle: rgba(248, 113, 113, 0.14);
  --info: var(--p-blue-400);
  --info-subtle: rgba(96, 165, 250, 0.14);
  /* Body-map heat ramp. A HEAT hue is deliberately not a status colour, and the
     map carries no text on it; the legend is decorative and the group label
     names the muscles. `--heat-0` is the untrained base. Canvas (the shared
     workout image) reads these same tokens. */
  --heat-0: var(--surface-3);
  --heat-1: rgba(255, 122, 26, 0.28);
  --heat-2: rgba(255, 122, 26, 0.5);
  --heat-3: rgba(255, 122, 26, 0.74);
  --heat-4: rgba(255, 122, 26, 0.96);
  /* Status TEXT on a surface tinted with the same hue. The base status colours
     are tuned for a bare surface; on their own 6-14% tint they land near 2:1
     (amber-on-amber measured 1.76:1 on the profile ratio tile). Dark keeps the
     base values, which already clear AA on a tint. */
  --warning-text: var(--warning);
  --success-text: var(--success);
  --danger-text: var(--danger);
  --info-text: var(--info);
  --domain-strength: var(--p-indigo-400);
  --domain-endurance: var(--p-orange-400);
  --domain-recovery: var(--p-green-400);
  --data-1: #4c8df6;
  --data-2: #34c77b;
  --data-3: #f59a3d;
  --data-4: #ef5a6f;
  --data-5: #9b7bf2;
  --data-6: #e873b9;
  --data-7: #2bb8b0;
  --data-8: #8a8a8a;
  --overlay-scrim: rgba(6, 6, 6, 0.76);
  --focus-ring: var(--p-cyan-400);

  /* --- Personality --- */
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 22px;
  --border-width: 1px;
  --elevation-1: 0 2px 8px rgba(0, 0, 0, 0.22);
  --elevation-2: 0 8px 24px rgba(0, 0, 0, 0.32);
  --elevation-3: 0 18px 48px rgba(0, 0, 0, 0.44);
  --bg-image: none;
  --label-style: uppercase;
  --label-spacing: 0.1em;
  --font-heading: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-body: system-ui, -apple-system, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --density: 1;
  --motion-scale: 1;
}


/* --- Alternate dark palettes -------------------------------------------------
   Only the semantic layer changes: status/data colours stay constant, and light
   mode keeps its own palette (a palette choice is remembered for dark mode).
   The JS token maps in js/theme/tokens.js carry the same values for canvas.
   ---------------------------------------------------------------------------- */
html[data-theme="dark"][data-palette="slate"] {
  --bg: #0a0f1a;
  --surface-1: #162033;
  --surface-2: #1c2941;
  --surface-3: #21314d;
  --text: #f1f5f9;
  --text-2: #b7c3d5;
  --text-3: #8d9bb1;
  --text-inverse: #04202a;
  --accent: #38bdf8;
  --accent-pressed: #0ea5e9;
  --accent-rgb: 56, 189, 248;
  --accent-subtle: rgba(56, 189, 248, 0.14);
  --on-accent: #04202a;
  --accent-text: #7dd3fc;
  --overlay-scrim: rgba(10, 15, 26, 0.78);
  --focus-ring: #38bdf8;
}

html[data-theme="dark"][data-palette="forest"] {
  --bg: #05100b;
  --surface-1: #0f2319;
  --surface-2: #132d20;
  --surface-3: #173626;
  --text: #edf7f1;
  --text-2: #b0c7ba;
  --text-3: #88a895;
  --text-inverse: #04231a;
  --accent: #34d399;
  --accent-pressed: #10b981;
  --accent-rgb: 52, 211, 153;
  --accent-subtle: rgba(52, 211, 153, 0.14);
  --on-accent: #04231a;
  --accent-text: #6ee7b7;
  --overlay-scrim: rgba(5, 16, 11, 0.78);
  --focus-ring: #34d399;
}

html[data-theme="dark"][data-palette="ember"] {
  --bg: #120b08;
  --surface-1: #291b15;
  --surface-2: #34231b;
  --surface-3: #3e2a20;
  --text: #f7f0ea;
  --text-2: #cdb9ab;
  --text-3: #ab9282;
  --text-inverse: #2a1204;
  --accent: #fb923c;
  --accent-pressed: #f97316;
  --accent-rgb: 251, 146, 60;
  --accent-subtle: rgba(251, 146, 60, 0.14);
  --on-accent: #2a1204;
  --accent-text: #fdba74;
  --overlay-scrim: rgba(18, 11, 8, 0.78);
  --focus-ring: #fb923c;
}

html[data-theme="light"] {
  --bg: #f0f4f8;
  --surface-1: #ffffff;
  --surface-2: #f4f7fb;
  --surface-3: #e4eaf2;
  /* Light body map: a neutral base at 1.54:1 against surface-2 and a solid
     orange ramp, so the silhouette reads on a white card without white seams. */
  --heat-0: #bfcad8;
  --heat-1: #fdba74;
  --heat-2: #fb923c;
  --heat-3: #f97316;
  --heat-4: #c2410c;
  --divider: rgba(15, 23, 42, 0.08);
  --border-strong: rgba(15, 23, 42, 0.16);
  --text: #0f172a;
  --text-2: #475569;
  --text-3: #526176;
  --text-inverse: #ffffff;
  --accent: #0e7490;
  --accent-pressed: #155e75;
  --accent-rgb: 14, 116, 144;
  --accent-subtle: rgba(14, 116, 144, 0.12);
  --on-accent: #ffffff;
  --accent-text: #155e75;
  --success: #047857;
  --success-subtle: rgba(4, 120, 87, 0.10);
  --warning: #b45309;
  --warning-subtle: rgba(180, 83, 9, 0.10);
  --danger: #b91c1c;
  --danger-subtle: rgba(185, 28, 28, 0.10);
  --info: var(--accent-pressed);
  --info-subtle: rgba(29, 78, 216, 0.10);
  /* Status text on its own tint: the base status hues measure 1.76-2.03:1 on
     their 6-14% tint in light mode, so they get a text-safe value instead. */
  --warning-text: #92400e;
  --success-text: #065f46;
  --danger-text: #991b1b;
  --info-text: #1e40af;
  --domain-strength: #4338ca;
  --domain-endurance: #c2410c;
  --domain-recovery: #047857;
  --data-1: var(--accent-pressed);
  --data-2: #047857;
  --data-3: #b45309;
  --data-4: #b91c1c;
  --data-5: #6d28d9;
  --data-6: #be185d;
  --data-7: #0f766e;
  --data-8: #475569;
  --overlay-scrim: rgba(15, 23, 42, 0.38);
  --focus-ring: #0e7490;
  --elevation-1: 0 1px 3px rgba(15, 23, 42, 0.08);
  --elevation-2: 0 8px 24px rgba(15, 23, 42, 0.12);
  --elevation-3: 0 18px 48px rgba(15, 23, 42, 0.16);
  --bg-image: none;
}
