/* ============================================================
   RaceRoutes — main.css
   Design tokens, reset, layout, components, pages
   ============================================================ */

/* ------------------------------------------------------------
   1. Design tokens
   ------------------------------------------------------------ */
:root {
  --gold:          #e8b84b;
  --gold-dim:      rgba(232,184,75,0.12);
  --gold-border:   rgba(232,184,75,0.25);

  --dark-900:      #0b0d11;
  --dark-800:      #0f1218;
  --dark-700:      #131720;
  --dark-600:      #ebedf0;
  --dark-500:      #dde0e6;

  --text-primary:  #e8e6e0;
  --text-secondary:#a09e99;
  --text-muted:    #b8b5b0;

  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(232,184,75,0.35);

  /* Profile badge colours — solid, readable on light */
  --vflat-bg:   rgba(29,158,117,0.15);
  --vflat-text: #3dd8a0;
  --vflat-bdr:  rgba(29,158,117,0.3);

  --flat-bg:    rgba(56,180,100,0.15);
  --flat-text:  #5dd49a;
  --flat-bdr:   rgba(56,180,100,0.3);

  --undul-bg:   rgba(232,184,75,0.12);
  --undul-text: #e8b84b;
  --undul-bdr:  rgba(232,184,75,0.25);

  --hilly-bg:   rgba(230,130,50,0.15);
  --hilly-text: #f0a060;
  --hilly-bdr:  rgba(230,130,50,0.3);

  --vhilly-bg:  rgba(216,70,48,0.15);
  --vhilly-text:#f07060;
  --vhilly-bdr: rgba(216,70,48,0.3);

  --radius-sm:  6px;
  --radius-md:  10px;
  --radius-lg:  14px;

  --nav-height: 60px;
  --container:  1100px;
  --container-wide: 1300px;

  --font-head:  'Barlow Condensed', sans-serif;
  --font-body:  'Barlow', sans-serif;

  --transition: 0.15s ease;
}

/* ------------------------------------------------------------
   2. Reset & base
   ------------------------------------------------------------ */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--dark-900);
  min-height: 100vh;
}

img, svg { display: block; max-width: 100%; }

a { color: var(--gold); text-decoration: none; transition: opacity var(--transition); }
a:hover { opacity: 0.8; }

ul { list-style: none; }

h1, h2, h3, h4 {
  font-family: var(--font-head);
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: 0.02em;
  color: var(--text-primary);
}

h1 { font-size: clamp(2rem, 5vw, 3.2rem); }
h2 { font-size: clamp(1.3rem, 3vw, 1.8rem); margin-bottom: 1rem; }
h3 { font-size: 1.1rem; margin-bottom: 0.75rem; }

p { margin-bottom: 1rem; }
p:last-child { margin-bottom: 0; }

/* ------------------------------------------------------------
   3. Navigation
   ------------------------------------------------------------ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 1100;
  background: var(--dark-900);
  border-bottom: 1px solid var(--border);
  height: var(--nav-height);
}

.nav-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.site-logo {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.4rem;
  letter-spacing: 0.05em;
  color: #fff;
  flex-shrink: 0;
}
.site-logo span { color: var(--gold); }
.site-logo:hover { opacity: 1; }

.nav-links {
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.nav-links a {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
  padding: 0.4rem 0.875rem;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.nav-links a:hover { color: var(--text-primary); background: var(--dark-700); opacity: 1; }
.nav-links a.active { color: var(--gold); background: var(--gold-dim); }

/* Mobile nav toggle */
.nav-toggle {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem;
}
.nav-toggle span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text-secondary);
  border-radius: 2px;
  transition: all var(--transition);
}

/* ------------------------------------------------------------
   4. Buttons
   ------------------------------------------------------------ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-family: var(--font-body);
  font-size: 0.875rem;
  font-weight: 600;
  padding: 0.5rem 1.125rem;
  border-radius: var(--radius-sm);
  border: 1.5px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
}
.btn:hover { opacity: 1; }

.btn-primary {
  background: var(--gold);
  color: var(--dark-900);
  border-color: var(--gold);
}
.btn-primary:hover { background: #d4a643; border-color: #d4a643; }

.btn-secondary {
  background: transparent;
  color: var(--text-primary);
  border-color: var(--border);
}
.btn-secondary:hover { border-color: var(--text-muted); background: var(--dark-700); }

/* ------------------------------------------------------------
   5. Profile & distance badges
   ------------------------------------------------------------ */
