/* ─── Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

/* ─── Tokens — Light ─────────────────────────────────────────────── */
:root {
  --bg:              #f8f7f4;
  --bg-card:         #faf9f6;  /* [fix] warmer white, less glaring than #fff */
  --bg-subtle:       #f2f1ed;
  --text:            #111111;
  --text-2:          #555555;
  --text-3:          #999999;
  --text-4:          #cccccc;
  --border:          rgba(0, 0, 0, 0.08);
  --border-2:        rgba(0, 0, 0, 0.14);
  --red:             #c9211e;
  --red-soft:        rgba(201, 33, 30, 0.08);
  --ghost-year:      rgba(0, 0, 0, 0.07); /* [fix 8] more visible in light mode */
  --chart-grid:      rgba(0, 0, 0, 0.05);
  --chart-tick:      #cccccc;
  --font-serif:      'Lora', Georgia, serif;
  --font-sans:       'Inter', system-ui, sans-serif;
  --font-mono:       'JetBrains Mono', monospace;
  --radius:          8px;
  --radius-sm:       4px;
  --toggle-bg:       rgba(0, 0, 0, 0.06);
  --toggle-hover-bg: rgba(0, 0, 0, 0.10);
  --toggle-color:    #888888;
}

/* ─── Tokens — Dark ──────────────────────────────────────────────── */
html.dark {
  --bg:              #0e0e0e;
  --bg-card:         #161616;
  --bg-subtle:       #1a1a1a;
  --text:            #edebe6;
  --text-2:          #a0a0a0;
  --text-3:          #5a5a5a;
  --text-4:          #333333;
  --border:          rgba(255, 255, 255, 0.07);
  --border-2:        rgba(255, 255, 255, 0.12);
  --red:             #e63533;
  --red-soft:        rgba(230, 53, 51, 0.12);
  --ghost-year:      rgba(255, 255, 255, 0.025);
  --chart-grid:      rgba(255, 255, 255, 0.05);
  --chart-tick:      #444444;
  --toggle-bg:       rgba(255, 255, 255, 0.07);
  --toggle-hover-bg: rgba(255, 255, 255, 0.12);
  --toggle-color:    #888888;
}

/* ─── Theme transition ───────────────────────────────────────────── */
body,
.nav,
.chart-card,
.chart-card-full {
  transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

.no-transition *,
.no-transition *::before,
.no-transition *::after {
  transition: none !important;
}

/* ─── Base ───────────────────────────────────────────────────────── */
@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

::-webkit-scrollbar           { width: 4px; height: 4px; background: transparent; }
::-webkit-scrollbar-thumb     { background: var(--text-4); border-radius: 2px; }

/* ─── Focus styles ───────────────────────────────────────────────── */
:focus-visible {
  outline: 2px solid var(--red);
  outline-offset: 2px;
  border-radius: var(--radius-sm);
}
:focus:not(:focus-visible) {
  outline: none;
}

/* ─── Animations ─────────────────────────────────────────────────── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes slideInL {
  from { opacity: 0; transform: translateX(-8px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes barGrow {
  0%   { transform: scaleX(0); }
  70%  { transform: scaleX(1.04); }
  85%  { transform: scaleX(0.98); }
  100% { transform: scaleX(1); }
}
@keyframes blink   { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }
@keyframes spin    { to { transform: rotate(360deg); } }
@keyframes pulse   { 0%, 100% { opacity: 0.4; } 50% { opacity: 1; } }

.fade-up      { opacity: 0; animation: fadeUp   0.55s ease forwards; }
.slide-in     { opacity: 0; animation: slideInL 0.45s ease forwards; }
.bar-anim {
  transform-origin: left center;
  animation: barGrow 0.9s cubic-bezier(0.34, 1.4, 0.64, 1) forwards;
}
.cursor-blink { animation: blink 0.7s steps(1) infinite; }

@media (prefers-reduced-motion: reduce) {
  .fade-up,
  .slide-in,
  .bar-anim,
  .cursor-blink,
  .loading-spinner,
  .pit-loading {
    animation: none;
    opacity: 1;
    transform: none;
  }
}

/* ─── Nav ────────────────────────────────────────────────────────── */
.nav {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(248, 247, 244, 0.93);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
}

html.dark .nav {
  background: rgba(14, 14, 14, 0.93);
  background: color-mix(in srgb, var(--bg) 93%, transparent);
}

.nav-inner {
  max-width: 1160px;
  margin: 0 auto;
  padding: 0 32px;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 0;
}
.nav-logo {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  margin-right: 32px;
  flex-shrink: 0;
}
.nav-dot { color: var(--red); }

.nav-page-links {
  display: flex;
  align-items: center;
  gap: 2px;
}
.nav-page-link {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 400;
  color: var(--text-3);
  text-decoration: none;
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  white-space: nowrap;
}
.nav-page-link:hover  { color: var(--text-2); background: var(--bg-subtle); }
.nav-page-link.active { color: var(--text);   font-weight: 500; }

/* [fix 8] Removed dead .nav-page-link--portfolio rule */

.nav-controls {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
  margin-left: 8px;
}

/* ─── Season bar (below nav) ─────────────────────────────────────── */
.season-bar-wrap {
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 56px;
  z-index: 99;
}
.season-bar {
  display: flex;
  gap: 2px;
  padding: 10px 0;
  overflow-x: auto;
  scrollbar-width: none;
}
.season-bar::-webkit-scrollbar { display: none; }

/* ─── Season button ──────────────────────────────────────────────── */
.season-btn {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 400;
  padding: 5px 12px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  letter-spacing: 0.5px;
  white-space: nowrap;
  transition: color 0.2s, background 0.25s, border-color 0.25s;
}
.season-btn:hover    { color: var(--text-2); background: var(--bg-subtle); }
.season-btn.active {
  background: var(--red-soft);
  border-color: rgba(201,33,30,0.25);
  color: var(--red);
  font-weight: 500;
}
.season-btn:disabled { opacity: 0.3; cursor: not-allowed; }
/* [fix 3] Removed dead .api-badge rule — element is never rendered */

/* ─── Theme toggle ───────────────────────────────────────────────── */
.theme-toggle {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border-2);
  background: var(--toggle-bg);
  color: var(--toggle-color);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s, transform 0.1s;
}
.theme-toggle:hover  { background: var(--toggle-hover-bg); color: var(--text-2); }
.theme-toggle:active { transform: scale(0.94); }

