/* Pulsroute onboarding intro: a full-screen overlay that intro.js adds on a first
   visit. Tokens only (theme.css). Without JavaScript none of this renders and the
   page stays as it is; html.intro-pending only hides the page until the overlay
   is mounted, and a timer in the head script lifts it if the overlay never comes. */

.intro-pending body { visibility: hidden; }
.intro-pending .intro-overlay { visibility: visible; }
.intro-open { overflow: hidden; }

.intro-overlay {
  --intro-pad: clamp(20px, 4vw, 48px);
  position: fixed; inset: 0; z-index: 2000;
  display: grid; grid-template-rows: auto minmax(0, 1fr) auto;
  height: 100vh; height: 100dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--bg); color: var(--ink); font-family: var(--font-body);
  transition: opacity 220ms var(--ease-out);
}
.intro-overlay:focus { outline: none; }
.intro-overlay.is-leaving { opacity: 0; }

/* ── Top bar: logo, step counter, Skip (always there) ── */
.intro-top {
  display: flex; align-items: center; gap: 16px;
  padding: 12px var(--intro-pad); border-bottom: 1px solid var(--line-strong);
}
.intro-brand { display: flex; align-items: center; margin-right: auto; }
.intro-brand .brand-logo { height: 34px; width: auto; display: block; }
.intro-count { white-space: nowrap; font-family: var(--font-mono); font-size: var(--fs-micro); color: var(--muted); letter-spacing: 0.08em; }
.intro-skip { min-height: 44px; }
@media (max-width: 479px) { .intro-count { display: none; } }

/* ── Slide: scene band edge to edge on phones, beside the copy from 960px ── */
.intro-slide { display: grid; grid-template-rows: minmax(250px, 46vh) auto; min-height: 0; }
.intro-slide[hidden] { display: none; }
.intro-stage {
  position: relative; overflow: hidden; background: var(--ink-field); color: var(--on-ink);
  display: grid; place-items: center; padding: 16px var(--intro-pad);
}
.intro-copy { display: grid; align-content: start; gap: 14px; padding: 24px var(--intro-pad) 20px; max-width: 40rem; }
.intro-eyebrow { margin: 0; font-family: var(--font-mono); font-size: var(--fs-micro); font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--accent-text); }
.intro-eyebrow::before { content: ""; display: inline-block; width: 12px; height: 12px; margin-right: 10px; vertical-align: -1px; border-radius: 50%; background: var(--accent-fill); box-shadow: 0 0 0 2px var(--disc-ring); }
.intro-title { margin: 0; font-family: var(--font-display); font-weight: var(--w-display); font-size: clamp(2.4rem, 1.7rem + 3.4vw, 4.6rem); line-height: 0.98; letter-spacing: var(--tr-h2); text-wrap: balance; }
.intro-text { margin: 0; font-size: clamp(1.05rem, 1rem + 0.3vw, 1.25rem); line-height: 1.5; color: var(--muted-strong); max-width: 36ch; }
@media (min-width: 960px) {
  .intro-slide { grid-template-rows: none; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); }
  .intro-copy { order: -1; align-content: center; padding-block: 48px; padding-right: clamp(24px, 4vw, 64px); }
  .intro-stage { padding: 48px; }
}

/* ── Foot: progress dots on a line, Next ── */
.intro-foot {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  padding: 12px var(--intro-pad) max(16px, env(safe-area-inset-bottom)); border-top: 1px solid var(--line-strong); background: var(--bg);
}
.intro-dots { position: relative; display: flex; gap: 6px; margin: 0; padding: 0; list-style: none; }
.intro-dots::before { content: ""; position: absolute; left: 22px; right: 22px; top: 50%; height: 4px; margin-top: -2px; background: var(--line-strong); }
.intro-dots button {
  position: relative; width: 44px; height: 44px; display: grid; place-items: center;
  border: 0; padding: 0; background: transparent; cursor: pointer; color: inherit;
}
.intro-dots button::before {
  content: ""; width: 14px; height: 14px; border-radius: 50%;
  background: var(--surface-2); box-shadow: inset 0 0 0 3px var(--line-strong);
  transition: transform 200ms var(--ease-out), background 200ms var(--ease-out);
}
.intro-dots button.is-past::before { background: var(--accent); box-shadow: none; }
.intro-dots button[aria-current="step"]::before { width: 22px; height: 22px; background: var(--accent-fill); box-shadow: 0 0 0 3px var(--disc-ring); }
.intro-next { min-width: 9.5rem; }

