/* Sweep page styles (base styles are in base.css, tokens in tokens.css). */

/* Viewport-structured play shell: eyes at top, track in focus, thumb dock pinned at bottom on mobile. */
body {
  overscroll-behavior-y: none;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}
.wrap {
  flex: 1;
  width: 100%;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-bottom: var(--space-4);
}
#game {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

/* The grid is drawn on a canvas here (it pulses, ripples and carries trails), so hide the shell's CSS grid. */
body::before { display: none; }
.bg-grid { position: fixed; inset: 0; width: 100vw; height: 100vh; z-index: -1; pointer-events: none; }

/* Persistent HUD (never re-animates between rounds). */
.hud {
  position: relative;
  z-index: 2;
}
.progress {
  display: flex;
  gap: 6px;
  margin: 0 0 12px;
}
.progress span {
  position: relative;
  flex: 1;
  height: 5px;
  border-radius: 0;
  background: var(--grid-line);
  overflow: hidden;
  transition: background-color 240ms ease, box-shadow 240ms ease;
}
.progress span.now {
  background: var(--grid-line-strong);
}
.progress span.now.running::after {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--player);
  opacity: 0.85;
  transform-origin: left center;
  animation: pip-sweep 1.2s ease-in-out infinite alternate;
}
.progress span.tier-day {
  background: var(--truth);
  box-shadow: var(--glow-truth);
}
.progress span.tier-month {
  background: var(--player);
  box-shadow: var(--glow-player);
}
.progress span.tier-year {
  background: var(--player);
  opacity: 0.72;
}
.progress span.tier-none {
  background: var(--alert);
  opacity: 0.55;
}
@keyframes pip-sweep {
  from { transform: scaleX(0.25); opacity: 0.45; }
  to { transform: scaleX(1); opacity: 0.95; }
}

.subject {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 6px;
}
.subject .tag {
  background: var(--panel-raised);
  border: var(--stroke-hairline) solid var(--grid-line-strong);
  border-radius: var(--radius-1);
  padding: var(--space-1) var(--space-3);
  font: 600 12px/16px var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}
.subject .special {
  background: transparent;
  color: var(--player-ink);
  border-color: var(--player);
}
.subject .vs {
  background: transparent;
  color: var(--rival);
  border-color: var(--rival);
}
.subject .speed {
  font: 700 12px/16px var(--font-mono);
  letter-spacing: 0.06em;
  color: var(--ink-muted);
  border-color: var(--grid-line);
  padding: var(--space-1) var(--space-2);
  font-variant-numeric: tabular-nums;
  transition: color 200ms ease, border-color 200ms ease, transform 200ms cubic-bezier(.2, 1.5, .4, 1);
}
.subject .speed.hot {
  color: var(--player-ink);
  border-color: var(--player);
}
.subject .speed.pulse {
  animation: speed-pop 340ms cubic-bezier(.2, 1.6, .4, 1);
}
@keyframes speed-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.18); }
  100% { transform: scale(1); }
}