.theme-icon-light { display: flex; }
.theme-icon-dark  { display: none; }
html.dark .theme-icon-light { display: none; }
html.dark .theme-icon-dark  { display: flex; }

/* ─── Layout ─────────────────────────────────────────────────────── */
.container { max-width: 1160px; margin: 0 auto; padding: 0 32px; }

@media (max-width: 600px) {
  .container  { padding: 0 20px; }
  .nav-inner  { padding: 0 20px; }
}

/* ─── Loading state ──────────────────────────────────────────────── */
.loading-wrap {
  padding: 80px 0;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.loading-spinner {
  width: 18px;
  height: 18px;
  border: 1.5px solid var(--border-2);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
.loading-text { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); letter-spacing: 1.5px; }
.loading-sub  { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); letter-spacing: 1px; opacity: 0.6; }

/* ─── Error state ────────────────────────────────────────────────── */
.error-wrap    { padding: 60px 0; }
.error-eyebrow { font-family: var(--font-mono); font-size: 10px; letter-spacing: 2px; color: var(--red); margin-bottom: 10px; text-transform: uppercase; }
.error-msg     { font-size: 14px; color: var(--text-3); line-height: 1.8; }

/* ─── Eyebrow label ──────────────────────────────────────────────── */
.eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 10px;
}

/* ─── Hero ───────────────────────────────────────────────────────── */
.hero {
  padding: 64px 0 52px;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.hero-year-ghost {
  position: absolute;
  right: -8px;
  top: 10px;
  font-family: var(--font-serif);
  font-size: clamp(100px, 16vw, 180px);
  color: var(--ghost-year);
  font-weight: 600;
  line-height: 1;
  user-select: none;
  pointer-events: none;
  overflow: hidden;
  z-index: 0;
  letter-spacing: -4px;
}
.hero-name-row {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  position: relative;
  z-index: 1;
}
.hero-name {
  font-family: var(--font-serif);
  font-size: 60px;
  font-size: clamp(44px, 7vw, 80px);
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}
.hero-name em { font-style: italic; font-weight: 400; }

#hero-cursor {
  display: inline-block;
  width: 3px;
  height: 0.75em;
  background: var(--red);
  margin-left: 3px;
  vertical-align: baseline;
  position: relative;
  top: 2px;
}
.hero-meta {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 20px;
  flex-wrap: wrap;
}
.hero-team-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 5px 14px;
  border-radius: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-2);
}
.hero-team-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.hero-nat {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 1px;
}

