/* lane0: the race (README §6). Monochrome; hairlines and type do the work. Tokens: tokens.css */

.lz-race {
  --r-name: 96px;
  --r-tps: 92px;
  --r-tok: 76px;
  --r-status: 128px;
  --r-gap: 20px;
  --r-car: 14px;               /* keep in step with CAR_W in race.js */
  max-width: var(--wide);
  margin: 0 auto;
  color: var(--ink);
  font: 400 var(--fs-small)/1.4 var(--font-sans);
  font-variant-numeric: tabular-nums;
  -webkit-font-smoothing: antialiased;
}

/* ---------- prompt and clock ---------- */
.lz-r-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  grid-template-areas: "prompt clock" "meta meta";
  column-gap: var(--r-gap);
  align-items: center;
  margin-bottom: 36px;
}
.lz-r-prompt {
  grid-area: prompt;
  display: grid;
  padding: 15px 18px;
  background: var(--bg-2);
  border-radius: 8px;
  font: 400 14px/1.55 var(--font-mono);
  color: var(--ink);
}
.lz-r-ghost, .lz-r-line-text { grid-area: 1 / 1; }
.lz-r-ghost { visibility: hidden; }
.lz-r-chev { color: var(--ink-3); }
.lz-r-cursor {
  display: inline-block;
  width: 0.6em;
  height: 1.15em;
  margin-left: 1px;
  vertical-align: -0.2em;
  background: var(--accent);
  animation: lz-r-blink 1.06s steps(1) infinite;
}
.lz-race[data-phase="typing"] .lz-r-cursor { animation: none; }
.lz-race[data-phase="race"] .lz-r-cursor,
.lz-race[data-phase="done"] .lz-r-cursor { visibility: hidden; }
@keyframes lz-r-blink { 50% { opacity: 0; } }

.lz-r-clock {
  grid-area: clock;
  justify-self: end;
  min-width: var(--r-status);
  text-align: right;
  font: 400 14px/1 var(--font-mono);
  color: var(--ink);
  white-space: nowrap;
}
.lz-race[data-phase="idle"] .lz-r-time,
.lz-race[data-phase="typing"] .lz-r-time { color: var(--ink-3); }
.lz-r-x { display: none; margin-left: 10px; color: var(--ink-3); }
.lz-race.is-fast .lz-r-x { display: inline; }
.lz-r-meta {
  grid-area: meta;
  margin-top: 12px;
  font-size: 13px;
  color: var(--ink-3);
}

/* ---------- rows ---------- */
.lz-r-rows {
  list-style: none;
  margin: 0;
  padding: 0;
}
.lz-r-row {
  display: grid;
  grid-template-columns: var(--r-name) var(--r-tps) var(--r-tok) minmax(0, 1fr) var(--r-status);
  column-gap: var(--r-gap);
  align-items: baseline;
  padding: 0 0 22px;
  transition: opacity var(--dur) var(--ease);
}
.lz-r-row:last-child { padding-bottom: 0; }
.lz-race[data-phase="idle"] .lz-r-row,
.lz-race[data-phase="typing"] .lz-r-row { visibility: hidden; opacity: 0; }

.lz-r-name { color: var(--ink-2); white-space: nowrap; }
.lz-r-row.is-us .lz-r-name { color: var(--ink); font-weight: 500; }

.lz-r-num, .lz-r-code, .lz-r-status {
  font: 400 var(--fs-mono)/1.4 var(--font-mono);
  white-space: nowrap;
}
.lz-r-num { text-align: right; color: var(--ink-2); }
.lz-r-u { color: var(--ink-3); }
.lz-r-row.is-us .lz-r-num { color: var(--ink); }

/* One line of code; when it overflows, the newest characters stay in view. */
.lz-r-code {
  overflow: hidden;
  direction: rtl;
  text-align: left;
  color: var(--ink-3);
}
.lz-r-code bdi { direction: ltr; unicode-bidi: isolate; }

