/* App tours (/rink-run, /edgebook): the device holds still while the story scrolls past it. */

.tour { position: relative; }
.tour-grid { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); grid-template-rows: auto 1fr; grid-template-areas: "intro stage" "chapters stage"; column-gap: clamp(32px, 5vw, 80px); }
.tour-grid:has(.phone) { grid-template-columns: minmax(0, 6fr) minmax(0, 5fr); }

/* The stage: sticky for the whole story */
.tour-stage {
  grid-area: stage; align-self: start;
  position: sticky; top: 0; height: 100svh;
  display: grid; place-items: center; padding-top: 64px;
}
.device { position: relative; }
.tour-stage .browser { width: min(100%, calc((100svh - 104px - 38px) * 1.6)); } /* never taller than the screen: 16:10 shot + 38px bar */
.tour-stage .phone { font-size: min(12px, calc((100svh - 120px) / 74)); }
/* Big monitors: a wider stage, so the screenshots grow with the room they have */
@media (min-width: 1600px) {
  .tour-page { --max: 1600px; } /* the whole page widens together: header, tour, strip, footer */
  .tour-grid { grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); }
}
.tour-page .screen > img {
  /* The outgoing screen stays fully visible under the incoming one and only hides once that has
     faded in, so the crossfade never dips through the dark background (and swapping a screen for
     the same image doesn't flicker at all). */
  opacity: 0; filter: blur(3px); transform: none;
  transition: opacity 0s linear 240ms, filter 0s linear 240ms;
}
.tour-page .screen > img.is-on { opacity: 1; filter: blur(0); z-index: 1; transition: opacity 240ms ease, filter 240ms ease; }
.browser-bar .url [data-url] { color: var(--muted); }

/* Replay frames sit exactly over the chart card of the replay screenshot */
/* Overlays sit above the screenshots (the visible one is lifted to z-index 1 for the crossfade) */
.replay, .clock, .notif { z-index: 2; }
.replay { position: absolute; left: 17.222%; top: 23.111%; width: 80.556%; height: 74.667%; pointer-events: none; }
.screen .replay img { width: 100%; height: 100%; opacity: 1; filter: none; transform: none; transition: none; }

/* Saturday clock: a line walking down Rink Run's day timeline */
.clock { position: absolute; inset: 0; pointer-events: none; }
.clock-line {
  position: absolute; left: 19%; right: 8.2%; top: 0;
  height: 0.28em; margin-top: -0.14em; border-radius: 1em;
  background: var(--pink);
  box-shadow: 0 0 1.2em color-mix(in srgb, var(--pink) 80%, transparent);
}
.clock-line::before { content: ""; position: absolute; left: -0.5em; top: 50%; width: 1em; height: 1em; margin-top: -0.5em; border-radius: 50%; background: var(--pink); }
.clock-line b {
  position: absolute; right: 0; bottom: 0.7em;
  padding: 0.35em 0.7em; border-radius: 0.8em;
  background: var(--pink); color: var(--pink-ink);
  font: 500 1.25em/1 var(--mono); font-variant-numeric: tabular-nums;
}

