/* ==========================================================
   Ride scrollytelling pages (rides/<slug>.html).
   Full-viewport fixed map; chapter cards float over it (left on
   desktop, bottom sheet on mobile); a fixed elevation strip runs
   along the bottom. Uses the shared design tokens from styles.css.
   All motion is gated behind prefers-reduced-motion.
   ========================================================== */

:root {
  --elev-h: 82px;          /* fixed elevation strip height (desktop) */
  --card-border: rgba(245, 240, 232, 0.14);
}

/* body scrolls normally; the map is fixed so it stays put behind the chapters.
   (horizontal overflow is already clipped by the base body rule in styles.css) */
.ride-page .site-nav {
  background: linear-gradient(rgba(11, 22, 38, 0.9), rgba(11, 22, 38, 0));
}

/* ---------- 3D elevation-ribbon hero (js/ride-ribbon.js) ----------
   In normal flow above the fixed map, so it scrolls away naturally;
   solid night background hides the map until the hand-off. */
#ride-hero {
  position: relative;
  z-index: 6; /* above the fixed status overlay (5) and elevation strip (3) */
  height: 100vh;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  background: var(--night);
  border-bottom: 1px solid var(--card-border);
}
#ride-hero canvas,
.ride-hero-still {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.ride-hero-content {
  position: relative;
  z-index: 1;
  padding: 0 24px;
}
.ride-hero-content h1 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(38px, 7vw, 66px);
  letter-spacing: 0.005em;
  margin-top: 14px;
}
.ride-hero-content .ride-cue { margin-top: 26px; }

/* ---------- Fixed map background ---------- */
#ride-map {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: var(--night);
}
/* keep MapLibre attribution clear of the elevation strip */
#ride-map .maplibregl-ctrl-bottom-right { bottom: var(--elev-h); }
#ride-map .maplibregl-ctrl-attrib {
  background: rgba(11, 22, 38, 0.6);
  font-size: 10px;
}
#ride-map .maplibregl-ctrl-attrib a { color: var(--cream-muted); }

/* ---------- Scroller + chapters ---------- */
.ride-scroll {
  position: relative;
  z-index: 1;
  /* leave room so the last card clears the elevation strip */
  padding-bottom: var(--elev-h);
}
.ride-chapter {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  padding: 12vh 5vw calc(var(--elev-h) + 6vh);
  pointer-events: none;                    /* let map show through gaps */
}
.ride-chapter.is-bookend { justify-content: center; text-align: left; }

/* ---------- Chapter card ---------- */
.ride-card {
  pointer-events: auto;
  width: min(384px, 86vw);
  background: rgba(9, 18, 32, 0.82);
  -webkit-backdrop-filter: blur(9px);
  backdrop-filter: blur(9px);
  border: 1px solid var(--card-border);
  padding: 26px 28px 28px;
  opacity: 0.28;
  transition: opacity 0.5s ease, border-color 0.5s ease;
}
.ride-chapter.is-active .ride-card {
  opacity: 1;
  border-color: rgba(217, 164, 65, 0.4);
}
.ride-card .eyebrow { margin-bottom: 12px; }
.ride-card h2 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(28px, 4vw, 40px);
  line-height: 1.08;
  letter-spacing: 0.005em;
}
.ride-card h3 {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: clamp(20px, 3vw, 27px);
  line-height: 1.12;
}
.ride-card .route-arrow { color: rgba(217, 164, 65, 0.9); font-style: normal; }
.ride-card p.note {
  font-weight: 300;
  font-size: 14px;
  line-height: 1.7;
  color: var(--cream-muted);
  margin-top: 14px;
}

/* stat rows */
.ride-stats {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1px;
  margin-top: 20px;
  background: var(--card-border);           /* becomes the 1px grid lines */
  border: 1px solid var(--card-border);
}
.ride-stat {
  background: rgba(9, 18, 32, 0.6);
  padding: 12px 14px;
}
.ride-stat .k {
  display: block;
  font-size: 10px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cream-muted);
}
.ride-stat .v {
  display: block;
  margin-top: 6px;
  font-family: 'Fraunces', serif;
  font-weight: 600;
  font-size: 21px;
  color: var(--cream);
}
.ride-stat .v .u {
  font-family: 'Inter', sans-serif;
  font-weight: 300;
  font-size: 12px;
  letter-spacing: 0.06em;
  color: var(--cream-muted);
  margin-left: 3px;
}

