/*
  Design tokens. Components in app.css read ONLY these variables; a theme is a block
  that overrides tokens under :root[data-theme="<id>"] (listed in app/config/theme-catalog.js).
  Display rules baked in (docs/UI-DESIGN-SYSTEM.md):
  - additive display: pure black is transparent negative space, not a surface;
  - visible surfaces stay in the dark RGB ~18–55 range, filled, no hairlines;
  - functional text ≥ 14px, body 16px, primary content/controls 20–24px+.
*/
:root {
  /* Color: text */
  --color-text: #ffffff;
  --color-text-muted: rgba(245, 250, 255, 0.9);
  --color-text-quiet: rgba(230, 243, 255, 0.76);
  --color-accent: #2388f5;
  --color-accent-soft: #86c8ff;
  --color-good: #66d8b3;
  --color-warn: #ffc76a;
  --color-bad: #ff8d9a;

  /* Color: stage */
  --color-stage: #000000;
  --color-glow-a: rgba(43, 128, 224, 0.24);
  --color-glow-b: rgba(80, 133, 218, 0.15);

  /* Surfaces (filled gradients, top → bottom) */
  --surface-panel-top: rgba(89, 133, 175, 0.46);
  --surface-panel-bottom: rgba(26, 48, 77, 0.78);
  --surface-control-top: rgba(75, 112, 151, 0.72);
  --surface-control-bottom: rgba(31, 58, 89, 0.82);
  --surface-action-top: #2d82ca;
  --surface-action-bottom: #155ca8;
  --surface-danger-top: rgba(150, 52, 70, 0.9);
  --surface-danger-bottom: rgba(92, 27, 42, 0.92);
  --surface-field-top: rgba(74, 111, 149, 0.72);
  --surface-field-bottom: rgba(27, 53, 84, 0.84);

  /* Focus: the selected state must read without color alone (border + glow + scale) */
  --focus-top: rgba(35, 107, 176, 0.94);
  --focus-bottom: rgba(18, 65, 125, 0.96);
  --focus-border: #86c8ff;
  --focus-ring: rgba(101, 181, 255, 0.42);
  --focus-scale: 1.03;

  /* Path selector (EMG Academy learning path style) */
  --path-violet: #c148ff;
  --path-violet-2: #b238f5;
  --path-indigo: #6631ed;
  --path-blue: #2871fa;
  --path-cyan: #009cf2;
  --path-sky: #81aaf7;
  --path-slot-top: #cc47fa;
  --path-slot-bottom: #006cf0;
  --path-gloss: rgba(255, 255, 255, 0.6);
  --path-shade: rgba(0, 28, 132, 0.42);
  --path-edge: rgba(37, 219, 255, 0.72);
  --path-ring: rgba(137, 209, 242, 0.55);
  --path-glow-core: rgba(82, 236, 255, 0.78);
  --path-glow-wide: rgba(71, 85, 255, 0.38);
  --path-bubble-edge: rgba(94, 219, 255, 0.44);
  --path-bubble-magenta: rgba(225, 39, 255, 0.6);
  --path-bubble-aqua: rgba(0, 232, 255, 0.62);
  --path-bubble-deep: rgba(0, 156, 242, 0.22);
  --path-badge-surface: rgba(14, 32, 108, 0.86);
  --path-badge-text: #c7e5ff;
  --path-copy: #8dd4f7;
  --path-side-edge: rgba(97, 226, 255, 0.4);
  --path-side-core: rgba(197, 67, 245, 0.5);
  --path-side-mid: rgba(71, 91, 235, 0.4);
  --path-side-deep: rgba(8, 60, 171, 0.25);
  --path-side-shine: rgba(255, 255, 255, 0.16);
  --path-mask-soft: rgba(0, 0, 0, 0.35);
  --path-white: #ffffff;
  --path-black: #000000;
  --path-footer-top: 512px; /* the path footer (Debug mode, "3 of 8"); the toast sits above it */

  /* Calisto display layer (docs/design/CALISTO-UI-PLAN.md §2, measured on the UI team's
     exercise screen): pure black stage (transparent on the additive display), glowing blue
     outlines and light text. No large filled surfaces. */
  --cal-stage: #000000;
  --cal-text: #ffffff;
  --cal-text-soft: #7ecdff;
  --cal-text-dim: #4f8fc4; /* reference #06598e, raised: too dim to read on the waveguide */
  --cal-accent: #009bfd;
  --cal-track: #003c62;
  --cal-ring-inner: #0a2740;
  --cal-line: #1666aa;
  --cal-line-dim: #0f436e;
  --cal-fill-focus-top: #003a5e;
  --cal-fill-focus-bottom: #001626;
  --cal-fill-quiet: #001929;
  --cal-glow: rgba(0, 155, 253, 0.45);
  --cal-glow-soft: rgba(22, 102, 170, 0.35);
  --cal-glow-panel: rgba(22, 102, 170, 0.5);
  /* Shape, focus and type of the display layer (docs/design/CALISTO-DISPLAY-DESIGN.md §2.1) */
  --cal-glow-blur: 14px;
  --cal-glow-blur-panel: 12px;
  --cal-border: 2px;
  --cal-border-panel: 3px;
  --cal-focus-inset: 2px;
  --cal-radius-panel: 28px;
  --cal-radius-control: 16px;
  --cal-radius-chip: 12px;
  --cal-focus-scale: 1.02;
  --cal-focus-scale-chip: 1.08;
  --cal-font-hero: 160px;
  --cal-font-title: 48px; /* one size for every screen title (reference ~52, design 44) */
  --cal-font-item: 28px;
  --cal-font-control: 24px;
  --cal-font-label: 20px;
  --cal-font-meta: 16px;

  /* Shape */
  --radius-sm: 12px;
  --radius-md: 18px;
  --radius-lg: 28px;
  --radius-pill: 999px;
  --border-width: 2px;
  --shadow-raised: 0 18px 42px rgba(5, 13, 25, 0.3);

  /* Space (4px grid) */
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 12px;
  --space-4: 16px;
  --space-5: 24px;
  --space-6: 32px;
  --space-7: 48px;

  /* Type */
  --font-family: "Roboto", "Segoe UI", system-ui, sans-serif;
  --font-size-caption: 14px;
  --font-size-body: 16px;
  --font-size-control: 22px;
  --font-size-title: 32px;
  --font-size-display: 40px;
  --line-height-tight: 1.15;
  --line-height-body: 1.35;

  /* Motion (30 FPS target; durations are multiples of ~33ms) */
  --motion-fast: 150ms;
  --motion-base: 230ms;
  --motion-slow: 380ms;
  --motion-ease-out: cubic-bezier(0.22, 0.75, 0.3, 1);
  --motion-ease-spring: cubic-bezier(0.16, 1, 0.3, 1);
  --motion-nudge-distance: 7px;

  /* Layout: MRBD stage and safe area */
  --stage-size: 600px;
  --safe-bottom: 576px; /* y=576..600 belongs to the system bar */
  --safe-inset: 32px;
}