/* ── Hero car animation ── */
.hero-car {
  position: absolute;
  right: 1px;
  bottom: -125px;
  height: 500px;
  display: none;
  filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.25)) brightness(0.75) saturate(0.80);
  opacity: 0.80;
  pointer-events: none;
  user-select: none;
  z-index: 0;
}

@keyframes carDriveIn {
  0%   { opacity: 0; transform: translateX(160px); }
  50%  { opacity: 1; }
  100% { opacity: 1; transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .hero-car {
    display: block;
    animation: none;
    opacity: 0.80;
    transform: none;
  }
}

@media (max-width: 600px) {
  .hero-car {
    height: 130px;
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 380px) {
  .hero-car {
    height: 90px;
    right: 10px;
    bottom: 10px;
  }
}

/* ─── Metrics ────────────────────────────────────────────────────── */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .metrics-grid { grid-template-columns: repeat(2, 1fr); }
  .metric-cell { border-bottom: 1px solid var(--border); }
  .metric-cell:nth-child(2n)   { border-right: none; }
  .metric-cell:nth-child(2n+1) { border-right: 1px solid var(--border); }
  .metric-cell:nth-last-child(-n+2) { border-bottom: none; }
}

.metric-cell {
  padding: 32px 24px;
  border-top: 1px solid var(--border);
  border-right: 1px solid var(--border);
}
.metric-cell:last-child { border-right: none; }

.metric-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
  margin-bottom: 10px;
}
.metric-value {
  font-family: var(--font-serif);
  font-size: 52px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}
.metric-track {
  height: 2px; /* [fix] thicker — more visible in light mode */
  background: var(--border);
  margin-top: 16px;
  border-radius: 1px;
  overflow: hidden;
}
.metric-fill {
  height: 100%;
  background: var(--red);
  border-radius: 1px;
  transform-origin: left center;
}

/* ─── Main two-col grid ──────────────────────────────────────────── */
.main-grid {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 64px;
  padding-bottom: 80px;
  align-items: start;
}
@media (max-width: 960px) {
  .main-grid { grid-template-columns: 1fr; gap: 48px; }
}

/* ─── Tab content scroll ─────────────────────────────────────────── */
#tab-content {
  overflow-y: visible;
  padding-right: 4px;
}

@media (max-width: 960px) {
  /* [fix 5] fade gradient at bottom so clipped content is signalled */
  #tab-content {
    max-height: clamp(400px, 60dvh, 680px);
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border-2) transparent;
    -webkit-mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
    mask-image: linear-gradient(to bottom, black 85%, transparent 100%);
  }
  #tab-content::-webkit-scrollbar       { width: 3px; }
  #tab-content::-webkit-scrollbar-track { background: transparent; }
  #tab-content::-webkit-scrollbar-thumb { background: var(--border-2); border-radius: 2px; }
}

/* ─── Tabs ───────────────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 24px;
  position: relative; /* needed for indicator positioning */
}
 
.tab-indicator {
  position: absolute;
  bottom: -1px;
  left: 0;
  height: 2px;
  background: var(--red);
  border-radius: 2px 2px 0 0;
  transition: left 0.25s cubic-bezier(0.34, 1.2, 0.64, 1),
              width 0.25s cubic-bezier(0.34, 1.2, 0.64, 1);
  pointer-events: none;
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 1.5px;
  padding: 10px 16px;
  border: none;
  border-bottom: 2px solid transparent;
  background: transparent;
  color: var(--text-3);
  cursor: pointer;
  text-transform: uppercase;
  margin-bottom: -1px;
  transition: color 0.15s;
}
.tab-btn:hover  { color: var(--text-2); }
.tab-btn.active { color: var(--text); border-bottom-color: transparent; }
 
/* ─── Row header ─────────────────────────────────────────────────── */
.row-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.row-count {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  letter-spacing: 1px;
}

/* ─── Race rows ──────────────────────────────────────────────────── */
/* [fix 4] Use consistent padding to prevent layout shift on hover */
.race-row {
  display: grid;
  grid-template-columns: 28px 1fr 80px auto 32px;
  align-items: center;
  gap: 16px;
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  animation: slideInL 0.42s ease forwards;
  cursor: pointer;
  border-radius: var(--radius);
  transition: background 0.15s;
}

