:root {
  --bg: #0d0f12;
  --bg-elevated: #151922;
  --bg-muted: #1a1f2a;
  --text: #e8eaef;
  --text-muted: #9aa3b5;
  --accent: #e63946;
  --accent-dim: #ff6b6b33;
  --border: #2a3142;
  --focus: #ffd166;
  --font-sans: "Source Sans 3", system-ui, sans-serif;
  --font-display: "Bebas Neue", Impact, sans-serif;
  --radius: 10px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

@media (prefers-reduced-motion: reduce) {
  html {
    scroll-behavior: auto;
  }
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

body {
  margin: 0;
  font-family: var(--font-sans);
  font-size: 1.05rem;
  line-height: 1.55;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 120% 80% at 50% -20%, rgba(230, 57, 70, 0.12), transparent),
    linear-gradient(180deg, var(--bg) 0%, #0a0b0e 100%);
  min-height: 100vh;
  padding-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
  padding-bottom: max(0px, env(safe-area-inset-bottom));
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 3px;
}

a:hover {
  color: #ff7a82;
}

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1rem;
  background: var(--accent);
  color: #fff;
}

.skip-link:focus {
  left: 0;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.container {
  width: min(1120px, 100% - 2rem);
  margin-inline: auto;
}

.site-header {
  position: sticky;
  top: 0;
  z-index: 50;
  background: rgba(13, 15, 18, 0.92);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
  padding-top: max(0px, env(safe-area-inset-top));
  padding-inline: max(0px, env(safe-area-inset-left)) max(0px, env(safe-area-inset-right));
}

.nav-primary {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: min(1120px, 100% - 2rem);
  max-width: 100%;
  margin-inline: auto;
  padding: 0.75rem 0;
}

.nav-brand {
  font-family: var(--font-display);
  font-size: 1.75rem;
  letter-spacing: 0.04em;
  color: var(--text);
  text-decoration: none;
}

.nav-brand span {
  color: var(--accent);
}

.nav-toggle {
  display: none;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius);
  cursor: pointer;
  font: inherit;
}

.nav-menu {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1rem;
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-menu a {
  color: var(--text-muted);
  text-decoration: none;
  font-weight: 600;
  font-size: 0.9rem;
}

.nav-menu a:hover {
  color: var(--text);
}

@media (max-width: 900px) {
  .nav-toggle {
    display: block;
    min-width: 44px;
    min-height: 44px;
    padding: 0.5rem 1rem;
  }
  .nav-menu {
    display: none;
    width: 100%;
    flex-direction: column;
    padding: 0.5rem 0;
  }
  .nav-menu.is-open {
    display: flex;
  }

  .table-scroll-hint {
    display: block;
  }

  .table-wrap {
    -webkit-overflow-scrolling: touch;
    mask-image: linear-gradient(to right, transparent, #000 16px, #000 calc(100% - 16px), transparent);
  }

  .th-sort {
    padding: 0.35rem 0.4rem;
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .year-pill {
    min-height: 40px;
    padding: 0.45rem 0.65rem;
    font-size: 0.78rem;
  }

  .back-to-top:not([hidden]) {
    display: block;
  }
}

.hero {
  padding: 4rem 1rem 3rem;
  text-align: center;
}

.hero-inner {
  max-width: 720px;
  margin-inline: auto;
}

.hero-kicker {
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0 0 0.5rem;
}

.hero h1 {
  font-family: var(--font-display);
  font-size: clamp(2.75rem, 8vw, 4.5rem);
  letter-spacing: 0.06em;
  margin: 0 0 1rem;
  line-height: 1;
}

.hero-lead {
  font-size: 1.15rem;
  color: var(--text-muted);
  margin: 0 0 2rem;
}

.hero-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: center;
  list-style: none;
  padding: 0;
  margin: 0;
}

.hero-stats li {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem 1.25rem;
  min-width: 120px;
  box-shadow: var(--shadow);
}

.hero-stats strong {
  display: block;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--accent);
  line-height: 1;
}

.hero-stats span {
  font-size: 0.8rem;
  color: var(--text-muted);
}

.hero-cap {
  display: block;
  font-size: 0.72rem;
  opacity: 0.85;
  margin-top: 0.25rem;
}

.section {
  padding: 3.5rem 1rem;
}

.section--muted {
  background: var(--bg-muted);
  border-block: 1px solid var(--border);
}

.section--seasons {
  padding-bottom: 4rem;
}

.section h2 {
  font-family: var(--font-display);
  font-size: 2.25rem;
  letter-spacing: 0.05em;
  margin: 0 0 0.75rem;
}

.section-intro {
  color: var(--text-muted);
  max-width: 70ch;
  margin: 0 0 1.5rem;
}

.registry-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  margin-bottom: 1rem;
}

.input-search,
.select-filter,
.input-year {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 0.55rem 0.85rem;
  border-radius: var(--radius);
  font: inherit;
  min-width: 160px;
}

.input-search {
  flex: 1 1 200px;
  min-width: 200px;
}

.registry-count {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-muted);
}

