/* =====================================================================
   How2 Studio: scroll story layer (see js/story.js)
   Scenes pin and play under scroll only when html.story is set, which
   story.js does when motion is allowed. Without it, every section below
   falls back to the static layout in styles.css.
   ===================================================================== */

/* ---------- Hero: restructured into stage > window so it can pin and fold ---------- */
.hero.hero { display: block; min-height: 0; padding: 0; overflow: visible; isolation: auto; color: #fff; }
.hero__stage { position: relative; }
.hero__window {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: min(100svh, 860px);
  display: flex; align-items: flex-end;
  padding: 140px 0 clamp(48px, 7vw, 88px);
}
.hero__haze { position: absolute; inset: 0; z-index: -1; pointer-events: none; opacity: 0;
  background: radial-gradient(60% 60% at 70% 45%, rgba(255,255,255,0.55), transparent 70%); }
.hero__inner { position: relative; z-index: 1; }
.hero__chips { display: none; }
.hero__beat { display: none; }
@media (max-width: 900px) {
  .hero__window { min-height: 100svh; padding-top: calc(var(--nav-h) + env(safe-area-inset-top) + 48px); padding-bottom: calc(var(--tabbar-h) + 28px); }
}
@media (max-width: 900px) and (max-height: 520px) and (orientation: landscape) { .hero__window { min-height: 0; } }

/* Static fallbacks for the story-only pieces */
.deck, .tally, .fixlist, .pan-rail, .year { display: none; }
.steps__line { display: none; }
.team { display: none; }
.wave { display: none; }

/* Tie ring around the final CTA (drawn when the thread arrives) */
.tie { position: relative; display: inline-flex; }
.tie__ring { position: absolute; left: -7px; top: -7px; width: calc(100% + 14px); height: calc(100% + 14px); overflow: visible; pointer-events: none; }
.tie__ring rect { width: calc(100% - 3px); height: calc(100% - 3px); rx: 30px; fill: none; stroke: #fff; stroke-width: 2; stroke-dasharray: 1; stroke-dashoffset: 1; opacity: 0.9; }
.final.is-tied .tie__ring rect { stroke-dashoffset: 0; transition: stroke-dashoffset 1100ms var(--ease-in-out); }

/* =====================================================================
   Everything below only applies with motion on
   ===================================================================== */

/* ---------- Pinning ---------- */
.story main { position: relative; }
.story [data-pinned] { padding: 0 !important; }
.story [data-pinned] > [data-stage] {
  position: sticky; top: 0; height: 100vh; height: 100svh; overflow: clip;
  z-index: 3; background: var(--stage-bg, var(--bg));
  display: flex; flex-direction: column; justify-content: center;
  padding-top: var(--nav-h); padding-bottom: var(--tabbar-h);
}
.story main > section > .wrap, .story main > section > [data-stage] > .wrap { position: relative; z-index: 2; }

/* ---------- The thread ---------- */
.thread { display: none; }
.story .thread { display: block; position: absolute; left: 0; top: 0; z-index: 1; pointer-events: none; overflow: visible; }
.thread__track { fill: none; stroke: #e4e4ea; stroke-width: 1.5; stroke-dasharray: 2 6; stroke-linecap: round; }
.thread__line { fill: none; stroke: url(#thread-grad); stroke-width: 2.5; stroke-linecap: round; }
.thread__node { fill: #fff; stroke: #d6d6de; stroke-width: 1.5; transition: fill 300ms ease, stroke 300ms ease, r 300ms var(--ease-out); }
.thread__node.is-lit { fill: url(#thread-grad); stroke: #fff; stroke-width: 2; r: 6px; }
.thread__tip circle:last-child { fill: #fff; stroke: url(#thread-grad); stroke-width: 2.5; }
.thread__halo { fill: url(#thread-grad); opacity: 0.18; transform-box: fill-box; transform-origin: center; animation: halo 1.8s ease-in-out infinite; }
@keyframes halo { 50% { transform: scale(1.5); opacity: 0.06; } }
.thread__tip.is-off { opacity: 0; }

/* ---------- 1. Hero: pinned, four planes, folds into a card ---------- */
.story .hero > .hero__stage { background: transparent; padding: 0; display: block; }
.story .hero__window {
  position: absolute; inset: 0; min-height: 0;
  clip-path: inset(var(--fold-y, 0px) var(--fold-x, 0px) round var(--fold-r, 0px));
}
.story .hero__chips { display: block; position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.gchip {
  position: absolute; left: var(--x); top: var(--y);
  display: inline-flex; align-items: center; gap: 8px; white-space: nowrap;
  padding: 10px 15px; border-radius: 999px; font-size: 14px; font-weight: 500; color: #fff;
  background: rgba(255,255,255,0.16); box-shadow: inset 0 0 0 1px rgba(255,255,255,0.38), 0 24px 40px -22px rgba(30,0,60,0.6);
  backdrop-filter: blur(14px) saturate(1.3); -webkit-backdrop-filter: blur(14px) saturate(1.3);
  animation: float 7s ease-in-out infinite alternate; animation-delay: calc(var(--d) * -2.3s);
  will-change: transform, opacity;
}
.gchip .ico { width: 16px; height: 16px; }
.gchip__dot { width: 7px; height: 7px; border-radius: 50%; background: #fbbf36; box-shadow: 0 0 0 4px rgba(251,191,54,0.25); }
.gchip--far { font-size: 12px; padding: 8px 12px; opacity: 0.75; filter: blur(0.4px); }
@keyframes float { to { translate: 0 -14px; } }
.story .hero__beat {
  display: block; position: absolute; left: 50%; top: 50%; z-index: 2; margin: 0;
  width: min(92vw, 15ch); translate: -50% -50%; text-align: center;
  font-size: clamp(38px, 5.6vw, 80px); font-weight: 600; line-height: 1.02; letter-spacing: -0.045em; text-wrap: balance;
  text-shadow: 0 2px 40px rgba(40, 0, 80, 0.35); opacity: 0; pointer-events: none;
}
.hero__beat em { font-family: var(--serif); font-style: italic; font-weight: 400; letter-spacing: -0.01em; }
.story .hero__glass { will-change: transform, opacity; }
.story [data-layer="back"] { will-change: transform; }
@media (max-width: 900px) {
  .gchip:nth-child(1) { --x: 8% !important; --y: 16% !important; }
  .gchip:nth-child(2) { --x: 36% !important; --y: 26% !important; }
  .gchip:nth-child(3), .gchip:nth-child(4) { display: none; }
  .gchip { font-size: 13px; padding: 8px 12px; }
}

/* ---------- 3. The fixes (peak): deck of old habits that flip into fixes ---------- */
.story .fixes .compare { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.story .fixes .dots--swipe { display: none !important; }
.story .fixes__grid { display: grid; grid-template-columns: 1fr 1.05fr; gap: clamp(32px, 6vw, 96px); align-items: center; }
.story .fixes__head { display: block; margin: 0; }
.story .fixes__head .h2 { margin-bottom: 16px; }
.story .fixes__head .head__aside { justify-self: start; margin-bottom: 28px; }
.story .tally { display: block; margin-bottom: 18px; max-width: 320px; }
.tally p { font-size: 15px; color: var(--muted); margin-bottom: 8px; }
.tally b { color: var(--text); font-weight: 600; font-variant-numeric: tabular-nums; display: inline-block; min-width: 1ch; }
.tally__bar { display: block; height: 4px; border-radius: 2px; background: var(--surface-2); overflow: hidden; }
.tally__bar i { display: block; height: 100%; background: linear-gradient(90deg, #5e17eb, #c4126f, #f36033); transform-origin: left; transform: scaleX(0); transition: transform 500ms var(--ease-out); }
.story .fixlist { display: grid; gap: 8px; }
.fixlist li { display: flex; align-items: center; gap: 10px; font-size: 15px; font-weight: 500; opacity: 0.28; transition: opacity 400ms ease; }
.fixlist li::before { content: ""; flex: none; width: 18px; height: 18px; border-radius: 50%; box-shadow: inset 0 0 0 1.5px #c9c9d2; transition: background-color 300ms ease, box-shadow 300ms ease; }
.fixlist li.is-lit { opacity: 1; }
.fixlist li.is-lit::before { background: var(--purple) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5.5 10.5l3 3 6-7' fill='none' stroke='white' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 14px no-repeat; box-shadow: none; }

.story .deck { display: block; position: relative; height: clamp(300px, 44svh, 380px); perspective: 1400px; }
.story .deck::before { content: ""; position: absolute; inset: -22% -18%; z-index: -1; pointer-events: none; border-radius: 50%;
  background: radial-gradient(closest-side, rgba(168, 22, 155, 0.28), rgba(243, 96, 51, 0.12) 55%, transparent);
  opacity: calc(0.15 + var(--glow, 0) * 0.85); transform: scale(calc(0.8 + var(--glow, 0) * 0.25)); transition: opacity 600ms ease, transform 600ms var(--ease-out); }
.fix { position: absolute; inset: 0; transform-style: preserve-3d; will-change: transform, opacity; }
.fix__inner { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; will-change: transform; }
.fix__face {
  position: absolute; inset: 0; border-radius: var(--r-lg); padding: clamp(24px, 3vw, 38px);
  display: flex; flex-direction: column; justify-content: space-between; gap: 16px;
  backface-visibility: hidden; -webkit-backface-visibility: hidden;
}
.fix__old { background: var(--surface); box-shadow: inset 0 0 0 1px var(--line), 0 40px 70px -48px rgba(11,11,15,0.4); }
.fix__new { background: linear-gradient(140deg, #3b0d8c 0%, #5e17eb 48%, #a8169b 100%); color: #fff; transform: rotateY(180deg); box-shadow: 0 40px 80px -40px rgba(94,23,235,0.65); }
.fix__tag { display: inline-flex; align-items: center; gap: 8px; font-size: 14px; font-weight: 600; color: var(--muted); }
.fix__new .fix__tag { color: rgba(255,255,255,0.85); }
.fix__new .fix__tag .ico { width: 16px; height: 16px; }
.fix__face .fix__title { font-size: clamp(24px, 2.7vw, 36px); font-weight: 600; letter-spacing: -0.035em; line-height: 1.08; text-wrap: balance; }
.fix__old .fix__title { color: #3f3f47; }
.fix__strike {
  background-image: linear-gradient(90deg, #5e17eb, #c4126f, #f36033); background-repeat: no-repeat;
  background-position: 0 56%; background-size: calc(var(--s, 0) * 100%) 0.12em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.fix__face p:not(.fix__title) { font-size: 16px; line-height: 1.45; max-width: 36ch; }
.fix__old p { color: var(--muted); }
.fix__new p { color: rgba(255,255,255,0.9); }

/* ---------- 4. Solutions: vertical scroll pans the carousel (desktop) ---------- */
.story .solutions[data-pinned] .head { margin-bottom: clamp(14px, 2.4svh, 28px); }
.story .solutions[data-pinned] .head .h2 { font-size: clamp(30px, 3.6vw, 46px); }
.story .solutions[data-pinned] .carousel__bar { margin-bottom: 14px; }
.story .solutions[data-pinned] .slide__main { padding: clamp(24px, 2.8vw, 40px); }
.story .solutions[data-pinned] .slide h3 { font-size: clamp(26px, 2.8vw, 38px); margin-bottom: 14px; }
.story .solutions[data-pinned] .slide__body { margin-bottom: 20px; }
.story .solutions[data-pinned] .chips-list { margin-bottom: 22px; }
.story .solutions[data-pinned] .result b { font-size: clamp(52px, 6vw, 84px); }
@media (max-height: 820px) { .story .solutions[data-pinned] .slide__label, .story .solutions[data-pinned] .head__aside { display: none; } }
.story .solutions[data-pinned] .carousel__track { overflow: hidden; scroll-snap-type: none; scroll-behavior: auto; }
.story .solutions[data-pinned] .slide { min-height: clamp(340px, calc(100svh - 420px), 500px); transform-origin: left center; transform: scale(calc(0.95 + 0.05 * var(--near, 1))); opacity: calc(0.4 + 0.6 * var(--near, 1)); will-change: transform, opacity; }
.story .solutions[data-pinned] .result img { transform: translateX(calc(var(--off, 0) * -48px)) scale(1.18); will-change: transform; }
.story .solutions[data-pinned] .pan-rail { display: block; height: 2px; margin-top: 18px; background: var(--surface-2); border-radius: 1px; overflow: hidden; }
.pan-rail i { display: block; height: 100%; background: linear-gradient(90deg, #5e17eb, #c4126f, #f36033); transform-origin: left; transform: scaleX(var(--pan, 0)); }

/* ---------- 4b. Industries: the situation & approach converge ---------- */
.story .industries .ind { position: relative; z-index: 2; }
@media (min-width: 861px) {
  .story .industries .ind__bar {
    opacity: calc(0.2 + var(--ind-e, 1) * 0.8);
    transform: translate3d(0, calc((1 - var(--ind-e, 1)) * 18px), 0);
    will-change: transform, opacity;
  }
  .story .industries .ind__stage {
    opacity: calc(0.25 + var(--ind-e, 1) * 0.75);
    transform: translate3d(0, calc((1 - var(--ind-e, 1)) * 28px), 0);
    will-change: transform, opacity;
  }
  .story .industries .ind__arrow {
    transform: scale(calc(0.65 + var(--ind-e, 1) * 0.35));
    will-change: transform;
  }
}

/* ---------- 5. Roleplay: the call builds itself ---------- */
.roleplay { --stage-bg: var(--surface); }
.story .wave { display: inline-flex; align-items: center; gap: 2px; height: 18px; margin-left: auto; }
.story .wave + .sim__live { margin-left: 8px; }
.wave i { width: 3px; height: 100%; border-radius: 2px; background: linear-gradient(#5e17eb, #e8245f); transform: scaleY(calc(0.18 + var(--amp, 0) * 0.82 * var(--h, 0.6))); transition: transform 140ms ease; }
.wave i:nth-child(1) { --h: 0.4; } .wave i:nth-child(2) { --h: 0.8; } .wave i:nth-child(3) { --h: 0.55; } .wave i:nth-child(4) { --h: 1; }
.wave i:nth-child(5) { --h: 0.65; } .wave i:nth-child(6) { --h: 0.9; } .wave i:nth-child(7) { --h: 0.45; }
.sim.is-talking .wave i { animation: talk 420ms ease-in-out infinite alternate; }
.sim.is-talking .wave i:nth-child(odd) { animation-delay: -210ms; }
.sim.is-talking .wave i:nth-child(3n) { animation-duration: 330ms; }
@keyframes talk { from { transform: scaleY(0.2); } to { transform: scaleY(var(--h)); } }
.story .sim__quote .w { opacity: 0.12; transition: opacity 160ms ease; }
.story .sim__quote .w.is-on { opacity: 1; }
.story [data-call-copy] > *, .story .sim, .story .sim__prompt, .story .choice { will-change: transform, opacity; }

/* ---------- 6. AI: the year rolls, the tracks close in ---------- */
.story .year { display: block; font-family: var(--serif); font-style: italic; font-size: clamp(96px, 17vw, 240px); line-height: 0.8; letter-spacing: -0.03em; color: #efe8ff; margin: 0 0 -0.3em; text-align: center; font-variant-numeric: tabular-nums; position: relative; z-index: 0; user-select: none; }
.story .ai .tracks { position: relative; z-index: 1; }
@media (min-width: 761px) {
  .story .ai .track { will-change: transform, opacity; }
  .story .ai .track:first-child { transform: translateX(calc(var(--c, 0) * -110px)) rotate(calc(var(--c, 0) * -3deg)); opacity: calc(1 - var(--c, 0) * 0.7); }
  .story .ai .track:last-child { transform: translateX(calc(var(--c, 0) * 110px)) rotate(calc(var(--c, 0) * 3deg)); opacity: calc(1 - var(--c, 0) * 0.7); }
}

/* ---------- 7. How it works: the line runs through the steps, the team lights up ---------- */
.story .steps-wrap { position: relative; }
.story .steps__line { display: block; position: absolute; left: 0; right: 0; top: 0; height: 2px; background: var(--line); border-radius: 1px; }
.steps__line i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #5e17eb, #a8169b, #e8245f, #f36033); transform-origin: left; transform: scaleX(var(--e, 0)); }
.story .steps li { border-top: 0; position: relative; padding-top: 30px; opacity: calc(0.3 + 0.7 * var(--lit, 0)); }
.story .steps li::before { content: ""; position: absolute; left: 0; top: -5px; width: 12px; height: 12px; border-radius: 50%; background: #fff; box-shadow: inset 0 0 0 2px #d6d6de; transition: background-color 300ms ease, box-shadow 300ms ease; }
.story .steps li.is-lit::before { background: var(--n-color, var(--purple)); box-shadow: 0 0 0 4px #fff, 0 0 0 5px var(--line); }
.story .steps li:nth-child(1) { --n-color: var(--purple); } .story .steps li:nth-child(2) { --n-color: #a8169b; }
.story .steps li:nth-child(3) { --n-color: #e8245f; } .story .steps li:nth-child(4) { --n-color: var(--orange); }
.story .step__n { transform-origin: left bottom; transform: scale(calc(0.78 + 0.22 * var(--lit, 0))); }
.story .team { display: flex; align-items: center; gap: 18px; flex-wrap: wrap; margin-top: clamp(32px, 6svh, 56px); padding-top: 24px; border-top: 1px solid var(--line); }
.team__people { display: flex; gap: 6px; }
.team__people i { width: 16px; height: 16px; border-radius: 50%; background: var(--surface-2); transform: scale(0.7); transition: background-color 400ms ease, transform 400ms var(--ease-out); }
.team__people i.is-on { background: var(--c); transform: none; }
.team__label { display: grid; font-weight: 600; font-size: 17px; letter-spacing: -0.01em; }
.team__label span { grid-area: 1 / 1; transition: opacity 400ms ease, transform 400ms var(--ease-out); }
.team__label span:last-child { opacity: 0; transform: translateY(8px); }
.team.is-done .team__label span:first-child { opacity: 0; transform: translateY(-8px); }
.team.is-done .team__label span:last-child { opacity: 1; transform: none; }
.team__label em { font-family: var(--serif); font-style: italic; font-weight: 400; font-size: 1.15em; }

/* Phones/tablets: steps stay in flow, as a vertical timeline */
@media (max-width: 900px) {
  .story .steps-wrap { padding-left: 30px; }
  .story .steps__line { left: 5px; right: auto; top: 6px; bottom: 6px; width: 2px; height: auto; }
  .story .steps__line i { transform-origin: top; transform: scaleY(var(--e, 0)); }
  .story .steps { display: grid !important; grid-template-columns: 1fr; gap: 28px; margin: 0; padding: 0; overflow: visible; }
  .story .steps > li { flex: none; background: none; border-radius: 0; padding: 0; }
  .story .steps li::before { left: -30px; top: 4px; }
  .story .step__n { font-size: 44px; margin-bottom: 8px; }
  .story .team__people { flex-wrap: wrap; }
}

/* ---------- 9. Close: the panel opens and the thread ties the button ---------- */
.story .final { transform: scale(var(--fs, 1)); transform-origin: 50% 100%; will-change: transform; }
.story .final .final__glass { transform: translateY(var(--fg, 0px)); }

/* ---------- Phones: fixes scene layout ---------- */
@media (max-width: 760px) {
  .story .fixes__grid { grid-template-columns: 1fr; gap: 18px; align-content: center; }
  .story .fixes__head .kicker { font-size: 18px; margin-bottom: 6px; }
  .story .fixes__head .h2 { font-size: clamp(26px, 7.4vw, 32px); margin-bottom: 14px; }
  .story .fixes__head .head__aside, .story .fixlist { display: none; }
  .story .tally { margin-bottom: 0; }
  .story .deck { height: clamp(250px, 40svh, 330px); }
  .fix__face { padding: 22px; }
  .fix__face .fix__title { font-size: clamp(22px, 6.4vw, 28px); }
  .fix__face p:not(.fix__title) { font-size: 15px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .story .fixes__head .kicker { display: none; }
  .story .deck { height: 230px; }
}
