/* SimTrackDays — visual design.
   Identity: a club track-day poster crossed with a paddock timing sheet.
   Entry-list typography (system DIN stack for display), thick-thin rules,
   tabular numerals, British racing green working in big fields (the hero
   band), kerb red as the signal colour (top stripe, ticker strap, racing
   line), one abstract racing-line motif drawn through every hero.
   Light scheme = paper sheet in the paddock; dark = night timing screen.
   System fonts only; no external assets; works from 320px up. */

:root {
  color-scheme: light dark;

  --bg: #f2f3f1;
  --surface: #ffffff;
  --row-hover: #eef3ef;
  --text: #191d1b;
  --muted: #58635e;
  --line: #d8ddd8;
  --accent: #0a5a3e;
  --accent-strong: #08422f;
  --accent-ink: #ffffff;
  --accent-wash: rgba(10, 90, 62, 0.08);
  --bad: #a33b2e;
  --bad-bg: #f7e9e6;
  --kerb-a: #c8102e;
  --kerb-b: #ffffff;
  --kerb-rule: #c8102e;

  /* Hero band: deep green field in daylight. */
  --hero-bg: #0a5a3e;
  --hero-bg-2: #063727;
  --hero-glow: rgba(255, 255, 255, 0.10);
  --hero-ink: #f3f8f5;
  --hero-sub: #cfe4d8;
  --hero-kicker: #a8e6c9;
  --hero-chip-line: rgba(243, 248, 245, 0.38);
  --hero-dot-on: #57d894;
  --hero-dot-off: #ff4a5c;
  --rl-ghost: rgba(243, 248, 245, 0.22);
  --rl-kerb: #ff4a5c;

  /* Broadcast strap. */
  --ticker-bg: #c8102e;
  --ticker-ink: #ffffff;
  --ticker-sep: rgba(255, 255, 255, 0.55);

  /* Night timing-screen panel (the status card). */
  --panel: #101915;
  --panel-text: #dbe8e0;
  --panel-muted: #8fa398;
  --panel-line: #2b3831;
  --panel-strong: #6fd8a5;

  /* Footer band. */
  --foot-bg: #0e1713;
  --foot-text: #b7ccc1;
  --foot-line: #26322b;
  --foot-link: #7bd3ac;

  --sans: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue",
          Arial, "Noto Sans", sans-serif;
  --display: "DIN Condensed", "DIN Alternate", "Bahnschrift", "Arial Narrow",
             system-ui, sans-serif;
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
          "Liberation Mono", monospace;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #101413;
    --surface: #171c1a;
    --row-hover: #1b211e;
    --text: #e6eae7;
    --muted: #97a19c;
    --line: #2a312e;
    --accent: #4fc38b;
    --accent-strong: #6bd6a2;
    --accent-ink: #08130d;
    --accent-wash: rgba(79, 195, 139, 0.12);
    --bad: #e58573;
    --bad-bg: #2c1b17;
    --kerb-a: #a0263a;
    --kerb-b: #24292b;
    --kerb-rule: #c23a4a;

    --hero-bg: #0d1811;
    --hero-bg-2: #0a110d;
    --hero-glow: rgba(79, 195, 139, 0.10);
    --hero-ink: #eaf4ee;
    --hero-sub: #a9bfb4;
    --hero-kicker: #4fc38b;
    --hero-chip-line: rgba(234, 244, 238, 0.30);
    --hero-dot-on: #4fc38b;
    --hero-dot-off: #ff5566;
    --rl-ghost: rgba(79, 195, 139, 0.22);
    --rl-kerb: #ff5566;

    --ticker-bg: #7e1c2b;
    --ticker-ink: #f7e9eb;
    --ticker-sep: rgba(247, 233, 235, 0.55);

    --panel: #0c110f;
    --panel-text: #cfe0d6;
    --panel-muted: #7c8d84;
    --panel-line: #242d28;
    --panel-strong: #4fc38b;

    --foot-bg: #0b0f0e;
    --foot-text: #8ea295;
    --foot-line: #222a26;
    --foot-link: #4fc38b;
  }
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

body {
  margin: 0;
  color: var(--text);
  font: 400 16.5px/1.62 var(--sans);
  overflow-x: hidden;
  background:
    radial-gradient(1100px 460px at 82% -160px, var(--accent-wash), transparent 62%),
    repeating-linear-gradient(135deg, rgba(25, 29, 27, 0.022) 0 1px, transparent 1px 9px),
    var(--bg);
}

