/* kit/ui — the arcade's game-UI design language (docs/GAME_STANDARDS.md
 * "UI/UX standard"). Seed-policy: copied into your game, then yours.
 *
 * Tokens first: retheme by editing :root (keep them in sync with your JS
 * THEME object — one tone, every surface). The components below are the
 * canonical HUD strip, overlay, and keyboard-navigable menu.
 */

:root {
  /* palette — mirror your THEME object */
  --bg: #0f1115;
  --surface: #181c24;
  --edge: #2a3140;
  --ink: #e8eaf0;
  --muted: #9aa3b2;
  --accent: #5eead4;
  --reward: #f59e0b;
  --danger: #f4646c;

  /* type scale (4 steps — enough for any game screen) */
  --font-ui: system-ui, sans-serif;
  --text-s: 0.8rem;   /* captions, back link, hints        */
  --text-m: 0.95rem;  /* HUD, body                          */
  --text-l: 1.4rem;   /* section titles, big numbers        */
  --text-xl: 2.2rem;  /* screen titles (TITLE, GAME OVER)   */

  /* spacing unit — use multiples, avoid ad-hoc pixel gaps */
  --space: 0.5rem;

  --radius: 8px;
}

/* ---- HUD: one strip at the screen edge, never mid-field chrome ---- */

.hud {
  display: flex;
  gap: calc(var(--space) * 3);
  align-items: baseline;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--text-m);
  /* fixed-width digits: a score going 9→10 must never shift layout */
  font-variant-numeric: tabular-nums;
}
.hud b { color: var(--accent); font-weight: 600; }
.hud .danger { color: var(--danger); }

/* ---- keyboard hint chip: <span class="kbd">P</span> ---- */

.kbd {
  display: inline-block;
  padding: 0 calc(var(--space) * 0.75);
  border: 1px solid var(--edge);
  border-bottom-width: 2px;
  border-radius: 4px;
  background: var(--surface);
  color: var(--ink);
  font-size: var(--text-s);
  font-family: var(--font-ui);
  line-height: 1.6;
}

/* ---- status badge (WIP, MUTED, combo multipliers) ---- */

.badge {
  display: inline-block;
  padding: 0 calc(var(--space) * 0.75);
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--edge);
  color: var(--muted);
  font-size: var(--text-s);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ---- overlay: the title / pause / gameover screen scrim ---- */

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: calc(var(--space) * 2);
  background: rgba(10, 12, 17, 0.62);
  color: var(--ink);
  font-family: var(--font-ui);
  text-align: center;
}
.overlay[hidden] { display: none; }
.overlay h1 {
  margin: 0;
  font-size: var(--text-xl);
  letter-spacing: 0.04em;
}
.overlay p {
  margin: 0;
  color: var(--muted);
  font-size: var(--text-m);
  max-width: 34ch;
  line-height: 1.5;
}

/* ---- menu: keyboard-first vertical list (see ui.js createMenu) ---- */

.menu {
  display: flex;
  flex-direction: column;
  gap: var(--space);
  min-width: 14rem;
}
.menu-item {
  padding: calc(var(--space) * 1.25) calc(var(--space) * 2);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-m);
  text-align: center;
  cursor: pointer;
  transition: border-color 120ms, transform 120ms;
}
.menu-item:hover { border-color: var(--accent); }
.menu-item[aria-selected="true"] {
  border-color: var(--accent);
  color: var(--accent);
  transform: translateX(2px);
}

/* ---- sheet: an edge panel over live gameplay (shop, inventory, talents).
 * One sheet at a time; gameplay stays visible behind it. ---- */

.sheet {
  position: absolute;
  left: 50%;
  bottom: 0;
  transform: translateX(-50%);
  width: 100%;
  max-width: 30rem;
  padding: calc(var(--space) * 2);
  background: var(--surface);
  border: 1px solid var(--edge);
  border-bottom: none;
  border-radius: var(--radius) var(--radius) 0 0;
  color: var(--ink);
  font-family: var(--font-ui);
}
.sheet[hidden] { display: none; }

/* ---- tabs: exclusive panes inside a sheet/panel; badge for attention ---- */

.tabs { display: flex; gap: calc(var(--space) * 0.75); }
.tab {
  flex: 1;
  padding: var(--space) calc(var(--space) * 0.5);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: none;
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--text-s);
  cursor: pointer;
  position: relative;
}
.tab[aria-selected="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }
.tab .badge { position: absolute; top: -0.5em; right: -0.25em; }

/* ---- settings controls: slider / segmented / toggle.
 * Hit targets stay ≥ 44px; state is shown by position/shape, not colour alone. ---- */

input[type="range"].slider {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 6px;
  border-radius: 3px;
  /* set --fill from JS on input: el.style.setProperty('--fill', el.value + '%') */
  background: linear-gradient(90deg, var(--accent) var(--fill, 50%), var(--edge) var(--fill, 50%));
  cursor: pointer;
}
input[type="range"].slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: var(--ink);
  border: 1px solid var(--edge);
  cursor: pointer;
}

.seg-row { display: flex; gap: calc(var(--space) * 0.6); }
.seg {
  padding: calc(var(--space) * 1.4) calc(var(--space) * 1.6);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-family: var(--font-ui);
  font-size: var(--text-s);
  cursor: pointer;
}
.seg[aria-pressed="true"] { color: var(--bg); background: var(--accent); border-color: var(--accent); }

.toggle {
  width: 58px;
  height: 32px;
  border-radius: 17px;
  border: 1px solid var(--edge);
  background: var(--surface);
  position: relative;
  cursor: pointer;
}
.toggle i {
  position: absolute;
  top: 2px;
  left: 2px;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: var(--muted);
  transition: left 160ms;
}
.toggle.on { background: var(--accent); border-color: var(--accent); }
.toggle.on i { left: 28px; background: var(--bg); }

/* ---- two-step confirm: destructive buttons arm before they fire
 * (see ui.js confirmable(); never window.confirm) ---- */

.confirm.armed {
  color: var(--bg);
  background: var(--danger);
  border-color: var(--danger);
}

/* ---- toast: ONE transient slot, top-center; never persistent state ---- */

.toast {
  position: fixed;
  top: calc(var(--space) * 2);
  left: 50%;
  transform: translate(-50%, -140%);
  padding: var(--space) calc(var(--space) * 2);
  background: var(--surface);
  border: 1px solid var(--edge);
  border-radius: var(--radius);
  color: var(--ink);
  font-family: var(--font-ui);
  font-size: var(--text-m);
  opacity: 0;
  transition: transform 300ms, opacity 300ms;
  pointer-events: none;
}
.toast.show { transform: translate(-50%, 0); opacity: 1; }

/* reduce-motion: set html.rm from the game's setting so pure-CSS animation
 * obeys it too (the JS setting defaults from prefers-reduced-motion) */
html.rm .toast { transition: opacity 250ms; transform: translate(-50%, 0); }
html.rm .toggle i { transition: none; }

/* Every interactive element shows a visible focus ring when keyboard-driven —
 * accessibility is part of the standard, not a polish item. */
.menu-item:focus-visible,
button:focus-visible,
a:focus-visible,
input:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
