/* The leaderboard, on a page of its own: a timing screen for a classroom wall. It reads twice — once
   on a phone in somebody's hand, and once from the back of the room on a projector — so everything
   here is built out of ruled rows with nothing decorative between them.
   This page loads styles.css and session.css only, never racesim.css. */

:root {
  /* Medal colours. Not a second palette: these are the content — a gold lap is gold — and the three
     of them are told apart by fill and shape first, colour second, because some of the room is
     colourblind and all of it is looking at a projector. */
  --gold: #8A5A0B;
  --gold-line: #B4791A;
  --silver: #5A6675;
  --silver-line: #98A3B0;
  --bronze: #8A4E2B;
  --bronze-line: #B07A57;
}

/* The session bar is fixed over the top of the page, so anything scrolled to — a tabbed-to filter
   chip, an anchor — has to stop short of it rather than under it. */
body.board-page { scroll-padding-top: 46px; padding-block-end: var(--s-6); }

.board-main { max-width: 1180px; margin: 0 auto; }

/* ---------- the head: which board, and the two things you can do with it ---------- */
.board-head {
  display: flex; flex-wrap: wrap; gap: var(--s-3) var(--s-5);
  align-items: flex-end; justify-content: space-between;
  margin-bottom: var(--s-5);
}
.board-head > div:first-child { min-width: 0; flex: 1 1 24rem; }
#board-title { font-size: var(--t-2xl); letter-spacing: -0.025em; }
#board-sub { margin-top: 6px; max-width: 62ch; }
.board-actions { display: flex; flex-wrap: wrap; gap: var(--s-2); }

/* ---------- the tabs: one track each, then the championship ---------- */
.board-tabs {
  display: flex; gap: 2px;
  overflow-x: auto; overflow-y: hidden; scrollbar-width: thin;
  border-bottom: 1px solid var(--line); margin-bottom: var(--s-4);
}
.board-tab {
  flex: none; background: none; border: 0; border-bottom: 3px solid transparent;
  padding: var(--s-3) var(--s-4); min-height: 48px;
  color: var(--ink-2); font-weight: 500; white-space: nowrap;
}
.board-tab:hover { color: var(--ink); border-bottom-color: var(--line); }
.board-tab:focus-visible { outline-offset: -3px; }
.board-tab.is-on { color: var(--ink); font-weight: 700; border-bottom-color: var(--orange); }

.board-filter { margin-bottom: var(--s-4); }

/* What a target is, said once, above the board it applies to. */
.board-pars {
  background: var(--surface); border: 1px solid var(--line);
  border-left: 3px solid var(--orange);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: var(--s-3) var(--s-4);
  margin-bottom: var(--s-4);
  color: var(--ink-2); font-size: var(--t-sm); line-height: 1.55; max-width: 84ch;
}

/* ---------- the board ---------- */
.board-body { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); }
.board-body > .hint { padding: var(--s-5); margin: 0 auto; text-align: center; color: var(--ink-3); }
/* The championship is as wide as there are tracks, so only that one gets a scroller. The track board
   is left without one on purpose: an overflow container would become the scroll box for the sticky
   header below, and then the header would not stay put as the page scrolls past thirty names. */
.board-body:has(.champ-table) { overflow-x: auto; -webkit-overflow-scrolling: touch; }
/* the card is rounded, so the last row has to be too */
.board-body tr:last-child td:first-child { border-bottom-left-radius: var(--radius); }
.board-body tr:last-child td:last-child { border-bottom-right-radius: var(--radius); }

.board-table, .champ-table { width: 100%; border-collapse: collapse; font-size: var(--t-sm); }
.board-table th, .champ-table th {
  position: sticky; top: 0; z-index: 1; background: var(--surface);
  text-align: left; font-weight: 600; font-size: var(--t-xs); color: var(--ink-3);
  padding: var(--s-3) var(--s-3) var(--s-2);
  border-bottom: 2px solid var(--line); white-space: nowrap;
}
.board-table td, .champ-table td {
  padding: var(--s-3); border-bottom: 1px solid var(--grid);
  white-space: nowrap; vertical-align: middle;
}
.board-table tr:last-child td, .champ-table tr:last-child td { border-bottom: 0; }

/* the rank is the spine of the table, so it is set like one */
.board-row td:first-child { font-weight: 700; color: var(--ink-3); width: 1%; padding-right: var(--s-2); }
.board-row td:nth-child(3), .champ-driver { font-weight: 600; color: var(--ink); }

