/* ============================================================
   TESLA SPEED OPTIMIZER — Cockpit / HUD Design
   Palette: Tesla Red #E31937 · Electric White · Deep Charcoal
   ============================================================ */

:root {
  /* Core palette */
  --bg-deep:       #0d0d0f;
  --bg-panel:      #121215;
  --bg-card:       #161619;
  --bg-elevated:   #1c1c20;
  --bg-hover:      #222226;

  /* Tesla brand */
  --tesla-red:     #E31937;
  --tesla-red-dim: #b01328;
  --tesla-red-glow:rgba(227,25,55,0.25);
  --tesla-red-bg:  rgba(227,25,55,0.07);

  /* Accents */
  --white-bright:  #ffffff;
  --white-main:    #e8e8ec;
  --white-dim:     #a0a0a8;
  --white-muted:   #5a5a62;
  --white-ghost:   #2a2a2e;

  /* Data viz colors */
  --data-blue:     #4a9eff;
  --data-green:    #34c77b;
  --data-amber:    #f0a500;
  --data-purple:   #a855f7;

  /* Typography */
  --font-display:  'Helvetica Neue', 'Arial', sans-serif;
  --font-mono:     'Courier New', 'Consolas', monospace;
  --font-data:     'Arial Narrow', 'Arial', sans-serif;

  /* Effects */
  --glow-red:      0 0 12px rgba(227,25,55,0.5), 0 0 30px rgba(227,25,55,0.2);
  --glow-red-sm:   0 0 6px rgba(227,25,55,0.4);
  --glow-white:    0 0 8px rgba(255,255,255,0.15);
  --border-subtle: 1px solid rgba(255,255,255,0.06);
  --border-red:    1px solid rgba(227,25,55,0.3);
  --border-panel:  1px solid rgba(255,255,255,0.08);

  --section-pad:   6rem 0;
}

/* --- Reset --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; font-size: 18px; }

body {
  background: var(--bg-deep);
  color: var(--white-main);
  font-family: var(--font-display);
  line-height: 1.65;
  overflow-x: hidden;
  min-height: 100vh;
}

/* --- Keyframes --- */
@keyframes blink         { 0%,100%{opacity:1} 50%{opacity:0} }
@keyframes fade-in       { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:translateY(0)} }
@keyframes slide-up      { from{opacity:0;transform:translateY(24px)} to{opacity:1;transform:translateY(0)} }
@keyframes red-pulse     { 0%,100%{box-shadow:var(--glow-red-sm)} 50%{box-shadow:var(--glow-red)} }
@keyframes bounce-down   { 0%,100%{transform:translateY(0) rotate(45deg)} 50%{transform:translateY(5px) rotate(45deg)} }
@keyframes hud-scan      { 0%{transform:translateX(-100%)} 100%{transform:translateX(100vw)} }
@keyframes spin-dial     { from{stroke-dashoffset:283} to{stroke-dashoffset:var(--dial-target)} }
@keyframes count-up      { from{opacity:0} to{opacity:1} }
@keyframes shimmer       { 0%{background-position:-200% 0} 100%{background-position:200% 0} }

/* --- Utility --- */
.container { max-width: 1200px; margin: 0 auto; padding: 0 2.5rem; }

.section {
  padding: var(--section-pad);
  border-bottom: var(--border-subtle);
  position: relative;
}

/* Section heading — Tesla style: left red bar */
.section-title {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 300;
  color: var(--white-bright);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  margin-bottom: 0.6rem;
  position: relative;
}
.section-title::after {
  content: '';
  display: block;
  width: 40px;
  height: 2px;
  background: var(--tesla-red);
  box-shadow: var(--glow-red-sm);
  margin: 0.75rem auto 0;
}

.section-desc {
  color: var(--white-dim);
  font-size: 1rem;
  text-align: center;
  margin-bottom: 3rem;
  letter-spacing: 0.03em;
}

.red   { color: var(--tesla-red); }
.dim   { color: var(--white-dim); }
.mono  { font-family: var(--font-mono); }