.race-row:hover    { background: var(--bg-subtle); }
.race-row.expanded { background: var(--bg-subtle); }

.race-num {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  font-weight: 300;
}
.race-name {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.3;
}
.race-winner {
  display: flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  color: var(--text-3);
}
.team-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}
.race-pole-note {
  font-family: var(--font-mono);
  font-size: 9px;
  color: var(--text-4);
  text-align: right;
  letter-spacing: 0.5px;
}
.race-date {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  text-align: right;
  white-space: nowrap;
}

/* [fix 4] Expand icon — intentional circular button, no layout shift */
.race-expand-icon {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 1px solid var(--border-2);
  background: var(--bg-subtle);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  color: var(--text-3);
  transition: color 0.15s, background 0.15s, border-color 0.15s;
  justify-self: end;
  flex-shrink: 0;
}
.race-row:hover    .race-expand-icon,
.race-row.expanded .race-expand-icon {
  color: var(--text);
  background: var(--bg-card);
  border-color: var(--border-2);
}

/* ─── Qualifying rows ────────────────────────────────────────────── */
.qual-row {
  display: grid;
  grid-template-columns: 28px 1fr 90px;
  gap: 14px;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  animation: slideInL 0.42s ease forwards;
}
.qual-time      { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); text-align: right; }
.qual-time.pole { color: var(--red); }

/* ─── Driver standings rows ──────────────────────────────────────── */
.driver-row {
  display: grid;
  grid-template-columns: 28px 1fr 48px 64px;
  align-items: center;
  gap: 14px;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  opacity: 0;
  animation: slideInL 0.42s ease forwards;
}
.driver-pos  { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); }
.driver-name { font-size: 13px; font-weight: 500; margin-bottom: 3px; }
.driver-team { display: flex; align-items: center; gap: 6px; font-size: 11px; color: var(--text-3); }
.driver-wins { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); text-align: right; }
.driver-pts  { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); text-align: right; font-weight: 500; }

/* ─── Right column ───────────────────────────────────────────────── */
.right-divider { border: none; border-top: 1px solid var(--border); margin: 36px 0; }

.constructor-list { display: flex; flex-direction: column; gap: 18px; }
.constructor-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.constructor-left   { display: flex; align-items: center; gap: 10px; }
.constructor-pos    { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); }
.constructor-name   { font-size: 13px; font-weight: 500; color: var(--text); }
.constructor-pts    { font-family: var(--font-mono); font-size: 12px; color: var(--text-3); }
.constructor-track  { height: 1.5px; background: var(--border); border-radius: 1px; overflow: hidden; }
.constructor-fill   { height: 100%; border-radius: 1px; transform-origin: left center; }

/* ─── Win share ──────────────────────────────────────────────────── */
.win-row  { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }
.win-name {
  font-size: 12px;
  color: var(--text-3);
  min-width: 11ch;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.win-track { flex: 1; height: 1.5px; background: var(--border); border-radius: 1px; overflow: hidden; }
.win-fill  { height: 100%; border-radius: 1px; transform-origin: left center; }
.win-num   { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); min-width: 14px; text-align: right; }

/* ─── Stats / pit block ──────────────────────────────────────────── */
.stat-row   { display: flex; justify-content: space-between; padding: 10px 0; border-bottom: 1px solid var(--border); }
.stat-label { font-size: 13px; color: var(--text-3); }
.stat-val   { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); }
.pit-source  { font-family: var(--font-mono); font-size: 9px; letter-spacing: 1.5px; color: var(--text-4); text-transform: uppercase; margin-bottom: 14px; }

/* ─── Charts section ─────────────────────────────────────────────── */
.charts-section {
  padding: 40px 0 56px; /* [fix spacing] reduced from 56px/80px */
  /* [fix] border-top removed — single divider now comes from cvs-section border-bottom */
}
.charts-heading {
  font-family: var(--font-serif);
  font-size: 32px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}
.charts-heading em { font-style: italic; font-weight: 400; }
.charts-sub {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-4);
  letter-spacing: 1px;
  margin-bottom: 28px; /* [fix spacing] reduced from 40px */
}
.charts-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
@media (max-width: 800px) { .charts-grid { grid-template-columns: 1fr; } }

.chart-card      { background: var(--bg-card); padding: 28px; }
.chart-card-full { background: var(--bg-card); padding: 28px; grid-column: 1 / -1; }