.profile-badge {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
}

.profile-very-flat  { background: var(--vflat-bg);  color: var(--vflat-text);  border: 1px solid var(--vflat-bdr); }
.profile-flat       { background: var(--flat-bg);   color: var(--flat-text);   border: 1px solid var(--flat-bdr); }
.profile-undulating { background: var(--undul-bg);  color: var(--undul-text);  border: 1px solid var(--undul-bdr); }
.profile-hilly      { background: var(--hilly-bg);  color: var(--hilly-text);  border: 1px solid var(--hilly-bdr); }
.profile-very-hilly { background: var(--vhilly-bg); color: var(--vhilly-text); border: 1px solid var(--vhilly-bdr); }

.badge-net-downhill {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  background: var(--gold-dim);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

.distance-badge {
  display: inline-block;
  font-family: var(--font-head);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 0.2rem 0.6rem;
  border-radius: var(--radius-sm);
  background: var(--dark-900);
  color: var(--gold);
  border: 1px solid var(--gold-border);
}

/* ------------------------------------------------------------
   6. Race detail page
   ------------------------------------------------------------ */

/* Hero — elevation chart */
.race-hero {
  position: relative;
  background: var(--dark-800);
  border-bottom: 1px solid var(--border);
}

.chart-hero-wrap {
  height: clamp(180px, 28vw, 320px);
  width: 100%;
}

.chart-hero-wrap canvas {
  width: 100% !important;
  height: 100% !important;
}

.race-hero--no-chart {
  height: 80px;
  background: var(--dark-800);
}

.hero-overlay {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  pointer-events: none;
}
.hero-overlay > * { pointer-events: auto; }

.hero-overlay--static {
  position: relative;
  height: 100%;
  align-items: center;
}

.back-link {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  background: rgba(11,13,17,0.7);
  padding: 0.3rem 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  backdrop-filter: blur(4px);
  transition: all var(--transition);
}
.back-link:hover { color: var(--text-primary); opacity: 1; }

.hero-badges {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Race container */
.race-container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 2rem 1.5rem 4rem;
}

/* Race header */
.race-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1.5rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.race-header h1 {
  margin-bottom: 0.3rem;
}

.race-location {
  font-size: 1rem;
  color: var(--text-secondary);
  margin: 0;
}

.race-ctas {
  display: flex;
  gap: 0.5rem;
  flex-shrink: 0;
  flex-wrap: wrap;
}

/* Stats bar */
.race-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 0;
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 2rem;
  overflow: hidden;
}

.stat-item {
  flex: 1;
  min-width: 100px;
  padding: 1rem 1.25rem;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.stat-item:last-child { border-right: none; }

.stat-label {
  font-size: 0.7rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-head);
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-primary);
}

/* Body layout — main + aside */
.race-body {
  display: grid;
  grid-template-columns: 1fr 280px;
  gap: 2rem;
  align-items: start;
}

/* Sections */
.race-section {
  margin-bottom: 2.5rem;
}
.race-section:last-child { margin-bottom: 0; }

.race-section h2 {
  font-size: 1.1rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1rem;
}

/* Course map */
.course-map {
  height: 400px;
  border-radius: var(--radius-md);
  overflow: hidden;
  border: 1px solid var(--border);
}

.map-source {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-top: 0.5rem;
}

/* Description */
.race-description {
  color: var(--text-secondary);
  line-height: 1.75;
}