.table-scroll-hint {
  display: none;
  font-size: 0.88rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--bg-elevated);
}

.back-to-top {
  display: none;
  position: fixed;
  z-index: 45;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, calc(0.75rem + env(safe-area-inset-bottom)));
  min-width: 44px;
  min-height: 44px;
  padding: 0.5rem 0.85rem;
  font: inherit;
  font-weight: 700;
  font-size: 0.85rem;
  color: #fff;
  background: var(--accent);
  border: none;
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  cursor: pointer;
}

.back-to-top:hover {
  filter: brightness(1.08);
}

.back-to-top:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 3px;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.92rem;
}

.data-table th,
.data-table td {
  padding: 0.65rem 0.85rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.data-table th {
  background: var(--bg-muted);
  color: var(--text-muted);
  font-weight: 600;
}

.th-sort {
  background: none;
  border: none;
  color: inherit;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.data-table tbody tr:hover {
  background: rgba(230, 57, 70, 0.06);
}

.accordion {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.accordion-item {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}

.accordion-trigger {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.25rem;
  background: var(--bg-muted);
  border: none;
  color: var(--text);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  text-align: left;
}

.accordion-panel {
  padding: 0 1.25rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
}

.accordion-item.is-open .accordion-panel {
  padding: 1rem 1.25rem 1.25rem;
  max-height: 2000px;
}

.accordion-panel ul {
  margin: 0.5rem 0 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.stats-grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}

.stats-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  box-shadow: var(--shadow);
}

.stats-card--wide {
  grid-column: 1 / -1;
}

.stats-card h3 {
  margin: 0 0 0.5rem;
  font-size: 1.1rem;
}

.stats-caption {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin: 0 0 1rem;
}

.bar-chart {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.bar-row {
  display: grid;
  grid-template-columns: 100px 1fr 36px;
  gap: 0.5rem;
  align-items: center;
  font-size: 0.88rem;
}

.bar-track {
  height: 10px;
  background: var(--bg-muted);
  border-radius: 5px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent), #ff8a90);
  border-radius: 5px;
  min-width: 2px;
}

.era-cards {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
}

.era-card {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
}

.era-card h3 {
  margin: 0 0 0.5rem;
  color: var(--accent);
  font-size: 1.05rem;
}

.era-card p {
  margin: 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.diagram-block {
  margin-bottom: 2.5rem;
}

.diagram-block h3 {
  margin: 0 0 0.75rem;
  font-size: 1.15rem;
}

.diagram-hint {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin: 0 0 0.75rem;
}

.mermaid-wrap {
  background: #fff;
  border-radius: var(--radius);
  padding: 1rem;
  overflow-x: auto;
  border: 1px solid var(--border);
}

.mermaid-wrap .mermaid {
  margin: 0;
  display: flex;
  justify-content: center;
}

.year-rail {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  padding: 1rem;
  background: var(--bg-elevated);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  max-height: 280px;
  overflow-y: auto;
}

.year-pill {
  font: inherit;
  font-size: 0.72rem;
  font-weight: 600;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg-muted);
  color: var(--text-muted);
  cursor: pointer;
}

.year-pill:hover {
  border-color: var(--accent);
  color: var(--text);
}

.year-pill.is-hiatus {
  border-style: dashed;
  opacity: 0.85;
}

.year-pill.is-active {
  background: var(--accent-dim);
  border-color: var(--accent);
  color: var(--text);
}

.validation-msg {
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  margin-bottom: 1rem;
  font-size: 0.95rem;
}

.validation-msg--ok {
  background: rgba(46, 160, 67, 0.15);
  border: 1px solid #3fb950;
  color: #aff5b4;
}

.validation-msg--err {
  background: rgba(230, 57, 70, 0.15);
  border: 1px solid var(--accent);
}

.season-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  align-items: center;
}

.btn {
  font: inherit;
  font-weight: 600;
  padding: 0.55rem 1rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
}

.btn:hover {
  filter: brightness(1.08);
}

.season-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.season-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-elevated);
  overflow: hidden;
}

