/* ============================================================
   WEIGHTED AVERAGES — DESIGN TOKENS
   Broadcast Brutalism: one source of truth for palette,
   type, spacing, motion. Imported by all three surfaces
   (player phone, admin laptop, presenter TV).
   ============================================================ */

:root {
  /* ── Palette (semantic, not decorative) ──────────────────── */
  /* Ground */
  --color-bg:          #000000;
  --color-fg:          #ffffff;
  --color-surface:     #111111;  /* elevated surface on black */
  --color-border-low:  #222222;
  --color-border-mid:  #444444;
  --color-muted:       #767676;  /* dim text, passes WCAG AA on #000 */

  /* Semantic accents — one color = one meaning, across all surfaces */
  --color-primary:     #00ffff;  /* cyan: primary action, live, now, focus */
  --color-emphasis:    #ff00ff;  /* magenta: reveal, emphasis, urgent */
  --color-success:     #aaff00;  /* lime: correct, winning, confirmed */
  --color-brand:       #ffff00;  /* yellow: heroic accent, team codes */
  --color-warning:     #ff8800;  /* orange: caution, action-needed */
  --color-danger:      #ff2040;  /* red: destructive, error (NEW) */

  /* Difficulty ladder — crescendo of drama.
     Shares hues with semantic palette but scoped to star icons. */
  --color-difficulty-1: #ffffff;
  --color-difficulty-2: #00ffff;
  --color-difficulty-3: #aaff00;
  --color-difficulty-4: #ff8800;
  --color-difficulty-5: #ff00ff;

  /* Legacy aliases — kept so existing class-level references that
     read `var(--cyan, #fallback)` keep working while we migrate. */
  --cyan:    var(--color-primary);
  --magenta: var(--color-emphasis);
  --lime:    var(--color-success);
  --yellow:  var(--color-brand);
  --orange:  var(--color-warning);
  --pink:    var(--color-emphasis);
  --white:   var(--color-fg);
  --black:   var(--color-bg);

  /* ── Typography ──────────────────────────────────────────── */
  --font-display: 'Inter', 'Helvetica Neue', 'Arial Black', system-ui, sans-serif;
  --font-body:    'Inter', system-ui, sans-serif;
  --font-mono:    'IBM Plex Mono', 'Courier New', 'Lucida Console', monospace;

  /* Three-tier weight hierarchy.
     display: hero numbers, H1, presenter categories.
     label:   card H3, nav, buttons, badges.
     body:    hints, form values, running copy.
     whisper: decorative thin type. */
  --weight-whisper: 100;
  --weight-body:    400;
  --weight-label:   700;
  --weight-display: 900;

  /* Letter-spacing */
  --tracking-tight:  -0.03em;
  --tracking-snug:   -0.01em;
  --tracking-normal:  0;
  --tracking-wide:    0.12em;
  --tracking-wider:   0.2em;
  --tracking-widest:  0.4em;

  /* ── Spacing — modular golden-ratio scale (px) ───────────── */
  --space-0: 2px;
  --space-1: 4px;
  --space-2: 8px;
  --space-3: 13px;
  --space-4: 21px;
  --space-5: 34px;
  --space-6: 55px;
  --space-7: 89px;

  /* ── Border widths ───────────────────────────────────────── */
  --border-hair:  1px;
  --border-thin:  2px;
  --border-thick: 3px;
  --border-bold:  4px;

  /* ── Motion ──────────────────────────────────────────────── */
  --motion-instant:    80ms;   /* tap flash, micro-feedback */
  --motion-quick:      160ms;  /* hover, focus, state flip */
  --motion-standard:   320ms;  /* panel/screen transitions */
  --motion-theatrical: 640ms;  /* presenter reveals */

  --ease-out:    cubic-bezier(.2, .8, .2, 1);
  --ease-in-out: cubic-bezier(.4, 0, .2, 1);

  /* ── Focus ring (identical on all three surfaces) ────────── */
  --focus-ring: 3px solid var(--color-primary);
  --focus-ring-offset: 2px;
}

/* ============================================================
   Shared @keyframes — defined once, consumed everywhere.
   ============================================================ */

@keyframes wa-pulse {
  0%, 100% { opacity: 0.4; }
  50%      { opacity: 1; }
}

@keyframes wa-fade-in {
  from { opacity: 0; transform: translateY(4px); }
  to   { opacity: 1; transform: translateY(0); }
}

@keyframes wa-glow-box {
  0%, 100% { box-shadow: 0 0 6px var(--color-emphasis), 0 0 12px var(--color-emphasis); }
  50%      { box-shadow: 0 0 10px var(--color-emphasis), 0 0 20px var(--color-emphasis), 0 0 30px var(--color-emphasis); }
}

@keyframes wa-glow-text {
  0%, 100% { text-shadow: 0 0 6px var(--color-emphasis), 0 0 12px var(--color-emphasis); }
  50%      { text-shadow: 0 0 10px var(--color-emphasis), 0 0 20px var(--color-emphasis), 0 0 30px var(--color-emphasis); }
}

/* ============================================================
   Global focus + reduced motion — inherited by all surfaces.
   ============================================================ */

:focus-visible {
  outline: var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

input:focus-visible,
select:focus-visible,
textarea:focus-visible {
  outline: var(--focus-ring);
  outline-offset: 0;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Screen-reader utility — identical on all surfaces. */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}