/* The signature device: a kerb stripe across the top of every page. */
body::before {
  content: "";
  display: block;
  height: 5px;
  background: repeating-linear-gradient(
    90deg, var(--kerb-a) 0 16px, var(--kerb-b) 16px 32px);
}

::selection { background: var(--accent); color: var(--accent-ink); }

a:focus-visible, button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}
input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-wash);
  outline: 0;
}

/* ---- Type ---- */

h1 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(2.8rem, 8vw, 4.8rem);
  line-height: 0.95;
  letter-spacing: 0.015em;
  text-transform: uppercase;
  margin: 0;
  text-wrap: balance;
}

/* Section headers read like session boards on a timing sheet. */
h2 {
  font-family: var(--display);
  font-weight: 500;
  font-size: clamp(1.5rem, 3.4vw, 1.9rem);
  line-height: 1.05;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  margin: 52px 0 14px;
  padding-bottom: 7px;
  border-bottom: 2px solid var(--text);
}
h3 { font-size: 1.02rem; font-weight: 700; margin: 0 0 6px; }
p { margin: 9px 0; }
p, ul, ol { max-width: 66ch; }

a {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}
a:hover { text-decoration-thickness: 2px; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  font-variant-numeric: tabular-nums;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 1px 5px;
  word-break: break-all;
}

.muted { color: var(--muted); }
.small { font-size: 0.88rem; }

/* Field labels — sheet labels, kept tight and quiet. */
.label {
  display: block;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  margin-bottom: 6px;
}

/* ---- Topbar ---- */

.topbar {
  border-bottom: 1px solid var(--line);
  background: color-mix(in srgb, var(--bg) 92%, #ffffff);
}
@supports not (background: color-mix(in srgb, red, blue)) {
  .topbar { background: var(--bg); }
}
.topbar-in {
  max-width: 46rem;
  margin: 0 auto;
  padding: 15px 20px 13px;
  display: flex;
  align-items: baseline;
  gap: 8px 28px;
  flex-wrap: wrap;
}
.brand {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.35rem;
  letter-spacing: 0.045em;
  text-transform: uppercase;
  text-decoration: none;
  color: var(--text);
}
.brand::before {
  content: "";
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 10px;
  background: var(--kerb-a);
}
.site-nav {
  display: flex;
  gap: 4px 20px;
  flex-wrap: wrap;
  font-family: var(--display);
  font-size: 1.02rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.site-nav a { text-decoration: none; color: var(--muted); font-weight: 500; }
.site-nav a:hover { color: var(--text); }
.site-nav a[aria-current="page"] {
  color: var(--accent);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 6px;
}

/* ---- Broadcast strap ---- */

.ticker {
  background: var(--ticker-bg);
  color: var(--ticker-ink);
  overflow: hidden;
  border-bottom: 1px solid rgba(0, 0, 0, 0.18);
  font-family: var(--mono);
  font-size: 0.76rem;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}
.ticker-track {
  display: flex;
  width: max-content;
  animation: ticker-scroll 55s linear infinite;
}
.ticker:hover .ticker-track { animation-play-state: paused; }
.ticker-group {
  display: flex;
  align-items: center;
  gap: 3.2em;
  padding: 9px 0 8px 3.2em;
  white-space: nowrap;
}
.tick-sep { color: var(--ticker-sep); letter-spacing: 0.08em; }
@keyframes ticker-scroll { to { transform: translateX(-50%); } }

/* ---- Hero band ---- */

.hero {
  position: relative;
  overflow: hidden;
  color: var(--hero-ink);
  background:
    radial-gradient(1000px 420px at 80% -12%, var(--hero-glow), transparent 62%),
    linear-gradient(165deg, var(--hero-bg) 0%, var(--hero-bg-2) 100%);
  border-bottom: 3px solid var(--kerb-rule);
  padding: clamp(36px, 6.5vw, 64px) 0 clamp(44px, 7.5vw, 80px);
}
.hero--home {
  padding: clamp(48px, 9vw, 96px) 0 clamp(60px, 9.5vw, 104px);
}
.hero .wrap {
  position: relative;
  z-index: 1;
  max-width: 46rem;
  margin: 0 auto;
  padding: 0 20px;
}
.hero--home .wrap { max-width: 58rem; }
.hero--home h1 {
  font-size: clamp(3.4rem, 13.5vw, 8.6rem);
  line-height: 0.9;
  letter-spacing: 0.01em;
}
.hero .sub {
  color: var(--hero-sub);
  margin: 18px 0 0;
  max-width: 56ch;
  font-size: 1.05rem;
  line-height: 1.55;
}

/* Kicker row: live chip plus one line of session context. */
.hero-kicker {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px 14px;
  margin-bottom: 22px;
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--hero-kicker);
}
.hero-kicker-sep { color: var(--rl-kerb); letter-spacing: 0.1em; }

.chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 13px 4px;
  border: 1px solid var(--hero-chip-line);
  border-radius: 999px;
  font: inherit;
  letter-spacing: 0.14em;
}
.chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--hero-sub);
}
.chip.is-online .chip-dot {
  background: var(--hero-dot-on);
  animation: chip-pulse 2.4s ease-in-out infinite;
}
.chip.is-offline .chip-dot { background: var(--hero-dot-off); }
@keyframes chip-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.35; }
}

