/* v09 The Stopwatch: tokens, type, the pusher button, the chronograph dial, the stage. */
:root {
  --ink: #0a0b0d;
  --case: #121418;
  --case2: #191c21;
  --line: #2a2f37;
  --line2: #3b414b;
  --cream: #f3efe4;
  --mute: #a3a9b2;
  --dim: #6f7680;
  --lume: #d4ff3a;
  --lume-ink: #141b04;
  --lume-glow: rgba(212, 255, 58, .38);
  --red: #ff4b3e;
  --red-soft: #ff8a80;
  --amber: #ffc046;
  --digits: "DIN Alternate", "DIN Condensed", "Bahnschrift", "Roboto Mono", ui-monospace, Menlo, monospace;
  --cond: "DIN Condensed", "Bahnschrift Condensed", "Avenir Next Condensed", "Arial Narrow", system-ui, sans-serif;
  --sans: "Avenir Next", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --st: env(safe-area-inset-top, 0px);
  --sb: env(safe-area-inset-bottom, 0px);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}
* { box-sizing: border-box; }
html, body { margin: 0; background: var(--ink); color: var(--cream); }
html { -webkit-text-size-adjust: 100%; overflow-x: hidden; }
body { font: 500 16px/1.4 var(--sans); min-height: 100svh; overflow-x: clip; -webkit-font-smoothing: antialiased; }
button { font: inherit; color: inherit; }
[hidden] { display: none !important; }
.num, .digits { font-family: var(--digits); font-variant-numeric: tabular-nums; }

/* ---------- the stage (the engine fills it) ---------- */
.stage { position: fixed; inset: 0; z-index: 0; }
.stage.is-bg::after, .stage.is-dim::after {
  content: ''; position: absolute; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(120% 80% at 50% 40%, rgba(10, 11, 13, .25) 0%, rgba(10, 11, 13, .82) 70%, rgba(10, 11, 13, .95) 100%);
}
.stage.is-dim::after { background: linear-gradient(180deg, rgba(10, 11, 13, .55), rgba(10, 11, 13, .9) 55%, rgba(10, 11, 13, .97)); }

/* ---------- screens (normal flow, above the fixed stage) ---------- */
.screen { position: relative; z-index: 5; min-height: 100svh; overflow-x: clip; }
.screen > section { opacity: 0; transform: translateY(14px); transition: opacity .45s var(--ease), transform .55s var(--ease); }
.screen.is-in > section { opacity: 1; transform: none; }
.screen.is-leaving > section { opacity: 0; transform: scale(.97); transition-duration: .3s; }

.kick, .lap__k { font: 700 13px/1 var(--cond); letter-spacing: .14em; text-transform: uppercase; color: var(--mute); margin: 0; }