/* Red accent cursor */
.cursor {
  display: inline-block; width: 2px; height: 1.1em;
  background: var(--tesla-red); animation: blink 1s step-end infinite;
  vertical-align: text-bottom; margin-left: 3px;
  box-shadow: var(--glow-red-sm);
}

/* ============================================================
   NAVIGATION — Tesla touchscreen style
   ============================================================ */
.tesla-nav {
  position: sticky; top: 0; z-index: 1000;
  background: rgba(13,13,15,0.97);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: var(--border-subtle);
  padding: 0 2.5rem;
  display: flex; justify-content: space-between; align-items: stretch;
  height: 64px;
}

.nav-brand {
  display: flex; align-items: center; gap: 0.75rem;
  color: var(--white-bright);
  font-size: 0.95rem;
  font-weight: 500;
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

/* Tesla "T" logo using CSS */
.tesla-t {
  width: 28px; height: 28px; position: relative;
  display: flex; align-items: center; justify-content: center;
}
.tesla-t::before {
  content: 'T';
  font-size: 1.4rem; font-weight: 900;
  color: var(--tesla-red);
  text-shadow: var(--glow-red-sm);
  line-height: 1;
}

.nav-links { display: flex; align-items: stretch; }
.nav-links a {
  color: var(--white-dim);
  text-decoration: none;
  font-size: 0.82rem;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 0 1.1rem;
  display: flex; align-items: center;
  border-bottom: 2px solid transparent;
  transition: color 0.2s, border-color 0.2s;
}
.nav-links a:hover, .nav-links a.active {
  color: var(--white-bright);
  border-bottom-color: var(--tesla-red);
}
.nav-links .nav-github {
  color: var(--tesla-red);
  border: 1px solid rgba(227,25,55,0.4);
  margin: auto 0 auto 1rem;
  padding: 0.4rem 1rem;
  border-bottom: 1px solid rgba(227,25,55,0.4);
  font-size: 0.72rem;
  border-radius: 2px;
  transition: background 0.2s, box-shadow 0.2s;
}
.nav-links .nav-github:hover { background: var(--tesla-red-bg); box-shadow: var(--glow-red-sm); }

.nav-toggle {
  display: none; flex-direction: column; gap: 5px;
  background: none; border: none; cursor: pointer; padding: 4px;
}
.nav-toggle span { display: block; width: 22px; height: 1.5px; background: var(--white-main); }

/* ============================================================
   HERO — Cockpit / Instrument Cluster
   ============================================================ */
.hero {
  min-height: 100vh;
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  padding: 5rem 5% 4rem;
  position: relative; overflow: hidden;
  text-align: center;
  background:
    radial-gradient(ellipse 80% 60% at 50% 100%, rgba(227,25,55,0.07) 0%, transparent 70%),
    radial-gradient(ellipse 60% 40% at 50% 0%, rgba(30,30,35,0.8) 0%, transparent 70%),
    var(--bg-deep);
}

/* Subtle grid lines — cockpit glass effect */
.hero::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; bottom: 0;
  background-image:
    linear-gradient(rgba(255,255,255,0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,0.015) 1px, transparent 1px);
  background-size: 60px 60px;
  pointer-events: none;
}

/* HUD scan line */
.hero::after {
  content: '';
  position: absolute; top: 0; left: 0;
  width: 200px; height: 100%;
  background: linear-gradient(90deg, transparent, rgba(227,25,55,0.04), transparent);
  animation: hud-scan 8s linear infinite;
  pointer-events: none;
}

#particle-canvas {
  position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; opacity: 0.5; z-index: 0;
}

.hero-content {
  position: relative; z-index: 1;
  max-width: 900px; width: 100%;
  display: flex; flex-direction: column; align-items: center;
  animation: slide-up 0.9s ease both;
}

.hero-eyebrow {
  font-size: 0.82rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--tesla-red);
  margin-bottom: 1.25rem;
  font-weight: 500;
}

.hero-title {
  font-size: clamp(2.4rem, 6vw, 4.8rem);
  font-weight: 200;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--white-bright);
  margin-bottom: 1rem;
  min-height: 2.5em;
  line-height: 1.2;
}
.hero-title .red-word { color: var(--tesla-red); font-weight: 500; }

