/* The Thread — homepage journey section (Phase 7.1).
   One smooth ribbon runs down the section, shifting red to ink along
   its length, with round icon stops for the five story beats: First
   Call, the Guides, Farewell, Handl'd, capturing it all. The cards
   sit in normal flow beside the ribbon; JS (src/lib/home-motion.ts)
   only draws the ribbon's coloured overlay as a function of scroll
   progress and lights each stop as the draw reaches it.

   Progressive enhancement: the default styles are the fallback — the
   ribbon fully drawn behind stacked, fully readable cards (no JS,
   narrow screens, reduced motion). home-motion adds .route-live to
   the section only on wide, motion-OK viewports (the identical
   pre-paint gate sits inline in index.astro), which switches the
   cards to the tall alternating journey rhythm. If the JS fails, the
   section still reads perfectly.

   Palette: white base, ink and brand red only. Transform/opacity
   family motion only; the draw is a stroke-dashoffset change driven
   by ScrollTrigger scrub. */

/* ---------- Fallback / base layout ---------- */

.route-journey {
  background: #fff;
  color: var(--ink);
  overflow: hidden;
  overflow: clip;
}

/* Section heading: normal flow before the track, in every mode. */
.route-intro {
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding: var(--space-7, 2.5rem) var(--pad-page) var(--space-4, 1rem);
}

.route-head {
  max-width: 40rem;
}

.route-head h2 {
  margin: 0 0 var(--space-3, .75rem);
}

.route-head .route-dek {
  color: var(--ink-muted);
  font-size: var(--fs-small);
  margin: 0;
  max-width: 34rem;
}

.route-track {
  position: relative;
}

/* The ribbon layer spans the whole track behind the cards. */
.thread-layer {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

.thread-svg {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  /* ease the ribbon out at the end instead of a hard cut into the next section */
  -webkit-mask-image: linear-gradient(to bottom, #000 0, #000 93%, transparent 100%);
  mask-image: linear-gradient(to bottom, #000 0, #000 93%, transparent 100%);
}

.thread-base {
  stroke: #1d1b18;
  stroke-opacity: .10;
  stroke-width: 16;
  stroke-linecap: round;
}

.thread-draw {
  stroke: url(#thread-grad);
  stroke-width: 16;
  stroke-linecap: round;
}

/* Round icon stops on the ribbon. They light (brand red fill) when
   the draw reaches them; below the wide gate they stay hidden, so
   stacked phone cards never sit on top of them. */
.thread-node {
  position: absolute;
  width: 44px;
  height: 44px;
  margin: -22px 0 0 -22px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--ink);
  color: var(--ink);
  display: grid;
  place-items: center;
  transition: background-color .35s ease, border-color .35s ease, color .35s ease;
}

.thread-node svg {
  width: 22px;
  height: 22px;
}

.thread-node.is-on {
  background: var(--brand-red);
  border-color: var(--brand-red);
  color: #fff;
}

@media (max-width: 860px) {
  .thread-node { display: none; }
}

.route-cards {
  position: relative;
  z-index: 1;
  max-width: var(--measure-wide);
  margin-inline: auto;
  padding: var(--space-7, 2.5rem) var(--pad-page) var(--r2-section-y, clamp(2.75rem, 6vw, 5.5rem));
  display: grid;
  grid-template-columns: 1fr;
  gap: var(--space-5, 1.25rem);
}

@media (min-width: 560px) and (max-width: 860px) {
  .route-cards { grid-template-columns: 1fr 1fr; }
  .route-spacer { display: none; }
}

.route-card {
  display: flex;
  flex-direction: column;
  background: var(--bone);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: var(--space-6, 1.75rem);
  box-shadow: 0 1.25rem 2.5rem rgba(29, 27, 24, .10);
}

.route-card .route-stop {
  font-family: var(--font-sans);
  font-size: .6875rem;
  font-weight: 500;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: var(--brand-red);
  margin: 0 0 var(--space-3, .75rem);
}

.route-card h3 {
  font-size: 1.6rem;
  margin: 0 0 var(--space-3, .75rem);
}

.route-card p {
  color: var(--ink-soft);
  margin: 0 0 var(--space-5, 1.25rem);
}

.route-card p:last-child { margin-bottom: 0; }

.route-card .btn { margin-top: auto; }

.route-spacer { display: none; }

/* ---------- Enhanced: the journey rhythm (wide + motion OK) ---------- */

/* Cards alternate beside the ribbon on a tall, even rhythm: first
   card 12vh in, each card 40vh, 30vh of ribbon between stops, a
   24vh run-out. The stop nodes' percentage tops are set against
   this rhythm, so each lit stop sits at its card's centre. */
.route-journey.route-live .route-cards {
  max-width: none;
  margin: 0;
  padding: 0 var(--pad-page);
  display: flex;
  flex-direction: column;
}

.route-journey.route-live .route-card {
  width: min(38vw, 34rem);
  height: auto;
  min-height: 0;
  flex: none;
}

.route-journey.route-live .route-card--r {
  align-self: flex-end;
  margin-right: 5vw;
}

.route-journey.route-live .route-card--l {
  align-self: flex-start;
  margin-left: 5vw;
}

.route-journey.route-live .route-card:first-child {
  margin-top: 12vh;
}

.route-journey.route-live .route-card + .route-card {
  margin-top: 30vh;
}

.route-journey.route-live .route-spacer {
  display: block;
  height: 24vh;
  flex: none;
}
