/*
  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;
  /* Stars: lit ones bright and filled, unlit ones a dark filled slot. */
  --color-star: #ffd04a;
  --color-star-unlit: rgb(52, 58, 72);

  /* 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);
  /* Locked or empty slots (a locked level, a path not reached yet) */
  --surface-locked: rgb(38, 42, 52);

  /* Rhythm: the target ring is a thick white line; the falling note is a filled disc. */
  --color-ring: #ffffff;
  --color-ring-hit: #66d8b3;
  --note-top: #3da0ff;
  --note-bottom: #1a6fd0;
  --color-dot-empty: rgb(52, 58, 72);

  /* Pinch Punch: filled, bright shapes (black is transparent on the display). */
  --punch-floor-top: rgb(44, 40, 62);
  --punch-floor-bottom: rgb(26, 24, 40);
  --punch-boxer-body: #3fb7a6;
  --punch-boxer-head: #58d1bf;
  --punch-boxer-visor: rgb(30, 42, 58);
  --punch-boxer-eye: #9ff7ff;
  --punch-boxer-belt: #ffd35a;
  --punch-glove-top: #ff6b5e;
  --punch-glove-bottom: #d0352c;
  --punch-ball: #ffa23d;
  --punch-crate-top: #c98b4f;
  --punch-crate-bottom: #8a5a2c;
  --punch-melon-top: #7fe07a;
  --punch-melon-bottom: #2f9a3c;
  --punch-pow: #ffe35a;
  --punch-pow-text: rgb(40, 28, 8);
  --grade-fail: #ff8a80;
  --grade-pass: #d8e8ff;
  --grade-great: #66d8b3;
  --grade-perfect: #ffd35a;

  /* Swipe Steps: each lane has its own color, but the arrow's shape carries the direction. */
  --steps-target-fill: rgb(36, 40, 56);
  --steps-target-line: #ffffff;
  --steps-target-press: rgb(70, 78, 104);
  --steps-lane-left: #ff6fae;
  --steps-lane-down: #4fb3ff;
  --steps-lane-up: #66e08a;
  --steps-lane-right: #ffb347;
  --steps-missed: rgb(90, 96, 112);
  --steps-perfect: #ffd35a;
  --steps-good: #9ff7ff;
  --steps-miss: #ff8a80;

  /* Pinch Dash: bright blocks and spikes over a filled, dark ground. */
  --dash-ground-top: rgb(48, 44, 76);
  --dash-ground-stripe: rgb(38, 34, 62);
  --dash-ground-edge: #b59cff;
  --dash-block-top: #6b8cff;
  --dash-block-bottom: #3b55c8;
  --dash-block-edge: #c9d6ff;
  --dash-spike: #ff6b5e;
  --dash-runner-top: #58d1bf;
  --dash-runner-bottom: #2e9e8d;
  --dash-runner-eye: rgb(30, 42, 58);
  --dash-finish: #ffd35a;
  --dash-progress-track: rgb(52, 58, 72);
  --dash-progress-fill: #66e08a;

  /* 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;

  /* 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;
  /* Meta UI Toolkit motion (docs/MOTION.md): toolkit design values, not measured device timing. */
  --motion-focus-ms: 300ms;
  --motion-focus-fast-ms: 150ms;
  --ease-focus: cubic-bezier(.68, 0, .29, 1);
  --motion-press-in-ms: 80ms;
  --ease-press-in: cubic-bezier(.23, .23, .24, 1);
  --press-scale: 0.96;
  --motion-release-ms: 420ms;
  --ease-release: cubic-bezier(.25, .08, .4, 1);
  --rubberband-ms: 300ms;
  --rubberband-distance: 5px;
  --screen-shift: 15px;

  /* 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;
  --rubberband-distance: 0px;
  --screen-shift: 0px;
  --press-scale: 1;
  --focus-scale: 1;
}

/* Toolkit press release: a spring (k300 c19 m1, ~10 % overshoot) where linear() easing exists. */
@supports (transition-timing-function: linear(0, 1)) {
  :root {
    --motion-release-ms: 600ms;
    --ease-release: linear(0 0%, .217 5.4%, .532 10.8%, .807 16.2%, .989 21.6%, 1.076 27%, 1.096 32.4%, 1.079 37.8%, 1.05 43.2%, 1.022 48.6%, 1.003 54.1%, .994 59.5%, .991 64.9%, .992 70.3%, .995 75.7%, .997 81.1%, .999 86.5%, 1.001 91.9%, 1 100%);
  }
}