.hero-subtitle {
  color: var(--white-dim);
  font-size: 1rem;
  letter-spacing: 0.06em;
  max-width: 600px;
  margin-bottom: 3rem;
  min-height: 1.4em;
}

/* ---- Speedometer Arc ---- */
.speedometer-wrap {
  position: relative;
  width: 280px; height: 180px;
  margin: 0 auto 2.5rem;
}
.speedometer-svg { width: 100%; height: 100%; }

/* Speed arc track */
.speed-track {
  fill: none;
  stroke: var(--bg-elevated);
  stroke-width: 8;
  stroke-linecap: round;
}
/* Speed arc fill — animated */
.speed-arc {
  fill: none;
  stroke: var(--tesla-red);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 283;
  stroke-dashoffset: 283;
  transition: stroke-dashoffset 2s cubic-bezier(0.4, 0, 0.2, 1);
  filter: drop-shadow(0 0 6px rgba(227,25,55,0.6));
}
/* Tick marks on arc */
.speed-ticks { fill: none; stroke: var(--white-ghost); stroke-width: 1.5; }
.speed-ticks-major { fill: none; stroke: var(--white-muted); stroke-width: 2; }

.speed-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -35%);
  text-align: center;
}
.speed-big {
  font-size: 4rem; font-weight: 100;
  color: var(--white-bright); line-height: 1;
  letter-spacing: -0.02em;
}
.speed-unit-label {
  font-size: 0.8rem; letter-spacing: 0.2em;
  color: var(--white-dim); text-transform: uppercase;
}
.speed-sublabel {
  font-size: 0.72rem; letter-spacing: 0.15em;
  color: var(--tesla-red); margin-top: 0.3rem;
  text-transform: uppercase; font-weight: 500;
}

/* Arc tick labels */
.arc-label {
  font-size: 0.55rem; fill: var(--white-muted);
  font-family: var(--font-display);
  letter-spacing: 0.05em;
}

/* HUD data row under arc */
.hud-row {
  display: flex; gap: 1px;
  margin-bottom: 2rem;
  border: var(--border-subtle);
  background: var(--white-ghost);
}
.hud-cell {
  flex: 1; background: var(--bg-panel);
  padding: 0.85rem 1rem; text-align: center;
}
.hud-val {
  font-size: 1.5rem; font-weight: 200;
  color: var(--white-bright); letter-spacing: 0.05em;
}
.hud-val .hud-unit { font-size: 0.72rem; color: var(--white-dim); margin-left: 2px; }
.hud-lbl {
  font-size: 0.68rem; letter-spacing: 0.15em;
  text-transform: uppercase; color: var(--white-muted);
  margin-top: 0.25rem;
}
.hud-cell:first-child .hud-val { color: var(--tesla-red); }

.hero-cta {
  display: flex; gap: 1rem; flex-wrap: wrap;
  justify-content: center; margin-bottom: 1rem;
}

/* ---- Buttons ---- */
.btn {
  font-family: var(--font-display);
  font-size: 0.75rem; font-weight: 500;
  letter-spacing: 0.12em; text-transform: uppercase;
  padding: 0.8rem 2rem; text-decoration: none;
  border-radius: 2px; display: inline-block;
  cursor: pointer; transition: all 0.22s;
  border: 1px solid transparent;
}
.btn-primary {
  background: var(--tesla-red);
  color: var(--white-bright);
  border-color: var(--tesla-red);
  box-shadow: var(--glow-red-sm);
}
.btn-primary:hover { background: var(--tesla-red-dim); box-shadow: var(--glow-red); }
.btn-ghost {
  background: transparent;
  color: var(--white-dim);
  border-color: rgba(255,255,255,0.15);
}
.btn-ghost:hover { border-color: rgba(255,255,255,0.4); color: var(--white-bright); }