/* ── Copy enters with each step ── */
.intro-slide.is-playing .intro-copy > * { animation: introUp 420ms var(--ease-out) both; }
.intro-slide.is-playing .intro-copy > :nth-child(2) { animation-delay: 60ms; }
.intro-slide.is-playing .intro-copy > :nth-child(3) { animation-delay: 120ms; }
@keyframes introUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
@keyframes introPop { 0% { opacity: 0; transform: scale(0.4); } 70% { opacity: 1; transform: scale(1.08); } 100% { opacity: 1; transform: none; } }
@keyframes introFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes introDraw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes introSlideIn { from { opacity: 0; transform: translateY(-12px); } to { opacity: 1; transform: none; } }

/* ── Shared scene parts (SVG) ── */
.sc { width: 100%; height: 100%; max-width: 640px; max-height: 100%; display: block; overflow: visible; }
.sc-street { fill: none; stroke: color-mix(in srgb, var(--on-ink) 13%, transparent); stroke-width: 12; stroke-linecap: square; }
.sc-lane { fill: none; stroke: color-mix(in srgb, var(--on-ink) 9%, transparent); stroke-width: 5; }
.sc-park { fill: color-mix(in srgb, var(--accent-fill) 10%, transparent); }
.sc-casing { fill: none; stroke: var(--ink-field); stroke-width: 10; stroke-linecap: round; stroke-linejoin: round; }
.sc-route { fill: none; stroke: var(--accent-fill); stroke-width: 5; stroke-linecap: round; stroke-linejoin: round; stroke-dasharray: 1; stroke-dashoffset: 0; }
.sc-route-ghost { fill: none; stroke: color-mix(in srgb, var(--on-ink) 35%, transparent); stroke-width: 3; stroke-dasharray: 6 7; stroke-linecap: round; stroke-linejoin: round; }
.sc-home { fill: var(--on-ink); }
.sc-home-ring { fill: none; stroke: var(--accent-fill); stroke-width: 3; }
.sc-person { fill: var(--ink-field); }
.sc-tag { font-family: var(--font-mono); font-size: 11px; font-weight: 600; fill: var(--on-ink-muted); }
.sc-stop { fill: var(--accent-fill); stroke: var(--ink-field); stroke-width: 3; }
.sc-stop-no { font-family: var(--font-mono); font-size: 12px; font-weight: 700; fill: var(--accent-on-fill); text-anchor: middle; dominant-baseline: central; }
.sc-centre { fill: var(--ink-field); stroke: var(--accent-fill); stroke-width: 3; }
.sc-cross { fill: var(--accent-fill); }
.sc-van-box { fill: var(--signal); stroke: var(--on-ink); stroke-width: 2.5; }
.sc-van .van-body { fill: var(--on-ink); }
.sc-van .van-glass { fill: var(--signal); }
.sc-van .van-wheel { fill: var(--ink-field); stroke: var(--on-ink); stroke-width: 1.2; }

/* Scene 1: homes appear, rides draw to the centre, vans follow */
.is-playing .sc1-home { animation: introPop 480ms var(--ease-out) both; transform-box: fill-box; transform-origin: center; }
.is-playing .sc1-home:nth-of-type(2) { animation-delay: 160ms; }
.is-playing .sc1-home:nth-of-type(3) { animation-delay: 320ms; }
.is-playing .sc1-home:nth-of-type(4) { animation-delay: 480ms; }
.is-playing .sc1-centre { animation: introPop 520ms var(--ease-out) 640ms both; transform-box: fill-box; transform-origin: center; }
.is-playing .sc1-ride { animation: introDraw 900ms var(--ease-out) both; }
.is-playing .sc1-ride:nth-of-type(1) { animation-delay: 900ms; }
.is-playing .sc1-ride:nth-of-type(2) { animation-delay: 1050ms; }
.is-playing .sc1-ride:nth-of-type(3) { animation-delay: 1200ms; }
.is-playing .sc1-ride:nth-of-type(4) { animation-delay: 1350ms; }

