/* board.css — the public leaderboard. Dark ground (theme-ink), hi-vis accents.
 * Two targets: a phone at 375 px and a 1920×1080 screen or broadcast feed.
 * Red is never used (red means ON AIR house-wide). */

:root { --gut: 16px; --fs: 15px; }
body.theme-ink { font-size: var(--fs); min-height: 100vh; }

.mast { padding: 18px var(--gut) 10px; max-width: 1840px; margin: 0 auto; }
.mast-top { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.brandmark { display: inline-flex; align-items: center; gap: 8px; font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; color: var(--hivis); }
.brandmark .dot { width: 10px; height: 10px; border-radius: 2px; background: var(--hivis); }
.conn { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: var(--cloth-mute); }
.conn::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--time-on-ink); }
.conn[data-state="ok"]::before { background: var(--clear-on-ink); animation: pulse 2s infinite; }
.conn[data-state="offline"]::before { background: var(--fault-on-ink); }
h1 { margin: 6px 0 2px; font-size: clamp(26px, 5vw, 44px); line-height: 1.05; font-weight: 800; font-stretch: 112%; letter-spacing: -.01em; }
.ev-meta { color: var(--cloth-mute); font-size: 14px; }

.div-tabs { display: flex; gap: 6px; padding: 8px var(--gut); max-width: 1840px; margin: 0 auto; overflow-x: auto; scrollbar-width: none; }
.div-tabs button { flex: none; background: var(--ink-700); color: var(--cloth-dim); border: 1px solid var(--ink-500); border-radius: 99px; padding: 8px 16px; font-weight: 700; min-height: 40px; display: inline-flex; align-items: center; gap: 8px; }
.div-tabs button[aria-selected="true"] { background: var(--hivis); color: var(--ink); border-color: var(--hivis); }
.live-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--clear-on-ink); animation: pulse 1.4s infinite; }

.boards { max-width: 1840px; margin: 0 auto; padding: 4px var(--gut) 8px; display: grid; gap: 24px; }
.division { display: none; }
.division.is-selected { display: block; }
.empty { text-align: center; color: var(--cloth-mute); padding: 64px 0; }

.div-head { display: flex; align-items: baseline; gap: 12px; flex-wrap: wrap; margin: 6px 0 8px; }
.div-head h2 { margin: 0; font-size: 22px; font-weight: 800; }
.profile { font-size: 12px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--cloth-mute); }

/* one grid for the header and every row */
.cols, .row {
  display: grid; align-items: center; column-gap: 12px;
  grid-template-columns: calc(var(--fs) * 2.2) calc(var(--fs) * 3) minmax(0, 1fr) repeat(var(--phases, 3), minmax(calc(var(--fs) * 5), calc(var(--fs) * 6.6))) calc(var(--fs) * 4.8);
}
.cols { padding: 0 14px 6px; font-size: 11px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; color: var(--cloth-mute); border-bottom: 1px solid var(--ink-500); }
.cols .c-ph em { display: block; font-style: normal; font-size: 10px; letter-spacing: .08em; margin-top: 2px; }
.cols em.prov { color: var(--cloth-mute); }
.cols em.prov::before { content: "◌ "; }
.cols em.off { color: var(--hivis); }
.cols em.off::before { content: "● "; }
.cols .c-ph, .cols .c-total, .row .c-ph, .row .c-total { text-align: right; }
.c-place { text-align: right; }