.scroll-indicator {
  position: absolute; bottom: 2rem; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; gap: 6px;
  color: var(--white-muted); font-size: 0.6rem; letter-spacing: 0.15em;
  text-transform: uppercase; z-index: 1;
}
.scroll-arrow {
  width: 10px; height: 10px;
  border-right: 1.5px solid var(--white-muted);
  border-bottom: 1.5px solid var(--white-muted);
  animation: bounce-down 1.6s ease infinite;
}

/* ============================================================
   STATS STRIP — like a telemetry dashboard strip
   ============================================================ */
.stats-section { padding: 0; border-bottom: var(--border-subtle); }
.stats-row {
  display: flex; flex-wrap: wrap;
  border-top: 2px solid var(--tesla-red);
}
.stat-card {
  flex: 1; min-width: 130px;
  padding: 1.75rem 1.25rem; text-align: center;
  border-right: var(--border-subtle);
  position: relative; overflow: hidden;
  background: var(--bg-panel);
  transition: background 0.2s;
}
.stat-card:last-child { border-right: none; }
.stat-card:hover { background: var(--bg-card); }

/* Red shimmer on hover */
.stat-card::after {
  content: ''; position: absolute; top: 0; left: -100%;
  width: 40%; height: 1px; background: var(--tesla-red);
  transition: left 0.5s ease;
}
.stat-card:hover::after { left: 130%; }

.stat-val {
  font-size: 2rem; font-weight: 200;
  color: var(--white-bright); letter-spacing: 0.02em;
  line-height: 1; margin-bottom: 0.4rem;
}
.stat-lbl {
  font-size: 0.72rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--white-muted);
}

/* ============================================================
   PIPELINE — Engineering diagram style
   ============================================================ */
.arch-diagram {
  display: flex; align-items: center; justify-content: center;
  flex-wrap: wrap; gap: 0;
  margin-bottom: 3.5rem;
  border: var(--border-panel);
  background: var(--bg-panel);
  overflow: hidden;
}
.arch-box {
  padding: 1.25rem 1.5rem; text-align: center;
  flex: 1; min-width: 140px;
  border-right: var(--border-subtle);
  position: relative;
}
.arch-box:last-child { border-right: none; }
.arch-box::before {
  content: ''; position: absolute; top: 0; left: 0; right: 0;
  height: 2px; background: transparent;
  transition: background 0.3s;
}
.arch-input::before  { background: var(--white-dim); }
.arch-etl::before    { background: var(--tesla-red); box-shadow: var(--glow-red-sm); }
.arch-storage::before{ background: var(--data-blue); }
.arch-output::before { background: var(--data-green); }

.arch-label {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--white-dim); margin-bottom: 0.5rem;
}
.arch-etl .arch-label    { color: var(--tesla-red); }
.arch-storage .arch-label{ color: var(--data-blue); }
.arch-output .arch-label { color: var(--data-green); }
.arch-detail { font-size: 0.7rem; color: var(--white-muted); line-height: 1.6; }
.arch-arrow  { font-size: 1rem; color: var(--white-ghost); padding: 0 0.25rem; flex-shrink: 0; }

.pipeline-steps {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
  gap: 1px;
  background: var(--white-ghost);
  border: var(--border-subtle);
}
.step-card {
  background: var(--bg-panel);
  padding: 1.75rem 1.5rem;
  transition: background 0.2s;
  position: relative;
}
.step-card:hover { background: var(--bg-card); }

/* Red left border on hover */
.step-card::before {
  content: ''; position: absolute;
  left: 0; top: 0; bottom: 0; width: 0;
  background: var(--tesla-red);
  transition: width 0.2s ease;
}
.step-card:hover::before { width: 2px; }

