/*
  Hand-written and small. Read on a phone in a field, often in sunlight, by
  someone who has just taken their helmet off - so: big type, high contrast,
  one column, and nothing that needs a second tap to reveal a lap time.
*/

:root {
  color-scheme: light;
  --surface: #fcfcfb;
  --surface-raised: #ffffff;
  --border: #e2e1dc;
  --border-strong: #c9c8c1;
  --text: #0b0b0b;
  --text-secondary: #52514e;
  --text-muted: #77756e;

  /* Validated against the light surface; see the dataviz palette. */
  --series-focus: #2a78d6;
  --series-winner: #eb6834;
  --series-field: #c9c8c1;
  --accent: #2a78d6;
  --good: #1baf7a;
  --warn: #eda100;

  --radius: 10px;
  --gutter: 16px;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface: #1a1a19;
    --surface-raised: #232322;
    --border: #35342f;
    --border-strong: #4a4943;
    --text: #ffffff;
    --text-secondary: #c3c2b7;
    --text-muted: #9a988e;
    --series-focus: #3987e5;
    --series-winner: #d95926;
    --series-field: #4a4943;
    --accent: #3987e5;
    --good: #199e70;
    --warn: #c98500;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--surface);
  color: var(--text);
  font: 16px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

.wrap {
  max-width: 900px;
  margin: 0 auto;
  padding-inline: var(--gutter);
  padding-block: 20px 56px;
}

a { color: var(--accent); }
a:hover { text-decoration: none; }

/* ---- masthead ---- */

.masthead {
  border-bottom: 1px solid var(--border);
  background: var(--surface-raised);
}
.masthead .wrap { padding-block: 14px; display: flex; align-items: baseline; gap: 12px; }
.masthead a.brand { font-weight: 650; color: var(--text); text-decoration: none; letter-spacing: -0.01em; }
.masthead .tag { color: var(--text-muted); font-size: 13px; }

/* ---- headings ---- */

h1 { font-size: 26px; line-height: 1.2; margin: 0 0 4px; letter-spacing: -0.02em; }
h2 { font-size: 18px; margin: 32px 0 10px; letter-spacing: -0.01em; }
h3 { font-size: 15px; margin: 20px 0 8px; color: var(--text-secondary); }
.subtitle { color: var(--text-secondary); margin: 0 0 20px; }

.badge {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  background: var(--border); color: var(--text-secondary);
  font-size: 12px; font-weight: 600; vertical-align: middle;
}

/* ---- tiles ---- */

.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 10px; margin: 18px 0; }
.tile { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; }
.tile .k { font-size: 12px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.04em; }
.tile .v { font-size: 22px; font-weight: 650; margin-top: 2px; font-variant-numeric: tabular-nums; letter-spacing: -0.02em; }
.tile .n { font-size: 13px; color: var(--text-secondary); }

/* ---- tables ---- */

.table-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table { border-collapse: collapse; width: 100%; font-variant-numeric: tabular-nums; }
th, td { text-align: left; padding: 9px 10px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); font-weight: 600; }
td.num, th.num { text-align: right; }
tbody tr:hover { background: var(--surface-raised); }
tr.is-out td { color: var(--text-muted); }
tr.is-you td { background: color-mix(in srgb, var(--accent) 12%, transparent); }
td .rider { white-space: normal; }
td .sub { display: block; font-size: 12px; color: var(--text-muted); }
.pos { font-weight: 650; }

/* ---- search ---- */

.finder { position: sticky; top: 0; z-index: 5; background: var(--surface); padding: 10px 0; border-bottom: 1px solid var(--border); }
.finder input {
  width: 100%; padding: 11px 13px; font-size: 16px;
  border: 1px solid var(--border-strong); border-radius: var(--radius);
  background: var(--surface-raised); color: var(--text);
}
.finder input:focus { outline: 2px solid var(--accent); outline-offset: -1px; }

/* ---- chips ---- */

.chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 14px 0; }
.chip {
  padding: 6px 12px; border-radius: 999px; border: 1px solid var(--border-strong);
  background: var(--surface-raised); color: var(--text-secondary);
  text-decoration: none; font-size: 14px;
}
.chip[aria-current="page"] { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }

/* ---- cards ---- */

.card { background: var(--surface-raised); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px 16px; margin: 12px 0; }
.card a.title { font-weight: 650; color: var(--text); text-decoration: none; font-size: 17px; }
.card .meta { color: var(--text-muted); font-size: 13px; margin-top: 2px; }

.meeting { margin: 26px 0; }
.meeting > h2 { margin-bottom: 6px; }
.session-row { display: flex; justify-content: space-between; gap: 12px; align-items: baseline; padding: 11px 0; border-bottom: 1px solid var(--border); }
.session-row a { font-weight: 600; text-decoration: none; }
.session-row .meta { color: var(--text-muted); font-size: 13px; white-space: nowrap; }

/* ---- conditions ---- */

details.conditions { margin: 16px 0; border: 1px solid var(--border); border-radius: var(--radius); background: var(--surface-raised); }
details.conditions summary { padding: 11px 14px; cursor: pointer; font-weight: 600; }
details.conditions dl { margin: 0; padding: 0 14px 14px; }
details.conditions dt { font-size: 12px; text-transform: uppercase; letter-spacing: 0.04em; color: var(--text-muted); margin-top: 10px; }
details.conditions dd { margin: 2px 0 0; color: var(--text-secondary); }

/* ---- notes ---- */

.note { border-left: 3px solid var(--warn); background: var(--surface-raised); padding: 10px 14px; margin: 14px 0; color: var(--text-secondary); font-size: 14px; border-radius: 0 var(--radius) var(--radius) 0; }

/* ---- charts ---- */

figure.chart { margin: 8px 0 20px; }
figure.chart svg { width: 100%; height: auto; display: block; }
figure.chart figcaption { font-size: 13px; color: var(--text-muted); margin-top: 6px; }

.lap-line { fill: none; stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.lap-line.field { stroke: var(--series-field); }
.lap-line.winner { stroke: var(--series-winner); }
.lap-line.focus { stroke: var(--series-focus); stroke-width: 3; }
.lap-label { font-size: 11px; font-weight: 600; dominant-baseline: middle; }
.lap-label.winner { fill: var(--series-winner); }
.lap-label.focus { fill: var(--series-focus); }
.axis { font-size: 11px; fill: var(--text-muted); }
.gridline { stroke: var(--border); stroke-width: 1; }
.bar { fill: var(--series-focus); }
.bar.outlier { fill: var(--series-field); }
.best-line { stroke: var(--series-winner); stroke-width: 1.5; stroke-dasharray: 4 3; }

/* ---- map ---- */

#map { height: 340px; border-radius: var(--radius); border: 1px solid var(--border); background: var(--surface-raised); }

/* ---- footer ---- */

footer.site { border-top: 1px solid var(--border); margin-top: 40px; padding-top: 16px; color: var(--text-muted); font-size: 13px; }
footer.site a { color: var(--text-secondary); }

.empty { color: var(--text-muted); padding: 30px 0; text-align: center; }

/* The rider's own line carries best lap and gap only where the columns
   holding them have been dropped, so nothing is said twice. */
.narrow-only { display: none; }

@media (max-width: 560px) {
  .opt { display: none; }
  .narrow-only { display: block; }
}

@media (max-width: 480px) {
  h1 { font-size: 22px; }
  th, td { padding: 8px 7px; }
  .tile .v { font-size: 19px; }
  td .rider { white-space: nowrap; }
}
