/* The ride: a vertical line with four stops. With no script, or under
   reduced motion, the line is full, every stop is lit and the bus sits at
   the last stop. ride.js adds html.ride-live (not under reduced motion):
   then the bus follows the scroll, the mint fill grows behind it and each
   dot lights as the bus passes. Where scroll timelines exist the browser
   drives it; elsewhere ride.js sets --p (0 to 1) on .ride-wrap and
   toggles .lit on the legs (html.ride-poll). Only transform, opacity and
   filter ever animate. */

.ride {
  --deep: #0B1230; --rail: #3A456B; --rline: rgba(238, 243, 255, .14);
  background: var(--night); color: var(--ink);
  border-radius: 0;
  padding: 0 var(--gut) 96px;
}
.ride-in { max-width: 980px; margin: 0 auto; }
.ride h2 {
  font: 900 clamp(28px, 7vw, 52px)/1.02 var(--display); letter-spacing: -.03em;
  margin-top: 12px; max-width: 14em;
}

.ride-wrap { --p: 1; position: relative; padding-left: 62px; margin-top: 40px; }

/* Rail, fill and bus: decorative. */
.ride-rail { position: absolute; left: 0; top: 0; bottom: 0; width: 48px; pointer-events: none; }
.ride-line, .ride-fill { position: absolute; left: 22px; top: 0; width: 6px; border-radius: 3px; }
.ride-line { bottom: 0; background: var(--rail); opacity: .6; }
.ride-fill {
  bottom: 13px; background: var(--mint); box-shadow: 0 0 18px rgba(77, 242, 180, .5);
  transform-origin: top; transform: scaleY(var(--p));
}
/* The mover is one bus shorter than the rail, so moving it by its own
   height (100%) takes the bus from the top stop to the bottom one. */
.ride-mover {
  position: absolute; left: 2px; top: 0; width: 46px; height: calc(100% - 26px); z-index: 2;
  transform: translateY(calc(var(--p) * 100%));
}
.ride-bus { display: block; }

.leg { position: relative; padding-block: 24px; }
.vdot {
  position: absolute; left: -50px; top: 44px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--night); border: 5px solid var(--rail); box-sizing: border-box;
}
.vdot-on {
  position: absolute; inset: -5px; border-radius: 50%; background: var(--mint);
  box-shadow: 0 0 14px rgba(77, 242, 180, .55);
}

.panel {
  background: var(--deep); border: 1px solid var(--rline); border-radius: 22px;
  padding: 22px 20px; display: grid; gap: 16px;
}
.panel h3 { font: 800 clamp(20px, 5vw, 28px)/1.08 var(--display); }
.panel p { margin-top: 12px; color: var(--muted); font-size: 17px; line-height: 1.5; font-weight: 600; max-width: 44ch; }
@media (min-width: 760px) {
  .panel { grid-template-columns: 1fr auto; align-items: center; padding: 28px; gap: 28px; }
}

/* 1. Arrivals row */
.mini {
  background: var(--night); border: 1px solid var(--rline); border-radius: 16px;
  padding: 12px 14px; min-width: min(250px, 100%); box-sizing: border-box;
  display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 14px;
  font: 700 14px/1.3 var(--body);
}
.mini small { display: block; margin-top: 2px; font: 700 12px/1.3 var(--body); letter-spacing: .04em; color: var(--muted); }
.mini-min { margin-left: auto; font: 900 24px/1 var(--display); color: var(--mint); white-space: nowrap; }

/* 2. Notification */
.notif {
  background: rgba(238, 243, 255, .94); color: var(--night); border-radius: 16px;
  padding: 10px 14px; min-width: min(250px, 100%); box-sizing: border-box;
  display: flex; gap: 10px; align-items: center; font: 700 14px/1.3 var(--body);
}
.notif svg { flex: none; }
.notif b { display: block; font-weight: 800; }
.notif-line { font-weight: 600; }

/* 3. Ticket */
.tick {
  position: relative; background: var(--yellow); color: var(--night); border-radius: 14px;
  padding: 12px 22px; min-width: min(250px, 100%); box-sizing: border-box;
  display: flex; justify-content: space-between; gap: 14px; font: 800 13px/1.3 var(--body);
}
.tick::before, .tick::after {
  content: ""; position: absolute; top: 50%; width: 16px; height: 16px; margin-top: -8px;
  border-radius: 50%; background: var(--deep);
}
.tick::before { left: -8px; }
.tick::after { right: -8px; }
.tick b { display: block; font: 900 16px/1.2 var(--display); }
.tick-go { text-align: right; }

/* 4. Moon */
.moon { display: flex; align-items: center; gap: 12px; font: 800 15px/1.3 var(--body); }
.moon svg { flex: none; }
.moon b { display: block; font: 900 20px/1.2 var(--display); color: var(--mint); }

/* Live: unlit until the bus passes. */
.ride-live .vdot-on { opacity: 0; transform: scale(.4); }
.ride-live .leg.lit .vdot-on { opacity: 1; transform: none; transition: opacity .3s ease, transform .3s ease; }

/* Loops: the notification drops in, the ticket wobbles, the moon bobs. */
.notif { animation: ride-drop 3.6s cubic-bezier(.2, .9, .3, 1.2) infinite; }
.tick { animation: ride-wobble 4s ease-in-out infinite alternate; }
.moon svg { animation: ride-bob 3s ease-in-out infinite; }
@keyframes ride-drop {
  0% { transform: translateY(-16px) scale(.97); }
  14%, 85% { transform: none; }
  100% { transform: translateY(-6px) scale(.99); }
}
@keyframes ride-wobble { from { transform: rotate(-1.4deg); } to { transform: rotate(1.4deg); } }
@keyframes ride-bob { 50% { transform: translateY(-5px) rotate(-6deg); } }

/* Scroll timelines: the bus rides a line 60% down the viewport. The wrapper
   progresses 0 to 1 while that line crosses it; each dot lights as that line
   crosses the dot itself. */
@supports (animation-timeline: view()) {
  .ride-wrap { view-timeline: --ride block; }
  .vdot { view-timeline: --dot block; }
  .ride-live:not(.ride-poll) .ride-mover {
    animation: ride-bus linear both; animation-timeline: --ride;
    animation-range: cover 40vh cover calc(100% - 60vh);
  }
  .ride-live:not(.ride-poll) .ride-fill {
    animation: ride-fill linear both; animation-timeline: --ride;
    animation-range: cover 40vh cover calc(100% - 60vh);
  }
  .ride-live:not(.ride-poll) .vdot-on {
    animation: ride-dot linear both; animation-timeline: --dot;
    animation-range: cover 40vh cover calc(40vh + 24px);
  }
}
@keyframes ride-bus { from { transform: translateY(0); } to { transform: translateY(100%); } }
@keyframes ride-fill { from { transform: scaleY(0); } to { transform: scaleY(1); } }
@keyframes ride-dot { from { opacity: 0; transform: scale(.4); } to { opacity: 1; transform: none; } }

/* Reduced motion: the full line, every stop lit, nothing moves. */
@media (prefers-reduced-motion: reduce) {
  .notif, .tick, .moon svg,
  .ride-live:not(.ride-poll) .ride-mover, .ride-live:not(.ride-poll) .ride-fill,
  .ride-live:not(.ride-poll) .vdot-on { animation: none; }
  .ride-live .ride-wrap { --p: 1; }
  .ride-live .vdot-on, .ride-live .leg.lit .vdot-on { opacity: 1; transform: none; transition: none; }
}