.step-num {
  font-size: 0.6rem; letter-spacing: 0.2em;
  text-transform: uppercase; color: var(--tesla-red);
  margin-bottom: 0.5rem; font-weight: 600;
}
.step-file {
  font-family: var(--font-mono); font-size: 0.7rem;
  color: var(--white-muted); margin-bottom: 0.6rem;
}
.step-title {
  font-size: 1.1rem; font-weight: 400;
  color: var(--white-bright); margin-bottom: 0.75rem;
  letter-spacing: 0.02em;
}
.step-desc {
  font-size: 0.88rem; color: var(--white-dim);
  line-height: 1.7; margin-bottom: 1rem;
}
.step-tech { display: flex; flex-wrap: wrap; gap: 0.35rem; margin-bottom: 0.75rem; }
.tech-pill {
  font-size: 0.62rem; padding: 0.18rem 0.5rem;
  border: 1px solid rgba(227,25,55,0.2);
  color: var(--tesla-red); border-radius: 1px;
  letter-spacing: 0.05em;
}
.step-output { font-size: 0.7rem; color: var(--white-muted); }
.step-output::before { content: '→ '; color: var(--data-green); }

/* ============================================================
   RESULTS — Data dashboard panels
   ============================================================ */
.results-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}
.result-block {
  background: var(--bg-panel);
  border: var(--border-panel);
  padding: 1.75rem;
  border-radius: 2px;
  position: relative; overflow: hidden;
}
.result-block::before {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--tesla-red), transparent);
  opacity: 0.4;
}
.result-block--full { grid-column: span 2; }

.result-block-title {
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--white-muted); margin-bottom: 1.5rem;
}

/* Bar chart */
.bar-chart { display: flex; flex-direction: column; gap: 0.85rem; }
.bar-row { display: grid; grid-template-columns: 115px 1fr 95px; align-items: center; gap: 0.85rem; }
.bar-label { font-size: 0.72rem; color: var(--white-dim); text-align: right; letter-spacing: 0.03em; }
.bar-label--optimal { color: var(--white-bright); font-weight: 500; }

.optimal-tag {
  font-size: 0.55rem; color: var(--tesla-red);
  background: var(--tesla-red-bg); border: 1px solid rgba(227,25,55,0.3);
  padding: 0.1rem 0.35rem; margin-left: 4px; border-radius: 1px;
  letter-spacing: 0.08em;
}

.bar-wrap { height: 6px; background: var(--bg-elevated); border-radius: 1px; overflow: hidden; }
.bar-fill {
  height: 100%; background: var(--white-muted); width: 0%;
  transition: width 1.5s cubic-bezier(0.4,0,0.2,1); border-radius: 1px;
}
.bar-fill--optimal {
  background: linear-gradient(90deg, var(--tesla-red-dim), var(--tesla-red));
  box-shadow: 0 0 8px rgba(227,25,55,0.4);
}
.bar-val { font-size: 0.72rem; color: var(--white-dim); font-family: var(--font-mono); }
.bar-val--optimal { color: var(--tesla-red); font-weight: 600; }
.chart-note { font-size: 0.68rem; color: var(--white-muted); margin-top: 1.25rem; letter-spacing: 0.03em; }

/* Mode cards */
.mode-cards { display: flex; flex-direction: column; gap: 0.75rem; }
.mode-card {
  background: var(--bg-card); border: var(--border-subtle);
  padding: 1rem 1.25rem; border-radius: 2px;
  display: grid; grid-template-columns: 1fr auto; gap: 0.5rem;
  align-items: start;
  transition: border-color 0.2s;
}
.mode-card--best { border-color: rgba(227,25,55,0.25); }
.mode-name {
  font-size: 0.78rem; font-weight: 500;
  color: var(--white-bright); letter-spacing: 0.06em;
  text-transform: uppercase; margin-bottom: 0.25rem;
}
.best-tag {
  font-size: 0.55rem; color: var(--tesla-red);
  border: 1px solid rgba(227,25,55,0.3); padding: 0.1rem 0.35rem;
  letter-spacing: 0.1em; margin-left: 6px; border-radius: 1px;
}
.mode-wh {
  font-size: 1.5rem; font-weight: 100;
  color: var(--white-bright); line-height: 1;
  grid-column: 1; font-family: var(--font-display);
}
.mode-wh.best-wh { color: var(--tesla-red); }
.mode-unit { font-size: 0.65rem; color: var(--white-dim); margin-left: 3px; }
.mode-meta { font-size: 0.65rem; color: var(--white-muted); letter-spacing: 0.03em; grid-column: span 2; }
.mode-bar-wrap { height: 2px; background: var(--bg-elevated); border-radius: 1px; overflow: hidden; grid-column: span 2; margin-top: 0.25rem; }
.mode-bar { height: 100%; background: var(--white-ghost); width: 0%; transition: width 1.5s ease; }
.mode-bar--best { background: var(--tesla-red); box-shadow: 0 0 4px rgba(227,25,55,0.4); }