/* Aside */
.race-aside {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.aside-card {
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.aside-card h3 {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.times-table,
.info-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.times-table tr,
.info-table tr {
  border-bottom: 1px solid var(--border);
}
.times-table tr:last-child,
.info-table tr:last-child { border-bottom: none; }

.times-table td,
.info-table td {
  padding: 0.5rem 0;
}

.times-label,
.info-table td:first-child {
  color: var(--text-muted);
  width: 50%;
}

.times-value,
.info-table td:last-child {
  color: var(--text-primary);
  font-weight: 600;
  font-family: var(--font-head);
  font-size: 1rem;
  text-align: right;
}

/* ------------------------------------------------------------
   7. Race cards (index / list pages)
   ------------------------------------------------------------ */
.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.race-card {
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  transition: border-color var(--transition), transform var(--transition);
  text-decoration: none;
  display: flex;
  flex-direction: column;
}
.race-card:hover {
  border-color: var(--border-hover);
  transform: translateY(-2px);
  opacity: 1;
}

.card-top {
  padding: 1rem 1rem 0.5rem;
  flex: 1;
}

.card-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.625rem;
}

.card-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: var(--text-primary);
  line-height: 1.3;
  margin-bottom: 0.2rem;
}

.card-location {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 0.625rem;
}

.card-sparkline {
  height: 36px;
  width: 100%;
}

.card-bottom {
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-date {
  font-size: 0.75rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.card-ascent {
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* ------------------------------------------------------------
   8. List view table
   ------------------------------------------------------------ */
.race-list-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.race-list-table thead tr {
  background: var(--dark-800);
}

.race-list-table th {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  padding: 0.625rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

.race-list-table td {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: middle;
}

.race-list-table tbody tr {
  transition: background var(--transition);
  cursor: pointer;
}
.race-list-table tbody tr:hover { background: var(--dark-700); }
.race-list-table tbody tr:last-child td { border-bottom: none; }

.race-list-table .td-name {
  font-weight: 500;
  color: var(--text-primary);
}

/* ------------------------------------------------------------
   9. Page sections / containers
   ------------------------------------------------------------ */
.page-container {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 1.5rem;
}

.page-section {
  padding: 2rem 0;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 0.75rem;
}

.section-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.2rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-primary);
}

.section-count {
  font-size: 0.8rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------
   10. Hero / homepage
   ------------------------------------------------------------ */
.site-hero {
  background: var(--dark-800);
  padding: 3rem 1.5rem 2.5rem;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.hero-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--gold);
  margin-bottom: 0.875rem;
}
.hero-tag::before {
  content: '';
  display: block;
  width: 20px;
  height: 2px;
  background: var(--gold);
  border-radius: 1px;
}

.hero-title {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: clamp(2.4rem, 6vw, 4rem);
  line-height: 1.0;
  color: #fff;
  margin-bottom: 0.625rem;
}
.hero-title em { font-style: normal; color: var(--gold); }

.hero-sub {
  font-size: 0.95rem;
  color: var(--text-muted);
  max-width: 480px;
  line-height: 1.65;
  margin-bottom: 1.75rem;
}

/* Stats bar */
.stats-bar {
  display: flex;
  background: var(--dark-900);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
}

.stats-bar-item {
  flex: 1;
  text-align: center;
  padding: 1rem 0.5rem;
  border-right: 1px solid var(--border);
}
.stats-bar-item:last-child { border-right: none; }

.stats-bar-num {
  display: block;
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.6rem;
  color: var(--gold);
  line-height: 1;
  margin-bottom: 0.2rem;
}

.stats-bar-label {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
}

/* ------------------------------------------------------------
   11. Filters
   ------------------------------------------------------------ */
.filters-wrap {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  align-items: center;
}

.filter-select {
  background: var(--dark-700);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.5rem 1.75rem 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  outline: none;
  appearance: none;
  -webkit-appearance: none;
  color-scheme: light;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23999' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.625rem center;
  transition: border-color var(--transition);
}
.filter-select:hover, .filter-select:focus { border-color: var(--gold); }

.filter-search {
  background: var(--dark-700);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.8rem;
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-sm);
  outline: none;
  width: 180px;
  transition: border-color var(--transition), width var(--transition);
  -webkit-appearance: none;
  appearance: none;
  color-scheme: light;
}
.filter-search::placeholder { color: var(--text-muted); }
.filter-search:focus { border-color: var(--gold); width: 220px; }
.filter-search:-webkit-autofill,
.filter-search:-webkit-autofill:hover,
.filter-search:-webkit-autofill:focus {
  -webkit-box-shadow: 0 0 0 1000px #131720 inset;
  -webkit-text-fill-color: var(--text-primary);
  caret-color: var(--text-primary);
}

@media (max-width: 600px) {
  .filters-wrap { flex-direction: column; align-items: stretch; }
  .filter-search { width: 100%; box-sizing: border-box; background: var(--dark-700); }
  .filter-search:focus { width: 100%; }
  .filter-select { width: 100%; box-sizing: border-box; }
  .filter-btn-reset { text-align: left; padding: 0.5rem 0; }
  .site-hero { padding-left: 1rem; padding-right: 1rem; }
  .hero-inner { padding: 0; }
}

.filter-btn-reset {
  font-size: 0.8rem;
  color: var(--text-muted);
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.5rem 0.25rem;
  transition: color var(--transition);
}
.filter-btn-reset:hover { color: var(--text-primary); }
.filter-btn-near {
  font-size: 0.8rem;
  color: var(--gold);
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  padding: 0.45rem 0.875rem;
  font-family: var(--font-body);
  font-weight: 600;
  transition: background var(--transition), color var(--transition);
  white-space: nowrap;
}
.filter-btn-near:hover { background: rgba(232,184,75,0.2); }
.filter-btn-near.active { background: var(--gold); color: var(--dark-900); }

/* ------------------------------------------------------------
   12. Map view
   ------------------------------------------------------------ */
.map-view {
  height: calc(100vh - var(--nav-height));
  position: relative;
}

#mainMap {
  width: 100%;
  height: 100%;
}

.map-sidebar {
  position: absolute;
  top: 0;
  left: 0;
  width: 340px;
  height: 100%;
  background: var(--dark-800);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  z-index: 10;
  display: flex;
  flex-direction: column;
}

.map-sidebar-header {
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.map-sidebar-races {
  flex: 1;
  overflow-y: auto;
  padding: 0.75rem;
}

.map-race-item {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding: 0.75rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  margin-bottom: 0.5rem;
  cursor: pointer;
  transition: all var(--transition);
  text-decoration: none;
}
.map-race-item:hover {
  border-color: var(--border-hover);
  background: var(--dark-700);
  opacity: 1;
}

.map-race-name {
  font-weight: 600;
  font-size: 0.875rem;
  color: var(--text-primary);
}

.map-race-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
  display: flex;
  gap: 0.75rem;
}

/* ------------------------------------------------------------
   13. Tab bar
   ------------------------------------------------------------ */
.tab-bar {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--border);
  background: var(--dark-800);
}