:root[data-theme="aurora"] {
  --color-accent: #25efff;
  --color-accent-soft: #f8fdff;
  --color-text-muted: #d8e8ff;
  --color-text-quiet: #aebfdf;
  --color-good: #79f2d5;
  --color-glow-a: rgba(193, 72, 255, 0.22);
  --color-glow-b: rgba(37, 239, 255, 0.14);
  --surface-panel-top: rgba(102, 181, 255, 0.3);
  --surface-panel-bottom: rgba(15, 43, 118, 0.32);
  --surface-control-top: rgba(100, 177, 255, 0.3);
  --surface-control-bottom: rgba(37, 88, 177, 0.22);
  --surface-action-top: #20e9ef;
  --surface-action-bottom: #1268f4;
  --focus-top: rgba(47, 160, 255, 0.58);
  --focus-bottom: rgba(63, 59, 220, 0.52);
  --focus-border: #f4feff;
  --focus-ring: rgba(37, 239, 255, 0.5);
}

:root[data-theme="minimal"] {
  --color-accent: #e8eef6;
  --color-accent-soft: #ffffff;
  --color-glow-a: rgba(255, 255, 255, 0.05);
  --color-glow-b: rgba(255, 255, 255, 0.03);
  --surface-panel-top: rgba(46, 50, 56, 0.9);
  --surface-panel-bottom: rgba(28, 30, 34, 0.92);
  --surface-control-top: rgba(52, 55, 60, 0.92);
  --surface-control-bottom: rgba(34, 36, 40, 0.94);
  --surface-action-top: #5a6270;
  --surface-action-bottom: #3a4049;
  --focus-top: rgba(92, 100, 112, 0.96);
  --focus-bottom: rgba(60, 66, 76, 0.98);
  --focus-border: #ffffff;
  --focus-ring: rgba(255, 255, 255, 0.35);
}

/* Reduced motion: the system setting or the in-app preference. */
:root[data-motion="reduced"] {
  --motion-fast: 1ms;
  --motion-base: 1ms;
  --motion-slow: 1ms;
  --motion-nudge-distance: 0px;
  --focus-scale: 1;
  --cal-focus-scale: 1;
  --cal-focus-scale-chip: 1;
}