/* A notification banner dropping onto the phone */
.notif {
  position: absolute; left: 1.1em; right: 1.1em; top: 1.1em;
  display: flex; gap: 1.1em; align-items: flex-start;
  padding: 1.2em 1.3em; border-radius: 2.2em;
  background: rgb(46 44 52 / 0.86); color: #f6f5f8;
  -webkit-backdrop-filter: blur(1.6em) saturate(1.4); backdrop-filter: blur(1.6em) saturate(1.4);
  box-shadow: 0 1.2em 3em -1em rgb(0 0 0 / 0.6);
  font: 400 1.32em/1.35 system-ui, -apple-system, "Segoe UI", sans-serif;
  transform: translateY(-130%); opacity: 0;
  transition: transform 200ms var(--ease-out), opacity 150ms ease; /* leaving: quick */
  pointer-events: none;
}
.notif.is-shown { transform: none; opacity: 1; transition: transform 560ms var(--ease-drawer), opacity 200ms ease; }
.notif-icon { flex: none; width: 3.3em; height: 3.3em; border-radius: 0.8em; background: #151f27; position: relative; }
.notif-icon::after { content: ""; position: absolute; inset: 0.85em; border-radius: 50%; background: #e8eef2; }
.notif-text { display: grid; gap: 0.1em; min-width: 0; }
.notif-app { display: flex; justify-content: space-between; color: rgb(255 255 255 / 0.6); font-size: 0.85em; text-transform: uppercase; letter-spacing: 0.04em; }
.notif-app i { font-style: normal; text-transform: none; letter-spacing: 0; }

/* Chapters, strung on an axon */
.chapters { grid-area: chapters; position: relative; list-style: none; margin: 0; padding: 0 0 0 40px; }
/* The axon. A gray line from the first chapter's dot to the last one's (tour.js sizes it). The fill
   follows your scroll: it reaches each dot exactly as that chapter takes over and grows steadily in
   between, eased by gsap.quickTo so it trails the scroll slightly instead of jittering on iPhone.
   It's scaled, so its pink-to-app-color fade always ends at the tip. A dot lights when the tip
   reaches it (.is-lit, set by tour.js). */
.rail {
  position: absolute; left: 4px; top: 50svh; height: 0; width: 1px;
  list-style: none; background: var(--line);
}
.rail-fill {
  display: block; height: 100%;
  background: linear-gradient(var(--pink), var(--node));
  box-shadow: 0 0 12px color-mix(in srgb, var(--node) 60%, transparent);
  transform-origin: top; transform: scaleY(0);
}
/* An even rhythm: every chapter is the same height with its text at the top, so headings are always
   the same distance apart and the next one is on screen as the previous one leaves. */
.chapter { position: relative; min-height: 72svh; display: flex; flex-direction: column; justify-content: flex-start; padding: 0 0 72px; }
.chapter > h2::before, .chapter-sticky > h2::before {
  /* the chapter's neuron */
  content: ""; position: absolute; left: -40px; margin-top: 0.42em;
  width: 9px; height: 9px; border-radius: 50%;
  background: var(--bg); box-shadow: inset 0 0 0 1.5px var(--faint);
  transition: background 240ms ease, box-shadow 240ms ease;
}
.chapter.is-lit > h2::before, .chapter.is-lit .chapter-sticky > h2::before {
  background: var(--node);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--node) 22%, transparent), 0 0 16px color-mix(in srgb, var(--node) 70%, transparent);
}
/* The moment the line arrives, the dot fires once, like the logo's neurons */
.chapter.is-firing > h2::before, .chapter.is-firing .chapter-sticky > h2::before { animation: dot-fire 320ms var(--ease-out); }
@keyframes dot-fire {
  from { transform: scale(1.7); box-shadow: 0 0 0 7px color-mix(in srgb, var(--node) 0%, transparent), 0 0 26px color-mix(in srgb, var(--node) 95%, transparent); }
}
.chapter h2 { font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -0.025em; max-width: 14ch; }
.chapter p { max-width: 42ch; margin-top: 18px; color: var(--muted); font-size: 18px; }
.chapter-long { min-height: 300svh; justify-content: flex-start; }
.measuring-dots .chapter-sticky { position: static !important; } /* see measureDots in tour.js */
/* Long chapters (the replay, Saturday) on desktop: the heading, its dot, the text and the scrubbing
   readout stay pinned together while it plays; the rail's fill follows the pinned dot down. */
.chapter-sticky { position: sticky; top: calc(50svh - 170px); }

.chapter-intro { grid-area: intro; min-height: 100svh; justify-content: center; padding: 120px 0 80px 40px; } /* lines up with the chapters, which sit right of the axon */
.chapter-intro::before { display: none; }
.tour-kicker { display: flex; align-items: center; gap: 10px; color: var(--muted); font-weight: 600; margin: 0 0 22px !important; }
.tour-kicker .status { margin-left: 4px; }
.tour-title { font-size: clamp(44px, 4.4vw, 66px); font-weight: 800; letter-spacing: -0.035em; line-height: 0.98; max-width: none; }
.tour-title .line { display: block; overflow: hidden; padding-bottom: 0.06em; }
.tour-title .line > span { display: inline-block; }
.chapter-lede { font-size: 19px !important; color: var(--text) !important; opacity: 0.86; }
.chapter-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 30px; }
.scroll-cue { margin-top: 56px !important; font-size: 14px !important; color: var(--muted) !important; display: flex; align-items: center; gap: 10px; }
.scroll-cue::before { content: ""; width: 1px; height: 28px; background: linear-gradient(var(--faint), transparent); }