/* Formula box */
.formula-box {
  background: var(--bg-card); border: var(--border-red);
  padding: 1rem 1.5rem; margin-bottom: 1.5rem; border-radius: 2px;
  font-family: var(--font-mono); font-size: 0.82rem;
  color: var(--white-dim); text-align: center;
  letter-spacing: 0.03em;
}
.formula-box .red { color: var(--tesla-red); }

/* Results table */
.optimal-result-table { overflow-x: auto; }
.result-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.result-table th {
  padding: 0.85rem 1.25rem; text-align: left;
  font-size: 0.7rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--white-muted);
  font-weight: 400; border-bottom: var(--border-subtle);
  background: var(--bg-card);
}
.result-table td {
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  color: var(--white-dim); font-family: var(--font-mono); font-size: 0.88rem;
}
.result-table tbody tr:hover { background: rgba(255,255,255,0.02); }
.optimal-row { background: rgba(227,25,55,0.05) !important; }
.optimal-row td { color: var(--white-bright); border-bottom-color: rgba(227,25,55,0.15); }
.optimal-row td:first-child { color: var(--tesla-red); font-weight: 600; }

/* ============================================================
   VISUALIZATIONS — Gallery with overlay captions
   ============================================================ */
.viz-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem;
}
.viz-card--wide { grid-column: span 2; }

.viz-card {
  background: var(--bg-panel); border: var(--border-panel);
  border-radius: 2px; overflow: hidden;
  transition: border-color 0.25s, transform 0.25s;
  position: relative;
}
.viz-card:hover { border-color: rgba(227,25,55,0.3); transform: translateY(-2px); }

.viz-label {
  padding: 0.75rem 1.25rem;
  font-size: 0.65rem; font-weight: 600;
  letter-spacing: 0.15em; text-transform: uppercase;
  color: var(--white-muted); border-bottom: var(--border-subtle);
  background: var(--bg-card);
  display: flex; justify-content: space-between; align-items: center;
}
.viz-num { color: var(--tesla-red); font-size: 0.6rem; }

.viz-img-wrap {
  overflow: hidden; background: var(--bg-deep); cursor: zoom-in;
  max-height: 280px;
}
.viz-img-wrap img {
  width: 100%; display: block; object-fit: cover;
  transition: transform 0.4s ease, filter 0.3s ease;
  filter: brightness(0.92) saturate(0.9);
}
.viz-card:hover .viz-img-wrap img { transform: scale(1.03); filter: brightness(1) saturate(1); }

.viz-desc {
  padding: 0.85rem 1.25rem; font-size: 0.75rem;
  color: var(--white-muted); line-height: 1.65;
}

/* ============================================================
   TECH STACK — Card grid
   ============================================================ */
.tech-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 1px; background: var(--white-ghost); border: var(--border-subtle); }

.tech-block {
  background: var(--bg-panel); padding: 1.75rem;
  transition: background 0.2s;
}
.tech-block:hover { background: var(--bg-card); }

.tech-block-title {
  font-size: 0.6rem; font-weight: 600;
  letter-spacing: 0.2em; text-transform: uppercase;
  color: var(--tesla-red); margin-bottom: 1.25rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid rgba(227,25,55,0.15);
}

.tech-items { display: flex; flex-direction: column; gap: 1rem; }
.tech-item { display: flex; gap: 1rem; align-items: flex-start; }
.tech-icon { font-size: 1.25rem; flex-shrink: 0; line-height: 1.4; }
.tech-name { font-size: 1rem; color: var(--white-bright); font-weight: 400; margin-bottom: 0.2rem; }
.tech-detail { font-size: 0.82rem; color: var(--white-muted); line-height: 1.55; }