.total {
  margin-left: auto;
  font: 400 18px/24px var(--font-display);
  font-variant-numeric: tabular-nums;
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  transition: color 180ms ease, transform 220ms cubic-bezier(.2, 1.5, .4, 1);
}
.total.bump {
  color: var(--player-ink);
  transform: scale(1.1);
}
.total small {
  font: 600 11px/1 var(--font-body);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

/* Round Stage (prompt + track + reserved reveal bay). */
.stage {
  display: flex;
  flex-direction: column;
  position: relative;
  z-index: 1;
}
.stage.swap {
  animation: stage-in 210ms cubic-bezier(.22, 1, .36, 1) both;
}
@keyframes stage-in {
  from { opacity: 0; transform: translateX(16px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Soft scrim behind prompt so glowing light-trails never hurt legibility on mobile. */
.prompt-wrap {
  position: relative;
  margin: var(--space-2) 0 var(--space-2);
  padding: 6px 0 4px;
}
.prompt-wrap::before {
  content: '';
  position: absolute;
  inset: -8px -12px;
  background: radial-gradient(ellipse at 30% 50%, var(--void) 38%, transparent 100%);
  opacity: 0.86;
  z-index: -1;
  pointer-events: none;
}
.round-kicker {
  font: 600 11px/14px var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin-bottom: 4px;
}
.prompt {
  font: 400 22px/30px var(--font-display);
  letter-spacing: 0.02em;
  margin: 0;
  text-wrap: balance;
}

/* Timeline Track */
.track {
  position: relative;
  height: 164px;
  background: transparent;
  isolation: isolate;
  border: var(--stroke-hairline) solid var(--grid-line);
  border-radius: var(--radius-0);
  margin: 6px 0 12px;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  overflow: hidden;
  transition: border-color 140ms ease, box-shadow 180ms ease;
}
.track::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--panel);
  opacity: 0.86;
  z-index: -1;
}
.track.running {
  border-color: var(--grid-line-strong);
}
.track.kick {
  animation: track-kick 170ms cubic-bezier(.2, .9, .3, 1);
}
@keyframes track-kick {
  0% { transform: translateY(0); }
  30% { transform: translateY(3px); }
  100% { transform: translateY(0); }
}
.track.bounce-l {
  box-shadow: inset 4px 0 0 var(--player), inset 18px 0 24px -10px rgba(255, 154, 60, 0.55);
}
.track.bounce-r {
  box-shadow: inset -4px 0 0 var(--player), inset -18px 0 24px -10px rgba(255, 154, 60, 0.55);
}
.track-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  pointer-events: none;
  z-index: 1;
}
.track-flash {
  position: absolute;
  inset: 0;
  background: var(--player);
  opacity: 0;
  pointer-events: none;
  z-index: 3;
}
.track-flash.go {
  animation: flash-fade 210ms ease-out;
}
.track-flash.exact {
  background: var(--truth);
  animation: flash-fade-strong 360ms ease-out;
}
@keyframes flash-fade {
  from { opacity: 0.24; }
  to { opacity: 0; }
}
@keyframes flash-fade-strong {
  from { opacity: 0.42; }
  to { opacity: 0; }
}
.track-blind-badge {
  position: absolute;
  top: 8px;
  right: 10px;
  z-index: 2;
  font: 700 10px/14px var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--player-ink);
  opacity: 0.65;
  pointer-events: none;
}

/* GPU-composited timeline markers */
.markers {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}
.marker {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 0;
  width: var(--stroke-needle);
  margin-left: -1.5px;
  transform: translate3d(var(--x, 0px), 0, 0);
  will-change: transform;
}
.marker[hidden] { display: none; }