/* Replay scrub readout */
.scrub-hint { display: flex; align-items: center; gap: 14px; font: 500 14px/1 var(--mono) !important; color: var(--text) !important; font-variant-numeric: tabular-nums; }
.scrub-bar { position: relative; width: 160px; height: 3px; border-radius: 3px; background: var(--line); overflow: hidden; }
.scrub-bar i { position: absolute; inset: 0; background: var(--node); transform-origin: left; transform: scaleX(0); }

/* Saturday log: entries light up as the clock passes them */
.day-log { list-style: none; margin: 26px 0 0; padding: 0; display: grid; gap: 4px; }
.day-log li { display: flex; gap: 14px; align-items: baseline; color: var(--muted); transition: color 240ms ease; font-size: 16px; }
.day-log time { min-width: 52px; font: 500 13px/1 var(--mono); font-variant-numeric: tabular-nums; }
.day-log li.is-past { color: var(--text); }
.day-log li.is-past time { color: var(--pink-hi); }

/* More screens: a strip you can swipe, scroll or step through */
.more { padding: 120px 0 40px; border-top: 1px solid var(--line-soft); }
.more-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; margin-bottom: 32px; }
.more-head h2 { font-size: clamp(30px, 3.4vw, 46px); letter-spacing: -0.025em; }
.more-nav { display: flex; gap: 10px; }
.icon-btn {
  display: grid; place-items: center; width: 46px; height: 46px; padding: 0;
  border: 1px solid var(--line); border-radius: 50%; background: var(--bg-raise); color: var(--text); cursor: pointer;
  transition: transform 160ms var(--ease-out), border-color 160ms ease, opacity 160ms ease;
}
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.icon-btn:active { transform: scale(0.97); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
@media (hover: hover) and (pointer: fine) { .icon-btn:not(:disabled):hover { border-color: var(--faint); } }

.strip {
  --h: clamp(300px, 34vw, 460px);
  --pad: max(var(--gutter), calc((100vw - var(--max)) / 2 + var(--gutter)));
  display: flex; gap: clamp(16px, 2vw, 28px); margin: 0; padding: 8px var(--pad) 40px; list-style: none;
  overflow-x: auto; scroll-snap-type: x mandatory; scroll-padding-inline: var(--pad); overscroll-behavior-x: contain;
  scrollbar-width: none;
}
.strip::-webkit-scrollbar { display: none; }
.shot { flex: none; scroll-snap-align: start; }
.shot-wide { width: calc(var(--h) * 1.6); }
.shot-phone { width: calc(var(--h) * 0.462); }
.shot button { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: zoom-in; border-radius: var(--radius); }
.shot img {
  width: 100%; height: var(--h); object-fit: cover; object-position: top;
  border-radius: var(--radius); background: var(--bg-sunk);
  box-shadow: 0 0 0 1px var(--line), 0 24px 60px -30px rgb(0 0 0 / 0.8);
  transition: transform 200ms var(--ease-out);
}
.shot-phone img { border-radius: calc(var(--h) * 0.06); }
@media (hover: hover) and (pointer: fine) { .shot button:hover img { transform: translateY(-4px); } }
.shot button:active img { transform: scale(0.98); transition-duration: 120ms; }
.shot p { margin-top: 14px; color: var(--muted); font-size: 15px; line-height: 1.5; }
.shot p b { color: var(--text); font-weight: 600; }

/* Full-size viewer */
.viewer {
  width: fit-content; max-width: 94vw; max-height: 94svh; padding: 18px; border: 1px solid var(--line); border-radius: var(--radius-lg);
  background: var(--bg-raise); color: var(--text); overflow: auto;
}
.viewer[open] { animation: viewer-in 240ms var(--ease-out); }
.viewer::backdrop { background: rgb(8 5 11 / 0.78); -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px); }
@keyframes viewer-in { from { opacity: 0; transform: scale(0.96); } }
.viewer img { width: auto; max-width: 100%; max-height: calc(94svh - 120px); margin: 0 auto; border-radius: var(--radius-sm); }
.viewer p { margin: 14px 4px 2px; color: var(--muted); font-size: 15px; }
.viewer p b { color: var(--text); }
.viewer form { position: sticky; top: 0; height: 0; display: flex; justify-content: flex-end; z-index: 1; }
.viewer-close { margin: 6px; }