/* ============================================================
   CANVAS CHARTS — Live chart panels in Results section
   ============================================================ */

/* Two-column chart row */
.charts-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

/* Individual chart panel */
.chart-panel {
  background: var(--bg-panel);
  border: var(--border-panel);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.chart-panel::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--tesla-red), transparent);
  opacity: 0.5;
}
.chart-panel--full {
  grid-column: span 2;
  margin-bottom: 1.5rem;
}

/* Panel header */
.chart-panel-header {
  display: flex; justify-content: space-between; align-items: baseline;
  padding: 1rem 1.5rem 0.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.chart-panel-title {
  font-size: 0.75rem; font-weight: 600;
  letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--white-dim);
}
.chart-panel-sub {
  font-size: 0.68rem; color: var(--white-muted);
  letter-spacing: 0.05em;
}
.chart-panel-sub .red-text { color: var(--tesla-red); font-weight: 500; }

/* Canvas wrappers */
.chart-wrap {
  height: 230px;
  position: relative;
  overflow: hidden;
}
.chart-wrap canvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

.chart-wrap--donut {
  display: flex; align-items: center; justify-content: center;
  height: 250px;
  position: relative;
  overflow: hidden;
}
.chart-wrap--donut canvas {
  display: block;
  flex-shrink: 0;
  position: static;   /* NOT absolute — stays in flex flow */
  width: 230px !important;
  height: 230px !important;
}

.chart-wrap--tall {
  height: 300px;
  position: relative;
  overflow: hidden;
}
.chart-wrap--tall canvas {
  display: block;
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
}

/* Donut center overlay — sits on top of the canvas in flex */
.donut-center {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  pointer-events: none;
  z-index: 2;
}
.donut-val {
  font-size: 1.6rem; font-weight: 200;
  color: var(--white-bright); line-height: 1;
  letter-spacing: -0.01em;
}
.donut-lbl {
  font-size: 0.6rem; color: var(--white-muted);
  letter-spacing: 0.12em; text-transform: uppercase;
  margin-top: 0.2rem; line-height: 1.4;
}

/* Chart legend row */
.chart-legend-row {
  display: flex; align-items: center; gap: 1rem;
  padding: 0.75rem 1.5rem 1rem;
  flex-wrap: wrap;
}
.legend-dot {
  display: inline-block;
  width: 10px; height: 10px; border-radius: 50%;
  flex-shrink: 0;
}
.legend-dot--red    { background: var(--tesla-red); }
.legend-dot--bright { background: #ff6b6b; box-shadow: 0 0 6px rgba(255,107,107,0.5); }

.legend-line {
  display: inline-block; width: 18px; height: 2px;
  flex-shrink: 0; border-radius: 1px;
}
.legend-line--red   { background: var(--tesla-red); }
.legend-line--blue  { background: var(--data-blue); }
.legend-line--white { background: var(--white-bright); }

.legend-text {
  font-size: 0.68rem; color: var(--white-muted);
  letter-spacing: 0.05em;
}

/* KPI Cards row */
.results-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--white-ghost);
  border: var(--border-subtle);
  margin-bottom: 1.5rem;
}
.kpi-card {
  background: var(--bg-panel);
  padding: 1.5rem 1.25rem;
  text-align: center;
  transition: background 0.2s;
  position: relative; overflow: hidden;
}
.kpi-card:hover { background: var(--bg-card); }
.kpi-card::after {
  content: ''; position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: rgba(255,255,255,0.06);
}
.kpi-card--red::after { background: var(--tesla-red); }
.kpi-icon {
  font-size: 1.4rem; margin-bottom: 0.5rem; display: block;
}
.kpi-val {
  font-size: 2.2rem; font-weight: 100;
  color: var(--white-bright); line-height: 1;
  letter-spacing: -0.01em;
}
.kpi-card--red .kpi-val { color: var(--tesla-red); }
.kpi-unit {
  font-size: 0.68rem; color: var(--white-muted);
  letter-spacing: 0.15em; text-transform: uppercase;
  margin-top: 0.2rem;
}
.kpi-lbl {
  font-size: 0.68rem; color: var(--white-muted);
  letter-spacing: 0.1em; text-transform: uppercase;
  margin-top: 0.35rem;
}