.chart-eyebrow {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-4);
  text-transform: uppercase;
  margin-bottom: 4px;
}
.chart-title {
  font-family: var(--font-serif);
  font-size: 16px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 20px;
}
.chart-title em { font-style: italic; font-weight: 400; }

.chart-wrap      { position: relative; height: 280px; }
.chart-wrap-tall { position: relative; height: 340px; }

/* ─── Footer ─────────────────────────────────────────────────────── */
.site-footer { border-top: 1px solid var(--border); padding: 24px 0 32px; }
.site-footer .container { display: flex; justify-content: space-between; align-items: center; }
.site-footer span { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); letter-spacing: 1px; }

/* ─── Race drill-down panel ──────────────────────────────────────── */
@keyframes drilldownOpen {
  from { opacity: 0; max-height: 0; }
  to   { opacity: 1; max-height: 3000px; }
}
@keyframes drilldownClose {
  from { opacity: 1; max-height: 3000px; }
  to   { opacity: 0; max-height: 0; }
}

.race-drilldown {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  border-bottom: 1px solid var(--border);
  margin: 4px 0;
  border-radius: var(--radius);
}
.race-drilldown.drilldown-open {
  animation: drilldownOpen 0.28s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}
.race-drilldown.drilldown-closing {
  animation: drilldownClose 0.2s ease forwards;
}

@media (prefers-reduced-motion: reduce) {
  .race-drilldown,
  .race-drilldown.drilldown-open { animation: none; max-height: 3000px; opacity: 1; }
  .race-drilldown.drilldown-closing { display: none; }
}

.drilldown-inner {
  display: grid;
  grid-template-columns: 1fr 1px 1fr;
  gap: 0;
  padding: 24px 8px 16px;
  background: var(--bg-subtle);
  border-radius: var(--radius);
}
@media (max-width: 600px) {
  .drilldown-inner { grid-template-columns: 1fr; }
  .drilldown-divider { display: none; }
}

.drilldown-divider {
  background: var(--border);
  margin: 0 20px;
}
.drilldown-col {
  padding: 0 16px;
  display: flex;
  flex-direction: column;
}
.drilldown-col-title {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-4);
  text-transform: uppercase;
  margin-bottom: 12px;
}
.drilldown-row {
  display: grid;
  grid-template-columns: 22px 1fr 10px auto;
  align-items: center;
  gap: 10px;
  padding: 6px 0;
  border-bottom: 1px solid var(--border);
}
.drilldown-row:last-child { border-bottom: none; }
.drilldown-pos  { font-family: var(--font-mono); font-size: 10px; color: var(--text-4); }
.drilldown-name { font-size: 12px; font-weight: 500; color: var(--text); }
.drilldown-team-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }
.drilldown-time { font-family: var(--font-mono); font-size: 11px; color: var(--text-3); text-align: right; }
.drilldown-fl   { font-family: var(--font-mono); font-size: 9px; letter-spacing: 0.5px; color: var(--red); text-align: right; }
.drilldown-fl-empty { display: block; width: 16px; }
.drilldown-empty { font-size: 12px; color: var(--text-4); padding: 8px 0; }
.drilldown-lap-loading {
  font-family: var(--font-mono);
  font-size: 10px;
  color: var(--text-4);
  padding: 10px 0;
  animation: pulse 1.8s ease infinite;
}

/* ─── Track layout ───────────────────────────────────────────────── */
.drilldown-track-wrap {
  margin-top: 16px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  flex: 1;
  display: flex;
  align-items: center;
}
.drilldown-track-img {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  object-position: top;
  opacity: 0.99;
  filter: invert(1);
}
html:not(.dark) .drilldown-track-img {
  filter: invert(0);
  opacity: 0.55;
}