/* ---------- the pusher: a chronograph start button ---------- */
.pusher {
  --bg: #2a2e35;
  position: relative; display: inline-flex; align-items: center; justify-content: center; gap: 10px;
  min-width: 220px; min-height: 64px; padding: 0 34px; border: 0; border-radius: 999px; cursor: pointer;
  font: 700 26px/1 var(--cond); letter-spacing: .1em; text-transform: uppercase;
  background: var(--bg); color: var(--mute);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, .18), inset 0 -3px 0 rgba(0, 0, 0, .35), 0 0 0 5px #1a1d22, 0 0 0 6px #3a3f47, 0 10px 26px rgba(0, 0, 0, .5);
  transition: transform .12s var(--ease), box-shadow .3s;
  -webkit-tap-highlight-color: transparent; touch-action: manipulation;
}
.pusher__t { display: inline-flex; align-items: center; gap: 10px; padding-top: 3px; }
.pusher__t svg { width: 22px; height: 22px; margin-top: -3px; }
.pusher.is-ready { --bg: var(--lume); color: var(--lume-ink); box-shadow: inset 0 2px 0 rgba(255, 255, 255, .55), inset 0 -4px 0 rgba(0, 0, 0, .18), 0 0 0 5px #1a1d22, 0 0 0 6px #4a5030, 0 12px 34px var(--lume-glow); }
.pusher::after { content: ''; position: absolute; inset: -6px; border-radius: inherit; box-shadow: 0 0 34px 6px rgba(212, 255, 58, .55); opacity: 0; pointer-events: none; will-change: opacity; }
.pusher.is-ready:not(:disabled)::after { animation: pusher-breathe 2.4s ease-in-out infinite; }
.pusher:active:not(:disabled), .pusher.is-pressed { transform: translateY(3px) scale(.98); }
.pusher.is-pressed::after { animation: none; opacity: 0; }
.pusher:disabled { cursor: default; }
.pusher.is-ready:disabled { opacity: .55; animation: none; }
.pusher--wide { width: 100%; min-width: 0; }
.pusher.is-failed { --bg: var(--cream); color: var(--ink); }
.pusher__spin { width: 18px; height: 18px; border-radius: 50%; border: 3px solid rgba(255, 255, 255, .2); border-top-color: var(--cream); animation: spin .8s linear infinite; }
.pusher.is-ready .pusher__spin, .pusher.is-failed .pusher__spin { display: none; }
.pusher.is-pulse { animation: pusher-pulse 1s ease-in-out infinite; }
@keyframes pusher-breathe { 50% { opacity: 1; } }
@keyframes pusher-pulse { 50% { transform: scale(1.03); } }
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- mute ---------- */
.mute {
  position: fixed; z-index: 40; top: calc(var(--st) + 12px); right: 12px; width: 44px; height: 44px; border-radius: 50%;
  border: 1px solid var(--line2); background: rgba(18, 20, 24, .82); color: var(--cream); display: grid; place-items: center; cursor: pointer; padding: 0;
}
.mute svg { width: 20px; height: 20px; }
.mute.is-muted { color: var(--dim); }
body[data-phase="results"] .mute { position: absolute; }

/* ---------- the chronograph dial ---------- */
.chrono { position: relative; width: min(74vw, 300px, 40svh); aspect-ratio: 1; margin: 0 auto; }
.chrono .dial { width: 100%; height: 100%; display: block; filter: drop-shadow(0 18px 40px rgba(0, 0, 0, .55)); }
.dial .tk { stroke: #59606a; stroke-width: 1.5; }
.dial .tk--half { stroke: #8a919b; stroke-width: 2; }
.dial .tk--maj { stroke: var(--cream); stroke-width: 3.2; }
.dial .lb { fill: var(--mute); font: 700 17px/1 var(--digits); text-anchor: middle; dominant-baseline: central; }
.dial .arc-track { fill: none; stroke: rgba(255, 255, 255, .06); stroke-width: 6; }
.dial .arc { fill: none; stroke: var(--lume); stroke-width: 6; stroke-linecap: round; filter: drop-shadow(0 0 6px var(--lume-glow)); }
.dial .hand__line { stroke: var(--red); stroke-width: 3.2; stroke-linecap: round; }
.dial .hand__tail { stroke: var(--red); stroke-width: 5; stroke-linecap: round; }
.dial .hand__hub { fill: var(--red); }
.dial .hand__pin { fill: var(--ink); }
.chrono__face { position: absolute; inset: 0; display: grid; place-content: center; justify-items: center; text-align: center; gap: 2px; pointer-events: none; }
.chrono__k { font: 700 11px/1.15 var(--cond); letter-spacing: .14em; color: var(--mute); max-width: 52%; margin-top: 18%; }
.chrono__n { font: 700 clamp(52px, 17vw, 76px)/1 var(--digits); font-variant-numeric: tabular-nums; letter-spacing: -.02em; color: var(--cream); margin-top: 4px; }
.chrono__s { font: 700 11px/1 var(--cond); letter-spacing: .2em; color: var(--dim); }
.chrono.is-stopped .chrono__n { color: var(--lume); animation: digits-pop .45s var(--spring); }
@keyframes digits-pop { 0% { transform: scale(1.12); } 100% { transform: scale(1); } }

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

/* keyboard focus: a lume ring on everything you can press */
.pusher:focus-visible, .key:focus-visible, .mute:focus-visible, .pt-mk:focus-visible { outline: 3px solid var(--lume); outline-offset: 9px; }
.key:focus-visible, .mute:focus-visible { outline-offset: 3px; }
.field input:focus-visible { box-shadow: 0 0 0 3px var(--lume-glow); }
