/* replay.css: owned by the replay agent. Everything inside #band. Tokens and the frame live in app.css
   (docs/site-modules.md). Spec: docs/design.md section 7, "Band". */

#band {
  display: grid; grid-template-columns: var(--rail-w) minmax(0, 1fr);
  --track-pad: var(--s-5);
}

/* ---------- transport ---------- */
/* The title over the play button and the readout, flush with the rail's section titles. */
.replay-transport {
  display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center; align-content: center;
  gap: var(--s-2) var(--s-5); padding: 0 var(--gutter); min-width: 0;
}

/* The rail's section-title type (.rail-body h2), in the band's ink. */
.replay-title {
  grid-column: 1 / -1; margin: 0; font: 600 var(--t-14) / 1.2 var(--font); font-stretch: var(--wdth-text);
  color: var(--band-ink); white-space: nowrap;
}

.replay-play {
  display: grid; place-items: center; flex: none; width: 40px; height: 40px; padding: 0;
  border: 0; border-radius: var(--radius); background: var(--signal); color: var(--on-signal);
  transition: transform var(--t-fast) var(--ease);
}
.replay-play svg { fill: currentColor; }
.replay-play:active { transform: scale(0.94); }

/* Fixed width so the minute readout ("Jan 17, 1994, 4:31 am") does not move the band. */
.replay-readout { width: 8.6em; white-space: nowrap; color: var(--band-ink); font-variant-numeric: tabular-nums; }

/* ---------- track ---------- */
/* One vertical stack in 96px: chip 2-26, trace 24-68 (midline 46), ticks 68-72, years 73-84,
   so the years sit 12px above the band's bottom edge. */
.replay-track { position: relative; height: var(--band-h); margin: 0 var(--track-pad); }

.replay-trace { position: absolute; left: 0; top: 24px; width: 100%; height: 44px; }
.replay-trace-lit { will-change: clip-path; }

.replay-axis { position: absolute; inset: 0; pointer-events: none; }
/* timeline.js sets each tick's and label's x; a label stays inside the track. */
.replay-axis .axis {
  position: absolute; left: 0; top: 73px; line-height: 11px; color: var(--band-ink-2);
  font-variant-numeric: tabular-nums; white-space: nowrap;
}
.replay-tick { position: absolute; left: -0.5px; top: 68px; width: 1px; height: 4px; background: var(--band-rule); }

/* Playhead: 1px line from the top of the band to the foot of the trace, so it never strikes
   through a year; a 10px signal dot on the midline ringed by the band. */
.replay-head {
  position: absolute; left: -0.5px; top: 0; bottom: 28px; width: 1px; background: var(--band-ink);
  pointer-events: none; will-change: transform;
}
.replay-head i {
  position: absolute; left: 50%; top: 46px; width: 14px; height: 14px; margin: -7px 0 0 -7px;
  border: 2px solid var(--band); border-radius: 50%; background: var(--signal);
}

/* The Northridge chip stands on the track above its spike, tied to it by a 1px leader.
   timeline.js places the box on the date and slides the chip to stay inside the track. */
.replay-chip-box { position: absolute; left: 0; top: 2px; width: 0; z-index: 2; }
.replay-chip {
  position: absolute; left: 0; top: 0; display: inline-flex; align-items: center; gap: 6px; height: 24px; padding: 0 var(--s-2);
  border: 0; border-radius: var(--radius); background: var(--signal); color: var(--on-signal);
  font-weight: 600; white-space: nowrap;
}
.replay-chip[aria-pressed="true"] { box-shadow: inset 0 0 0 1px var(--on-signal); }
/* While pressed the chip is the way back: an 8px x after its name, in its text color. */
.replay-chip[aria-pressed="true"]::after {
  content: ""; width: 8px; height: 8px;
  background: linear-gradient(45deg, transparent 43%, currentColor 43% 57%, transparent 57%),
    linear-gradient(-45deg, transparent 43%, currentColor 43% 57%, transparent 57%);
}
.replay-leader { position: absolute; left: -0.5px; top: 24px; width: 1px; height: 4px; background: var(--signal); }

/* The control: a transparent native range over the trace, 44px of hit height. */
.replay-range {
  position: absolute; left: 0; top: 24px; width: 100%; height: 44px; margin: 0; z-index: 1;
  appearance: none; -webkit-appearance: none; background: transparent; cursor: pointer; opacity: 0;
}
.replay-range:focus-visible { opacity: 1; }

/* Focus inside the band is band-ink: signal belongs to the replay's marks and controls. */
#band :focus-visible { outline: 2px solid var(--band-ink); outline-offset: 2px; }
.replay-range::-webkit-slider-runnable-track { height: 44px; background: transparent; }
.replay-range::-moz-range-track { height: 44px; background: transparent; }
.replay-range::-webkit-slider-thumb { -webkit-appearance: none; width: 2px; height: 44px; background: transparent; border: 0; }
.replay-range::-moz-range-thumb { width: 2px; height: 44px; background: transparent; border: 0; }

.replay-tip { left: 0; top: 0; white-space: nowrap; color: var(--ink); }

/* ---------- phone: one 110px block ---------- */
/* The play button left of the track, the title and readout over it: title 0-24 (hidden while
   Northridge plays, the chip takes its place), trace 28-72, ticks 72-76, years 77-88. */
@media (max-width: 820px), (max-height: 520px) {
  #band { grid-template-columns: 44px minmax(0, 1fr); grid-template-rows: 28px 44px 26px; column-gap: var(--s-3); padding: var(--s-3) var(--gutter) 0; }
  .replay-transport { display: contents; }
  .replay-title { grid-area: 1 / 1 / 2 / 3; align-self: start; line-height: 24px; }
  #band:has(.replay-chip[aria-pressed="true"]) .replay-title { visibility: hidden; }
  .replay-readout { grid-area: 1 / 2; justify-self: end; align-self: start; width: auto; font-size: var(--t-20); line-height: 24px; }
  .replay-play { grid-area: 2 / 1; width: 44px; height: 44px; }
  .replay-track { grid-area: 1 / 2 / 4 / 3; height: auto; margin: 0; }
  .replay-chip-box { top: 0; }
  .replay-trace, .replay-range { top: 28px; }
  .replay-tick { top: 72px; }
  .replay-axis .axis { top: 77px; }
  .replay-head { top: 28px; bottom: 26px; }
  .replay-head i { top: 22px; }
  /* The chip keeps its 24px; its touch target is 44px. */
  .replay-chip::before { content: ""; position: absolute; inset: -10px -4px; }
}

@media (prefers-reduced-motion: reduce) {
  .replay-play { transition: none; }
}