.tab-btn {
  font-family: var(--font-body);
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.75rem 1.25rem;
  color: var(--text-muted);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
  margin-bottom: -1px;
}
.tab-btn:hover { color: var(--text-primary); }
.tab-btn.active { color: var(--gold); border-bottom-color: var(--gold); }

/* ------------------------------------------------------------
   14. Footer
   ------------------------------------------------------------ */
.site-footer {
  background: var(--dark-800);
  border-top: 1px solid var(--border);
  padding-top: 3rem;
  margin-top: 4rem;
}

.footer-inner {
  max-width: var(--container-wide);
  margin: 0 auto;
  padding: 0 1.5rem 2.5rem;
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 3rem;
}

.footer-logo {
  font-family: var(--font-head);
  font-weight: 800;
  font-size: 1.3rem;
  letter-spacing: 0.05em;
  color: #fff;
  margin-bottom: 0.75rem;
}
.footer-logo span { color: var(--gold); }

.footer-about {
  font-size: 0.825rem;
  color: var(--text-muted);
  line-height: 1.65;
  margin-bottom: 0.75rem;
}

.footer-notice {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.6;
  border-left: 2px solid var(--gold-border);
  padding-left: 0.75rem;
}

.footer-col h4 {
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.875rem;
}

.footer-col ul li {
  margin-bottom: 0.5rem;
}

.footer-col ul a {
  font-size: 0.825rem;
  color: var(--text-secondary);
  transition: color var(--transition);
}
.footer-col ul a:hover { color: var(--text-primary); opacity: 1; }

.footer-bottom {
  border-top: 1px solid var(--border);
  padding: 1rem 1.5rem;
  text-align: center;
}
.footer-bottom p {
  font-size: 0.75rem;
  color: var(--text-muted);
  margin: 0;
}

/* ------------------------------------------------------------
   15. Utility
   ------------------------------------------------------------ */
.visually-hidden {
  position: absolute;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden;
  clip: rect(0,0,0,0);
  border: 0;
}

.page-stub {
  max-width: var(--container);
  margin: 4rem auto;
  padding: 0 1.5rem;
  color: var(--text-secondary);
}

/* ------------------------------------------------------------
   16. Responsive
   ------------------------------------------------------------ */