/* banding, because a championship row is long and the eye has to hold a line across it */
.board-row:nth-child(even) td { background: #FAFBFC; }
.board-row.is-first td:first-child { color: var(--orange); }
/* your own lap, wherever it lands: tinted the same orange the rest of the site uses for "this is
   yours", with a rule down the left so it is findable without reading a single name */
.board-row.is-me td { background: var(--orange-soft); }
.board-row.is-me td:first-child { box-shadow: inset 3px 0 0 var(--orange); color: var(--ink); }

.champ-driver { display: inline-flex; align-items: center; gap: 6px; }
.champ-track { text-align: center; color: var(--ink-2); }
.champ-track b { font-weight: 600; color: var(--ink); font-variant-numeric: tabular-nums; }
th.champ-track { text-align: center; }

/* ---------- the par tiers ----------
   Fill, then outline, then dashed outline: solid disc, open ring, open diamond. Three shapes that
   survive greyscale, a projector and a colourblind eye. The colour only confirms what the shape
   already said. */
.tier {
  display: inline-flex; align-items: center; gap: 6px;
  color: var(--ink-3); font-size: var(--t-xs); line-height: 1.4;
}
.tier.is-gold, .tier.is-silver, .tier.is-bronze {
  padding: 3px var(--s-2); border-radius: 999px; border: 1.5px solid; font-weight: 600;
}
.tier.is-gold::before, .tier.is-silver::before, .tier.is-bronze::before {
  content: ""; flex: none; width: 9px; height: 9px;
}
.tier.is-gold {
  background: var(--gold); border-color: var(--gold); color: #FFFFFF; font-weight: 700;
}
.tier.is-gold::before { border-radius: 50%; background: currentColor; }
.tier.is-silver {
  background: var(--surface); border-color: var(--silver-line); color: var(--silver);
}
.tier.is-silver::before { border-radius: 50%; border: 2.5px solid currentColor; }
.tier.is-bronze {
  background: transparent; border-color: var(--bronze-line); border-style: dashed; color: var(--bronze);
}
.tier.is-bronze::before { border: 2px solid currentColor; transform: rotate(45deg); }

#board-note { max-width: 84ch; margin-top: var(--s-4); }

/* ---------- projector mode ----------
   Same board, read from twenty rows back: roughly double the type, heavier, and stripped of
   everything that is for the person holding the device rather than the room looking at the wall. */
body.projector { padding-bottom: var(--s-5); }
/* everything that is for the person holding the device rather than the room looking at the wall.
   The projector button itself stays: it is the way back, and hiding it would strand a teacher. */
body.projector .who,
body.projector #link-drive,
body.projector #board-sub,
body.projector #board-note { display: none; }
body.projector .board-actions { align-self: flex-start; }
body.projector #btn-projector { font-size: var(--t-sm); min-height: 40px; padding: var(--s-2) var(--s-3); opacity: 0.55; }
body.projector #btn-projector:hover, body.projector #btn-projector:focus-visible { opacity: 1; }

body.projector .top { padding: 6px var(--s-4); margin-bottom: var(--s-4); }
body.projector .brand-logo { height: 36px; }
body.projector .brand { font-size: var(--t-md); }

body.projector .board-head { margin-bottom: var(--s-4); }
body.projector #board-title { font-size: 3.4rem; letter-spacing: -0.03em; }

/* at this size the tabs no longer fit across the wall, and nobody is going to drag a scrollbar from
   the back of a classroom, so they wrap instead */
body.projector .board-tabs { margin-bottom: var(--s-3); flex-wrap: wrap; overflow: visible; }
body.projector .board-tab { font-size: 1.5rem; padding: var(--s-3) var(--s-5); min-height: 64px; border-bottom-width: 5px; }
body.projector .board-tab.is-on { font-weight: 700; }

body.projector .board-filter .chip { font-size: 1.25rem; min-height: 52px; padding: var(--s-2) var(--s-4); }
body.projector .board-pars { font-size: 1.25rem; max-width: none; padding: var(--s-3) var(--s-5); }

body.projector .board-table, body.projector .champ-table { font-size: 1.75rem; }
body.projector .board-table th, body.projector .champ-table th {
  font-size: 1.1rem; letter-spacing: 0.02em; padding: var(--s-3) var(--s-4) var(--s-2);
  border-bottom-width: 3px; color: var(--ink-2);
}
body.projector .board-table td, body.projector .champ-table td {
  padding: var(--s-3) var(--s-4); border-bottom-width: 2px; border-bottom-color: var(--line);
}
body.projector .board-row td { font-weight: 500; }
body.projector .board-row td:first-child, body.projector .board-row td:nth-child(3) { font-weight: 700; }
body.projector .board-row.is-me td { background: var(--orange-soft); }
body.projector .board-row.is-me td:first-child { box-shadow: inset 6px 0 0 var(--orange); }

body.projector .car-chip i { width: 26px; height: 26px; }
body.projector .car-chip b { font-size: 1.1rem; }
body.projector .class-badge { font-size: 1.05rem; padding: 4px var(--s-3); }
body.projector .tier { font-size: 1.2rem; }
body.projector .tier.is-gold, body.projector .tier.is-silver, body.projector .tier.is-bronze {
  padding: 5px var(--s-3); border-width: 2.5px;
}
body.projector .tier.is-gold::before, body.projector .tier.is-silver::before, body.projector .tier.is-bronze::before {
  width: 15px; height: 15px;
}
body.projector .tier.is-silver::before { border-width: 4px; }
body.projector .tier.is-bronze::before { border-width: 3px; }
body.projector .champ-track { font-size: 1.35rem; }

@media (max-width: 560px) {
  #board-title { font-size: var(--t-xl); }
  .board-table, .champ-table { font-size: var(--t-xs); }
  .board-table td, .champ-table td { padding: var(--s-2); }
  .board-actions { width: 100%; }
  .board-actions .tool { flex: 1 1 auto; }
}