/* ============================================================
   GITHUB STATS
   ============================================================ */
.stats-layout { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.stat-block {
  background: var(--bg-panel); border: var(--border-panel);
  padding: 1.5rem; border-radius: 2px;
}
.stat-block--wide { grid-column: span 2; }
.stat-block-label {
  font-size: 0.6rem; letter-spacing: 0.18em;
  text-transform: uppercase; color: var(--white-muted);
  margin-bottom: 1rem;
}
.badges-row { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.badges-row img { border-radius: 2px; }

/* ============================================================
   FOOTER
   ============================================================ */
.tesla-footer {
  background: var(--bg-panel);
  border-top: 2px solid var(--tesla-red);
  padding: 2rem 0;
}
.footer-inner {
  display: flex; justify-content: space-between; align-items: center;
  flex-wrap: wrap; gap: 0.75rem;
  font-size: 0.7rem; letter-spacing: 0.06em;
  margin-bottom: 0.75rem;
}
.footer-left  { color: var(--white-dim); }
.footer-center { color: var(--white-muted); }
.footer-center a, .footer-right a {
  color: var(--tesla-red); text-decoration: none; transition: opacity 0.2s;
}
.footer-center a:hover, .footer-right a:hover { opacity: 0.8; }
.footer-tagline {
  text-align: center; font-size: 0.6rem;
  color: var(--white-ghost); letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1024px) {
  .hud-row { flex-wrap: wrap; }
  .hud-cell { min-width: 120px; }
}

@media (max-width: 900px) {
  .results-grid { grid-template-columns: 1fr; }
  .result-block--full { grid-column: span 1; }
  .viz-grid { grid-template-columns: 1fr; }
  .viz-card--wide { grid-column: span 1; }
  .tech-grid { grid-template-columns: 1fr; }
  .stats-layout { grid-template-columns: 1fr; }
  .stat-block--wide { grid-column: span 1; }
  .arch-diagram { flex-direction: column; }
  .charts-row { grid-template-columns: 1fr; }
  .chart-panel--full { grid-column: span 1; }
  .results-kpi-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  :root { --section-pad: 4rem 0; }
  .tesla-nav { padding: 0 1.25rem; }
  .nav-toggle { display: flex; }
  .nav-links {
    display: none; position: absolute; top: 64px; left: 0; right: 0;
    flex-direction: column; background: rgba(13,13,15,0.98);
    border-bottom: var(--border-subtle); padding: 0.5rem 0;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 0.85rem 2rem; border-bottom: none;
    border-left: 2px solid transparent;
  }
  .nav-links a:hover { border-left-color: var(--tesla-red); border-bottom: none; }
  .nav-links .nav-github { margin: 0.5rem 2rem; }
  .hero { padding: 4rem 5% 3rem; }
  .speedometer-wrap { width: 220px; height: 140px; }
  .speed-big { font-size: 2.5rem; }
  .hud-row { flex-direction: column; }
  .pipeline-steps { grid-template-columns: 1fr; }
  .bar-row { grid-template-columns: 90px 1fr 80px; }
  .container { padding: 0 1.25rem; }
  .footer-inner { flex-direction: column; text-align: center; }
}

@media (max-width: 480px) {
  .hero-title { font-size: 1.8rem; }
  .hero-cta { flex-direction: column; align-items: center; }
  .btn { width: 100%; max-width: 280px; text-align: center; }
  .speedometer-wrap { width: 200px; height: 130px; }
  .results-kpi-row { grid-template-columns: repeat(2, 1fr); }
  .chart-wrap { height: 210px; }
  .chart-wrap--tall { height: 260px; }
  .chart-wrap--donut { height: 210px; }
  .chart-wrap--donut canvas { width: 190px !important; height: 190px !important; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  .hero::after { animation: none; }
  .cursor { animation: none; opacity: 1; }
  .bar-fill, .mode-bar { transition: none; }
  .scroll-indicator { display: none; }
}
