/* Bike or Die 2026 — the shell.
 *
 * Every colour in this file is a var() from tokens.css. If a literal hex ever
 * appears here, the palette has been forked and the theme switch is broken.
 * The sheet has hairlines and right angles: nothing is rounded above 3px and
 * there are no shadows on anything.
 */

*, *::before, *::after { box-sizing: border-box; }

/* Our own display rules outrank the UA sheet, so say it once and mean it. */
[hidden] { display: none !important; }

body {
  min-height: 100dvh;
  overscroll-behavior: none;
  -webkit-text-size-adjust: 100%;
}
body[data-screen="play"] { user-select: none; }

.sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 60;
  background: var(--panel); color: var(--ink); border: 1px solid var(--rule-2);
  padding: 8px 12px; border-radius: var(--radius); text-decoration: none;
}
.skip:focus { top: 8px; }

.mono { font-family: var(--font-mono); font-variant-numeric: tabular-nums; }
.meta { color: var(--muted); font-size: 13px; }
/* A disclosed engine limitation, not decoration: portal levels report the
   wrong outcome (KNOWN-DEFECTS D14), so the sheet says so. Same colour as
   the clock running out and a warning toast. */
.meta.is-warn { color: var(--spark); }
.note { color: var(--ink-2); font-size: 14px; margin: 12px 0; }

/* --- buttons -------------------------------------------------------------- */
.btn {
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  min-height: 44px; padding: 8px 14px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  cursor: pointer; transition: border-color 120ms ease-out, color 120ms ease-out;
}
.btn:hover { border-color: var(--annot); color: var(--annot); }
.btn--primary {
  background: var(--signal); border-color: var(--signal); color: var(--sheet);
  font-weight: 700;
}
.btn--primary:hover { color: var(--sheet); border-color: var(--signal); filter: brightness(1.08); }
.btn--ghost { background: transparent; border-color: var(--rule); }
.btn--danger { color: var(--fail); border-color: var(--fail); }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .45; cursor: default; }

kbd {
  font-family: var(--font-mono); font-size: 11px; line-height: 1;
  padding: 4px 6px; min-width: 24px; display: inline-block; text-align: center;
  border: 1px solid var(--rule-2); border-bottom-width: 2px;
  border-radius: 3px; background: var(--panel); color: var(--ink-2);
}

/* --- top bar -------------------------------------------------------------- */
.topbar {
  height: 48px; display: flex; align-items: center; gap: 16px;
  padding: 0 16px; border-bottom: 1px solid var(--rule);
  background: var(--sheet-sunk);
}
.wordmark {
  font-family: var(--font-ui); font-weight: 700; font-size: 13px;
  letter-spacing: .02em; white-space: nowrap;
}
.wordmark b { color: var(--signal); }
.crumb { display: flex; flex-direction: column; min-width: 0; flex: 1; line-height: 1.15; }
.crumb-t {
  font-size: var(--fs-name); font-weight: 500;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.crumb-s { font-size: var(--fs-read-sm); color: var(--muted); }
.topnav { display: flex; gap: 8px; }
.topnav .btn { min-height: 34px; padding: 5px 10px; font-size: 13px; }

/* --- the stage ------------------------------------------------------------ */
.screen { display: block; }
.stage { position: relative; background: var(--sheet-sunk); }
#cv {
  display: block; width: 100%; aspect-ratio: 16 / 10; height: auto;
  background: var(--sky); touch-action: none;
}
#cv:focus-visible { outline: 2px solid var(--annot); outline-offset: -4px; }

.hud {
  position: absolute; left: 16px; right: 16px; top: 16px; height: 28px;
  display: flex; align-items: center; gap: 16px; z-index: 3;
  pointer-events: none; transition: opacity 200ms ease-out;
}
.hud.is-dim { opacity: .35; }
body.reduce-motion .hud.is-dim { opacity: 1; }
body.hud-large .hud { height: 35px; font-size: 125%; }

.hud-clock {
  font-size: var(--fs-read); font-weight: 500; color: var(--ink);
  text-shadow: 0 0 2px var(--sky);
}
.hud-clock.is-warn { color: var(--spark); }
.hud-bar {
  width: 120px; height: 2px; background: var(--rule); display: inline-block;
}
.hud-bar > span { display: block; height: 100%; background: var(--ink); }
.hud-bar.is-warn > span {
  background: repeating-linear-gradient(45deg,
    var(--spark) 0 3px, transparent 3px 6px), var(--spark);
}
.hud-flags { display: flex; align-items: center; gap: 8px; margin-inline: auto; }
.hud-flags .label { color: var(--muted); }
.pips { display: inline-flex; gap: 3px; }
.pip {
  width: 7px; height: 7px; border: 1px solid var(--flag); display: inline-block;
}
.pip.is-on { background: var(--flag); }
.hud-finish {
  font-size: var(--fs-read-sm); color: var(--muted); letter-spacing: .06em;
}
.hud-finish.is-open { color: var(--pass); font-weight: 700; }
.hud-finish.is-static { opacity: .7; }
.hud-pause {
  pointer-events: auto; min-width: 32px; min-height: 28px;
  font-family: var(--font-mono); font-size: 11px;
  background: transparent; color: var(--muted);
  border: 1px solid var(--rule); border-radius: var(--radius); cursor: pointer;
}