.lz-r-status { text-align: right; color: var(--ink-3); }
.lz-r-row.is-us.is-done .lz-r-status { color: var(--ink); font-weight: 500; }
.lz-r-place { display: inline-block; }
.lz-r-row.is-us .lz-r-place {
  color: var(--accent);
  animation: lz-r-stamp 160ms steps(2, jump-none) both;   /* a mechanical stamp: two frames, no bounce */
}
@keyframes lz-r-stamp {
  from { transform: scale(1.35); opacity: 0.4; }
  to   { transform: none; opacity: 1; }
}
.lz-r-row.is-done .lz-r-status { color: var(--ink-2); }

/* The track: a start tick, a hairline that draws itself in, a finish tick, and the car. */
.lz-r-track {
  grid-column: 1 / -1;
  position: relative;
  height: 9px;
  margin-top: 12px;
}
.lz-r-track i { position: absolute; display: block; }
.lz-r-start, .lz-r-finish {
  top: 0;
  width: 1px;
  height: 9px;
  background: var(--ink-4);
}
.lz-r-start { left: var(--r-car); }
.lz-r-finish { right: 0; opacity: 0; }
.lz-r-finish.is-on { opacity: 1; }
.lz-r-hair {
  top: 4px;
  left: var(--r-car);
  width: 0;
  height: 1px;
  background: var(--rule-2);
}
.lz-r-car {
  top: 1px;
  left: 0;
  width: var(--r-car);
  height: 7px;
  border-radius: 2px;
  background: var(--ink-4);
  will-change: transform;
}
.lz-r-row.is-us .lz-r-car { background: var(--accent); }
.lz-r-row.is-us .lz-r-start,
.lz-r-row.is-us .lz-r-finish { background: var(--ink-3); }

/* A short wake while the car moves: two hairline dashes behind it, the farther one fainter (flat, no gradient). */
.lz-r-car::before, .lz-r-car::after {
  content: "";
  position: absolute;
  top: 3px;
  height: 1px;
  background: var(--ink-3);
  opacity: 0;
  transition: opacity 400ms var(--ease);
}
.lz-r-car::before { right: calc(100% + 2px); width: 9px; }
.lz-r-car::after  { right: calc(100% + 14px); width: 5px; }
.lz-r-row.is-moving .lz-r-car::before { opacity: 0.7; }
.lz-r-row.is-moving .lz-r-car::after  { opacity: 0.3; }

/* ---------- controls ---------- */
.lz-r-controls {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  min-height: 32px;
  margin-top: 28px;
}
.lz-r-btn {
  height: 32px;
  padding: 0 15px;
  border: 0;
  border-radius: 999px;
  background: var(--bg-2);
  color: var(--ink);
  font: 400 13px/32px var(--font-sans);
  cursor: pointer;
  transition: background-color var(--dur) var(--ease), color var(--dur) var(--ease);
}
.lz-r-btn[hidden] { display: none; }
.lz-r-btn:hover { background: var(--rule); }
.lz-r-btn[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.lz-r-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.lz-r-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* ---------- narrow: the code line goes; name, numbers and track stay ---------- */
@media (max-width: 640px) {
  .lz-r-head {
    grid-template-areas: "prompt prompt" "meta clock";
    margin-bottom: 28px;
  }
  .lz-r-prompt { padding: 13px 15px; font-size: 13px; }
  .lz-r-clock { min-width: 0; margin-top: 12px; font-size: 13px; }
  .lz-r-row {
    grid-template-columns: auto auto minmax(0, 1fr);
    grid-template-areas: "name name status" "tps tok ." "track track track";
    column-gap: 14px;
    padding-bottom: 22px;
  }
  .lz-r-name { grid-area: name; }
  .lz-r-tps { grid-area: tps; }
  .lz-r-tok { grid-area: tok; }
  .lz-r-status { grid-area: status; }
  .lz-r-track { grid-area: track; margin-top: 10px; }
  .lz-r-code { display: none; }
  .lz-r-num { margin-top: 3px; font-size: 12px; text-align: left; min-width: 11ch; }
  .lz-r-tok { min-width: 9ch; }
  .lz-r-status { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .lz-race *, .lz-race { transition: none !important; animation: none !important; }
}
