/* ============================================================
   OwnSwing motion layer (2026-11)
   - Static layout for new pieces first (sticky CTA, closing CTA, replay
     stage). These apply to everyone, including reduced motion.
   - Every moving thing lives inside @media (prefers-reduced-motion:
     no-preference) and is gated on .js, so with reduced motion or without
     JavaScript the page is complete and still.
   - Only transform / opacity (and the individual translate / scale
     properties, which compose with transform) are animated.
   ============================================================ */

/* ---------- Header scroll progress ---------- */
.scroll-progress { position: absolute; left: 0; right: 0; bottom: -1px; height: 2px; pointer-events: none; opacity: 0; transform-origin: 0 50%; transform: scaleX(var(--sp, 0)); background: linear-gradient(90deg, var(--teal), var(--teal-bright) 60%, #7FE7DF); transition: opacity .35s; }
header.site.scrolled .scroll-progress { opacity: 1; }
header.site.menu-open .scroll-progress { opacity: 0; }

/* ---------- Sticky beta CTA ---------- */
.sticky-cta {
  position: fixed; z-index: 90; left: 50%; bottom: calc(16px + env(safe-area-inset-bottom, 0px));
  display: inline-flex; align-items: center; justify-content: center; gap: 10px; min-height: 52px; max-width: calc(100vw - 32px);
  padding: 14px 24px 14px 20px; border-radius: 999px; white-space: nowrap;
  font-weight: 800; font-size: 15.5px; letter-spacing: -.005em; color: #04211d;
  background: linear-gradient(120deg, var(--teal-bright), var(--teal));
  box-shadow: 0 16px 40px rgba(0,0,0,.45), 0 8px 30px rgba(14,154,144,.45), inset 0 1px 0 rgba(255,255,255,.35);
  transform: translate(-50%, calc(100% + 40px)); opacity: 0; visibility: hidden; pointer-events: none;
  transition: transform .45s cubic-bezier(.2,.8,.2,1), opacity .3s ease, visibility 0s linear .45s, box-shadow .2s;
}
.sticky-cta.show { transform: translate(-50%, 0); opacity: 1; visibility: visible; pointer-events: auto; transition: transform .5s cubic-bezier(.16,1,.3,1), opacity .3s ease, visibility 0s, box-shadow .2s; }
.sticky-cta:hover, .sticky-cta:focus-visible { color: #04211d; box-shadow: 0 18px 48px rgba(14,154,144,.6), inset 0 1px 0 rgba(255,255,255,.35); }
.sticky-cta:focus-visible { outline: 2px solid #fff; outline-offset: 3px; }
.sticky-cta svg { width: 18px; height: 18px; flex: none; }
.sticky-cta .dot { background: #04211d; animation: none; box-shadow: none; }
header.site.menu-open ~ .sticky-cta { opacity: 0; visibility: hidden; pointer-events: none; }
/* Desktop: the fixed header's own Apply button is always on screen, so no
   floating pill (it would sit over content); the header button pulses once
   the hero's button has scrolled away instead. */
@media (min-width: 901px) {
  .sticky-cta { display: none; }
  .nav-links .beta-cta { position: relative; }
  .nav-links .beta-cta::after { content: ""; position: absolute; inset: 0; border-radius: 999px; border: 2px solid var(--teal-bright); opacity: 0; pointer-events: none; }
}

/* ---------- Closing CTA ---------- */
.final-cta { padding-top: 40px; }
.final-card {
  position: relative; isolation: isolate; overflow: hidden; text-align: center;
  max-width: 980px; margin: 0 auto; padding: 76px 40px 64px; border-radius: 32px;
  background: linear-gradient(170deg, #0c2a25, #061513 70%);
  border: 1px solid rgba(78,205,196,.3);
  box-shadow: 0 50px 110px rgba(0,0,0,.5), inset 0 1px 0 rgba(255,255,255,.08);
}
/* soft teal glow from the top edge (breathes when motion is allowed) */
.final-card::after {
  content: ""; position: absolute; z-index: -1; left: 50%; top: -260px; width: 820px; height: 520px; margin-left: -410px; pointer-events: none;
  background: radial-gradient(closest-side, rgba(78,205,196,.26), transparent);
}
/* a light sheen that passes across the card */
.final-card::before {
  content: ""; position: absolute; z-index: -1; inset: 0; pointer-events: none; translate: -100% 0;
  background: linear-gradient(105deg, transparent 35%, rgba(127,231,223,.09) 50%, transparent 65%);
}
.final-card h2 { font-size: clamp(32px, 5vw, 56px); font-weight: 800; letter-spacing: -.035em; line-height: 1.04; max-width: 760px; margin: 0 auto; }
.final-card p { color: var(--text-soft); font-size: 18px; margin: 20px auto 34px; max-width: 520px; }
.final-card .kicker { margin-bottom: 18px; }
@media (max-width: 520px) {
  .final-card { padding: 54px 20px 46px; border-radius: 24px; }
  .final-card p { font-size: 16px; }
  .final-card .beta-cta, .final-card .btn { width: 100%; justify-content: center; }
}

/* ---------- Hero on small / short phones: the beta button stays on the first screen ---------- */
@media (max-width: 380px) {
  .hero .eyebrow { font-size: 10px; letter-spacing: .1em; padding: 6px 11px; gap: 7px; }
}
@media (max-width: 760px) and (max-height: 700px) {
  .hero { padding-top: 92px; padding-bottom: 44px; }
  .hero h1 { margin-top: 14px; font-size: clamp(36px, 11vw, 48px); }
  .hero p.lead { font-size: 15.5px; line-height: 1.55; margin: 14px 0 18px; }
  .hero-cta { gap: 10px; }
  .hero-note { margin-top: 14px; }
}

/* ---------- 3D replay stage (static layout) ---------- */
.replay-copy .sub { margin-top: 18px; }
.replay-stage { position: relative; }
.rp-phone { position: relative; z-index: 1; }
.rp-angle { display: none; }
.rp-track { width: min(340px, 100%); position: relative; z-index: 1; }
.rp-bar { height: 4px; border-radius: 99px; background: rgba(255,255,255,.1); overflow: hidden; }
.rp-bar i { display: block; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--teal), var(--teal-bright)); transform-origin: 0 50%; }
.rp-track ol { list-style: none; display: flex; justify-content: space-between; margin-top: 9px; }
.rp-track li { font-size: 11px; font-weight: 800; letter-spacing: .12em; text-transform: uppercase; color: var(--teal-bright); }
@media (min-width: 901px) {
  .rp-angle {
    display: block; position: absolute; z-index: 0; right: -2%; top: 12%; width: 47%; margin: 0;
    border-radius: 18px; overflow: hidden; box-shadow: 0 30px 70px rgba(0,0,0,.55), 0 0 0 1px rgba(255,255,255,.1);
  }
  .rp-angle img { width: 100%; height: auto; display: block; }
  .rp-angle span { position: absolute; right: 10px; bottom: 9px; font-size: 11px; font-weight: 700; letter-spacing: .06em; color: #fff; background: rgba(6,21,19,.72); padding: 3px 9px; border-radius: 999px; backdrop-filter: blur(8px); }
  .replay-stage .rp-phone { margin-right: 18%; }
}
@media (min-width: 1380px) {
  .rp-angle { right: -9%; width: 52%; }
}

/* ---------- Word-split headings (structure only; motion below) ---------- */
.ws .w { display: inline-block; }
/* gradient words carry their own gradient so they can move independently */
.ws .grad-text { background: none; color: inherit; padding-bottom: 0; }
.ws .grad-text .w { background: linear-gradient(115deg, var(--teal-bright) 10%, #7FE7DF 55%, var(--teal)); -webkit-background-clip: text; background-clip: text; color: transparent; padding-bottom: .1em; margin-bottom: -.1em; }

/* Anchor landing: html's scroll-padding-top already clears the fixed header;
   the section's own scroll-margin stacked on top of it and left ~85px of
   the previous section showing above the application. */
.beta-section { scroll-margin-top: 0; }

/* ---------- Fail-safe: motion.js never ran ---------- */
.motion-failed .reveal { opacity: 1 !important; transform: none !important; }

/* ============================================================
   MOTION (no-preference only)
   ============================================================ */
@media (prefers-reduced-motion: no-preference) {

  /* ---- Reveal variants (one-shot, IntersectionObserver adds .in) ---- */
  .js .reveal.pop { transform: translateY(26px) scale(.94); }
  .js .reveal.from-left { transform: translateX(-46px); }
  .js .reveal.from-right { transform: translateX(46px); }
  .js .reveal.tilt { transform: perspective(1200px) rotateX(16deg) translateY(50px) scale(.96); transform-origin: 50% 100%; }
  .js .reveal.chip-pop { transform: translateY(10px) scale(.7); transition-timing-function: cubic-bezier(.34,1.56,.64,1); transition-duration: .55s; }
  .js .reveal.in { opacity: 1; transform: none; }
  /* staggered groups: JS writes --i (0, 1, 2...) on each child */
  .js [data-stagger] > .reveal { transition-delay: calc(var(--i, 0) * 80ms); }
  .js .chips[data-stagger] > .reveal { transition-delay: calc(var(--i, 0) * 45ms + 120ms); }
  .js .reveal.settled { transition-delay: 0s !important; }

  /* feature icons pop after their card lands */
  .js .feature .ic { scale: .4; opacity: 0; transition: scale .6s cubic-bezier(.34,1.56,.64,1), opacity .3s ease, transform .35s cubic-bezier(.2,.8,.2,1), box-shadow .35s; transition-delay: calc(var(--i, 0) * 80ms + 260ms), calc(var(--i, 0) * 80ms + 260ms), 0s, 0s; }
  .js .feature.in .ic { scale: 1; opacity: 1; }
  /* timeline dots pop in sequence */
  .js .timeline .t-dot { scale: .3; transition: scale .7s cubic-bezier(.34,1.56,.64,1); transition-delay: calc(var(--i, 0) * 80ms + 200ms); }
  .js .timeline li.in .t-dot { scale: 1; }

  /* ---- Word-by-word heading rise ---- */
  .js .ws .w { opacity: 0; translate: 0 .55em; transition: opacity .55s ease, translate .8s cubic-bezier(.16,1,.3,1); transition-delay: calc(var(--wi, 0) * 50ms + 60ms); }
  .js .ws.in .w { opacity: 1; translate: 0 0; }

  /* ---- Hero ---- */
  .js .hero-bg img { animation: heroSettle 2.6s cubic-bezier(.2,.8,.2,1) both; }
  @keyframes heroSettle { from { scale: 1.1; } to { scale: 1; } }
  .btn-shine::after {
    content: ""; position: absolute; inset: 0; z-index: -1; pointer-events: none;
    background: linear-gradient(105deg, transparent 30%, rgba(255,255,255,.5) 50%, transparent 70%);
    translate: -110% 0; animation: shine 5.5s 2.4s ease-in-out infinite;
  }
  @keyframes shine { 0% { translate: -110% 0; } 28%, 100% { translate: 110% 0; } }

  /* ---- Closing CTA: breathing glow + passing sheen ---- */
  .final-card::after { animation: breathe 5s ease-in-out infinite; }
  @keyframes breathe { 0%, 100% { opacity: .6; } 50% { opacity: 1; } }
  .final-card::before { animation: sheen 7s 1s cubic-bezier(.45,0,.3,1) infinite; }
  @keyframes sheen { 0% { translate: -100% 0; } 45%, 100% { translate: 100% 0; } }

  /* ---- Header progress: native scroll timeline where supported ---- */
  @supports (animation-timeline: scroll()) {
    .js:not(.sda-off) .scroll-progress { animation: spGrow linear both; animation-timeline: scroll(root block); }
    @keyframes spGrow { from { transform: scaleX(0); } to { transform: scaleX(1); } }
  }

  /* ---- Sticky CTA dot / header button pulse ---- */
  .sticky-cta .dot { animation: ping 2.2s infinite; }
  @media (min-width: 901px) {
    .js header.site.cta-live .nav-links .beta-cta::after { animation: ringPulse 2.6s cubic-bezier(.2,.8,.2,1) infinite; }
    @keyframes ringPulse { 0% { opacity: .7; transform: scale(1); } 70%, 100% { opacity: 0; transform: scale(1.18, 1.45); } }
  }

  /* ============================================================
     Scroll-scrubbed scenes
     A [data-scrub] element is a timeline root; .scrub descendants animate
     against it over the window --a..--b (0..1) of its --rng range.
     Native: CSS scroll-driven animations (named view timeline).
     Fallback (Firefox, older Safari): motion.js writes the root's
     progress to --p and a paused animation is scrubbed through a
     negative animation-delay. Same keyframes either way.
     ============================================================ */
  [data-scrub] { view-timeline-name: --s; view-timeline-axis: block; --rng: cover; }
  .js .scrub, .js .timeline::before, .js .sc-steps::after {
    animation-duration: 1s; animation-timing-function: linear; animation-fill-mode: both; animation-play-state: paused;
    animation-delay: calc(-1s * clamp(0, (var(--p, 0) - var(--a, 0)) / (var(--b, 1) - var(--a, 0)), 1));
  }
  @supports (animation-timeline: view()) {
    .js:not(.sda-off) .scrub, .js:not(.sda-off) .timeline::before, .js:not(.sda-off) .sc-steps::after {
      animation-play-state: running; animation-delay: 0s; animation-duration: auto; animation-timeline: --s;
      animation-range: var(--rng) calc(var(--a, 0) * 100%) var(--rng) calc(var(--b, 1) * 100%);
    }
  }

  /* Hero: background drifts slower than the page, copy lifts away */
  .hero { --rng: exit; }
  .js .hero-bg { will-change: auto; animation-name: heroBg; }
  @keyframes heroBg { to { translate: 0 18%; } }
  .js .hero-inner { animation-name: heroOut; --a: 0; --b: .8; }
  @keyframes heroOut { to { translate: 0 -70px; opacity: .15; } }

  /* World tiles: image parallax inside each frame */
  .js .world img { scale: 1.16; animation-name: tileDrift; }
  @keyframes tileDrift { from { translate: 0 -6%; } to { translate: 0 6%; } }

  /* Coach photo parallax */
  .js .coach-media img { scale: 1.14; animation-name: tileDrift; }

  /* Ghost race: the phone floats at its own depth over the render */
  @media (min-width: 901px) {
    .js .ghost-media .phone-sm { animation-name: ghostPhone; }
    @keyframes ghostPhone { from { translate: 0 70px; } to { translate: 0 -50px; } }
  }

  /* Showcase rail fills as you read down the four chapters */
  .sc-steps { position: relative; }
  .js .sc-steps::after { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 2px; border-radius: 2px; background: linear-gradient(180deg, var(--teal-bright), var(--teal)); transform-origin: 50% 0; animation-name: railY; --a: .2; --b: .8; box-shadow: 0 0 12px rgba(78,205,196,.5); }
  .js .sc-step.active { border-left-color: rgba(255,255,255,.09); }
  @keyframes railY { from { transform: scaleY(0); } to { transform: none; } }

  /* Day-one timeline line draws itself */
  .js .timeline::before { transform-origin: 0 50%; animation-name: railX; --a: .12; --b: .5; }
  @keyframes railX { from { transform: scaleX(0); } to { transform: none; } }
  @media (max-width: 900px) {
    .js .timeline::before { transform-origin: 50% 0; animation-name: railY; --a: .1; --b: .6; }
  }

  /* ---- 3D replay: pinned + scrubbed on roomy screens ---- */
  @media (min-width: 901px) and (min-height: 640px) {
    .replay { height: 230vh; padding: 0; --rng: contain; }
    .replay-pin { position: sticky; top: 0; height: 100vh; height: 100svh; display: flex; align-items: center; padding-top: 76px; overflow: clip; }
    .replay-pin > .container { width: 100%; }
    .replay .phone { width: min(300px, calc((100svh - 230px) * .53)); }
    .js .replay .phone-stage.in .phone { animation: none; }
    .js .rp-phone { animation-name: rpPhone; --a: 0; --b: .38; will-change: transform; }
    @keyframes rpPhone { from { transform: perspective(1400px) rotateX(18deg) rotateY(-24deg) rotateZ(-3deg) translateY(40px) scale(.84); } to { transform: none; } }
    .js .rp-angle { animation-name: rpAngle; --a: .34; --b: .64; }
    @keyframes rpAngle { from { opacity: 0; transform: translate(70px, 50px) rotate(7deg) scale(.82); } to { opacity: 1; transform: none; } }
    .js .rp-bar i { animation-name: rpFill; --a: .08; --b: .86; }
    @keyframes rpFill { from { transform: scaleX(0); } to { transform: none; } }
    .js .rp-track li { animation-name: rpLit; }
    .js .rp-track li:nth-child(1) { --a: .06; --b: .12; }
    .js .rp-track li:nth-child(2) { --a: .32; --b: .38; }
    .js .rp-track li:nth-child(3) { --a: .58; --b: .64; }
    .js .rp-track li:nth-child(4) { --a: .80; --b: .86; }
    @keyframes rpLit { from { opacity: .35; } to { opacity: 1; } }
    .js .rp-step { animation-name: rpStep; }
    .js .rp-step:nth-child(1) { --a: .04; --b: .16; }
    .js .rp-step:nth-child(2) { --a: .30; --b: .42; }
    .js .rp-step:nth-child(3) { --a: .56; --b: .68; }
    @keyframes rpStep { from { opacity: .7; translate: -10px 0; } to { opacity: 1; translate: 0 0; } }
  }
  /* Phones / short screens: the replay plays itself once it is on screen */
  @media (max-width: 900px), (max-height: 639px) {
    .js .rp-bar i { transform: scaleX(0); }
    .js .replay-stage.in .rp-bar i { animation: rpLoop 4.6s .4s cubic-bezier(.45,0,.3,1) infinite; }
    .js .replay-stage.in .rp-track li { animation: rpLbl0 4.6s .4s linear infinite; }
    .js .replay-stage.in .rp-track li:nth-child(2) { animation-name: rpLbl1; }
    .js .replay-stage.in .rp-track li:nth-child(3) { animation-name: rpLbl2; }
    .js .replay-stage.in .rp-track li:nth-child(4) { animation-name: rpLbl3; }
    @keyframes rpLoop { 0% { transform: scaleX(0); opacity: 1; } 70%, 88% { transform: none; opacity: 1; } 100% { transform: none; opacity: 0; } }
    @keyframes rpLbl0 { 0% { opacity: .35; } 3%, 88% { opacity: 1; } 100% { opacity: .35; } }
    @keyframes rpLbl1 { 0%, 22% { opacity: .35; } 26%, 88% { opacity: 1; } 100% { opacity: .35; } }
    @keyframes rpLbl2 { 0%, 45% { opacity: .35; } 49%, 88% { opacity: 1; } 100% { opacity: .35; } }
    @keyframes rpLbl3 { 0%, 67% { opacity: .35; } 71%, 88% { opacity: 1; } 100% { opacity: .35; } }
    .js .replay-stage .rp-phone { opacity: 0; transform: perspective(1200px) rotateX(16deg) rotateY(-14deg) translateY(40px) scale(.9); transition: opacity .7s ease, transform 1.1s cubic-bezier(.16,1,.3,1); }
    .js .replay-stage.in .rp-phone { opacity: 1; transform: none; }
  }
}

/* Reduced motion: final states, nothing moves. */
@media (prefers-reduced-motion: reduce) {
  .js .scrub, .js .timeline::before, .js .sc-steps::after, .btn-shine::after, .final-card::before, .final-card::after { animation: none !important; }
  .scroll-progress { display: none; }
  .sticky-cta, .sticky-cta.show { transition: none; }
}