/* --- the strip under the canvas ------------------------------------------- */
.strip {
  display: flex; align-items: center; gap: 16px; flex-wrap: wrap;
  padding: 8px 16px; background: var(--sheet-sunk);
  border-top: 1px solid var(--rule); border-bottom: 1px solid var(--rule);
  min-height: 24px;
}
.legend { display: flex; gap: 14px; flex-wrap: wrap; }
body.no-legend .legend { display: none; }
.cap { display: inline-flex; align-items: center; gap: 6px; }
.cap-l { font-size: 12px; color: var(--muted); }
.cap.is-on kbd { background: var(--signal); border-color: var(--signal); color: var(--sheet); }
.dev { margin-left: auto; font-size: var(--fs-read-sm); color: var(--muted); }

/* --- touch deck ----------------------------------------------------------- */
.deck { display: none; }
.pad {
  font-family: var(--font-mono); font-size: 16px;
  background: var(--panel); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
  touch-action: none; cursor: pointer;
}
.pad.is-pressed { background: var(--signal); border-color: var(--signal); color: var(--sheet); }

@media (pointer: coarse) and (orientation: portrait) {
  /* Controls sit below the canvas. Nothing overlaps the game. */
  .deck {
    display: grid; height: 184px; padding: 8px 16px 16px;
    gap: 12px; background: var(--sheet-sunk);
    grid-template-columns: 72px 72px 1fr 88px;
    grid-template-rows: 88px 72px;
    grid-template-areas: "flip .    . fwd" "leanl leanr . brake";
    align-items: end;
  }
  .pad--flip  { grid-area: flip;  width: 64px; height: 64px; }
  .pad--lean-l { grid-area: leanl; width: 72px; height: 72px; }
  .pad--lean-r { grid-area: leanr; width: 72px; height: 72px; }
  .pad--fwd   { grid-area: fwd;   width: 88px; height: 88px; }
  .pad--brake { grid-area: brake; width: 72px; height: 72px; }
  body.left-handed .deck { direction: rtl; }
  #cv { aspect-ratio: 16 / 10; max-height: 62vh; }
  .strip { display: none; }
}

@media (pointer: coarse) and (orientation: landscape) {
  /* Full-bleed canvas, pads only in the corners — never in the action. */
  .deck { display: block; }
  .deck .pad {
    position: absolute; opacity: .4; z-index: 4;
    display: grid; place-items: center;
  }
  .deck .pad.is-pressed { opacity: .9; }
  .pad--lean-l { left: 16px;  bottom: 16px; width: 72px; height: 72px; }
  .pad--lean-r { left: 100px; bottom: 16px; width: 72px; height: 72px; }
  .pad--flip   { left: 50%; margin-left: -32px; bottom: 16px; width: 64px; height: 64px; }
  .pad--fwd    { right: 16px;  bottom: 16px; width: 96px; height: 96px; }
  .pad--brake  { right: 124px; bottom: 16px; width: 72px; height: 72px; }
  body.left-handed .pad--lean-l { left: auto; right: 16px; }
  body.left-handed .pad--lean-r { left: auto; right: 100px; }
  body.left-handed .pad--fwd    { right: auto; left: 16px; }
  body.left-handed .pad--brake  { right: auto; left: 124px; }
  .strip { display: none; }
}

@media (min-width: 1440px) {
  .stage { max-width: 1280px; margin: 0 auto; }
  .screen--levels { max-width: 1200px; margin: 0 auto; }
}

/* --- browser -------------------------------------------------------------- */
.screen--levels { padding: 0 16px 64px; }
.lanes {
  display: flex; gap: 0; border-bottom: 1px solid var(--rule);
  position: sticky; top: 0; background: var(--sheet); z-index: 5;
}
.lane-tab {
  font-family: var(--font-ui); font-size: 14px; font-weight: 500;
  background: none; border: 0; border-bottom: 2px solid transparent;
  color: var(--muted); padding: 14px 16px; min-height: 44px; cursor: pointer;
}
.lane-tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--signal); }
.lane { padding-top: 20px; }