/* Marker labels sit cleanly on a backing pill so beams never slice through text. */
.marker .d {
  position: absolute;
  left: var(--space-2);
  z-index: 5;
  background: var(--panel);
  padding: 1px 6px;
  border-radius: var(--radius-1);
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
.marker.flip .d {
  left: auto;
  right: var(--space-2);
}

/* Player needle + beat pulse + directional velocity wake */
.needle {
  --p: 0;
  --wake: 44px;
  top: 6px;
  background: var(--player);
  box-shadow: var(--glow-player);
}
.needle .d {
  top: 0;
  font: 700 20px/24px var(--font-mono);
  color: var(--player-ink);
}
.needle .d:empty { display: none; }
.needle .wake {
  position: absolute;
  top: 0;
  bottom: 0;
  width: var(--wake);
  pointer-events: none;
  opacity: 0;
  transition: opacity 140ms ease;
}
.needle.live .wake {
  opacity: 0.34;
}
.needle.dir-r .wake {
  right: 100%;
  background: linear-gradient(to left, var(--player), transparent);
}
.needle.dir-l .wake {
  left: 100%;
  background: linear-gradient(to right, var(--player), transparent);
}
.needle.live {
  box-shadow: 0 0 calc(10px + 28px * var(--p)) var(--player);
}
.needle.live::before {
  content: '';
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: calc(4px + 14px * var(--p));
  transform: translateX(-50%);
  background: var(--player);
  opacity: calc(var(--p) * 0.5);
  filter: blur(5px);
  pointer-events: none;
}
.needle.live .d {
  transform: scale(calc(1 + 0.055 * var(--p)));
  transform-origin: left center;
}
.needle.live.flip .d {
  transform-origin: right center;
}
.needle.lock {
  background: var(--truth);
  box-shadow: 0 0 26px var(--truth), 0 0 42px var(--player);
}

/* Real date (truth) marker */
.truth {
  top: 6px;
  background: var(--truth);
  box-shadow: var(--glow-truth);
  transform-origin: top center;
}
.truth.drop {
  animation: truth-drop 220ms cubic-bezier(.16, 1, .3, 1);
}
@keyframes truth-drop {
  from { opacity: 0; filter: brightness(2); }
  to { opacity: 1; filter: brightness(1); }
}
.truth .d {
  top: 28px;
  font: 700 17px/22px var(--font-mono);
  color: var(--truth);
}

/* Rival ghost marker */
.ghost {
  top: 6px;
  background: var(--rival);
  box-shadow: var(--glow-rival);
}
.ghost .d {
  top: 54px;
  font: 700 15px/19px var(--font-mono);
  color: var(--rival);
}

/* Reserved Reveal Bay: prevents vertical layout jumps across ready / running / revealing / done. */
.bay {
  min-height: 176px;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  margin-bottom: var(--space-3);
}

/* Idle / Running subtle telemetry inside bay */
.telemetry {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 108px;
  text-align: center;
  padding: var(--space-2) 0;
}
.telemetry-hint {
  font: 500 14px/20px var(--font-body);
  color: var(--ink-muted);
  letter-spacing: 0.04em;
}
.telemetry-meter {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font: 600 12px/16px var(--font-mono);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
}
.speed-bars {
  display: inline-flex;
  gap: 3px;
  align-items: flex-end;
  height: 14px;
}
.speed-bars i {
  display: block;
  width: 4px;
  background: var(--grid-line);
  transition: background-color 180ms ease, box-shadow 180ms ease;
}
.speed-bars i:nth-child(1) { height: 5px; }
.speed-bars i:nth-child(2) { height: 7px; }
.speed-bars i:nth-child(3) { height: 9px; }
.speed-bars i:nth-child(4) { height: 11px; }
.speed-bars i:nth-child(5) { height: 14px; }
.speed-bars i.on {
  background: var(--player);
  box-shadow: 0 0 6px rgba(255, 154, 60, 0.55);
}

/* Live zoom odometer */
.zoom-readout {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 112px;
  gap: 6px;
  text-align: center;
}
.offcount {
  font: 700 32px/38px var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  transition: transform 80ms linear;
}
.zoom-sub {
  font: 600 11px/14px var(--font-mono);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-muted);
  opacity: 0.8;
}

/* Post-landing result panel */
#game .panel {
  background: transparent;
  isolation: isolate;
  position: relative;
}
#game .panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--panel);
  opacity: 0.88;
  z-index: -1;
}
.reveal-card {
  animation: card-land 240ms cubic-bezier(.16, 1, .3, 1) both;
}
.reveal-card.tier-day {
  border-color: var(--truth);
}
.reveal-card.tier-month {
  border-color: var(--player);
}
@keyframes card-land {
  from { opacity: 0; transform: translateY(10px) scale(0.985); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.reveal-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
}
.reveal-points {
  font: 400 36px/40px var(--font-display);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.reveal-points.hot {
  color: var(--player-ink);
}
.reveal-points.exact-pts {
  color: var(--truth);
  text-shadow: var(--glow-truth);
}
.reveal-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  text-align: right;
}
.reveal-gap {
  font: 700 15px/20px var(--font-mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
}
.tierline {
  font: 600 12px/16px var(--font-body);
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--player-ink);
}
.exact {
  font: 400 22px/26px var(--font-display);
  letter-spacing: 0.1em;
  color: var(--truth);
  text-shadow: var(--glow-truth);
  animation: zoomin .48s cubic-bezier(.2, 1.55, .4, 1);
}
.pop {
  animation: zoomin .36s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes zoomin {
  from { transform: scale(.72); opacity: 0; }
}
.vsline {
  margin: var(--space-2) 0 0;
  font: 500 14px/20px var(--font-mono);
  color: var(--rival);
}
.reveal-card .story {
  margin: var(--space-3) 0 0;
  font-size: 16px;
  line-height: 1.45;
  color: var(--ink);
}
.wiki-link {
  display: inline-block;
  margin-left: 6px;
  font: 600 11px/1 var(--font-mono);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--ink-muted);
  border-bottom: var(--stroke-hairline) solid var(--grid-line-strong);
  padding-bottom: 1px;
  white-space: nowrap;
  transition: color 140ms ease, border-color 140ms ease;
}
.wiki-link:hover {
  color: var(--player-ink);
  border-color: var(--player);
}

/* Exact-day subtle viewport punch */
#game.exact-hit {
  animation: exact-punch 260ms cubic-bezier(.2, .9, .3, 1);
}
@keyframes exact-punch {
  0% { transform: translate(0, 0); }
  20% { transform: translate(-2px, 2px); }
  45% { transform: translate(2px, -1.5px); }
  70% { transform: translate(-1px, 1px); }
  100% { transform: translate(0, 0); }
}

