/* ===== RESET & VARIABLES ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --ver: #e10600;
  --per: #1e6bff;
  --gold: #f5a623;
  --dark: #0d0d0d;
  --dark2: #161616;
  --card: #1a1a1a;
  --border: #2a2a2a;
  --text: #e8e8e8;
  --muted: #888;
  --speed-low: #4fc3f7;
  --speed-high: #e10600;
}

html { scroll-behavior: smooth; }

body {
  background: var(--dark);
  color: var(--text);
  font-family: 'Barlow', sans-serif;
  font-weight: 300;
  line-height: 1.6;
  overflow-x: hidden;
}

/* ===== TOP PROJECT LINKS ===== */
.top-project-links {
  position: absolute;
  top: 18px;
  right: 32px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: var(--muted);
}

.top-project-links a {
  color: #9a9a9a;
  text-decoration: none;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.03em;
}

.top-project-links a:hover {
  color: var(--text);
  text-decoration: underline;
}

.top-project-links span {
  color: #555;
}

/* ===== HERO ===== */
.hero {
  position: relative;
  min-height: 100vh;
  display: flex;
  align-items: center;
  padding: 60px 40px;
  overflow: hidden;
}

.hero-bg {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 50% at 80% 50%, rgba(225,6,0,0.12) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 10% 80%, rgba(30,107,255,0.08) 0%, transparent 60%),
    linear-gradient(180deg, #0d0d0d 0%, #111 100%);
  z-index: 0;
}

.hero-bg::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image: repeating-linear-gradient(
    90deg,
    rgba(255,255,255,0.015) 0px,
    rgba(255,255,255,0.015) 1px,
    transparent 1px,
    transparent 80px
  );
}

.hero-inner {
  position: relative;
  z-index: 1;
  max-width: 900px;
}

.eyebrow {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--ver);
  margin-bottom: 20px;
}

h1 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: clamp(56px, 10vw, 120px);
  line-height: 0.92;
  letter-spacing: -0.02em;
  text-transform: uppercase;
  margin-bottom: 24px;
}

h1 em {
  font-style: italic;
  color: var(--ver);
}

.subtitle {
  font-size: 20px;
  font-weight: 300;
  color: var(--muted);
  max-width: 640px;
  margin-bottom: 36px;
  line-height: 1.5;
}

.team-names {
  font-family: 'Barlow', sans-serif;
  font-size: 14px;
  font-weight: 300;
  letter-spacing: 0.04em;
  color: #9a9a9a;
  margin-top: -10px;
  margin-bottom: 34px;
}

.controls-hero {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 20px;
}

.btn {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  border: none;
  border-radius: 4px;
  padding: 14px 28px;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.15s, box-shadow 0.15s;
}

.btn:hover { transform: translateY(-2px); box-shadow: 0 8px 24px rgba(0,0,0,0.4); }
.btn:active { transform: translateY(0); }

.btn-ver { background: var(--ver); color: #fff; }
.btn-per { background: var(--per); color: #fff; }
.btn-stop { background: #2a2a2a; color: var(--text); border: 1px solid #3a3a3a; }

.btn.playing { opacity: 0.6; }

.status-msg {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

/* ===== LAYOUT ===== */
main {
  max-width: 1280px;
  margin: 0 auto;
  padding: 40px 24px 80px;
}

.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  margin-bottom: 24px;
}

.card-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 24px;
}

.card-grid .card { margin-bottom: 0; }

/* ===== SECTION HEADER ===== */
.section-header {
  display: flex;
  align-items: flex-start;
  gap: 20px;
  margin-bottom: 24px;
}

.section-num {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 800;
  font-size: 48px;
  color: var(--ver);
  line-height: 1;
  opacity: 0.3;
  flex-shrink: 0;
  margin-top: -4px;
}

h2 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 24px;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  margin-bottom: 4px;
}

h3 {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 17px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 10px;
}

.section-desc {
  font-size: 13px;
  color: var(--muted);
  font-weight: 400;
}

/* ===== DRIVER TABS ===== */
.driver-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 20px;
}

.tab {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--muted);
  border-radius: 4px;
  padding: 8px 20px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 10px;
}