/* Scene 2: a booking from the app lands on the centre dashboard and is confirmed */
.sc2 { position: relative; width: min(100%, 560px); height: min(100%, 360px); }
.sc2-dash {
  position: absolute; top: 0; right: 0; width: 82%;
  background: var(--surface); color: var(--ink); box-shadow: 0 0 0 2px var(--ink);
  font-size: 12px; line-height: 1.3;
}
.sc2-bar { display: flex; gap: 5px; align-items: center; padding: 7px 10px; background: var(--ink); color: var(--bg); }
.sc2-bar i { width: 7px; height: 7px; border-radius: 50%; background: color-mix(in srgb, var(--bg) 45%, transparent); }
.sc2-bar em { margin-left: 6px; font-style: normal; font-family: var(--font-mono); font-size: 10px; opacity: 0.85; }
.sc2-head { padding: 10px 12px 6px; display: grid; gap: 2px; }
.sc2-label { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }
.sc2-h { font-family: var(--font-display); font-weight: 700; font-size: 20px; line-height: 1; }
.sc2-rows { margin: 0; padding: 0 12px 10px; list-style: none; }
.sc2-rows li { display: grid; grid-template-columns: 3.4em minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 4px; border-top: 1px solid var(--line); }
.sc2-rows .mono { font-family: var(--font-mono); }
.sc2-chip { display: inline-grid; justify-items: end; font-weight: 700; font-size: 11px; }
.sc2-chip > span { grid-area: 1 / 1; padding: 2px 7px; }
.sc2-ok { background: var(--ok-soft); color: var(--ok); }
.sc2-wait { background: var(--warn-soft); color: var(--warn); opacity: 0; }
.sc2-new { background: var(--accent-soft); }
.sc2-phone {
  position: absolute; left: 0; bottom: 0; width: 58%; min-width: 190px;
  background: var(--bg); color: var(--ink); box-shadow: 0 0 0 2px var(--ink), 8px 8px 0 0 color-mix(in srgb, var(--ink) 30%, transparent);
  padding: 12px; display: grid; gap: 8px; font-size: 12px; line-height: 1.3;
}
.sc2-phone .sc2-h { font-size: 18px; }
.sc2-fields { display: grid; grid-template-columns: minmax(0, 1.3fr) minmax(0, 1fr); gap: 10px; }
.sc2-field { display: grid; gap: 1px; padding-bottom: 6px; border-bottom: 1px solid var(--line); }
.sc2-btn { display: block; padding: 8px 10px; text-align: center; font-weight: 700; background: var(--accent-fill); color: var(--accent-on-fill); box-shadow: inset 0 0 0 2px var(--button-edge); }
.sc2-toast { display: flex; gap: 6px; align-items: center; font-weight: 700; color: var(--ok); }
.sc2-toast::before { content: ""; width: 12px; height: 7px; margin-top: -3px; border-left: 2.5px solid currentColor; border-bottom: 2.5px solid currentColor; transform: rotate(-45deg); }
.is-playing .sc2-phone { animation: introUp 500ms var(--ease-out) 100ms both; }
.is-playing .sc2-btn { animation: introPress 360ms var(--ease-out) 1000ms both; }
.is-playing .sc2-new { animation: introSlideIn 420ms var(--ease-out) 1450ms both, introFlash 900ms var(--ease-out) 2600ms both; }
.is-playing .sc2-wait { animation: introHold 1300ms linear 1450ms both; }
.is-playing .sc2-new .sc2-ok { animation: introPop 420ms var(--ease-out) 2700ms both; }
.is-playing .sc2-toast { animation: introUp 400ms var(--ease-out) 3000ms both; }
@keyframes introPress { 0% { transform: none; } 45% { transform: scale(0.94); background: var(--accent-fill-hover); } 100% { transform: none; } }
@keyframes introHold { 0% { opacity: 1; } 92% { opacity: 1; } 100% { opacity: 0; } }
@keyframes introFlash { from { background: var(--accent-fill); } to { background: var(--accent-soft); } }

/* Scene 3: the van drives the route (intro.js moves it), the run draws behind it */
.sc3-eta {
  position: absolute; top: 16px; left: var(--intro-pad); z-index: 1;
  display: flex; align-items: center; gap: 8px; padding: 6px 10px;
  background: var(--bg); color: var(--ink); box-shadow: 0 0 0 2px var(--ink);
  font-family: var(--font-mono); font-size: 12px; font-weight: 700;
}
.sc3-eta::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--signal); }
.is-playing .sc3-eta { animation: introFade 400ms var(--ease-out) 200ms both; }
.is-playing .sc3-stop { animation: introPop 420ms var(--ease-out) both; transform-box: fill-box; transform-origin: center; }

@media (min-width: 1300px) { .sc2 { width: min(100%, 520px); height: min(100%, 360px); zoom: 1.25; } }

@media (prefers-reduced-motion: reduce) {
  .intro-overlay, .intro-overlay *, .intro-overlay *::before { animation: none !important; transition: none !important; }
  .sc2-wait { opacity: 0; }
}
@media print { .intro-overlay { display: none !important; } .intro-open { overflow: visible; } .intro-pending body { visibility: visible; } }
