/*
  Ride: the map is the page. A live dark map fills the first screen and draws a real route
  (Rock Store to Leo Carrillo) with the turn card and the ride readout the app shows. The
  body reads as the route sheet: every section is a turn with its distance, and a mile rail
  down the side fills as you scroll. A static map sits under the live one as the fallback.
*/

/* ---------- Map hero ---------- */

.rmap { position: relative; isolation: isolate; overflow: hidden; min-height: max(700px, 100svh); display: grid; grid-template-rows: 1fr auto; }
.rmap__stage { position: absolute; inset: 0; z-index: -2; background: #1a1a1a; }
.rmap__static, .rmap__live { position: absolute; inset: 0; width: 100%; height: 100%; }
.rmap__static { object-fit: cover; object-position: 70% 50%; }
.rmap__live { opacity: 0; transition: opacity 700ms ease; }
.rmap__live.is-ready { opacity: 1; }
.rmap__live .mapboxgl-ctrl-bottom-right { bottom: auto; top: 76px; }
/* Dark fade so the headline reads over the map (an approved exception) */
.rmap::before { content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(90deg, rgba(12,16,20,0.94) 0%, rgba(12,16,20,0.78) 34%, rgba(12,16,20,0) 62%); }
.rmap::after { content: ""; position: absolute; inset: auto 0 0 0; height: 260px; z-index: -1; pointer-events: none;
  background: linear-gradient(0deg, rgba(12,16,20,0.96), rgba(12,16,20,0)); }

.rmap__grid { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; padding-top: clamp(130px, 17vh, 220px); gap: 40px; }
.rroute { display: flex; align-items: center; gap: 14px; margin: 0 0 clamp(20px, 2vw, 32px); font: 700 clamp(14px, 0.9vw, 17px)/1 var(--mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--legend-dim); }
.rroute__shield { display: inline-grid; place-items: center; width: 40px; height: 44px; border-radius: 6px 6px 20px 20px; box-shadow: inset 0 0 0 2px var(--legend); font: 900 20px/1 var(--font); color: var(--legend); letter-spacing: 0; }
.rmap h1 { font-size: clamp(3rem, 6.4vw, 9rem); font-weight: 900; letter-spacing: -0.04em; line-height: 0.92; max-width: 9ch; }
.rmap__lede { font-size: clamp(1.15rem, 1.25vw, 1.6rem); line-height: 1.55; color: #dcdee2; max-width: 34rem; margin: clamp(22px, 2vw, 34px) 0 clamp(26px, 2.4vw, 40px); }

/* Turn card: the app's next-turn banner */
.rturn { display: flex; align-items: center; gap: 18px; padding: 18px 26px 18px 20px; min-width: 330px; background: rgba(12,16,20,0.9); border-radius: 18px; box-shadow: inset 0 0 0 1px var(--shoulder); }
.rturn__icon { width: 52px; height: 52px; color: var(--signal); flex: none; }
.rturn b { display: block; font-size: clamp(2rem, 2.4vw, 3rem); font-weight: 700; line-height: 1; color: var(--legend); }
.rturn span { display: block; margin-top: 6px; font-size: clamp(1rem, 1vw, 1.25rem); font-weight: 700; color: var(--legend-dim); }

/* Ride readout along the bottom of the map */
.rhud { position: relative; padding: 0 0 clamp(26px, 3vh, 44px); }
.rhud__row { display: grid; grid-template-columns: auto repeat(3, minmax(0, max-content)) minmax(0, 1fr); align-items: end; gap: 0 clamp(28px, 3.4vw, 80px); border-top: 1px solid rgba(244,243,238,0.22); padding-top: 22px; }
.rhud__row > div { display: flex; flex-direction: column; }
.rhud b { font-size: clamp(1.5rem, 2.2vw, 3rem); font-weight: 700; line-height: 1; color: var(--legend); }
.rhud span { margin-top: 8px; font: 700 13px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--legend-mute); }
.rhud__speed { flex-direction: row !important; align-items: baseline; gap: 12px; }
.rhud__speed b { font-size: clamp(4.6rem, 8vw, 11rem); font-weight: 700; letter-spacing: -0.05em; line-height: 0.8; }
.rhud__speed span { color: var(--signal); font-size: 15px; }
.rhud__note { margin: 0; justify-self: end; text-align: right; max-width: 24rem; font: 600 14px/1.45 var(--mono); color: var(--legend-mute); }

/* ---------- Route sheet ---------- */

.rsheet { padding: clamp(80px, 8vw, 160px) 0 clamp(60px, 6vw, 120px); }
.rsheet__grid { display: grid; grid-template-columns: clamp(76px, 6vw, 120px) minmax(0, 1fr); gap: 0 clamp(24px, 3vw, 72px); }

/* Mile rail: fills as you read down the route */
.rrail { position: sticky; top: 96px; height: calc(100vh - 140px); max-height: 1100px; display: grid; grid-template-rows: auto 1fr; justify-items: center; }
.rrail__now { margin: 0 0 18px; text-align: center; line-height: 1; }
.rrail__now b { display: block; font-size: clamp(1.4rem, 1.6vw, 2.1rem); color: var(--signal); }
.rrail__now span { font: 700 12px/1 var(--mono); letter-spacing: 0.12em; color: var(--legend-mute); }
.rrail__track { grid-row: 2; grid-column: 1; width: 4px; height: 100%; background: var(--asphalt-3); border-radius: 2px; position: relative; overflow: hidden; }
.rrail__fill { position: absolute; inset: 0 0 auto 0; height: calc(var(--p, 0) * 100%); background: var(--signal); }
.rrail__marks { grid-row: 2; grid-column: 1; list-style: none; margin: 0; padding: 0; position: relative; width: 100%; height: 100%; }
.rrail__marks li { position: absolute; left: 50%; top: calc(var(--at) * 100%); transform: translate(-50%, -50%); }
.rrail__marks span { display: block; min-width: 50px; padding: 5px 6px 4px; text-align: center; font-size: 13px; font-weight: 700; color: var(--legend-mute); background: var(--asphalt); border-radius: 6px; box-shadow: inset 0 0 0 1.5px var(--shoulder); transition: color 200ms ease, box-shadow 200ms ease; }
.rrail__marks li.is-past span { color: var(--legend); box-shadow: inset 0 0 0 1.5px var(--legend-dim); }
.rrail__marks li.is-now span { color: var(--signal); box-shadow: inset 0 0 0 2px var(--signal); }

.rsteps { list-style: none; margin: 0; padding: 0; }
.rstep { display: grid; grid-template-columns: clamp(190px, 14vw, 300px) minmax(0, 40rem) minmax(0, 1fr); gap: 32px clamp(32px, 3.6vw, 100px); align-items: start; padding: clamp(56px, 5.4vw, 110px) 0; border-top: 1px solid var(--asphalt-3); }
.rstep:first-child { border-top: 0; padding-top: 0; }
.rstep__turn { position: sticky; top: 104px; }
.rstep__turn svg { display: block; width: clamp(48px, 3.6vw, 72px); height: clamp(48px, 3.6vw, 72px); color: var(--signal); margin-bottom: 18px; }
.rstep__turn b { display: block; font-size: clamp(2rem, 2.8vw, 3.8rem); font-weight: 700; line-height: 1; letter-spacing: -0.03em; }
.rstep__turn span { display: block; margin-top: 10px; font-size: clamp(1rem, 1vw, 1.2rem); font-weight: 700; line-height: 1.35; color: var(--legend-mute); max-width: 15rem; }
.rstep h2 { font-size: clamp(2rem, 3vw, 4.2rem); font-weight: 900; letter-spacing: -0.03em; line-height: 1; margin-bottom: clamp(18px, 1.5vw, 26px); }
.rstep p { font-size: clamp(1.1rem, 1.05vw, 1.4rem); line-height: 1.62; color: var(--legend-dim); margin: 0; }

.rstep__media { display: flex; flex-wrap: wrap; gap: clamp(24px, 2.4vw, 56px); align-items: flex-start; }
.rstep__media .phone { --pw: clamp(190px, 13vw, 330px); }
.rstep--wide .rstep__media { display: grid; grid-template-columns: minmax(0, 1fr) auto; }
.rstep--wide .rphoto { grid-column: 1 / -1; }

.rphoto { margin: 0; flex: 1 1 340px; max-width: 900px; }
.rphoto img { width: 100%; height: auto; aspect-ratio: 16 / 10; object-fit: cover; border-radius: 14px; }

/* Hairline readout rows beside the screens */
.rlist { list-style: none; margin: 0; padding: 0; flex: 1 1 220px; max-width: 440px; }
.rlist li { display: flex; flex-direction: column; gap: 4px; padding: 16px 0; border-top: 1px solid var(--shoulder); }
.rlist li:last-child { border-bottom: 1px solid var(--shoulder); }
.rlist b { font-size: clamp(1.05rem, 1vw, 1.3rem); font-weight: 800; color: var(--legend); }
.rlist span { font: 600 14px/1.3 var(--mono); color: var(--legend-mute); }
.rlist li:first-child b { color: var(--signal); }
.rlist--roles li:first-child b { color: var(--legend); }

/* Ride Detection prompt, drawn as the app asks it */
.rprompt { flex: 1 1 300px; max-width: 460px; padding: clamp(26px, 2.4vw, 40px); border-radius: 22px; background: var(--asphalt-2); box-shadow: inset 0 0 0 1px var(--shoulder); }
.rprompt__k { margin: 0 0 10px !important; font: 700 13px/1 var(--mono) !important; letter-spacing: 0.1em; text-transform: uppercase; color: var(--legend-mute) !important; }
.rprompt__q { margin: 0 0 28px !important; font-size: clamp(1.6rem, 2vw, 2.4rem) !important; font-weight: 900; line-height: 1.05 !important; color: var(--legend) !important; letter-spacing: -0.02em; }
.rprompt__btns { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.rprompt__btns span { display: grid; place-items: center; min-height: 52px; border-radius: 12px; font-weight: 800; font-size: 17px; box-shadow: inset 0 0 0 2px var(--shoulder); color: var(--legend-dim); }
.rprompt__btns span:first-child { box-shadow: inset 0 0 0 2px var(--signal); color: var(--signal); }

/* Navigation readout */
.rread { margin: 0; flex: 1 1 220px; max-width: 420px; display: grid; gap: 0; }
.rread div { padding: 18px 0; border-top: 1px solid var(--shoulder); display: flex; justify-content: space-between; align-items: baseline; gap: 20px; }
.rread div:last-child { border-bottom: 1px solid var(--shoulder); }
.rread dt { font: 700 13px/1 var(--mono); letter-spacing: 0.1em; text-transform: uppercase; color: var(--legend-mute); }
.rread dd { margin: 0; font-size: clamp(2rem, 2.6vw, 3.4rem); font-weight: 700; line-height: 1; }
.rread div:nth-child(2) dd { color: var(--legend); }
.rread div:last-child dd { color: var(--signal); }

/* Hazard types */
.rhaz { list-style: none; margin: 0; padding: 0; flex: 1 1 240px; max-width: 460px; display: grid; grid-template-columns: 1fr 1fr; gap: 0 24px; }
.rhaz li { display: flex; align-items: baseline; gap: 14px; padding: 16px 0; border-top: 1px solid var(--shoulder); font-weight: 800; font-size: clamp(1.05rem, 1vw, 1.3rem); }
.rhaz b { font-size: 14px; color: var(--signal); }

/* ---------- Responsive ---------- */

@media (max-width: 1500px) {
  .rstep { grid-template-columns: clamp(170px, 14vw, 240px) minmax(0, 1fr); }
  .rstep__media { grid-column: 2; }
}

@media (max-width: 900px) {
  .rmap { display: flex; flex-direction: column; min-height: 0; }
  .rmap__stage { position: relative; inset: auto; height: 50svh; min-height: 380px; }
  .rmap::before { display: none; }
  .rmap::after { top: calc(max(50svh, 380px) - 200px); bottom: auto; height: 200px; }
  .rmap__grid { display: contents; }
  .rturn { position: absolute; top: 84px; left: 16px; min-width: 0; padding: 14px 20px 14px 16px; }
  .rturn__icon { width: 40px; height: 40px; }
  .rhud { order: 1; margin-top: -96px; }
  .rhud__row { grid-template-columns: auto repeat(3, minmax(0, 1fr)); gap: 0 16px; }
  .rhud__note { grid-column: 1 / -1; justify-self: start; text-align: left; margin-top: 18px; }
  .rmap__copy { order: 2; width: min(var(--fp-max), 100% - 2 * var(--fp-gutter)); margin: 36px auto 8px; }
  .rsheet__grid { grid-template-columns: minmax(0, 1fr); }
  .rrail { display: none; }
  .rstep { grid-template-columns: minmax(0, 1fr); gap: 24px; }
  .rstep__turn { position: static; display: grid; grid-template-columns: auto 1fr; gap: 0 16px; align-items: center; }
  .rstep__turn svg { grid-row: span 2; margin: 0; width: 44px; height: 44px; }
  .rstep__turn span { margin-top: 4px; max-width: none; }
  .rstep__media { grid-column: auto; }
  .rstep__media .phone { --pw: min(44vw, 220px); }
  .rstep--wide .rstep__media { grid-template-columns: auto minmax(0, 1fr); }
}

@media (max-width: 600px) {
  .rhud__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .rhud__speed { grid-column: 1 / -1; margin-bottom: 14px; }
  .rhud b { font-size: 1.35rem; }
  .rhud .rhud__speed b { font-size: 4rem; }
  .rhud__note { font-size: 12px; margin-top: 14px; }
  .rstep__media .phone { --pw: min(46vw, 200px); }
  .rlist, .rread, .rhaz { flex-basis: 100%; }
  .rstep--wide .rstep__media { display: flex; }
}
