/* Home "How one reply reaches you" scene (1 Dec 2026).
   Markup: src/index.html section.rs[data-rscene]. Code: public/js/scene.js.
   Finished state is the default: with JS off or reduced motion every step is lit and every object is visible,
   stacked (phone) or in two columns with Nia beside the steps (desktop).
   With JS and motion (.rs.is-live):
   - desktop 1024px+ and 680px+ tall: a pinned ink stage. Nia stands at the left, the current runs from the dynamo through
     five stations, and each station's object lights in the panel below the rail as the visitor scrolls.
   - narrower or shorter screens: the stacked version, the current runs down the left edge and each object plays as it scrolls in.
   Tokens, .gate, .reply, .card-ink, .card-paper, .inlet, .nia-chip and .dynamo-mark come from depth.css / home.css (not edited). */

.rs {
  --lamp: .32;
  position: relative; color: var(--text-on-ink); padding: 104px 0 112px;
  background:
    radial-gradient(46% 60% at 18% 46%, rgba(56,82,150,.34) 0%, rgba(30,44,84,.14) 42%, rgba(11,13,18,0) 72%),
    radial-gradient(40% 40% at 70% 78%, rgba(91,140,255,.07) 0%, rgba(11,13,18,0) 70%),
    linear-gradient(180deg, #0B0D12 0%, #0D1018 60%, #0A0C11 100%);
}
.rs-room { display: none; }
.rs-stage { position: relative; width: min(var(--max, 1240px), calc(100% - 2 * var(--gutter))); margin-inline: auto; }
.rs-main { position: relative; }
.rs-wire { position: absolute; left: 0; top: 0; width: 100%; height: 100%; overflow: visible; pointer-events: none; z-index: 0; }

/* ---------- Head ---------- */
.rs-head { position: relative; z-index: 2; }
.rs-head .example-text { display: block; margin: 0 0 8px; }
.rs-head h2 { color: #fff; max-width: 15em; }
.rs-more { margin: 14px 0 0; }

/* ---------- Nia ---------- */
.rs-nia { position: relative; margin: 0; aspect-ratio: 1; pointer-events: none;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 72%, transparent 97%), linear-gradient(180deg, transparent 0%, #000 16%, #000 80%, transparent 100%);
  -webkit-mask-composite: source-in;
          mask-image: linear-gradient(90deg, transparent 0%, #000 10%, #000 72%, transparent 97%), linear-gradient(180deg, transparent 0%, #000 16%, #000 80%, transparent 100%);
          mask-composite: intersect; }
.rs-nia img { width: 100%; height: 100%; object-fit: cover; border-radius: 0;
  -webkit-mask-image: radial-gradient(34% 44% at 50% 38%, #000 76%, transparent 100%), radial-gradient(70% 36% at 52% 100%, #000 72%, transparent 100%), radial-gradient(48% 40% at 52% 92%, #000 70%, transparent 100%);
          mask-image: radial-gradient(34% 44% at 50% 38%, #000 76%, transparent 100%), radial-gradient(70% 36% at 52% 100%, #000 72%, transparent 100%), radial-gradient(48% 40% at 52% 92%, #000 70%, transparent 100%); }
.rs-nia .rim { position: absolute; inset: 0; pointer-events: none; opacity: var(--lamp); transition: opacity .6s var(--ease-arrive);
  background: radial-gradient(36% 44% at 80% 60%, rgba(91,140,255,.34), rgba(91,140,255,0) 70%); }
.rs-status { display: none; }

/* ---------- Dynamo (start of the current) ---------- */
.rs-dyn { position: relative; z-index: 2; display: block; width: 34px; height: 34px; margin: 40px 0 0; }

/* ---------- Steps (stacked) ---------- */
.rs-steps { position: relative; z-index: 1; list-style: none; margin: 22px 0 0; padding: 0 0 0 52px; display: grid; gap: 64px; }
.rs-steps::before { /* static current line for JS off / reduced motion */
  content: ""; position: absolute; left: 16px; top: -22px; bottom: 8px; width: 2px; margin-left: -1px; background: var(--signal); opacity: .8;
}
.rs-step { position: relative; }
.rs-node {
  position: absolute; z-index: 2; left: -44px; top: 3px; width: 16px; height: 16px; border-radius: 50%;
  background: var(--signal); border: 2px solid var(--signal); box-shadow: 0 0 0 5px rgba(91,140,255,.16);
  transition: background .3s ease, border-color .3s ease, box-shadow .3s ease;
}
.rs-step:nth-child(n+4) .rs-node { background: #DCE7FF; border-color: #fff; box-shadow: 0 0 0 5px rgba(169,195,255,.16); }
.rs-t { margin: 0; color: #fff; font: 700 1.2rem/1.2 var(--font-display); letter-spacing: -.01em; transition: color .3s ease; }
.rs-x { margin: 6px 0 0; max-width: 30rem; font-size: 1rem; line-height: 1.55; color: var(--text-on-ink); transition: color .3s ease; }
.rs-x .nia-chip { color: #fff; }
.rs-x .nia-chip img { width: 24px; height: 24px; }
.rs-vis { position: relative; margin-top: 22px; }

/* Found: the field of companies, one dot lit */
.rs-field { max-width: 560px; }
.rs-field-inner { position: relative; }
.rs-field-svg { width: 100%; height: auto; overflow: visible; }
.rs-dots circle { fill: #6A7488; }
.rs-t-halo { fill: rgba(91,140,255,.18); }
.rs-t-ring { fill: none; stroke: var(--signal); stroke-width: 1.6; }
.rs-t-dot { fill: #DCE7FF; stroke: var(--signal); stroke-width: 2.5; }
.rs-target { transform-box: fill-box; transform-origin: 50% 50%; }
.rs-field-tag {
  position: absolute; right: calc(100% - 63.1% + 22px); top: 56.7%; margin: 0; transform: translateY(-50%);
  text-align: right; font-size: .86rem; line-height: 1.35; color: var(--text-on-ink); max-width: none; white-space: nowrap;
}
.rs-field-tag b { display: block; color: #fff; font-weight: 600; }

/* Checked: the revenue gate */
.rs-gate { max-width: 400px; }

/* Emailed: Nia's email */
.rs-mail { max-width: 520px; padding: 18px 20px 20px; font-size: .95rem; line-height: 1.55; }
.rs-mail p { max-width: none; }
.rs-mail-from, .rs-mail-to { margin: 0; display: flex; align-items: baseline; gap: 10px; color: var(--mute-on-paper); font-size: .88rem; }
.rs-mail-v { flex: 1; min-width: 0; }
.rs-mail-from .nia-chip { margin-right: 6px; }
.rs-mail-to { margin-top: 6px; padding-bottom: 10px; border-bottom: 1px solid var(--rule-paper); }
.rs-mail-k { flex: none; width: 2.6em; color: var(--mute-on-paper); font-weight: 600; }
.rs-mail-from .nia-chip { color: var(--ink); }
.rs-mail-subj { margin: 10px 0 0; font-weight: 600; color: var(--ink); }
.rs-mail-body p { margin: 8px 0 0; color: var(--text-on-paper); }
.rs-w { transition: opacity 90ms linear; }
.rs-w.is-off { opacity: .14; }
.rs-w.is-caret { position: relative; }
.rs-w.is-caret::after { content: ""; position: absolute; right: -3px; top: .2em; bottom: .1em; width: 2px; background: var(--signal); }

/* Replied: the reply card (whiter, it comes back) */
.rs-reply { max-width: 440px; }
.rs-reply .reply-text { font-size: 1.3rem; }
.rs-reply-k { display: block; margin-bottom: 2px; font: 600 .8rem/1.3 var(--font-body); letter-spacing: .02em; color: var(--signal); }

/* In your portal */
.rs-portal { max-width: 520px; padding: 0 0 4px; overflow: hidden; border: 1px solid var(--rule-ink); }
.rs-p-bar { display: flex; align-items: center; gap: 10px; padding: 14px 18px; border-bottom: 1px solid var(--rule-ink); font-size: .88rem; color: var(--mute-on-ink); }
.rs-p-bar b { color: #fff; font: 700 1rem/1 var(--font-display); }
.rs-p-bar .dynamo-mark { width: 24px; height: 24px; }
.rs-p-rows { list-style: none; margin: 0; padding: 0; }
.rs-p-rows li { position: relative; display: grid; gap: 2px; padding: 12px 18px; border-bottom: 1px solid var(--rule-ink); font-size: .9rem; line-height: 1.45; }
.rs-p-who { color: var(--mute-on-ink); }
.rs-p-who b { color: #fff; font-weight: 600; }
.rs-p-who em { margin-left: 8px; font: 600 .8rem/1 var(--font-body); font-style: normal; color: var(--signal-lit); }
.rs-p-txt { color: var(--text-on-ink); }
.rs-p-new { background: rgba(91,140,255,.10); box-shadow: inset 2px 0 0 var(--signal); }
.rs-p-foot { margin: 0; padding: 12px 18px 10px; font-size: .86rem; line-height: 1.45; color: var(--text-on-ink); max-width: none; }

/* ---------- Desktop, stacked (JS off, reduced motion, short screens) ---------- */
@media (min-width: 1024px) {
  .rs-stage { display: grid; grid-template-columns: minmax(0, 4fr) minmax(0, 7fr); gap: 0 56px; align-items: start; }
  .rs-nia { position: sticky; top: calc(var(--hh, 68px) + 24px); width: 112%; margin-left: -12%; }
  .rs-step { display: grid; grid-template-columns: minmax(0, 5fr) minmax(0, 7fr); gap: 0 32px; align-items: start; }
  .rs-step > .rs-t, .rs-step > .rs-x { grid-column: 1; }
  .rs-step > .rs-vis { grid-column: 2; grid-row: 1 / span 3; margin-top: 0; }
  .rs-mail, .rs-portal { max-width: none; }
}

/* ---------- Phone and tablet: heading, then Nia, then the steps ---------- */
@media (max-width: 1023px) {
  .rs { padding: 80px 0 88px; }
  .rs-stage { display: flex; flex-direction: column; }
  .rs-main { display: contents; }
  .rs-head { order: 1; }
  .rs-nia { order: 2; width: min(320px, 88%); margin: 20px -16px 0 auto; }
  .rs-dyn { order: 3; margin-top: -8px; }
  .rs-steps { order: 4; }
}
@media (max-width: 520px) {
  .rs-steps { padding-left: 44px; gap: 52px; }
  .rs-node { left: -36px; }
  .rs-field-tag { font-size: .8rem; }
  .rs-mail { padding: 16px 16px 18px; }
  .rs-reply .reply-text { font-size: 1.15rem; }
}

/* ---------- Live (JS + motion): lights wait for the current ---------- */
@media (prefers-reduced-motion: no-preference) {
  .rs.is-live .rs-steps::before { display: none; }
  .rs.is-live .rs-node { background: var(--ink); border-color: rgba(169,195,255,.32); box-shadow: none; }
  .rs.is-live .rs-step.is-lit .rs-node { background: var(--signal); border-color: var(--signal); box-shadow: 0 0 0 5px rgba(91,140,255,.18); }
  .rs.is-live .rs-step:nth-child(n+4).is-lit .rs-node { background: #DCE7FF; border-color: #fff; box-shadow: 0 0 0 5px rgba(169,195,255,.2); }
  .rs.is-live .rs-step:not(.is-lit) .rs-t { color: rgba(245,246,248,.62); }
  .rs.is-live .rs-step:not(.is-lit) .rs-x { color: var(--mute-on-ink); }
  .rs.is-live .rs-reply, .rs.is-live .rs-p-new, .rs.is-live .rs-target, .rs.is-live .rs-field-tag { will-change: transform, opacity; }
  .rs.is-live .rs-reply.is-landing { box-shadow: var(--z4); }
}

/* ---------- Pinned stage (desktop, JS + motion) ---------- */
@media (min-width: 1024px) and (min-height: 680px) and (prefers-reduced-motion: no-preference) {
  /* html has overflow-x: clip (home.css), so body's overflow-x: hidden makes body a non-scrolling scroll container and
     position: sticky never pins. clip hides the same sideways overflow without creating a scroll container. */
  body:has(.rs.is-live) { overflow-x: clip; }
  .rs.is-live { padding: 0; }
  .rs.is-live .rs-track { height: 400vh; }
  .rs.is-live .rs-stage {
    position: sticky; top: var(--hh, 68px); height: calc(100vh - var(--hh, 68px)); width: 100%; margin: 0;
    display: block; overflow: hidden;
  }
  .rs.is-live .rs-room { display: block; position: absolute; inset: 0; pointer-events: none;
    background: radial-gradient(34% 62% at 17% 58%, rgba(91,140,255,.16), rgba(11,13,18,0) 72%); opacity: calc(.4 + var(--lamp)); transition: opacity .6s var(--ease-arrive); }
  .rs.is-live .rs-nia { position: absolute; z-index: 1; left: max(-5vw, -80px); bottom: 0; top: auto; width: auto; height: min(86%, 44vw); margin: 0; }
  .rs.is-live .rs-nia { /* bleeds off the stage bottom: fade only the right and top edges */
    -webkit-mask-image: linear-gradient(90deg, #000 72%, transparent 97%), linear-gradient(180deg, transparent 0%, #000 16%);
            mask-image: linear-gradient(90deg, #000 72%, transparent 97%), linear-gradient(180deg, transparent 0%, #000 16%); }
  /* Nia's live readout fills the top left of the stage, above her head */
  .rs.is-live .rs-status {
    display: grid; gap: 4px; position: absolute; z-index: 3; left: var(--gutter); top: clamp(24px, 5vh, 60px); width: calc(36% - var(--gutter) - 40px);
    margin: 0; min-height: 5.2em; padding-left: 16px; border-left: 2px solid var(--signal);
    font: 600 .95rem/1.35 var(--font-body); color: var(--signal-lit); max-width: none;
  }
  .rs.is-live .rs-status-k { font: 600 .74rem/1.2 var(--font-body); letter-spacing: .08em; text-transform: uppercase; color: var(--mute-on-ink); }
  .rs.is-live .rs-status b { display: block; font: 700 clamp(1.5rem, 2.2vw, 2rem)/1.05 var(--font-display); color: #fff; letter-spacing: -.015em; }
  .rs.is-live .rs-main {
    position: absolute; z-index: 2; top: 0; bottom: 0; left: 36%; right: var(--gutter);
    display: grid; grid-template-columns: 44px minmax(0, 1fr) minmax(0, 1.12fr) minmax(0, 1.3fr) minmax(0, 1fr) minmax(0, 1.18fr);
    grid-template-rows: auto auto auto auto minmax(0, 1fr); column-gap: 22px;
    padding: clamp(24px, 5vh, 60px) 0 clamp(18px, 3.5vh, 40px);
  }
  .rs.is-live .rs-head { grid-column: 1 / -1; grid-row: 1; margin-bottom: 30px; display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 6px 32px; }
  .rs.is-live .rs-head .example-text { flex-basis: 100%; }
  .rs.is-live .rs-head h2 { font-size: clamp(1.9rem, 2.7vw, 2.6rem); }
  .rs.is-live .rs-more { margin: 0 0 4px; }
  .rs.is-live .rs-steps, .rs.is-live .rs-step { display: contents; }
  .rs.is-live .rs-dyn { grid-column: 1; grid-row: 2; width: 44px; height: 44px; margin: 22px 0 0; align-self: start; }
  .rs.is-live .rs-node { position: relative; left: auto; top: auto; grid-row: 2; align-self: start; justify-self: start; margin-top: 8px; }
  .rs.is-live .rs-t { grid-row: 3; margin-top: 14px; font-size: 1.08rem; }
  .rs.is-live .rs-x { grid-row: 4; margin-top: 6px; font-size: .9rem; line-height: 1.5; }
  .rs.is-live .rs-x .nia-chip img { width: 22px; height: 22px; }
  .rs.is-live .rs-step:nth-child(1) > * { grid-column: 2; }
  .rs.is-live .rs-step:nth-child(2) > * { grid-column: 3; }
  .rs.is-live .rs-step:nth-child(3) > * { grid-column: 4; }
  .rs.is-live .rs-step:nth-child(4) > * { grid-column: 5; }
  .rs.is-live .rs-step:nth-child(5) > * { grid-column: 6; }
  /* uneven station heights: Found sits under the $1M line, the rest above it */
  .rs.is-live .rs-step:nth-child(1) > .rs-node { margin-top: 36px; }
  .rs.is-live .rs-step:nth-child(2) > .rs-node { margin-top: 2px; }
  .rs.is-live .rs-step:nth-child(3) > .rs-node { margin-top: 12px; }
  .rs.is-live .rs-step:nth-child(4) > .rs-node { margin-top: 0; }
  .rs.is-live .rs-step:nth-child(5) > .rs-node { margin-top: 8px; }

  /* the panel: one object at a time, the field behind them all */
  .rs.is-live .rs-step > .rs-vis {
    grid-row: 5; grid-column: 2 / -1; align-self: center; justify-self: center; margin: 16px 0 0; width: 100%; max-height: 100%;
    opacity: 0; transform: translate3d(0, 18px, 0) scale(.985); pointer-events: none;
    transition: opacity .45s var(--ease-arrive), transform .6s var(--ease-arrive);
  }
  .rs.is-live .rs-step > .rs-vis.is-on { opacity: 1; transform: none; pointer-events: auto; }
  .rs.is-live .rs-step:nth-child(1) > .rs-vis.rs-field {
    grid-column: 1 / -1; align-self: stretch; justify-self: stretch; max-width: none; margin: 8px 0 0;
    opacity: 1; transform: none; display: flex; align-items: center; justify-content: center;
  }
  .rs.is-live .rs-field-inner { height: 100%; aspect-ratio: 640 / 300; max-width: 100%; }
  .rs.is-live .rs-field-svg { width: 100%; height: 100%; }
  .rs.is-live .rs-field:not(.is-on) .rs-field-svg { opacity: .34; }
  .rs.is-live .rs-field:not(.is-on) .rs-field-tag { opacity: 0 !important; }
  .rs.is-live .rs-field-svg, .rs.is-live .rs-field-tag { transition: opacity .5s var(--ease-arrive); }
  .rs.is-live .rs-gatewrap { max-width: 460px; justify-self: start; margin-left: 6%; }
  .rs.is-live .rs-gate { max-width: none; }
  .rs.is-live .rs-mailwrap { max-width: 540px; }
  .rs.is-live .rs-replywrap { max-width: 460px; justify-self: end; margin-right: 10%; }
  .rs.is-live .rs-portalwrap { max-width: 540px; justify-self: end; }
  .rs.is-live .rs-mail, .rs.is-live .rs-portal { max-width: none; }
  .rs.is-live .rs-mail, .rs.is-live .rs-reply, .rs.is-live .rs-portal, .rs.is-live .rs-gate { box-shadow: var(--z4); }
}
@media (min-width: 1024px) and (min-height: 680px) and (max-height: 820px) and (prefers-reduced-motion: no-preference) {
  /* short laptop screens (1280x720): tighter so every object stays fully in view */
  .rs.is-live .rs-main { padding-top: 22px; }
  .rs.is-live .rs-status { top: 22px; }
  .rs.is-live .rs-head { margin-bottom: 26px; }
  .rs.is-live .rs-head h2 { font-size: clamp(1.7rem, 2.4vw, 2.2rem); }
  .rs.is-live .rs-dyn { margin-top: 14px; }
  .rs.is-live .rs-t { margin-top: 10px; font-size: 1rem; }
  .rs.is-live .rs-x { font-size: .84rem; line-height: 1.45; }
  .rs.is-live .rs-step > .rs-vis { margin-top: 12px; }
  .rs.is-live .rs-mail { padding: 12px 18px 14px; font-size: .88rem; line-height: 1.5; }
  .rs.is-live .rs-mail-to { padding-bottom: 8px; }
  .rs.is-live .rs-mail-subj { margin-top: 8px; }
  .rs.is-live .rs-mail-body p { margin-top: 4px; }
  .rs.is-live .rs-p-bar { padding: 10px 16px; }
  .rs.is-live .rs-p-rows li { padding: 7px 16px; font-size: .84rem; line-height: 1.4; }
  .rs.is-live .rs-p-foot { padding: 8px 16px 6px; font-size: .82rem; }
}

/* taller desktop screens: the smaller objects grow so they fill the space under the step row */
@media (min-width: 1024px) and (min-height: 821px) and (prefers-reduced-motion: no-preference) {
  .rs.is-live .rs-gatewrap { max-width: 520px; }
  .rs.is-live .rs-gate { padding: 22px 24px 18px; }
  .rs.is-live .rs-gate .gate-who { font-size: 1rem; }
  .rs.is-live .rs-gate .gate-val b { font-size: 1.5rem; }
  .rs.is-live .rs-gate .gate-meter { height: 10px; margin-top: 18px; }
  .rs.is-live .rs-gate .gate-status { font-size: .95rem; }
  .rs.is-live .rs-replywrap { max-width: 520px; }
  .rs.is-live .rs-reply { padding: 24px 28px 20px; }
  .rs.is-live .rs-reply .reply-text { font-size: 1.65rem; }
}

/* ---------- Wire (drawn by scene.js) ---------- */
.rs-wire .w-base { fill: none; stroke: rgba(169,195,255,.16); stroke-width: 1.5; stroke-linejoin: round; }
.rs-wire .w-lit { fill: none; stroke: var(--signal); stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
.rs-wire .w-lit.back { stroke: #DCE7FF; }
.rs-wire .w-th { stroke: var(--signal); stroke-width: 1; stroke-dasharray: 4 5; opacity: .6; }
.rs-wire .w-lab { font: 500 12.5px var(--font-body); fill: var(--signal-lit); }
.rs-wire .w-spark { fill: #fff; stroke: var(--signal); stroke-width: 3; }
.rs-wire .w-halo { opacity: .8; }

@media (prefers-reduced-motion: reduce) {
  .rs-nia .rim, .rs-node, .rs-t, .rs-x, .rs-w { transition: none; }
}