/* The racing line: one abstract flowing curve, drawn in on load. */
.racingline {
  position: absolute;
  inset: 0;
  z-index: 0;
  display: block;
  width: 100%;
  height: 100%;
}
.rl-ghost {
  fill: none;
  stroke: var(--rl-ghost);
  stroke-width: 12;
  stroke-linecap: round;
  stroke-dasharray: 1;
  stroke-dashoffset: 0;
  animation: rl-draw 1.5s cubic-bezier(0.2, 0.6, 0.2, 1) both;
}
.rl-kerb {
  fill: none;
  stroke: var(--rl-kerb);
  stroke-width: 12;
  stroke-linecap: butt;
  stroke-dasharray: 0.016 0.026;
  stroke-dashoffset: 0;
  opacity: 0;
  animation: rl-kerb-in 0.9s ease-out 1.15s both;
}
@keyframes rl-draw { from { stroke-dashoffset: 1; } }
@keyframes rl-kerb-in {
  from { opacity: 0; }
  to { opacity: 0.92; }
}

/* ---- Page body ---- */

main { max-width: 46rem; margin: 0 auto; padding: 36px 20px 76px; }

/* Ruled panels — sheet sections, not floating cards. */
.card {
  position: relative;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 18px 20px 16px;
  margin: 12px 0;
}
.card::before {
  content: "";
  position: absolute;
  top: -1px;
  left: -1px;
  right: -1px;
  height: 3px;
  border-radius: 6px 6px 0 0;
  background: var(--accent);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.22s ease;
}
.card:hover::before { transform: scaleX(1); }
.card:hover { border-color: color-mix(in srgb, var(--accent) 45%, var(--line)); }

/* Session numbers — cards on the home board are numbered like sessions. */
.card-num {
  display: block;
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.9rem;
  line-height: 1;
  color: var(--accent);
  margin-bottom: 8px;
}
.card-num::after {
  content: "";
  display: block;
  width: 34px;
  height: 2px;
  margin-top: 7px;
  background: var(--accent);
  opacity: 0.35;
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 14px;
}
.card--wide { grid-column: 1 / -1; }

/* The status card is a night timing screen even in daylight. */
.card--status {
  background: var(--panel);
  border-color: var(--panel-line);
  color: var(--panel-text);
}
.card--status::before { background: var(--panel-strong); }
.card--status:hover { border-color: var(--panel-line); }
.card--status .card-num { color: var(--panel-strong); }
.card--status .card-num::after { background: var(--panel-strong); }
.card--status .label,
.card--status .small,
.card--status .muted { color: var(--panel-muted); }
.card--status strong { color: var(--panel-strong); }
.card--status code {
  background: transparent;
  border-color: var(--panel-line);
  color: var(--panel-strong);
}

/* Paddock bulletin. */
.note {
  border-left: 3px solid var(--accent);
  background: var(--accent-wash);
  border-radius: 0 6px 6px 0;
  padding: 12px 16px;
  margin: 16px 0;
  font-size: 0.95rem;
}
.err {
  background: var(--bad-bg);
  color: var(--bad);
  border-radius: 6px;
  padding: 10px 14px;
  margin: 10px 0;
  font-size: 0.95rem;
}

