/* GRIT best times (services/web). Static page; reads the lobby's public GET /v1/times. */
:root {
  --bg: #0d0e10;
  --bg-raise: #15171a;
  --bg-row: #121417;
  --line: rgba(255, 255, 255, 0.07);
  --line-strong: rgba(255, 255, 255, 0.12);
  --text: #ece8e1;
  --dim: #8d8a84;
  --faint: #5b5955;
  --amber: #f2a516;
  --amber-soft: rgba(242, 165, 22, 0.14);
  --gravel: #b8a98f;
  --gold: #f2c14e;
  --silver: #c9ccd1;
  --bronze: #c98a5a;
  --ease-out: cubic-bezier(0.23, 1, 0.32, 1);
  --ease-in-out: cubic-bezier(0.77, 0, 0.175, 1);
  --display: "Barlow Condensed", "Arial Narrow", system-ui, sans-serif;
  --body: "Barlow", system-ui, -apple-system, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, "SF Mono", Menlo, monospace;
  color-scheme: dark;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 16px/1.5 var(--body);
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
}
/* A warm floodlight from the top and a little grain: the page's only decoration. */
body::before {
  content: "";
  position: fixed;
  inset: 0 0 auto 0;
  height: 70vh;
  background: radial-gradient(60% 80% at 70% -10%, rgba(242, 165, 22, 0.10), transparent 70%),
              radial-gradient(50% 60% at 10% -20%, rgba(184, 169, 143, 0.07), transparent 70%);
  pointer-events: none;
  z-index: 0;
}
.grain {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  opacity: 0.05;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='160' height='160'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}
main, header, footer { position: relative; z-index: 1; }
.wrap { width: 100%; max-width: 880px; margin: 0 auto; padding: 0 16px; }
@media (min-width: 640px) { .wrap { padding: 0 28px; } }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* Header */
.top { border-bottom: 1px solid var(--line); }
.top-row { display: flex; align-items: center; justify-content: space-between; height: 60px; }
.mark { display: inline-flex; align-items: baseline; gap: 3px; color: var(--text); text-decoration: none; }
.mark-word { font: 800 26px/1 var(--display); letter-spacing: 0.06em; }
.mark-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--amber); }
.live { display: inline-flex; align-items: center; gap: 8px; font: 500 13px/1 var(--body); color: var(--dim); }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--faint); transition: background-color 200ms ease; }
.live[data-state="ok"] .live-dot { background: #5fbf6a; box-shadow: 0 0 0 3px rgba(95, 191, 106, 0.15); }
.live[data-state="error"] .live-dot { background: #d9534f; }

/* Hero */
.hero { padding: 56px 0 28px; }
@media (min-width: 640px) { .hero { padding: 84px 0 36px; } }
.eyebrow { margin: 0 0 14px; font: 600 13px/1 var(--body); letter-spacing: 0.14em; text-transform: uppercase; color: var(--gravel); }
h1 { margin: 0; font: 800 clamp(56px, 13vw, 112px)/0.88 var(--display); letter-spacing: -0.01em; text-transform: uppercase; }
.lede { margin: 20px 0 0; max-width: 34em; color: var(--dim); font-size: 17px; text-wrap: pretty; }
.lede em { font-style: normal; color: var(--text); }

/* Segmented controls: a clipped "active" copy over the plain one, the clip moved to the chosen tab
   (one colour change, no two states crossing). */
.controls { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.seg { position: relative; display: inline-block; border-radius: 10px; background: var(--bg-raise); box-shadow: inset 0 0 0 1px var(--line); padding: 4px; }
.seg-track { display: flex; }
.seg button, .seg span {
  flex: 1 0 auto;
  min-width: 96px;
  height: 38px;
  padding: 0 16px;
  display: inline-flex; align-items: center; justify-content: center;
  font: 700 15px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase;
  border-radius: 7px;
}
.seg button {
  appearance: none; border: 0; background: none; color: var(--dim); cursor: pointer;
  transition: color 150ms ease, transform 160ms var(--ease-out);
  -webkit-tap-highlight-color: transparent;
}
.seg button:active { transform: scale(0.97); }
.seg button:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
@media (hover: hover) and (pointer: fine) { .seg button:hover { color: var(--text); } }
.seg-active { position: absolute; inset: 4px; pointer-events: none; clip-path: inset(0 100% 0 0 round 7px); transition: clip-path 260ms var(--ease-in-out); }
.seg-active span { background: var(--amber); color: #17130a; }
.seg-small button, .seg-small span { min-width: 0; height: 32px; font-size: 13px; padding: 0 14px; }
.seg-small .seg-active span { background: var(--text); color: var(--bg); }
.seg[data-instant] .seg-active { transition: none; }

.rule { margin: 18px 0 0; min-height: 1.5em; color: var(--faint); font-size: 14px; }

/* Podium: the top three, large. */
.podium { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 26px; }
@media (min-width: 640px) { .podium { grid-template-columns: 1.25fr 1fr 1fr; align-items: end; } }
.pod {
  position: relative; overflow: hidden;
  padding: 18px 18px 16px; border-radius: 14px;
  background: linear-gradient(180deg, var(--bg-raise), var(--bg-row));
  box-shadow: inset 0 0 0 1px var(--line);
}
.pod::after { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--pc); opacity: 0.9; }
.pod[data-p="1"] { --pc: var(--gold); padding-top: 26px; }
.pod[data-p="2"] { --pc: var(--silver); }
.pod[data-p="3"] { --pc: var(--bronze); }
.pod-pos { font: 800 15px/1 var(--display); color: var(--pc); letter-spacing: 0.1em; }
.pod-name { margin-top: 10px; font: 700 24px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.02em; overflow-wrap: anywhere; }
.pod[data-p="1"] .pod-name { font-size: 32px; }
.pod-time { margin-top: 8px; font: 600 22px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.pod[data-p="1"] .pod-time { font-size: 30px; color: var(--amber); }
.pod-meta { margin-top: 10px; display: flex; gap: 10px; align-items: center; color: var(--dim); font-size: 13px; }

/* Table */
.table { margin-top: 26px; }
.thead, .row { display: grid; grid-template-columns: 44px minmax(0, 1fr) 40px 100px; align-items: center; column-gap: 12px; padding: 0 14px; }
@media (min-width: 640px) {
  .thead, .row { grid-template-columns: 52px minmax(0, 1fr) 90px 120px 90px; }
}
.c-gap { display: none; }
@media (min-width: 640px) { .c-gap { display: block; } }
.thead { height: 34px; font: 600 12px/1 var(--body); letter-spacing: 0.12em; text-transform: uppercase; color: var(--faint); border-bottom: 1px solid var(--line-strong); }
.rows { list-style: none; margin: 0; padding: 0; }
.row { min-height: 54px; border-bottom: 1px solid var(--line); }
.c-time, .c-gap { text-align: right; }
.c-pos { font: 700 18px/1 var(--display); color: var(--dim); font-variant-numeric: tabular-nums; }
.c-name { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.name { font: 600 16px/1.2 var(--body); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.car { font-size: 12px; color: var(--faint); letter-spacing: 0.04em; text-transform: uppercase; }
.car:empty { display: none; }
.c-time { font: 600 16px/1 var(--mono); font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.c-gap { font: 500 13px/1 var(--mono); color: var(--faint); font-variant-numeric: tabular-nums; }
.c-dev { display: inline-flex; align-items: center; gap: 6px; color: var(--dim); font-size: 13px; }
.c-dev svg { width: 18px; height: 18px; flex: none; }
.c-dev .dev-label { display: none; }
@media (min-width: 640px) { .c-dev .dev-label { display: inline; } }
.thead .c-dev { visibility: hidden; }
@media (min-width: 640px) { .thead .c-dev { visibility: visible; } }

/* Rows come in once per board load, staggered and short; switching boards is quick (seen often). */
.rows[data-enter] .row, .podium[data-enter] .pod {
  animation: rise 320ms var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 35ms);
}
@keyframes rise { from { opacity: 0; transform: translateY(6px); } }
.rows[data-swap], .podium[data-swap] { animation: fade 140ms ease-out both; }
@keyframes fade { from { opacity: 0.4; } }

/* Loading and empty */
.skel { height: 54px; border-bottom: 1px solid var(--line); display: flex; align-items: center; padding: 0 14px; gap: 14px; }
.skel i { display: block; height: 10px; border-radius: 5px; background: linear-gradient(90deg, var(--bg-raise) 0%, #1d2024 50%, var(--bg-raise) 100%); background-size: 200% 100%; animation: shimmer 1.1s linear infinite; }
@keyframes shimmer { to { background-position: -200% 0; } }
.empty { padding: 56px 16px 64px; text-align: center; border-bottom: 1px solid var(--line); }
.empty-mark { display: inline-flex; width: 52px; height: 52px; border-radius: 14px; align-items: center; justify-content: center; background: var(--amber-soft); color: var(--amber); }
.empty-mark svg { width: 26px; height: 26px; }
.empty h3 { margin: 18px 0 6px; font: 700 26px/1.1 var(--display); text-transform: uppercase; letter-spacing: 0.03em; }
.empty p { margin: 0 auto; max-width: 28em; color: var(--dim); font-size: 15px; }
.retry {
  margin-top: 18px; appearance: none; border: 0; cursor: pointer;
  height: 38px; padding: 0 18px; border-radius: 9px;
  background: var(--text); color: var(--bg);
  font: 700 14px/1 var(--display); letter-spacing: 0.08em; text-transform: uppercase;
  transition: transform 160ms var(--ease-out);
}
.retry:active { transform: scale(0.97); }

/* Footer */
.foot { margin-top: auto; padding: 48px 0 32px; color: var(--faint); font-size: 13px; }
.foot-row { display: flex; flex-wrap: wrap; gap: 8px 24px; justify-content: space-between; border-top: 1px solid var(--line); padding-top: 20px; }

@media (prefers-reduced-motion: reduce) {
  .seg-active { transition: none; }
  .rows[data-enter] .row, .podium[data-enter] .pod { animation: fade 200ms ease both; animation-delay: 0ms; }
  .skel i { animation: none; }
}

.empty p em { font-style: normal; color: var(--text); }