/* inline chapter photos */
.ride-photos {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 18px;
}
.ride-photo-thumb {
  width: 76px;
  height: 56px;
  padding: 0;
  border: 1px solid var(--card-border);
  background: none;
  cursor: pointer;
  overflow: hidden;
}
.ride-photo-thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  display: block;
  transition: opacity 0.3s ease;
}
.ride-photo-thumb:hover img { opacity: 0.8; }
.ride-photo-thumb:focus-visible { outline: 2px solid var(--cream); outline-offset: 3px; }

.ride-scroll .colophon { padding: 0 5vw 40px; }

/* ---------- Photo markers on the map ---------- */
/* Positioned by MapLibre via inline transform on every animation frame —
   no transition/transform of its own, or the marker lags behind the live
   camera (see js/ride-scrolly.js addPhotoMarkers). Purely a hit target;
   the visible dot is the child .ride-photo-marker-dot below. */
.ride-photo-marker {
  width: 14px; height: 14px;
  cursor: pointer;
}
.ride-photo-marker-dot {
  width: 100%; height: 100%;
  border-radius: 50%;
  background: rgba(217, 164, 65, 0.28);
  border: 1.5px solid var(--amber);
  box-shadow: 0 0 0 3px rgba(11, 22, 38, 0.55);
  transition: transform 0.2s ease, background 0.2s ease;
}
.ride-photo-marker:focus-visible {
  outline: none;
}
.ride-photo-marker:hover .ride-photo-marker-dot,
.ride-photo-marker:focus-visible .ride-photo-marker-dot {
  transform: scale(1.35);
  background: var(--amber);
}

/* ---------- Fixed elevation strip ---------- */
#ride-elev {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: 3;
  height: var(--elev-h);
  background: linear-gradient(rgba(11, 22, 38, 0), rgba(8, 15, 27, 0.86) 34%);
  border-top: 1px solid var(--card-border);
  pointer-events: none;
}
.ride-elev-svg {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
}
.elev-line { fill: none; stroke: rgba(245, 240, 232, 0.22); stroke-width: 1.2; vector-effect: non-scaling-stroke; }
.elev-fill { fill: rgba(217, 164, 65, 0.16); stroke: none; }
.elev-progress-line { fill: none; stroke: var(--amber); stroke-width: 1.6; vector-effect: non-scaling-stroke; }
/* current-position needle + readout (DOM, positioned by % so it ignores SVG stretch) */
.ride-elev-needle {
  position: absolute;
  top: 0; bottom: 0;
  width: 1px;
  background: rgba(217, 164, 65, 0.75);
  transform: translateX(-0.5px);
}
.ride-elev-dot {
  position: absolute;
  width: 9px; height: 9px;
  margin: -4.5px 0 0 -4.5px;
  border-radius: 50%;
  background: var(--amber);
  box-shadow: 0 0 0 3px rgba(11, 22, 38, 0.6);
}
.ride-elev-read {
  position: absolute;
  top: 8px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-size: 10px;
  letter-spacing: 0.12em;
  color: var(--cream);
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.7);
}
.ride-elev-read .u { color: var(--cream-muted); }
.ride-elev-label {
  position: absolute;
  bottom: 6px; left: 12px;
  font-size: 9px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: rgba(245, 240, 232, 0.4);
}

/* ---------- Scroll cue on the opening card ---------- */
.ride-cue {
  margin-top: 22px;
  font-size: 10px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cream-muted);
}

/* ---------- Loading / error ---------- */
.ride-status {
  position: fixed;
  inset: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  font-size: 12px;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--cream-muted);
}

/* ---------- Mobile: bottom sheet ---------- */
@media (max-width: 768px) {
  :root { --elev-h: 62px; }
  .ride-chapter {
    align-items: flex-end;
    justify-content: center;
    padding: 0 0 calc(var(--elev-h) + 14px);
  }
  .ride-chapter.is-bookend { align-items: flex-end; }
  .ride-card {
    width: 100%;
    max-height: 46vh;
    overflow-y: auto;
    padding: 18px 20px 20px;
    border-left: 0; border-right: 0; border-bottom: 0;
    background: rgba(9, 18, 32, 0.9);
  }
  .ride-stats { grid-template-columns: repeat(2, 1fr); }
  .ride-scroll .colophon { display: none; }
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  .ride-card { transition: none; }
}
