/* ============================================================
   ROUTEBOOK — design tokens
   ============================================================ */
:root {
  --bg: #0F1013;
  --surface: #1A1C21;
  --surface-raised: #202329;
  --border: #2C2F37;
  --text: #EDEDF0;
  --text-muted: #90939E;
  --accent: #FF6A3D;      /* route orange */
  --accent-dim: #7A3A26;
  --recon: #35D68E;       /* recon green — recommended marker */
  --recon-dim: #1D5C42;

  /* tag category accents — length/type/series/season stand out from plain tags */
  --tag-length-rgb: 255, 106, 61;   /* route orange */
  --tag-type-rgb: 79, 163, 247;     /* signal blue */
  --tag-series-rgb: 178, 110, 242;  /* rally violet */
  --tag-season-rgb: 242, 201, 76;   /* dial gold */
  --tag-weather-rgb: 84, 209, 200;  /* haze teal */

  /* car class accents — matches Forza's class color coding */
  --tag-carclass-d-rgb: 120, 200, 245;   /* light blue */
  --tag-carclass-c-rgb: 235, 210, 70;    /* yellow */
  --tag-carclass-b-rgb: 240, 150, 60;    /* orange */
  --tag-carclass-a-rgb: 225, 70, 70;     /* red */
  --tag-carclass-s1-rgb: 190, 100, 235;  /* purple */
  --tag-carclass-s2-rgb: 90, 130, 250;   /* deep blue */
  --tag-carclass-r-rgb: 145, 80, 205;    /* darker purple */
  --tag-carclass-x-rgb: 70, 200, 110;    /* green */

  --font-display: "Rajdhani", sans-serif;
  --font-body: "Inter", sans-serif;

  --radius: 10px;
  --radius-sm: 6px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-body);
  -webkit-font-smoothing: antialiased;
}

body {
  background-image:
    radial-gradient(ellipse at top, rgba(255,106,61,0.06), transparent 55%),
    repeating-linear-gradient(135deg, rgba(255,255,255,0.015) 0px, rgba(255,255,255,0.015) 1px, transparent 1px, transparent 14px);
}

img { max-width: 100%; display: block; }
button { font-family: inherit; }

a { color: inherit; }

/* ============================================================
   Header
   ============================================================ */
.site-header {
  padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 64px) 20px;
  border-bottom: 1px solid var(--border);
}

.site-header .kicker {
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.35em;
  font-size: 12px;
  color: var(--accent);
  text-transform: uppercase;
  margin: 0 0 6px;
}

.site-header h1 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(34px, 6vw, 56px);
  letter-spacing: 0.01em;
  margin: 0 0 8px;
  text-transform: uppercase;
}

.site-header p {
  color: var(--text-muted);
  max-width: 56ch;
  margin: 0;
  font-size: 15px;
  line-height: 1.5;
}

/* ============================================================
   Search panel (category dropdowns)
   ============================================================ */
.search-panel {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 16px;
  padding: 24px clamp(20px, 5vw, 64px) 0;
}

.search-panel-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  flex: 1;
}

.search-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
  min-width: 140px;
}

.search-field-label {
  font-family: var(--font-display);
  font-size: 11px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.search-field select {
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 13px;
  cursor: pointer;
}

.search-field select:hover { border-color: var(--text-muted); }
.search-field select:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.search-reset {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.search-reset:hover { color: var(--text); border-color: var(--text-muted); }

/* ============================================================
   Tag filter bar
   ============================================================ */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 20px clamp(20px, 5vw, 64px) 0;
}

.filter-pill {
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text-muted);
  padding: 6px 14px;
  border-radius: 999px;
  font-size: 13px;
  font-family: var(--font-display);
  letter-spacing: 0.03em;
  text-transform: uppercase;
  cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}

.filter-pill:hover { color: var(--text); border-color: var(--text-muted); }

.filter-pill.active {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d06;
  font-weight: 700;
}