/* ─── Champion vs Runner-up strip ────────────────────────────────── */
.cvs-section {
  padding: 36px 0 36px; /* [fix spacing] reduced from 44px/48px */
  border-bottom: 1px solid var(--border);
  margin-bottom: 0; /* charts-section provides its own top padding */
}
.cvs-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 32px;
}
.cvs-driver {
  display: flex;
  align-items: center;
  gap: 14px;
  flex: 1;
}
.cvs-driver-right { justify-content: flex-end; }
.cvs-pos-badge {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.5px;
  padding: 4px 9px;
  border-radius: 20px;
  border: 1px solid;
  flex-shrink: 0;
}
.cvs-name {
  font-family: var(--font-serif);
  font-size: 20px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
.cvs-team-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 4px;
}
.cvs-team-name { font-size: 12px; color: var(--text-3); }
.cvs-vs {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-4);
  flex-shrink: 0;
  padding-top: 6px;
}
.cvs-stats { display: flex; flex-direction: column; gap: 14px; }
.cvs-stat-row {
  display: grid;
  grid-template-columns: 48px 1fr 48px;
  align-items: center;
  gap: 14px;
}
.cvs-val { font-family: var(--font-mono); font-size: 13px; font-weight: 500; color: var(--text-2); }
.cvs-val-left  { text-align: left; }
.cvs-val-right { text-align: right; }
.cvs-center {
  display: flex;
  flex-direction: column;
  gap: 5px;
  align-items: center;
}
.cvs-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 2px;
  color: var(--text-4);
  text-transform: uppercase;
}
.cvs-bar-track {
  width: 100%;
  height: 3px;
  display: flex;
  border-radius: 2px;
  overflow: hidden;
  background: var(--border);
}
.cvs-bar-left,
.cvs-bar-right { height: 100%; }
.cvs-bar-left  { border-radius: 2px 0 0 2px; transform-origin: left center; }
.cvs-bar-right { border-radius: 0 2px 2px 0; transform-origin: right center; }

@media (max-width: 600px) {
  .cvs-name { font-size: 16px; }
  .cvs-stat-row { grid-template-columns: 36px 1fr 36px; gap: 8px; }
}

/* ═══════════════════════════════════════════════════════════════════
   About / About API page styles
═══════════════════════════════════════════════════════════════════ */

/* ─── Page hero ──────────────────────────────────────────────────── */
.page-hero {
  padding: 64px 0 52px;
  border-bottom: 1px solid var(--border);
  max-width: 640px;
}
.page-title {
  font-family: var(--font-serif);
  font-size: 58px;
  font-size: clamp(44px, 7vw, 72px);
  font-weight: 600;
  line-height: 1;
  color: var(--text);
  margin-bottom: 20px;
}
.page-title em { font-style: italic; font-weight: 400; }
.page-subtitle {
  font-size: 16px;
  color: var(--text-3);
  line-height: 1.7;
  max-width: 520px;
}

/* ─── Two-col section layout ─────────────────────────────────────── */
.about-section {
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 48px;
  padding: 52px 0;
}
@media (max-width: 720px) {
  .about-section { grid-template-columns: 1fr; gap: 16px; padding: 36px 0; }
}
.about-section-label   { padding-top: 4px; }
.about-section-content { min-width: 0; }

.about-heading {
  font-family: var(--font-serif);
  font-size: 28px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 16px;
  line-height: 1.15;
}
.about-heading em { font-style: italic; font-weight: 400; }
.about-subheading {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2.5px;
  color: var(--text-3);
  text-transform: uppercase;
  margin: 32px 0 16px;
}
.about-body {
  font-size: 14px;
  color: var(--text-2);
  line-height: 1.8;
  margin-bottom: 14px;
}
.about-body code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--bg-subtle);
  padding: 1px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-2);
}
.about-divider { border: none; border-top: 1px solid var(--border); }
.about-links { display: flex; gap: 16px; margin-top: 20px; }
.about-link {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.5px;
  color: var(--red);
  text-decoration: none;
  transition: opacity 0.15s;
}
.about-link:hover { opacity: 0.7; }

/* ─── Stats row ──────────────────────────────────────────────────── */
.about-stats {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

@media (max-width: 640px) {
  .about-stats { grid-template-columns: repeat(2, 1fr); }
  .about-stat:nth-child(2)  { border-right: none; }
  .about-stat:nth-child(3)  { border-right: 1px solid var(--border); }
  .about-stat:nth-child(3),
  .about-stat:nth-child(4)  { border-top: 1px solid var(--border); }
}

.about-stat {
  padding: 28px 24px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.about-stat:last-child { border-right: none; }
.about-stat-num {
  font-family: var(--font-serif);
  font-size: 44px;
  font-weight: 600;
  line-height: 1;
  color: var(--text);
}
.about-stat-label {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--text-3);
  text-transform: uppercase;
}

/* ─── Feature grid ───────────────────────────────────────────────── */
.feature-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 4px;
}
@media (max-width: 640px) { .feature-grid { grid-template-columns: 1fr; } }
.feature-card { background: var(--bg-card); padding: 22px 24px; }
.feature-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 6px; }
.feature-body  { font-size: 13px; color: var(--text-3); line-height: 1.7; }

