/* Homepage story (story.js): a tall section whose stage stays pinned under the header while four chapters cross-fade. */
.story {
  position: relative;
  height: 420vh;
}

.story-stage {
  position: sticky;
  top: var(--ml-header-h);
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: calc(100svh - var(--ml-header-h));
  padding: clamp(28px, 6vh, 64px) 24px clamp(20px, 4vh, 40px);
}

.story-copy-slot,
.story-foot-slot {
  display: grid;
  justify-items: center;
  text-align: center;
}

/* Every chapter sits in the same grid cell, so the slot is as tall as the longest chapter. */
.story-copy,
.story-foot {
  grid-area: 1 / 1;
  max-width: 820px;
  will-change: opacity, transform;
}

.story-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  color: var(--ml-muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: .04em;
}

.story-eyebrow i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ml-coral);
}

.story-title {
  margin: 18px 0 0;
  color: var(--ml-ink);
  font-family: var(--ml-serif);
  font-size: clamp(34px, min(5.4vw, 7.4vh), 72px);
  font-weight: 500;
  line-height: 1.14;
  letter-spacing: -.01em;
}

.story-title em { font-style: normal; color: var(--ml-coral); }

.story-desc {
  margin: 20px auto 0;
  color: var(--ml-ink-2);
  font-size: 16px;
  line-height: 1.85;
}

.story-art {
  position: relative;
  min-height: 0;
  margin: 12px 0;
}

/* Absolutely placed so the SVG fills whatever height the row has left, never more. */
.story-net {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
}

/* Network art. Hosts are little aluminium Mac minis that light up; lines draw in, then carry pulses. */
.sn-map circle { fill: var(--ml-ink); }
.sn-map { transition: opacity .3s linear; }

.sn-line,
.sn-glow,
.sn-more-line {
  fill: none;
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  stroke-linecap: round;
}