.season-card.is-hiatus {
  border-style: dashed;
}

.season-summary {
  width: 100%;
  display: grid;
  grid-template-columns: 72px 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 1rem 1.25rem;
  background: transparent;
  border: none;
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
}

.season-summary:hover {
  background: rgba(255, 255, 255, 0.03);
}

.season-year {
  font-family: var(--font-display);
  font-size: 1.75rem;
  color: var(--accent);
  line-height: 1;
}

.season-badge {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
}

.season-champs {
  font-size: 0.92rem;
  color: var(--text-muted);
}

.season-champs strong {
  color: var(--text);
}

.chevron {
  transition: transform 0.2s;
  color: var(--text-muted);
}

.season-card.is-open .chevron {
  transform: rotate(180deg);
}

.season-detail {
  display: none;
  padding: 0 1.25rem 1.25rem;
  border-top: 1px solid var(--border);
}

.season-card.is-open .season-detail {
  display: block;
}

.season-detail ul {
  margin: 0.75rem 0;
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.season-cars-link {
  margin-top: 0.75rem;
  font-size: 0.9rem;
}

.season-car-category {
  margin-top: 0.65rem;
}

.season-car-category .car-chip-list {
  margin-top: 0.35rem;
}

.car-chip-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin: 0.5rem 0 0;
  padding: 0;
  list-style: none;
}

.car-chip {
  font-size: 0.8rem;
  padding: 0.25rem 0.5rem;
  background: var(--bg-muted);
  border-radius: 6px;
  border: 1px solid var(--border);
}

.section--sources {
  padding-bottom: 5rem;
}

.sources-list {
  padding-left: 1.25rem;
  color: var(--text-muted);
}

.methodology {
  font-size: 0.92rem;
  color: var(--text-muted);
  max-width: 75ch;
}

.methodology code {
  font-size: 0.85em;
  background: var(--bg-muted);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}

.site-footer {
  border-top: 1px solid var(--border);
  padding: 1.5rem 1rem;
  padding-bottom: max(1.5rem, calc(1rem + env(safe-area-inset-bottom)));
  text-align: center;
  font-size: 0.85rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

@media (max-width: 600px) {
  .season-summary {
    grid-template-columns: 56px 1fr;
    grid-template-rows: auto auto;
  }
  .chevron {
    grid-column: 2;
    justify-self: end;
  }

  .registry-toolbar {
    flex-direction: column;
    align-items: stretch;
  }

  .registry-toolbar .registry-count {
    flex-basis: 100%;
    order: 10;
  }

  .input-search,
  .select-filter,
  .input-year {
    width: 100%;
    min-width: 0;
    max-width: none;
    font-size: 1rem;
    padding: 0.65rem 0.9rem;
  }

  .input-search {
    flex: 1 1 auto;
  }

  .container {
    width: min(1120px, 100% - 1.25rem);
  }
}

@media (max-width: 480px) {
  .bar-row {
    display: grid;
    grid-template-columns: 1fr auto;
    grid-template-areas:
      "label count"
      "bar bar";
    gap: 0.35rem 0.5rem;
    align-items: center;
  }

  .bar-row > span:first-of-type {
    grid-area: label;
  }

  .bar-row .bar-track {
    grid-area: bar;
  }

  .bar-row > span:last-of-type {
    grid-area: count;
    justify-self: end;
    font-weight: 600;
  }
}