/* ─── Tag row ────────────────────────────────────────────────────── */
.tag-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.tag {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 20px;
  background: var(--bg-subtle);
  border: 1px solid var(--border);
  color: var(--text-3);
  white-space: nowrap;
}

/* ─── API meta row ───────────────────────────────────────────────── */
.api-meta-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 20px 0 28px;
}
@media (max-width: 640px) { .api-meta-row { grid-template-columns: 1fr; } }
.api-meta {
  background: var(--bg-card);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.api-meta-label {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1.5px;
  color: var(--text-4);
  text-transform: uppercase;
  min-width: 72px;
  flex-shrink: 0;
}
.api-meta-val {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-2);
  background: transparent;
  border: none;
  padding: 0;
}

/* ─── Endpoint list ──────────────────────────────────────────────── */
.endpoint-list { display: flex; flex-direction: column; gap: 1px; background: var(--border); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; margin-top: 4px; }
.endpoint { background: var(--bg-card); padding: 16px 20px; display: flex; gap: 16px; align-items: flex-start; }
.endpoint-method {
  font-family: var(--font-mono);
  font-size: 9px;
  letter-spacing: 1px;
  background: var(--red-soft);
  color: var(--red);
  padding: 3px 8px;
  border-radius: 3px;
  flex-shrink: 0;
  margin-top: 2px;
}
.endpoint-path { font-family: var(--font-mono); font-size: 12px; color: var(--text-2); display: block; margin-bottom: 6px; word-break: break-all; }
.endpoint-desc { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.endpoint-desc code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ─── Callout box ────────────────────────────────────────────────── */
.callout {
  background: var(--bg-subtle);
  border: 1px solid var(--border-2);
  border-left: 3px solid var(--red);
  border-radius: var(--radius-sm);
  padding: 16px 20px;
  margin-top: 24px;
}
.callout-title {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--red);
  text-transform: uppercase;
  margin-bottom: 8px;
}
.callout-body { font-size: 13px; color: var(--text-3); line-height: 1.8; }
.callout-body code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-card);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ─── Flow steps ─────────────────────────────────────────────────── */
.flow-steps {
  display: flex;
  flex-direction: column;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin-top: 20px;
}
.flow-step { background: var(--bg-card); padding: 16px 20px; display: flex; gap: 20px; align-items: flex-start; }
.flow-num  { font-family: var(--font-mono); font-size: 11px; color: var(--text-4); min-width: 24px; padding-top: 2px; flex-shrink: 0; }
.flow-title { font-size: 13px; font-weight: 500; color: var(--text); margin-bottom: 4px; }
.flow-body  { font-size: 12px; color: var(--text-3); line-height: 1.7; }
.flow-body code {
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--bg-subtle);
  padding: 1px 5px;
  border-radius: 3px;
  border: 1px solid var(--border);
  color: var(--text-2);
}

/* ── Funko pop ── */
.funko-pop {
  position: absolute;
  right: 0;
  bottom: 10px;
  height: 250px;
  opacity: 0;
  pointer-events: none;
  user-select: none;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.3));
  animation: funkoPop 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 0.3s forwards,
             funkoFloat 3s ease-in-out 1s infinite;
}

.race-row {
  position: relative; /* needed for ::before */
}
 
.race-row::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%) scaleY(0);
  width: 3px;
  height: 60%;
  background: var(--team-color, var(--red));
  border-radius: 0 2px 2px 0;
  transition: transform 0.2s cubic-bezier(0.34, 1.4, 0.64, 1);
}
 
.race-row:hover::before,
.race-row.expanded::before {
  transform: translateY(-50%) scaleY(1);
}
 

@media (max-width: 640px) {
  .funko-pop {
    display: none;
  }
}


@keyframes funkoFloat {
  0%   { transform: translateY(0px); }
  50%  { transform: translateY(-10px); }
  100% { transform: translateY(0px); }
}

@keyframes funkoPop {
  0%   { transform: scale(0) translateY(30px); opacity: 0; }
  60%  { transform: scale(1.08) translateY(-8px); opacity: 1; }
  80%  { transform: scale(0.96) translateY(0px); }
  100% { transform: scale(1) translateY(0px); opacity: 1; }
}