.sn-line { stroke-width: 1.5; }
.sn-glow { stroke: var(--ml-coral); stroke-width: 6; opacity: .32; }
.sn-more-line { stroke: var(--ml-ink); stroke-width: .8; opacity: .22; stroke-dasharray: 1; }
.sn-pulse { fill: #fff; stroke: var(--ml-coral); stroke-width: 1.4; opacity: 0; }

.sn-more { opacity: 0; }
.sn-more circle { fill: var(--ml-ink); opacity: .55; }
.sn-more .sn-more-halo { fill: var(--ml-ink); opacity: .07; }

.sn-halo { fill: var(--ml-coral); opacity: 0; transition: opacity .5s ease; }
.sn-ring { fill: none; stroke: var(--ml-coral); stroke-width: 1; opacity: 0; transform-box: fill-box; transform-origin: center; }
.sn-shadow { fill: var(--ml-ink); opacity: .14; }
.sn-foot { fill: #c3c8d0; }
.sn-mac { stroke: #aab1bc; stroke-width: .8; transition: stroke .4s ease; }
.sn-gloss { fill: #fff; opacity: .9; }
.sn-led { fill: #b8bec9; transition: fill .4s ease; }
.sn-host.lit .sn-halo { opacity: .1; }
.sn-host.lit .sn-ring { animation: sn-ring 2.8s ease-out infinite; }
.sn-host.lit .sn-mac { stroke: var(--ml-ink); }
.sn-host.lit .sn-led { fill: #2fd27a; filter: drop-shadow(0 0 2px #2fd27a); }
.sn-host:nth-child(odd).lit .sn-ring { animation-delay: -1.4s; }
.sn-city,
.sn-spec { paint-order: stroke; stroke: var(--ml-bg); stroke-width: 4px; stroke-linejoin: round; }
.sn-city { fill: var(--ml-ink); font-size: 12.5px; font-weight: 600; letter-spacing: .02em; }
.sn-spec { fill: var(--ml-muted); font-size: 10.5px; }

.sn-renter-ring { fill: #fff; stroke: var(--ml-coral); stroke-width: 1.2; }
.sn-renter-core { fill: var(--ml-coral); }
.sn-renter-wave { fill: var(--ml-coral); opacity: 0; transform-box: fill-box; transform-origin: center; animation: sn-wave 3.2s ease-out infinite; }
.sn-renter:nth-of-type(2n) .sn-renter-wave { animation-delay: -1.6s; }

@keyframes sn-ring { 0% { opacity: .55; transform: scale(1); } 100% { opacity: 0; transform: scale(2.4); } }
@keyframes sn-wave { 0% { opacity: .22; transform: scale(.6); } 100% { opacity: 0; transform: scale(2.2); } }

/* Light: a soft spotlight follows the camera (story.js sets --light-*), the edges fall into shade,
   and the room dims a touch (--dim) in the last chapter so the network glows. */
.story-stage { --light-x: 66%; --light-y: 52%; --light-r: 26%; --dim: 0; isolation: isolate; }
/* The light spans the full window width and fades out top and bottom, so it has no visible edges. */
#main { overflow-x: clip; }
.story-light {
  position: absolute;
  inset: 0 calc(50% - 50vw);
  -webkit-mask-image: linear-gradient(180deg, transparent, #000 14%, #000 82%, transparent);
  mask-image: linear-gradient(180deg, transparent, #000 14%, #000 82%, transparent);
  z-index: -1;
  pointer-events: none;
  background:
    radial-gradient(circle at var(--light-x) var(--light-y), rgba(255, 253, 248, .95), rgba(255, 253, 248, 0) var(--light-r)),
    radial-gradient(ellipse 60% 45% at var(--light-x) calc(var(--light-y) + 4%), rgba(232, 72, 77, calc(.05 + var(--dim) * .07)), transparent 70%),
    radial-gradient(ellipse 85% 75% at 50% 45%, transparent 55%, rgba(15, 23, 40, calc(.05 + var(--dim) * .06)) 100%),
    linear-gradient(180deg, rgba(15, 23, 40, calc(var(--dim) * .035)), rgba(15, 23, 40, 0) 40%);
}

.story-skip {
  position: absolute;
  right: 28px;
  bottom: 22px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 36px;
  padding: 0 14px 0 16px;
  border: 1px solid var(--ml-line);
  border-radius: 999px;
  background: rgba(255, 255, 255, .78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  color: var(--ml-ink-2);
  font: 500 12.5px/1 var(--ml-sans);
  cursor: pointer;
  box-shadow: var(--ml-shadow-sm);
  transition: opacity .25s ease, transform .25s ease, color .2s, border-color .2s;
}
.story-skip span { font-size: 13px; transition: transform .2s ease; }
.story-skip:hover { color: var(--ml-ink); border-color: var(--ml-line-strong); }
.story-skip:hover span { transform: translateY(2px); }
.story-skip.is-hidden { opacity: 0; transform: translateY(6px); pointer-events: none; }

/* Brief hero for returning or signed-in visitors: one screen, the network already lit. */
.story-brief {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr);
  align-items: center;
  gap: 24px;
  min-height: min(500px, calc(100svh - var(--ml-header-h) - 80px));
  padding: 40px 0 8px;
  isolation: isolate;
  --light-x: 70%; --light-y: 50%; --light-r: 48%; --dim: 0;
}
.story-brief .story-light { inset: -40px calc(50% - 50vw) 0; }
.story-brief .story-title { font-size: clamp(34px, 4.4vw, 58px); }
.story-brief .story-desc { max-width: 30em; margin-left: 0; font-size: 15px; }
.story-brief .story-actions { justify-content: flex-start; margin-top: 28px; }
.story-brief .story-facts { justify-content: flex-start; margin-top: 30px; }
.brief-art { position: relative; height: clamp(300px, 34vw, 440px); }
.brief-replay {
  margin-top: 22px;
  padding: 0;
  border: 0;
  background: none;
  color: var(--ml-muted);
  font: 500 12.5px/1.4 var(--ml-sans);
  text-decoration: underline;
  text-underline-offset: 3px;
  cursor: pointer;
}
.brief-replay:hover { color: var(--ml-ink); }

.story-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
}

.story-actions .button { min-height: 46px; padding: 0 24px; font-size: 14px; }
.story-note { margin: 12px 0 0; color: var(--ml-muted); font-size: 12px; }

.story-facts {
  display: flex;
  justify-content: center;
  gap: clamp(28px, 6vw, 72px);
  margin: 0;
}

.story-facts div { display: grid; gap: 4px; }
.story-facts dt { order: 2; color: var(--ml-muted); font-size: 12px; }
.story-facts dd { order: 1; margin: 0; color: var(--ml-ink); font-family: var(--ml-serif); font-size: 24px; font-weight: 500; }
.story-foot .story-facts + .story-actions { margin-top: 18px; }

.story-progress {
  position: absolute;
  right: 28px;
  top: 50%;
  display: grid;
  gap: 10px;
  transform: translateY(-50%);
}

.story-progress span {
  width: 4px;
  height: 18px;
  border-radius: 2px;
  background: var(--ml-line-strong);
  transition: background .3s ease, height .3s ease;
}

.story-progress span.active { height: 32px; background: var(--ml-ink); }

/* Reduced motion: no pinning, every chapter shown in order, the network drawn in its final state. */
.story.is-static { height: auto; }
.story.is-static .story-stage { position: static; height: auto; gap: 40px; }
.story.is-static .story-copy-slot,
.story.is-static .story-foot-slot { gap: 48px; }
.story.is-static .story-copy,
.story.is-static .story-foot { grid-area: auto; }
.story.is-static .story-art { height: min(480px, 70vw); }
.story.is-static .story-progress,
.story.is-static .story-skip { display: none; }

@media (prefers-reduced-motion: reduce) {
  .sn-ring, .sn-renter-wave { animation: none !important; }
  .sn-pulses { display: none; }
  .market-intro.is-arriving > * { animation: none; }
}

/* Heading above the listings, where the story hands off to the market. */
.market-intro {
  display: grid;
  gap: 28px;
  justify-items: center;
  padding: 96px 0 8px;
  text-align: center;
  scroll-margin-top: calc(var(--ml-header-h) + 8px);
}

/* After a jump from the story, the heading settles in rather than appearing abruptly. */
.market-intro.is-arriving > * { animation: market-arrive .6s cubic-bezier(.2, .7, .2, 1) both; }
.market-intro.is-arriving > :nth-child(2) { animation-delay: .08s; }
@keyframes market-arrive { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.story-brief + .market-intro { padding-top: 40px; }

.market-intro h2 {
  text-wrap: balance;
  margin: 14px 0 0;
  color: var(--ml-ink);
  font-family: var(--ml-serif);
  font-size: clamp(30px, 3.6vw, 46px);
  font-weight: 500;
  line-height: 1.2;
}

.market-intro .hero-search { width: 100%; margin-top: 0; text-align: left; }

/* Laptop-height windows: tighten the copy so the network keeps most of the stage. */
@media (max-height: 860px) and (min-width: 641px) {
  .story-stage { padding-top: 28px; }
  .story-title { margin-top: 12px; }
  .story-desc { margin-top: 12px; font-size: 15px; line-height: 1.7; }
  .story-facts dd { font-size: 21px; }
}

@media (max-width: 860px) {
  .story-progress { right: 12px; }
  .story-desc br { display: none; }
  .story-brief { grid-template-columns: 1fr; gap: 8px; min-height: 0; padding-top: 28px; text-align: center; }
  .story-brief .story-desc { margin-left: auto; }
  .story-brief .story-actions,
  .story-brief .story-facts { justify-content: center; }
  .brief-art { height: 280px; order: -1; }
}

@media (max-width: 640px) {
  .story { height: 400vh; }
  .story-stage { padding: 28px 20px 20px; }
  .story-title { font-size: 34px; margin-top: 14px; }
  .story-desc { margin-top: 14px; font-size: 14px; line-height: 1.75; }
  .story-facts dd { font-size: 19px; }
  .story-actions .button { min-height: 42px; padding: 0 18px; }
  .story-progress { display: none; }
  .story-skip { right: 50%; bottom: 14px; transform: translateX(50%); }
  .story-skip.is-hidden { transform: translate(50%, 6px); }
  .market-intro { padding-top: 64px; }
  .brief-art { height: 220px; }
  .story-brief .story-title { font-size: 32px; }
}