/* Persistent Bottom Thumb Dock: rock-solid CTA that never moves across phases */
.dock {
  position: relative;
  z-index: 20;
  padding-top: 8px;
}
.stop {
  position: relative;
  width: 100%;
  font-size: 22px;
  min-height: 76px;
  overflow: hidden;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.stop.is-ready {
  animation: ready-breathe 2.4s ease-in-out infinite;
}
@keyframes ready-breathe {
  0%, 100% { box-shadow: var(--glow-player); }
  50% { box-shadow: 0 0 24px rgba(255, 154, 60, 0.72); }
}
.stop.is-running {
  --p: 0;
  box-shadow: 0 0 calc(14px + 20px * var(--p)) rgba(255, 154, 60, 0.75);
}
.stop.is-skip {
  background: var(--panel-raised);
  color: var(--ink-muted);
  border: var(--stroke-line) solid var(--grid-line-strong);
  box-shadow: none;
  font-size: 17px;
  letter-spacing: 0.16em;
}
.stop.is-skip:hover {
  color: var(--ink);
  border-color: var(--ink-muted);
}
.go-bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--player);
  box-shadow: var(--glow-player);
  transform-origin: left center;
  transform: scaleX(0);
  opacity: 0;
  pointer-events: none;
}
.stop.is-skip .go-bar {
  opacity: 1;
}
.stop kbd {
  font: 600 12px/1 var(--font-mono);
  letter-spacing: 0.08em;
  border: var(--stroke-hairline) solid currentColor;
  border-radius: var(--radius-1);
  padding: 4px 6px;
  margin-left: var(--space-3);
  vertical-align: 2px;
  opacity: 0.75;
}

/* Full-viewport physics ember particle canvas */
.fx-canvas {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 70;
}

.cardwrap canvas {
  width: 100%;
  height: auto;
  border-radius: 10px;
  border: 1px solid var(--line);
  margin: 8px 0;
}

/* Mobile One-Handed Thumb Ergonomics */
@media (max-width: 640px) {
  .wrap {
    padding-top: var(--space-2);
    padding-bottom: 0;
  }
  .stage {
    flex: 1;
  }
  .track {
    height: 152px;
    margin: 4px 0 10px;
  }
  .prompt {
    font-size: 18px;
    line-height: 25px;
  }
  .needle .d { font-size: 16px; line-height: 20px; }
  .truth .d { font-size: 15px; line-height: 19px; top: 24px; }
  .ghost .d { font-size: 13px; line-height: 17px; top: 46px; }
  .bay {
    min-height: 132px;
    margin-bottom: var(--space-2);
  }
  .offcount {
    font-size: 26px;
    line-height: 32px;
  }
  .reveal-points {
    font-size: 30px;
    line-height: 34px;
  }
  .exact {
    font-size: 19px;
    line-height: 24px;
  }
  .reveal-card .story {
    font-size: 15px;
    line-height: 1.4;
  }
  .dock {
    margin-top: auto;
    position: sticky;
    bottom: 0;
    padding: 12px 0 8px;
    background: linear-gradient(to top, var(--void) 72%, transparent);
  }
  .site-foot {
    padding: 4px var(--space-4) max(10px, env(safe-area-inset-bottom));
    font-size: 11px;
  }
  .stop {
    min-height: 82px;
    font-size: 23px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .exact, .pop, .stage.swap, .track.kick, .stop.is-ready, .progress span.now.running::after,
  .reveal-card, .truth.drop, #game.exact-hit, .subject .speed.pulse {
    animation: none !important;
  }
  .needle .wake { display: none; }
}

/* Wikipedia credit after each story. */
.wiki-credit { font: 500 11px/1.4 var(--font-mono); color: var(--ink-muted); letter-spacing: 0.04em; white-space: nowrap; }
/* Countdown to the next puzzle (result screen and the locked day). */
.next-countdown { font: 600 13px/18px var(--font-body); letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-muted); text-align: center; }
.next-countdown b, .locked-card b { color: var(--player-ink); font-family: var(--font-mono); letter-spacing: 0; }