/* ---- Buttons and forms ---- */

.btn {
  display: inline-block;
  position: relative;
  padding: 11px 24px 10px;
  border-radius: 4px;
  background: var(--accent);
  color: var(--accent-ink);
  border: 1px solid var(--accent);
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.05rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  text-decoration: none;
  overflow: hidden;
}
.btn::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--kerb-a);
  transform: scaleX(0);
  transform-origin: left;
  transition: transform 0.18s ease;
}
.btn:hover {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  transform: translateY(-1px);
}
.btn:hover::after { transform: scaleX(1); }

input, textarea, button { font: inherit; color: inherit; }
input[type="text"], textarea {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
}
::placeholder { color: var(--muted); opacity: 1; }
button { cursor: pointer; }
form.stack { display: grid; gap: 12px; max-width: 30rem; }
form.stack label { display: grid; gap: 5px; font-weight: 600; font-size: 0.92rem; }

/* ---- Tables — the entry-list treatment ---- */

.table-wrap { overflow-x: auto; margin: 14px 0; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
  line-height: 1.45;
  font-variant-numeric: tabular-nums;
}
thead th {
  text-align: left;
  padding: 0 10px 8px;
  border-bottom: 2px solid var(--text);
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
td {
  padding: 10px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
th:first-child, td:first-child { padding-left: 0; }
th:last-child, td:last-child { padding-right: 0; }
tbody tr:last-child td { border-bottom: 0; }
tbody tr:hover { background: var(--row-hover); }

/* Garage manifest table. */
table.garage { min-width: 680px; }
.garage td:first-child { color: var(--muted); font-size: 0.85rem; white-space: nowrap; }
.garage td:nth-child(2) { font-weight: 600; }

/* Leaderboard boards: times and gaps read like a timing screen. */
table.board { min-width: 480px; }
.board td:first-child { color: var(--muted); }
.board th:nth-child(4), .board td:nth-child(4),
.board th:nth-child(5), .board td:nth-child(5) {
  text-align: right;
  font-family: var(--mono);
  font-size: 0.88rem;
  white-space: nowrap;
}

/* ---- Request board ---- */

.req-row {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  border-bottom: 1px solid var(--line);
  padding: 14px 0;
}
.req-votes {
  min-width: 3.2em;
  text-align: center;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.req-votes > div:first-child {
  font-family: var(--display);
  font-weight: 500;
  font-size: 1.4rem;
  line-height: 1.1;
  margin-bottom: 6px;
}
button.vote {
  padding: 3px 10px;
  border: 1px solid var(--line);
  border-radius: 4px;
  background: var(--surface);
  font-weight: 700;
  font-size: 0.85rem;
}
button.vote:hover { border-color: var(--accent); color: var(--accent); }

/* ---- Footer band ---- */

footer.site-foot {
  background: var(--foot-bg);
  color: var(--foot-text);
  border-top: 1px solid var(--foot-line);
  font-size: 0.85rem;
}
footer.site-foot .in { max-width: 46rem; margin: 0 auto; padding: 22px 20px 40px; }
footer.site-foot p { margin: 6px 0; max-width: none; }
footer.site-foot a { color: var(--foot-link); }
footer.site-foot::after {
  content: "";
  display: block;
  height: 5px;
  background: repeating-linear-gradient(
    90deg, var(--kerb-a) 0 16px, var(--kerb-b) 16px 32px);
}

/* ---- Motion ---- */

a, .btn, button.vote, tbody tr, .card, .card::before, .btn::after {
  transition: background-color 0.15s ease, color 0.15s ease,
              border-color 0.15s ease, transform 0.15s ease;
}

@media (prefers-reduced-motion: reduce) {
  a, .btn, button.vote, tbody tr, .card, .card::before, .btn::after {
    transition: none;
  }
  .ticker { overflow: visible; }
  .ticker-track { animation: none; width: auto; }
  .ticker-group + .ticker-group { display: none; }
  .ticker-group { flex-wrap: wrap; row-gap: 8px; padding: 9px 20px 8px; white-space: normal; }
  .rl-ghost, .rl-kerb, .chip.is-online .chip-dot { animation: none; }
  .rl-kerb { opacity: 0.92; }
  .btn:hover { transform: none; }
}