/* ============================================================
   Track grid + cards
   ============================================================ */
.track-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
  padding: 24px clamp(20px, 5vw, 64px) 64px;
}

.track-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.track-card:hover {
  transform: translateY(-3px);
  border-color: #454955;
}

.track-card:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.card-media {
  position: relative;
  aspect-ratio: 10 / 10;
  background: #000;
  overflow: hidden;
}

.card-media img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  user-select: none;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: rgba(15,16,19,0.65);
  color: #fff;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(2px);
  opacity: 0;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.card-media:hover .carousel-btn { opacity: 1; }
.carousel-btn:hover { background: var(--accent); }
.carousel-btn.prev { left: 8px; }
.carousel-btn.next { right: 8px; }

.carousel-dots {
  position: absolute;
  bottom: 8px;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  gap: 5px;
}

.carousel-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
}

.carousel-dots span.active { background: #fff; }

.card-body {
  padding: 16px 16px 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.card-body h3 {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  margin: 0;
  text-transform: uppercase;
  letter-spacing: 0.01em;
}

.tag-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.tag {
  font-size: 12px;
  font-family: var(--font-display);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-muted);
  border: 1px solid var(--border);
  padding: 3px 9px;
  border-radius: 999px;
  white-space: nowrap;
}

/* Category badges (length/type/series/season) get a tinted color and extra
   weight so they read as structured metadata rather than free-form tags. */
.tag-length,
.tag-type,
.tag-series,
.tag-season,
.tag-weather {
  font-weight: 700;
  background: rgba(var(--tag-rgb), 0.14);
  border-color: rgba(var(--tag-rgb), 0.5);
  color: rgb(var(--tag-rgb));
}

.tag-length { --tag-rgb: var(--tag-length-rgb); }
.tag-type { --tag-rgb: var(--tag-type-rgb); }
.tag-series { --tag-rgb: var(--tag-series-rgb); }
.tag-season { --tag-rgb: var(--tag-season-rgb); }
.tag-weather { --tag-rgb: var(--tag-weather-rgb); }

/* Car class badges — matches Forza's per-class color coding. */
.tag-carclass-d,
.tag-carclass-c,
.tag-carclass-b,
.tag-carclass-a,
.tag-carclass-s1,
.tag-carclass-s2,
.tag-carclass-r,
.tag-carclass-x {
  font-weight: 700;
  background: rgba(var(--tag-rgb), 0.14);
  border-color: rgba(var(--tag-rgb), 0.5);
  color: rgb(var(--tag-rgb));
}

.tag-carclass-d { --tag-rgb: var(--tag-carclass-d-rgb); }
.tag-carclass-c { --tag-rgb: var(--tag-carclass-c-rgb); }
.tag-carclass-b { --tag-rgb: var(--tag-carclass-b-rgb); }
.tag-carclass-a { --tag-rgb: var(--tag-carclass-a-rgb); }
.tag-carclass-s1 { --tag-rgb: var(--tag-carclass-s1-rgb); }
.tag-carclass-s2 { --tag-rgb: var(--tag-carclass-s2-rgb); }
.tag-carclass-r { --tag-rgb: var(--tag-carclass-r-rgb); }
.tag-carclass-x { --tag-rgb: var(--tag-carclass-x-rgb); }

/* Car restriction / Horizon Special / "any car" — solid white so they pop
   against the class-colored tags next to them. */
.tag-carrestriction {
  font-weight: 700;
  background: var(--text);
  border-color: var(--text);
  color: var(--bg);
}

/* Season/weather badges show a symbol plus their label — see WEATHER_TAG_ICONS
   and SEASON_ICONS in app.js. */
.tag-icon {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  line-height: 1;
}

.tag-icon > span:first-child { font-size: 14px; }

.card-body .short-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.5;
  color: var(--text-muted);
}