/* Closing call to action */
.tour-cta { padding: 100px 0 140px; }
.cta-inner h2 { font-size: clamp(36px, 5vw, 68px); letter-spacing: -0.03em; max-width: 16ch; }
.cta-inner p { margin-top: 20px; max-width: 46ch; color: var(--muted); font-size: 19px; }
.cta-inner .btn .node-dot { margin-right: 2px; }

/* Phones held upright and small tablets: the device sticks to the top and the story scrolls up beneath
   it. A phone turned sideways (landscape, short screen) keeps the side-by-side layout instead. */
@media (max-width: 999px) and (orientation: portrait), (max-width: 999px) and (min-height: 521px) {
  .tour-grid, .tour-grid:has(.phone) { display: block; padding: 0; }
  .tour-stage {
    top: 60px; z-index: 2; height: auto; padding: 14px var(--gutter) 28px;
    background: linear-gradient(var(--bg) 82%, color-mix(in srgb, var(--bg) 0%, transparent));
  }
  .tour-stage .browser { max-width: 560px; }
  .tour-stage .phone { font-size: min(10px, calc(44svh / 74)); }
  .chapters { padding: 0 var(--gutter) 0 calc(var(--gutter) + 28px); }
  .rail { left: calc(var(--gutter) + 4px); }
  .chapter > h2::before, .chapter-sticky > h2::before { left: -28px; }
  .chapter { min-height: 72svh; justify-content: flex-start; padding: 8px 0 64px; }
  .chapter-intro { padding: 100px var(--gutter) 48px; min-height: 0; } /* clear of the fixed header */
  .chapter-long { min-height: 200svh; }
  /* Long chapters: the heading and text scroll away and only the scrubbing readout (Saturday's
     times, the replay bar) stays pinned under the device, so all of it fits on a phone screen. */
  .chapter-sticky { display: contents; }
  .chapter-sticky .day-log, .chapter-sticky .scrub-hint {
    position: sticky; top: calc(var(--stage-bottom, 360px) + 4px); z-index: 1;
    margin-top: 18px !important; padding: 10px 0 14px; background: var(--bg);
  }
  .tour-title { font-size: clamp(38px, 10vw, 60px); }
  /* Keyboard focus never lands under the pinned device */
  html:has(.tour-page) { scroll-padding-top: calc(var(--stage-bottom, 360px) + 16px); }
  .scroll-cue { display: none !important; }
  .chapter p { font-size: 17px; }
  .more { padding-top: 80px; }
  .more-nav { display: none; }
  .strip { --h: clamp(260px, 62vw, 380px); }
  .tour-cta { padding: 64px 0 96px; }
}

/* A phone turned sideways: side by side, with the device as tall as the short screen allows */
@media (max-width: 999px) and (orientation: landscape) and (max-height: 520px) {
  .tour-stage { padding-top: 60px; }
  .tour-stage .phone { font-size: calc((100svh - 84px) / 74); }
  .tour-stage .browser { width: min(100%, calc((100svh - 76px - 38px) * 1.6)); }
  .chapter { padding-block: 0 48px; }
  .chapter-intro { padding-top: 92px; }
  .chapter p { font-size: 17px; }
  /* Long chapters: only the scrubbing readout stays pinned, so it fits under the header */
  .chapter-sticky { display: contents; }
  .chapter-sticky .day-log, .chapter-sticky .scrub-hint {
    position: sticky; top: 72px; z-index: 1;
    margin-top: 18px !important; padding: 10px 0 14px; background: var(--bg);
  }
  .strip { --h: clamp(220px, 62svh, 300px); }
}

@media (prefers-reduced-motion: reduce) {
  /* Keep the fades that show what changed; drop the movement */
  .tour-page .screen > img { filter: none; transition: opacity 0s linear 200ms; }
  .tour-page .screen > img.is-on { transition: opacity 200ms ease; }
  .notif, .notif.is-shown { transform: none; transition: opacity 200ms ease; }
  .chapter-sticky { position: static; }
  .chapter-sticky .day-log, .chapter-sticky .scrub-hint { position: static; }
  .chapter-long { min-height: 100svh; }
  .viewer[open] { animation: none; }
}