.rows { list-style: none; margin: 0; padding: 0; }
.row { position: relative; padding: 10px 14px; border-bottom: 1px solid var(--ink-600); background: var(--ink); cursor: pointer; will-change: transform; }
.row:nth-child(odd) { background: var(--ink-800); }
.row:hover { background: var(--ink-700); }
.row .c-place { font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums; color: var(--cloth); }
.row:nth-child(-n+3) .c-place { color: var(--hivis); }
.row .c-bib { font-variant-numeric: tabular-nums; color: var(--cloth-mute); font-weight: 600; }
.c-who { min-width: 0; display: grid; }
.rider { font-weight: 700; font-size: 1.08em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.horse { color: var(--cloth-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nat { margin-left: 8px; font-size: 11px; font-weight: 800; letter-spacing: .08em; text-decoration: none; color: var(--cloth-dim); border: 1px solid var(--ink-400); border-radius: 3px; padding: 0 4px; vertical-align: 2px; }
.c-ph b, .c-total b { display: block; font-variant-numeric: tabular-nums; font-weight: 700; font-size: 1.08em; }
.c-total b { font-size: 1.35em; font-weight: 800; color: var(--cloth); }
.c-ph small { display: block; font-size: 11px; color: var(--cloth-mute); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dim { color: var(--ink-400); }
.run { color: var(--clear-on-ink); }
.code { display: inline-block; min-width: 2.6em; text-align: center; padding: 2px 8px; border-radius: 99px; font-size: 12px; font-weight: 800; letter-spacing: .06em; background: var(--ink-600); color: var(--cloth-dim); border: 1px solid var(--ink-400); }

.row.is-out { opacity: .72; }
.row.is-live { background: color-mix(in srgb, var(--clear-on-ink) 10%, var(--ink)); box-shadow: inset 4px 0 0 var(--clear-on-ink); }
.live { display: inline-flex; align-items: center; gap: 6px; margin-top: 3px; width: fit-content; font-size: 12px; font-weight: 700; color: var(--ink); background: var(--clear-on-ink); border-radius: 99px; padding: 2px 10px 2px 8px; }
.live::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: var(--ink); animation: pulse 1.4s infinite; }
.live .clock { font-variant-numeric: tabular-nums; }

.flash-up { animation: flashUp 1.6s ease-out; }
@keyframes flashUp { 0% { background: color-mix(in srgb, var(--hivis) 30%, var(--ink)); } 100% { } }

.note { max-width: 1840px; margin: 8px auto 0; padding: 0 var(--gut); font-size: 12px; color: var(--cloth-mute); }

/* ---------- phone: place · rider · total, tap to expand the phases ---------- */
@media (max-width: 720px) {
  .cols, .row { grid-template-columns: calc(var(--fs) * 1.8) minmax(0, 1fr) calc(var(--fs) * 4.2); column-gap: 10px; }
  .cols .c-bib, .cols .c-ph, .row .c-bib { display: none; }
  .cols { padding: 0 10px 6px; }
  .row { padding: 10px; }
  .row .c-place { font-size: 20px; align-self: start; padding-top: 1px; }
  .row .c-place { grid-row: 1; grid-column: 1; }
  .row .c-who { grid-row: 1; grid-column: 2; }
  .row .c-total { align-self: start; grid-row: 1; grid-column: 3; }
  .row .c-ph { display: none; }
  .row.is-open .c-ph {
    display: flex; justify-content: space-between; align-items: baseline; gap: 10px;
    grid-column: 2 / -1; text-align: left; padding: 6px 0 0; margin-top: 6px; border-top: 1px solid var(--ink-600);
  }
  .row.is-open .c-ph + .c-ph { margin-top: 0; }
  .row.is-open .c-ph::before { content: attr(data-ph); font-size: 11px; font-weight: 800; letter-spacing: .12em; color: var(--cloth-mute); width: 2.5em; flex: none; }
  .row.is-open .c-ph b { order: 3; margin-left: auto; }
  .row.is-open .c-ph small { order: 2; flex: 1; text-align: right; }
  .row::after { content: "›"; position: absolute; right: 4px; bottom: 6px; font-size: 14px; color: var(--ink-400); transition: transform .2s; }
  .row.is-open::after { display: none; }
  .rider { font-size: 1em; }
}

/* ---------- big screen / broadcast: every division side by side ---------- */
@media (min-width: 1400px) {
  :root { --gut: 32px; --fs: 17px; }
  .div-tabs { display: none; }
  .boards { grid-template-columns: repeat(auto-fit, minmax(640px, 1fr)); align-items: start; }
  .division { display: block; }
  .div-head h2 { font-size: 28px; }
  .row { padding: 9px 14px; }
}
@media (min-width: 1800px) {
  :root { --fs: 18px; }
  .row .c-place { font-size: 26px; }
}