.sec {
  display: flex; align-items: center; gap: 12px;
  margin: 32px 0 12px; padding-bottom: 9px; border-bottom: 1px solid var(--rule);
}
.sec:first-child { margin-top: 0; }
.sec-h { font-size: var(--fs-head); font-weight: 500; margin: 0; letter-spacing: .005em; }
.sec-r { font-size: var(--fs-read-sm); color: var(--muted); margin-left: auto; }
.bar { width: 90px; height: 4px; background: var(--rule); display: inline-block; }
.bar-fill { display: block; height: 100%; background: var(--pass); }

.card {
  display: flex; gap: 14px; align-items: center;
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius-panel); padding: 14px;
}
.card--wide .card-body { flex: 1; min-width: 0; }
.cardrow {
  display: flex; gap: 12px; overflow-x: auto; padding-bottom: 8px;
  scroll-snap-type: x proximity;
}
body.reduce-motion .cardrow { scroll-behavior: auto; }
.card--sm {
  flex-direction: column; align-items: stretch; gap: 6px; min-width: 128px;
  text-align: left; cursor: pointer; scroll-snap-align: start;
  font-family: var(--font-ui);
}
.card--sm:hover { border-color: var(--annot); }
.card--sm.is-complete { border-color: var(--pass); }
.card-sm-name {
  font-size: 13px; font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-sm-time { font-size: var(--fs-read-sm); color: var(--muted); }
.name {
  font-size: var(--fs-name); font-weight: 500; color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; display: block;
}
.map { background: var(--sheet-sunk); border: 1px solid var(--rule); display: block; }
.map--big { width: 192px; height: 120px; }
.map--sheet { width: 100%; height: auto; aspect-ratio: 17 / 10; }

.actions { display: flex; gap: 10px; flex-wrap: wrap; margin: 12px 0; }
.intro { color: var(--ink-2); max-width: var(--measure); }

.grid {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.ccard {
  height: 116px; text-align: left; cursor: pointer; font-family: var(--font-ui);
  background: var(--panel); border: 1px solid var(--rule);
  border-radius: var(--radius-panel); padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}
.ccard:hover { border-color: var(--annot); }
.ccard.is-complete { border-color: var(--pass); }
.ccard-top { display: flex; gap: 8px; align-items: baseline; }
.ccard-name {
  font-size: var(--fs-name); font-weight: 500; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.ccard-n { font-size: var(--fs-read-sm); color: var(--muted); }
.ccard .bar { width: 100%; }
.ccard-foot { display: flex; gap: 6px; align-items: center; flex-wrap: wrap; margin-top: auto; }
.ccard-k { font-size: var(--fs-read-sm); color: var(--muted); }
.crumbs { display: flex; align-items: center; gap: 12px; margin-bottom: 16px; }

.chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-family: var(--font-mono); font-size: var(--fs-read-sm);
  border: 1px solid var(--rule); background: var(--panel); color: var(--ink-2);
  border-radius: var(--radius); padding: 3px 7px;
}
.chip--era { color: var(--muted); }
.chip--sig { color: var(--signal); background: var(--signal-soft); border-color: var(--signal); }
.chip--best { color: var(--signal); background: var(--signal-soft); border-color: var(--signal); }
.chip--facet { cursor: pointer; min-height: 32px; }
.chip--facet[aria-checked="true"] {
  border-color: var(--annot); background: var(--annot-soft); color: var(--annot);
}
.chip--facet.is-zero { opacity: .4; }
.chip-check { width: 10px; display: inline-block; }
.chip-n { color: var(--muted); }

.searchbar { display: flex; gap: 10px; margin-bottom: 16px; }
.search, .select {
  font-family: var(--font-ui); font-size: 14px; min-height: 44px;
  padding: 8px 12px; background: var(--panel); color: var(--ink);
  border: 1px solid var(--rule-2); border-radius: var(--radius);
}
.search { flex: 1; min-width: 0; }
.facets { display: flex; flex-direction: column; gap: 10px; margin-bottom: 16px; }
.facet { display: flex; gap: 12px; align-items: baseline; flex-wrap: wrap; }
.facet > .label { min-width: 84px; }
.chips { display: flex; gap: 6px; flex-wrap: wrap; }
.sortbar { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
#showing { margin-bottom: 8px; }

.vl {
  position: relative; height: 60vh; min-height: 320px; overflow-y: auto;
  border: 1px solid var(--rule); border-radius: var(--radius-panel);
  background: var(--panel);
}
.vl--group { height: 68vh; }
.vl-win { position: absolute; top: 0; left: 0; right: 0; }
.vl-spacer { width: 1px; }

.row {
  display: flex; align-items: center; gap: 12px; padding: 0 12px;
  border-bottom: 1px solid var(--rule); cursor: pointer; overflow: hidden;
}
.row:hover { background: var(--sheet-sunk); }
.row.is-current { box-shadow: inset 3px 0 0 var(--signal); }
.row.is-complete .row-main .name::after { content: " ✓"; color: var(--pass); }
.row.is-attempted .row-main .name::after { content: " ◐"; color: var(--muted); }
.row.is-absent { opacity: .45; }
.row-main { flex: 1; min-width: 0; }
.row-side { text-align: right; display: flex; flex-direction: column; gap: 2px; }
.row-side .meta { font-size: var(--fs-read-sm); white-space: nowrap; }
.badge { margin-right: 6px; }
.peek {
  background: none; border: 1px solid var(--rule); border-radius: var(--radius);
  color: var(--muted); min-width: 44px; min-height: 44px; cursor: pointer;
}
.empty { padding: 32px 8px; color: var(--ink-2); }

/* --- overlays ------------------------------------------------------------- */
.modalhost { position: fixed; inset: 0; z-index: 40; }
.scrim { position: absolute; inset: 0; background: var(--sheet-sunk); opacity: .82; }
.dialog {
  position: absolute; left: 50%; top: 50%; transform: translate(-50%, -50%);
  width: min(420px, calc(100vw - 32px)); max-height: 86vh; overflow: auto;
  background: var(--panel); border: 1px solid var(--rule-2);
  border-radius: var(--radius-panel); padding: var(--pad-panel);
}
.dialog--sheet { width: min(380px, calc(100vw - 32px)); left: auto; right: 16px;
                 top: 64px; transform: none; max-height: calc(100vh - 96px); }
.dialog-h {
  font-family: var(--font-ui); font-size: var(--fs-head); font-weight: 500;
  letter-spacing: .06em; margin: 0 0 12px; padding-bottom: 9px;
  border-bottom: 1px solid var(--rule); text-transform: uppercase;
}
.dialog-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 18px; }
.res-name { font-size: 20px; font-weight: 500; }
.res-time {
  font-size: 34px; font-weight: 500; margin: 14px 0 4px;
  font-variant-numeric: tabular-nums;
}
.res-2 { font-size: 15px; color: var(--ink-2); display: flex; gap: 8px; align-items: center; }
.res-2.is-pass { color: var(--pass); }
.res-2.is-fail { color: var(--fail); }
.res-3 { font-size: 13px; color: var(--muted); margin-top: 4px; }

.kv { display: grid; grid-template-columns: 96px 1fr; gap: 6px 12px; margin: 14px 0; }
.kv dt { margin: 0; }
.kv dd { margin: 0; font-size: 14px; color: var(--ink-2); }
.sheet-body .map--sheet { margin: 12px 0; }

.settings { display: flex; flex-direction: column; gap: 8px; }
.set-g { margin-top: 14px; }
.set-row {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  min-height: 40px; font-size: 14px;
}
.help p { font-size: 15px; color: var(--ink-2); max-width: var(--measure); }
.legend-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0; }
.legend-item { display: flex; gap: 10px; align-items: center; font-size: 13px; }
.legend-mark { width: 40px; height: 40px; flex: none; }
table.keys { border-collapse: collapse; margin-top: 8px; }
table.keys td { padding: 3px 10px 3px 0; font-size: 13px; }

.toasts { position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
          z-index: 50; display: flex; flex-direction: column; gap: 8px; }
.toast {
  background: var(--panel); border: 1px solid var(--rule-2);
  border-radius: var(--radius); padding: 10px 14px; font-size: 14px;
  color: var(--ink);
}
.toast--warn { border-color: var(--spark); }
.toast--error { border-color: var(--fail); color: var(--fail); }

.boot { position: fixed; inset: 0; background: var(--sheet); z-index: 70;
        display: grid; place-items: center; }
.bootcard { text-align: center; }
.bootcard h2 { font-family: var(--font-ui); font-weight: 700; font-size: var(--fs-masthead);
               letter-spacing: var(--ls-masthead); margin: 0 0 8px; }

@media (max-width: 599px) {
  .topbar { gap: 10px; }
  .crumb-s { display: none; }
  .hud { left: 10px; right: 10px; gap: 10px; }
  .hud-flags .label, .hud-flags #hud-frac { display: none; }
  .dialog { left: 0; right: 0; bottom: 0; top: auto; transform: none;
            width: 100%; max-width: none; border-radius: 0; max-height: 88vh; }
  .dialog--sheet { top: auto; height: 60vh; }
  .legend-grid { grid-template-columns: 1fr; }
  .row-side .meta:first-child { display: none; }
}