@media (max-width: 900px) {
  .race-body {
    grid-template-columns: 1fr;
  }
  .race-aside {
    order: -1;
  }
  .footer-inner {
    grid-template-columns: 1fr 1fr;
  }
  .footer-col:first-child {
    grid-column: 1 / -1;
  }
  .map-sidebar {
    width: 100%;
    height: auto;
    max-height: 40vh;
    position: relative;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .map-view {
    display: flex;
    flex-direction: column;
    height: auto;
  }
  #mainMap {
    height: 55vw;
    min-height: 280px;
  }
}

@media (max-width: 680px) {
  .nav-links {
    display: none;
    position: absolute;
    top: var(--nav-height);
    left: 0;
    right: 0;
    background: var(--dark-900);
    border-bottom: 1px solid var(--border);
    flex-direction: column;
    padding: 0.75rem 1rem;
    gap: 0.125rem;
  }
  .nav-links.open { display: flex; }
  .nav-links a {
    padding: 0.625rem 0.875rem;
    width: 100%;
  }
  .nav-toggle { display: flex; }

  .race-stats {
    flex-wrap: wrap;
  }
  .stat-item {
    flex: 1 0 45%;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
  .stat-item:nth-child(odd) {
    border-right: 1px solid var(--border);
  }

  .race-header {
    flex-direction: column;
  }
  .race-ctas {
    width: 100%;
  }
  .btn {
    flex: 1;
    justify-content: center;
  }

  .footer-inner {
    grid-template-columns: 1fr;
    gap: 2rem;
  }

  .race-grid {
    grid-template-columns: 1fr 1fr;
  }

  .hero-title {
    font-size: 2.2rem;
  }

  .stats-bar {
    flex-wrap: wrap;
  }
  .stats-bar-item {
    flex: 1 0 50%;
    border-bottom: 1px solid var(--border);
  }
}

@media (max-width: 400px) {
  .race-grid {
    grid-template-columns: 1fr;
  }
}

/* ------------------------------------------------------------
   Breadcrumbs
   ------------------------------------------------------------ */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.25rem;
  font-size: 0.75rem;
  color: var(--text-muted);
  margin-bottom: 1.25rem;
}
.breadcrumbs a {
  color: var(--text-muted);
  transition: color var(--transition);
}
.breadcrumbs a:hover { color: var(--gold); opacity: 1; }
.breadcrumbs span { color: var(--text-muted); }
.breadcrumb-current { color: var(--text-secondary); }

/* ------------------------------------------------------------
   Related races
   ------------------------------------------------------------ */
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 0.75rem;
}

.related-card {
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  text-decoration: none;
  display: block;
  transition: border-color var(--transition), transform var(--transition);
}
.related-card:hover { border-color: var(--border-hover); transform: translateY(-1px); opacity: 1; }

.related-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.375rem;
}
.related-name {
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--text-primary);
  line-height: 1.3;
}
.related-meta {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* ------------------------------------------------------------
   County link (aside)
   ------------------------------------------------------------ */
.aside-county-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--gold-dim);
  border: 1px solid var(--gold-border);
  border-radius: var(--radius-md);
  padding: 0.875rem 1rem;
  text-decoration: none;
  transition: background var(--transition);
  font-size: 0.825rem;
  font-weight: 600;
  color: var(--gold);
}
.aside-county-link:hover { background: rgba(232,184,75,0.18); opacity: 1; }
.county-count { font-size: 0.75rem; font-weight: 500; opacity: 0.8; }

@media (max-width: 680px) {
  .related-grid { grid-template-columns: 1fr 1fr; }
  .breadcrumbs { font-size: 0.7rem; }
}

/* ------------------------------------------------------------
   Related races carousel
   ------------------------------------------------------------ */
.related-section { overflow: hidden; }

.related-carousel-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 -0.5rem;
}

.related-carousel {
  display: flex;
  gap: 0.75rem;
  overflow-x: auto;
  scroll-snap-type: x mandatory;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  padding: 0.25rem 0.5rem 0.75rem;
  flex: 1;
}
.related-carousel::-webkit-scrollbar { display: none; }

.carousel-btn {
  flex-shrink: 0;
  width: 32px; height: 32px;
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: 50%;
  color: var(--text-secondary);
  font-size: 1.2rem;
  line-height: 1;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
  z-index: 2;
}
.carousel-btn:hover { border-color: var(--gold-border); color: var(--gold); }

.related-card {
  flex: 0 0 220px;
  scroll-snap-align: start;
  background: var(--dark-700);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  transition: border-color var(--transition), transform var(--transition);
}
.related-card:hover { border-color: var(--border-hover); transform: translateY(-2px); opacity: 1; }

