/* Soonu landing page: the line and the city scene. A stop per city, a bus
   touring the live ones, and the scene, bus card and caption of the city
   it is at (line.js). Without JavaScript every stop shows and the first
   city is current. Only transform and opacity animate. */

/* ---------- 3. The line ---------- */
.line { background: var(--night); color: var(--ink); }
.line-in { max-width: 1360px; margin: 0 auto; padding: 44px var(--gut) 36px; }
.line-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 8px 16px;
}
.line-hint { color: var(--muted); font-size: 15px; }

/* The only scroll box on the page, and it holds no reveal. It runs to the
   band's edges, so the bus drives in from behind them; the top padding is
   room for the bus and the bubble. */
.line-scroll {
  margin: 0 calc(var(--gut) * -1); padding: 78px var(--gut) 10px;
  overflow-x: auto; overscroll-behavior-x: contain; scrollbar-width: thin;
}
/* More stops than fit: fade both edges to show the line goes on. The fades
   cover only the gutters, so the first and last stops are never dimmed. */
.line-scroll.is-scrolly {
  -webkit-mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
  mask-image: linear-gradient(90deg, transparent, #000 var(--gut), #000 calc(100% - var(--gut)), transparent);
}

/* Stops spread evenly; each gets at least 56 px, past that the box scrolls.
   --stops and --live are in the markup and kept by line.js. Stop centres
   sit at (i + .5) / --stops, so the rails need no measuring. */
.line-track { position: relative; width: 100%; min-width: calc(var(--stops) * 56px); }
.rail, .rail-live { position: absolute; top: 13px; height: 6px; border-radius: 3px; }
.rail {
  left: calc(50% / var(--stops)); right: calc(50% / var(--stops));
  background: repeating-linear-gradient(90deg, rgba(238, 243, 255, .3) 0 12px, transparent 12px 20px);
}
.rail-live {
  left: calc(50% / var(--stops)); width: calc((var(--live) - 1) * 100% / var(--stops));
  background: var(--mint); box-shadow: 0 0 18px rgba(77, 242, 180, .55);
  transform-origin: left center;
}

.stops { position: relative; z-index: 1; display: flex; margin: 0; padding: 0; list-style: none; }
.stops > li { flex: 1 1 0; min-width: 0; display: flex; justify-content: center; }
.stop {
  display: flex; flex-direction: column; align-items: center; width: 100%;
  min-height: 44px; padding: 0 0 4px; border: 0; border-radius: 12px;
  background: none; color: var(--ink); font: inherit; text-align: center;
  text-decoration: none; cursor: pointer;
}
.stop-next { cursor: default; }
.dot {
  position: relative; width: 32px; height: 32px; margin-bottom: 10px;
  border: 5px solid var(--mint); border-radius: 50%; background: var(--night);
  transition: transform .3s;
}
.stop-live:hover .dot, .stop-ask:hover .dot { transform: scale(1.12); }
.stop-live[aria-pressed="true"] .dot { background: var(--mint); }
/* The current stop pulses: a ring behind the dot grows and fades. */
.stop-live .dot::after {
  content: ""; position: absolute; inset: -5px; z-index: -1;
  border-radius: 50%; background: var(--mint); opacity: 0;
}
.stop-live[aria-pressed="true"] .dot::after { animation: line-ping 1.8s ease-out infinite; }
@keyframes line-ping { from { opacity: .55; transform: scale(1); } to { opacity: 0; transform: scale(1.9); } }
.stop-next .dot { border-color: rgba(238, 243, 255, .3); border-style: dashed; }
.stop-ask .dot { border-color: var(--yellow); border-style: dashed; }

/* On phones the labels shrink and wrap rather than overflow: a long name
   hyphenates ("Edmon-ton"), and breaks anywhere where it can't. */
.stop b {
  display: block; max-width: 100%;
  font: 700 clamp(10px, 2.6vw, 15px)/1.15 var(--display); letter-spacing: -.01em;
  -webkit-hyphens: auto; hyphens: auto; overflow-wrap: anywhere;
}
/* "Edmonton" is 66 px wide at 10 px, wider than a stop's 56-64 px on the
   narrowest phones: tighten the letters and, under 360 px, shave the label
   to 9.5 px and the band's side padding (the box is full-bleed, so only the
   stops move) so the name sits whole on one line. */
@media (max-width: 399px) { .stop b { letter-spacing: -.04em; } }
@media (max-width: 359px) {
  .line-scroll { padding-left: 8px; padding-right: 8px; }
  .stop b { font-size: 9.5px; }
}
.stop small { display: block; margin-top: 3px; font-size: 12px; line-height: 1.2; color: var(--muted); }
.stop-live small { color: var(--mint); }
.stop-next b { color: #9AA3C2; }
.stop-ask b, .stop-ask small { color: var(--yellow); }

/* The bus starts at the first stop; line.js moves it with transform. */
.bus {
  position: absolute; top: -16px; left: calc(50% / var(--stops) - 23px); z-index: 2;
  width: 46px; height: 26px; pointer-events: none; transition: opacity .4s;
}
.bus.is-ghost { opacity: .55; }
.bus-face, .bus-body { display: block; width: 100%; height: 100%; }

/* "Next stop: yours?" over the last stop. */
.bubble {
  position: absolute; top: -66px; left: calc(100% - 50% / var(--stops)); z-index: 3;
  padding: 7px 12px; border-radius: 12px; background: var(--yellow); color: var(--night);
  font: 800 13px/1.2 var(--body); white-space: nowrap; pointer-events: none;
  opacity: 0; transform: translate(-88%, 6px) scale(.9); transform-origin: 88% 100%;
  transition: opacity .3s, transform .3s;
}
.bubble::after {
  content: ""; position: absolute; right: calc(12% - 6px); bottom: -6px;
  border: 6px solid transparent; border-top-color: var(--yellow); border-bottom: 0;
}
.bubble.is-shown { opacity: 1; transform: translate(-88%, 0); }

/* Before the intro (line.js, motion allowed) the parts wait out of sight. */
.line.is-pre .stop, .line.is-pre .rail-live, .line.is-pre .bus { opacity: 0; }

/* ---------- 4. The city scene ---------- */
/* One .city per live city, stacked; only the current one is shown (the
   others are hidden). Each holds four depth layers, sky, far, middle and
   street, which line.js slides by their depth when the city changes; it
   never moves an .ed-par layer, whose scroll parallax would fight it.
   .ed-layer, .ed-svg and .ed-par-* are every city's layer classes (named
   for the first). The bus card and caption are shared and sit on top. */
.scene {
  position: relative; display: flex; flex-direction: column; min-height: 780px;
  background: var(--night); color: #FFFFFF;
  border-radius: 0 0 56px 56px; overflow: clip; isolation: isolate;
}
.city, .depth { position: absolute; inset: 0; }
.city { pointer-events: none; }
/* The incoming city, over the outgoing one while they swap. */
.city.is-in { z-index: 1; }
.scene-top, .scene-foot { position: relative; z-index: 2; }

.ed-layer { position: absolute; inset: 0; pointer-events: none; }
.ed-par-sky { inset: -40px 0 0 0; }
.ed-svg { position: absolute; inset: 0; width: 100%; height: 100%; }

/* The bus card, top right. line.js flips its stop and route over, and
   counts the minutes down to "Now". */
.scene-top {
  display: flex; justify-content: flex-end; width: 100%; max-width: 1360px;
  margin: 0 auto; padding: 32px var(--gut) 0;
}
.bus-card {
  width: 236px; padding: 14px 16px 16px; border-radius: 22px;
  background: var(--yellow); color: var(--night);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .5); transform-origin: 50% 0;
}
.bus-card p { display: flex; align-items: center; gap: 8px; }
.bc-top { justify-content: space-between; font: 800 11px/1.3 var(--body); letter-spacing: .08em; }
.bc-live { flex: none; display: inline-flex; align-items: center; gap: 5px; }
.bc-dot {
  width: 8px; height: 8px; border-radius: 50%; background: #0A7A4F;
  animation: bc-ping 1.4s ease-in-out infinite;
}
.bc-route { margin-top: 10px; font: 800 16px/1.2 var(--display); }
.bc-num { padding: 1px 8px; border: 3px solid var(--night); border-radius: 9px; }
.bc-mid { margin-top: 8px; }
.bc-min { font: 900 44px/1 var(--display); letter-spacing: -.03em; }
.bc-unit { font: 800 14px var(--body); }
.bc-stop, .bc-num, .bc-to, .bc-min { display: inline-block; backface-visibility: hidden; }
.bc-to { white-space: nowrap; }
@keyframes bc-ping { 50% { opacity: .25; } }

/* The caption, bottom left, always over the dark fade. On wide screens the
   fade gives way to the right of the text, so the street shows there. */
.scene-foot { margin-top: auto; padding: 160px var(--gut) 72px; }
.scene-foot::before {
  content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
  background: linear-gradient(rgba(5, 10, 26, 0), rgba(5, 10, 26, .9) 150px);
  -webkit-mask-image: linear-gradient(90deg, #000 calc(max(var(--gut), 50% - 640px) + 760px), transparent calc(max(var(--gut), 50% - 640px) + 1160px));
  mask-image: linear-gradient(90deg, #000 calc(max(var(--gut), 50% - 640px) + 760px), transparent calc(max(var(--gut), 50% - 640px) + 1160px));
}
.scene-copy {
  max-width: 680px; margin-left: max(0px, (100% - 1280px) / 2);
  display: flex; flex-direction: column; gap: 22px;
}
.scene-copy h2 { font: 900 clamp(40px, 4.8vw, 72px)/1 var(--display); letter-spacing: -.04em; }
.scene-line { font-size: 20px; line-height: 1.5; color: var(--muted); max-width: 36ch; }
/* The re-typed headline: words never break, letters rise in one by one. */
.scene-wd { display: inline-block; white-space: nowrap; }
.scene-ch { display: inline-block; animation: scene-type .45s cubic-bezier(.2, .8, .2, 1) both; }
@keyframes scene-type { from { opacity: 0; transform: translateY(.3em); } }

@media (max-width: 720px) {
  .scene { min-height: 640px; border-radius: 0 0 36px 36px; }
  .scene-top { padding-top: 20px; }
  .bus-card { width: 216px; }
  .bc-route { font-size: 14px; }
  .scene-foot { padding: 120px var(--gut) 48px; }
  .scene-line { font-size: 17px; }
}

/* Edmonton: northern lights, stars, the skyline with its windows, the
   river valley and bridge with a bus, and the seasons (snow, fireflies). */
.ed-au-a { transform-box: fill-box; transform-origin: 50% 50%; animation: ed-au 12s ease-in-out infinite alternate; }
.ed-au-b { transform-box: fill-box; transform-origin: 50% 50%; animation: ed-au 9s -4s ease-in-out infinite alternate-reverse; }
.ed-star { animation: ed-tw 3.4s ease-in-out infinite; }
.ed-win { animation: ed-win 9s steps(1) infinite; }
.ed-beacon { animation: ed-tw 1.4s ease-in-out infinite; }
.ed-bus { animation: ed-bus 16s linear infinite; }
.ed-shim { animation: ed-shim 3s ease-in-out infinite; }
.ed-snow-a { animation: ed-snow 16s linear infinite; }
.ed-snow-b { animation: ed-snow 9s linear infinite; }
.ed-winter { animation: ed-season 20s ease-in-out infinite; }
.ed-summer { opacity: 0; animation: ed-season 20s -10s ease-in-out infinite; }
.ed-fly { animation: ed-fly 5s ease-in-out infinite; }
.ed-par-sky { animation: ed-par-sky linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }
.ed-par-city { animation: ed-par-city linear both; animation-timeline: view(); animation-range: entry 0% exit 100%; }

@keyframes ed-au { 0% { transform: translateX(-50px) scaleY(.85); opacity: .7; } 50% { opacity: 1; } 100% { transform: translateX(50px) scaleY(1.15); opacity: .8; } }
@keyframes ed-tw { 0%, 100% { opacity: .25; } 50% { opacity: 1; } }
@keyframes ed-win { 0%, 60% { opacity: .85; } 61%, 100% { opacity: .1; } }
@keyframes ed-bus { from { transform: translateX(-220px); } to { transform: translateX(1500px); } }
@keyframes ed-shim { 0%, 100% { opacity: .1; transform: translateX(0); } 50% { opacity: .6; transform: translateX(10px); } }
@keyframes ed-snow { from { transform: translate(0, 0); } to { transform: translate(-30px, 640px); } }
@keyframes ed-par-sky { from { transform: translateY(-50px); } to { transform: translateY(50px); } }
@keyframes ed-par-city { from { transform: translateY(-20px); } to { transform: translateY(20px); } }
@keyframes ed-season { 0%, 40% { opacity: 1; } 50%, 90% { opacity: 0; } 100% { opacity: 1; } }
@keyframes ed-fly { 0%, 100% { opacity: .15; transform: translate(0, 0); } 50% { opacity: 1; transform: translate(12px, -14px); } }

/* Calgary: a sunset under a drifting chinook arch, the Rockies, the
   skyline with its observation tower and blinking light, the Bow River,
   and a red light-rail train and a bus on the street. */
.yyc-arch { animation: yyc-drift 18s ease-in-out infinite alternate; }
.yyc-lens { animation: yyc-drift 13s -5s ease-in-out infinite alternate-reverse; }
.yyc-beacon { animation: yyc-blink 1.6s steps(1) infinite; }
.yyc-win { animation: ed-win 9s steps(1) infinite; }
.yyc-shim { animation: ed-shim 3s ease-in-out infinite; }
.yyc-train { animation: yyc-train 20s linear infinite; }
.yyc-bus { animation: ed-bus 15s -6s linear infinite; }
@keyframes yyc-drift { from { transform: translateX(-40px); } to { transform: translateX(40px); } }
@keyframes yyc-blink { 0%, 49% { opacity: 1; } 50%, 100% { opacity: .15; } }
/* Right to left across the street, then a wait before the next one. */
@keyframes yyc-train { 0% { transform: translateX(1500px); } 55%, 100% { transform: translateX(-420px); } }

/* No scroll timelines: the layers simply sit still. */
@supports not (animation-timeline: view()) {
  .ed-par-sky, .ed-par-city { animation: none; }
}

/* ---------- Reduced motion: no pulse; the bus never moves on its own ---------- */
/* The scene holds still; a city change cross-fades and the card and
   caption change in place (line.js). */
@media (prefers-reduced-motion: reduce) {
  .stop-live[aria-pressed="true"] .dot::after { animation: none; }
  .dot, .bus, .bubble { transition: none; }
  .ed-au-a, .ed-au-b, .ed-star, .ed-win, .ed-beacon, .ed-bus, .ed-shim, .ed-snow-a, .ed-snow-b,
  .ed-par-sky, .ed-par-city, .ed-winter, .ed-summer, .ed-fly,
  .yyc-arch, .yyc-lens, .yyc-beacon, .yyc-win, .yyc-shim, .yyc-train, .yyc-bus,
  .bc-dot, .scene-ch {
    animation: none;
  }
  .ed-summer { opacity: 0; }
}