/* Practice mode and special cards. */
.practice-link { color: var(--player-ink); font-weight: 600; white-space: nowrap; }
.new-card { display: flex; gap: var(--space-4); align-items: center; }
.practice-result .row .btn { text-align: center; text-decoration: none; color: inherit; }
.practice-result .row .btn.primary { color: var(--on-player); }

.retry-row { display: flex; justify-content: center; margin-top: var(--space-3); }
.retry-btn { min-height: 40px; padding: var(--space-2) var(--space-4); font: 600 14px/1 var(--font-body); letter-spacing: 0.1em; text-transform: uppercase; }
.retry-btn kbd { font: 600 11px/1 var(--font-mono); border: var(--stroke-hairline) solid currentColor; border-radius: var(--radius-1); padding: 3px 5px; margin-left: var(--space-2); opacity: .7; }

/* Day picker in the header: previous and next day. */
.day-picker { display: inline-flex; align-items: center; gap: var(--space-1); }
.day-nav { display: inline-grid; place-items: center; min-width: 28px; height: 28px; font: 700 18px/1 var(--font-mono); color: var(--player-ink); text-decoration: none; border-radius: var(--radius-1); }
a.day-nav:hover { background: var(--panel-raised); }
span.day-nav { color: var(--grid-line-strong); }
.subject .past { color: var(--ink-muted); border-style: dashed; }

.day-picker .d-short { display: none; }
.day-picker .d-long { white-space: nowrap; }
/* The header also holds the Sign up button, so the short date starts earlier. */
@media (max-width: 720px) {
  .topbar .date.day-picker { display: inline-flex; }
  .day-picker .d-long { display: none; }
  .day-picker .d-short { display: inline; }
}

/* Clean sweep banner. */
.clean-banner { position: fixed; inset: 0; z-index: 85; display: grid; place-content: center; text-align: center; pointer-events: none;
  background: radial-gradient(circle at 50% 45%, rgba(10, 8, 7, .55), rgba(10, 8, 7, .85)); animation: clean-in .45s cubic-bezier(.2, 1.4, .4, 1) both; }
.clean-banner b { font: 400 clamp(34px, 9vw, 76px)/1 var(--font-display); letter-spacing: 0.08em; color: #fff;
  text-shadow: 0 0 12px var(--player), 0 0 32px var(--player), 0 0 64px #ff4dd2; }
.clean-banner span { margin-top: var(--space-3); font: 600 14px/1 var(--font-body); letter-spacing: 0.2em; text-transform: uppercase; color: var(--rival); text-shadow: 0 0 12px var(--rival); }
.clean-banner.out { animation: clean-out .45s ease-in forwards; }
@keyframes clean-in { from { opacity: 0; transform: scale(1.25); } }
@keyframes clean-out { to { opacity: 0; transform: scale(.92); } }

.day-picker .d-short { white-space: nowrap; }
/* Result-screen buttons wrap to a second row on phones instead of cutting off their labels. */
.result .row > .btn { flex: 1 1 140px; }
.track[hidden] { display: none; }
.replay-note { font: 500 13px/18px var(--font-body); text-align: center; }

/* End-of-round sweep (game.js sweepWipe): a tall glowing needle wipes the screen clean. */
.sweep-wipe { position: fixed; inset: 0; z-index: 75; pointer-events: all; overflow: hidden; }
.sweep-curtain { position: absolute; inset: 0; background: var(--bg); transform-origin: 0 50%; transform: scaleX(0); }
.sweep-blade {
  position: absolute; top: -5vh; bottom: -5vh; left: 0; width: 6px; margin-left: -3px;
  background: linear-gradient(#fff, #fff8ef 50%, #fff);
  box-shadow: 0 0 10px 2px var(--player), 0 0 36px 8px var(--player), 0 0 110px 26px color-mix(in srgb, var(--player) 55%, transparent);
  will-change: transform;
}
.sweep-blade::before {
  content: ''; position: absolute; top: 0; bottom: 0; right: 3px; width: 34vw;
  background: linear-gradient(to left, color-mix(in srgb, var(--player) 38%, transparent), transparent);
}
.sweep-blade::after {
  content: ''; position: absolute; top: 0; bottom: 0; left: -14px; width: 34px;
  background: radial-gradient(ellipse at center, rgba(255, 255, 255, .55), transparent 70%); filter: blur(4px);
}