/* ============================================================
   Modal
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(6,6,8,0.78);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding: clamp(0px, 4vw, 48px) 16px;
  overflow-y: auto;
  z-index: 100;
}

.modal-overlay.hidden { display: none; }

.modal-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-width: 780px;
  width: 100%;
  margin: 24px 0;
  overflow: hidden;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  background: rgba(15,16,19,0.7);
  color: #fff;
  font-size: 18px;
  cursor: pointer;
  z-index: 5;
}

.modal-close:hover { background: var(--accent); }

.modal-media {
  position: relative;
  aspect-ratio: 16 / 9;
  background: #000;
}

.modal-media img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.modal-media .carousel-btn { opacity: 1; }

.modal-body {
  padding: clamp(20px, 4vw, 34px);
}

.modal-body h2 {
  font-family: var(--font-display);
  font-size: clamp(26px, 4vw, 34px);
  text-transform: uppercase;
  margin: 0 0 10px;
}

.modal-body > .tag-row { margin-bottom: 14px; }

.modal-body .long-desc {
  color: var(--text-muted);
  line-height: 1.6;
  font-size: 15px;
  margin: 0 0 30px;
}

/* Route sheet — signature element */
.route-sheet-label {
  font-family: var(--font-display);
  font-size: 12px;
  letter-spacing: 0.35em;
  text-transform: uppercase;
  color: var(--accent);
  margin: 0 0 18px;
}

.route-sheet {
  position: relative;
  padding-left: 28px;
}

.route-sheet::before {
  content: "";
  position: absolute;
  left: 8px;
  top: 10px;
  bottom: 10px;
  width: 0;
  border-left: 2px dashed var(--border);
}

.variant {
  position: relative;
  padding-bottom: 26px;
}

.variant:last-child { padding-bottom: 0; }

.variant::before {
  content: "";
  position: absolute;
  left: -28px;
  top: 6px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--surface);
  border: 2px solid var(--text-muted);
}

.variant.recommended::before {
  border-color: var(--recon);
  background: var(--recon);
  box-shadow: 0 0 0 4px rgba(53,214,142,0.15);
}

.variant-card {
  background: var(--surface-raised);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  overflow: hidden;
  display: flex;
  align-items: stretch;
}

.variant.recommended .variant-card {
  border-color: var(--recon-dim);
  box-shadow: 0 0 0 1px var(--recon-dim);
}

/* Width is derived from the row's height via aspect-ratio, since every
   variant image is 16:9 — this fills the full card height with no crop
   and no letterboxing, whatever the description length ends up being. */
.variant-thumb {
  aspect-ratio: 16 / 9;
  flex: 0 0 auto;
  min-width: 140px;
  max-width: 320px;
  overflow: hidden;
  background: #000;
}

.variant-thumb img { width: 100%; height: 100%; object-fit: cover; }

.variant-content {
  flex: 1 1 auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-width: 0;
}

.variant-title-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.variant-content h4 {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  margin: 0;
}

.recommended-badge {
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #08251a;
  background: var(--recon);
  padding: 2px 7px;
  border-radius: 4px;
}

.variant-content .tag-row .tag { font-size: 11px; padding: 3px 8px; }

.variant-content p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.5;
  color: var(--text-muted);
}

.share-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 4px;
}

.share-code {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.12em;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  color: var(--text);
}

.copy-btn {
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-size: 12px;
  font-family: var(--font-display);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.copy-btn:hover {
  background: var(--accent);
  border-color: var(--accent);
  color: #1a0d06;
}

.copy-btn.copied {
  background: var(--recon);
  border-color: var(--recon);
  color: #08251a;
}

/* ============================================================
   Empty state
   ============================================================ */
.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}

.empty-state h3 {
  font-family: var(--font-display);
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 6px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 520px) {
  .variant-thumb { max-width: 160px; }
  .modal-panel { margin: 0; border-radius: 0; min-height: 100%; }
  .modal-overlay { padding: 0; }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .track-card, .carousel-btn, .copy-btn, .filter-pill { transition: none; }
}