.related-sparkline-wrap {
  height: 56px;
  background: var(--dark-800);
  overflow: hidden;
}
.related-sparkline-wrap svg { width: 100%; height: 100%; }
.related-no-map {
  display: flex; align-items: center; justify-content: center;
  height: 100%; font-size: 0.7rem; color: var(--text-muted);
  letter-spacing: 0.06em;
}

.related-card-body { padding: 0.75rem 0.875rem 0.5rem; flex: 1; }
.related-card-meta { display: flex; align-items: center; gap: 0.375rem; margin-bottom: 0.4rem; flex-wrap: wrap; }
.related-name { font-weight: 600; font-size: 0.825rem; color: var(--text-primary); line-height: 1.3; margin-bottom: 0.2rem; }
.related-location { font-size: 0.7rem; color: var(--text-muted); }

.related-card-footer {
  padding: 0.5rem 0.875rem 0.75rem;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
}
.related-date { font-size: 0.72rem; color: var(--text-secondary); font-weight: 500; }
.related-ascent { font-size: 0.72rem; color: var(--text-muted); }

@media (max-width: 600px) {
  .related-card { flex: 0 0 180px; }
  .carousel-btn { width: 28px; height: 28px; font-size: 1rem; }
}

/* ============================================================
   Form / content page styles
   ============================================================ */
.content-page { max-width: 760px; margin: 0 auto; padding: 2.5rem 1.5rem 4rem; }
.content-page h1 { font-family: var(--font-head); font-size: clamp(1.8rem,4vw,2.6rem); font-weight: 800; color: var(--text-primary); margin-bottom: 0.375rem; }
.content-page h2 { font-family: var(--font-head); font-size: 1.25rem; font-weight: 700; color: var(--text-primary); margin: 2rem 0 0.75rem; }
.content-page h3 { font-size: 1rem; font-weight: 700; color: var(--text-primary); margin: 1.5rem 0 0.5rem; }
.content-page p { color: var(--text-secondary); line-height: 1.75; margin-bottom: 1rem; font-size: 0.925rem; }
.content-page ul { color: var(--text-secondary); line-height: 1.75; margin: 0 0 1rem 1.25rem; font-size: 0.925rem; }
.content-page li { margin-bottom: 0.375rem; }
.content-page strong { color: var(--text-primary); }
.content-page hr { border: none; border-top: 1px solid var(--border); margin: 2rem 0; }

.form-box { background: var(--dark-800); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 2rem; }
.form-group { display: flex; flex-direction: column; gap: 0.375rem; margin-bottom: 1rem; }
.form-group label { font-size: 0.75rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted); }
.form-group input,
.form-group select,
.form-group textarea { background: var(--dark-700); border: 1px solid var(--border); color: var(--text-primary); font-family: var(--font-body); font-size: 0.875rem; padding: 0.625rem 0.875rem; border-radius: var(--radius-sm); outline: none; width: 100%; box-sizing: border-box; transition: border-color var(--transition); color-scheme: light; }
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--gold); }
.form-group input::placeholder,
.form-group textarea::placeholder { color: var(--text-muted); }
.form-group select { appearance: none; -webkit-appearance: none; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M1 1l4 4 4-4' stroke='%23888' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; padding-right: 2rem; }
.form-group textarea { resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
@media (max-width: 560px) { .form-row { grid-template-columns: 1fr; } }
.btn-submit { width: 100%; background: var(--gold); color: var(--dark-900); font-family: var(--font-body); font-size: 0.875rem; font-weight: 800; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.875rem; border: none; border-radius: var(--radius-sm); cursor: pointer; transition: opacity var(--transition), transform var(--transition); margin-top: 0.5rem; }
.btn-submit:hover { opacity: 0.9; transform: translateY(-1px); }
.form-note { font-size: 0.78rem; color: var(--text-muted); line-height: 1.6; margin-bottom: 1.5rem; }

.info-box { background: var(--dark-700); border: 1px solid var(--border); border-radius: var(--radius-md); padding: 1.25rem 1.5rem; margin: 1.5rem 0; }
.info-box p { margin: 0; font-size: 0.875rem; }

.page-breadcrumb { font-size: 0.78rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.page-breadcrumb a { color: var(--text-muted); }
.page-breadcrumb a:hover { color: var(--gold); }