.tab.active[data-driver="VER"] { border-color: var(--ver); color: var(--ver); }
.tab.active[data-driver="PER"] { border-color: var(--per); color: var(--per); }
.tab:hover { border-color: #555; color: var(--text); }

.laptime {
  font-weight: 300;
  color: var(--muted);
  font-size: 13px;
}

/* ===== PLAYER CONTROLS ROW ===== */
.player-controls-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.playback-controls {
  display: flex;
  gap: 8px;
}

.btn-icon {
  background: var(--dark2);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 4px;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.2s;
}

.btn-icon:hover {
  background: var(--border);
  border-color: var(--muted);
}

/* ===== TELEMETRY LAYOUT (Side-by-Side) ===== */
.telemetry-layout {
  display: grid;
  grid-template-columns: 1fr 220px;
  gap: 24px;
  align-items: start;
}

#mini-map-container {
  background: rgba(0,0,0,0.2);
  border-radius: 12px;
  padding: 12px;
  border: 1px solid var(--border);
}

/* ===== TELEMETRY CHART ===== */
#telemetry-chart { width: 100%; min-width: 0; }

.tel-svg { overflow: visible; }

.lane-label {
  font-family: 'Barlow Condensed', sans-serif;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  fill: var(--muted);
}

.axis path, .axis line { stroke: #2a2a2a; }
.axis text { fill: #666; font-family: 'Barlow', sans-serif; font-size: 11px; }

.playhead-line {
  stroke: rgba(255,255,255,0.6);
  stroke-width: 1.5;
  pointer-events: none;
}

.tel-brush .selection {
  fill: white;
  fill-opacity: 0.15;
  stroke: white;
  stroke-width: 1px;
}

.tel-brush .handle {
  fill: white;
  fill-opacity: 0.8;
}

.hover-overlay {
  fill: transparent;
  cursor: crosshair;
}

/* ===== READOUT ===== */
.readout {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-top: 16px;
}

.readout div {
  background: var(--dark2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 14px;
}

.readout b {
  display: block;
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  margin-bottom: 4px;
  font-weight: 600;
}

.readout span {
  font-family: 'Barlow Condensed', sans-serif;
  font-size: 22px;
  font-weight: 600;
  color: var(--text);
}

/* ===== TRACK MAP ===== */
#track-map svg { width: 100%; height: auto; }

.track-dot {
  fill: #fff;
  stroke: var(--dark);
  stroke-width: 2;
}

/* ===== SCATTER ===== */
#scatter-chart { width: 100%; }
#scatter-chart svg { width: 100%; height: auto; overflow: visible; }

.scatter-dot {
  transition: r 0.15s;
  cursor: pointer;
}

.scatter-dot:hover { r: 7; }

.annotation {
  font-size: 12px;
  color: var(--muted);
  margin-top: 10px;
  font-style: italic;
}

/* ===== DELTA ===== */
#delta-chart { width: 100%; }
#delta-chart svg { width: 100%; height: auto; }

/* ===== TOOLTIP ===== */
.tooltip {
  position: fixed;
  pointer-events: none;
  background: #111;
  border: 1px solid #333;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  font-family: 'Barlow Condensed', sans-serif;
  opacity: 0;
  transition: opacity 0.15s;
  z-index: 9999;
  white-space: nowrap;
}

/* ===== WRITEUP ===== */
.writeup-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 40px;
}

.writeup p, .rationale-item p, #section-takeaway p {
  font-size: 15px;
  color: #aaa;
  line-height: 1.7;
  font-weight: 300;
}

/* ===== RATIONALE ===== */
.rationale-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 32px;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 40px 24px;
  font-size: 12px;
  color: #444;
  border-top: 1px solid var(--border);
  font-family: 'Barlow Condensed', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

/* ===== DRIVER CONTEXT ===== */
.driver-context {
  max-width: 620px;
  font-size: 12px;
  color: var(--muted);
  margin-top: -6px;
  margin-bottom: 14px;
  line-height: 1.4;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 900px) {
  .card-grid { grid-template-columns: 1fr; }
  .writeup-grid { grid-template-columns: 1fr; }
  .rationale-grid { grid-template-columns: 1fr; }
  .readout { grid-template-columns: repeat(3, 1fr); }
  h1 { font-size: clamp(44px, 12vw, 80px); }
}

@media (max-width: 600px) {
  .hero { padding: 70px 20px 40px; }
  .card { padding: 20px; }
  .readout { grid-template-columns: 1fr 1fr; }
  main { padding: 24px 16px 60px; }

  .top-project-links {
    top: 16px;
    left: 20px;
    right: auto;
    font-size: 11px;
  }

  .top-project-links a {
    font-size: 11px;
  }
}