/* =====================================================
   HOMEPAGE MOTION (index.html only)
   Pairs with assets/js/home-motion.js (GSAP + ScrollTrigger + Lenis).
   Everything here is gated on html.js-motion, which is only set when
   the visitor has not asked for reduced motion and the libraries
   loaded. Without it the page is the plain site.
===================================================== */

/* ---- Lenis smooth scroll ---- */
html.lenis, html.lenis body { height: auto; }
.lenis.lenis-smooth { scroll-behavior: auto !important; }
.lenis.lenis-stopped { overflow: clip; }

/* ---- Hero: GSAP runs the entrance instead of the CSS keyframes ---- */
.js-motion .hero-content > *,
.js-motion .hero-art { animation: none; opacity: 0; }

/* Headline lines rise out of a mask */
.ln { display: block; overflow: hidden; padding-bottom: 0.14em; margin-bottom: -0.14em; }
.ln-in { display: block; will-change: transform; }

/* Depth: the dot grid drifts slower than the page, the glow follows the pointer */
.js-motion .hero::before {
  inset: -140px 0 0;
  transform: translate3d(0, var(--hero-py, 0px), 0);
}
.hero-glow {
  position: absolute;
  top: 0;
  left: 0;
  width: 620px;
  height: 620px;
  margin: -310px 0 0 -310px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(78, 203, 160, 0.11), transparent 62%);
  pointer-events: none;
  z-index: 0;
  opacity: 0;
}

/* ---- Cards: a light that follows the pointer ---- */
.js-motion .outcome,
.js-motion .pricing-cell { position: relative; overflow: hidden; isolation: isolate; }
.js-motion .outcome::before,
.js-motion .pricing-cell::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: -1;
  background: radial-gradient(280px circle at var(--mx, 50%) var(--my, 50%), rgba(78, 203, 160, 0.16), transparent 68%);
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.js-motion .outcome:hover::before,
.js-motion .pricing-cell:hover::before { opacity: 1; }
.outcome.is-entering { transition: none !important; }

/* Softer corners where the page still had square ones */
.pricing-grid { border-radius: 18px; overflow: hidden; }
.modal { border-radius: 20px; }

/* ---- How it works: the line draws, the dots light up in turn ---- */
.js-motion .steps::after {
  background: var(--spearmint);
  opacity: 0.5;
  transform: scaleX(var(--draw, 0));
  transform-origin: left center;
}
.js-motion .step-tag::before {
  background: rgba(78, 203, 160, 0.28);
  transition: background 0.4s ease, box-shadow 0.4s ease, transform 0.4s var(--ease);
}
.js-motion .step.is-lit .step-tag::before {
  background: var(--spearmint);
  box-shadow: 0 0 0 5px rgba(78, 203, 160, 0.16);
  transform: scale(1.15);
}
.js-motion .step h3,
.js-motion .step p { transition: opacity 0.5s ease; }
.js-motion .steps.is-staged .step:not(.is-lit) h3,
.js-motion .steps.is-staged .step:not(.is-lit) p { opacity: 0.45; }

/* ---- FAQ: answers open and close smoothly ---- */
.faq-item.is-closing summary::after { transform: rotate(45deg); }

/* ---- CTA: the glow builds as you arrive ---- */
.js-motion .cta-band::before { opacity: var(--glow, 1); }
.magnet { display: inline-block; }

/* ---- Buttons: one pass of light on hover ---- */
@media (prefers-reduced-motion: no-preference) {
  .btn { position: relative; overflow: hidden; }
  .btn::after {
    content: '';
    position: absolute;
    top: 0;
    bottom: 0;
    left: -60%;
    width: 45%;
    background: linear-gradient(100deg, transparent, rgba(255, 255, 255, 0.38), transparent);
    transform: skewX(-18deg);
    opacity: 0;
    pointer-events: none;
  }
  .btn:hover::after { opacity: 1; left: 120%; transition: left 0.7s var(--ease); }
}

/* =====================================================
   PATCH, THE SCROLL COMPANION
   Wide screens: he leaves the hero, rides a rail down the right
   gutter, reacts at each section and docks into the chat button
   at the bottom. Narrower screens: he hops from the hero into the
   chat button, which then reacts and shows scroll progress.
===================================================== */
.pg {
  position: fixed;
  inset: 0;
  z-index: 490; /* under the chat button (500), panel (550) and modal (600) */
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}
.pg.is-on { opacity: 1; }

/* Hand-over between the travelling Patch and the chat button */
.pg-on .patch-chat { transition: opacity 0.14s linear; }
.pg-on .patch-chat.is-hidden { transform: none; }
.pg-flying .ph-patch { visibility: hidden; }

/* The rail */
.pg-rail {
  position: absolute;
  width: 1px;
  background: rgba(78, 203, 160, 0.14);
  opacity: 0;
}
.pg-rail-fill {
  position: absolute;
  left: 0;
  top: 0;
  width: 1px;
  height: 100%;
  background: linear-gradient(180deg, rgba(78, 203, 160, 0), rgba(78, 203, 160, 0.7));
  transform-origin: top;
  transform: scaleY(0);
}
.pg-stop {
  position: absolute;
  left: -3px;
  width: 7px;
  height: 7px;
  margin-top: -3px;
  border-radius: 50%;
  background: #10161E;
  border: 1px solid rgba(78, 203, 160, 0.4);
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.pg-stop.is-passed { background: #4ECBA0; border-color: #4ECBA0; }
.pg-stop.is-here { box-shadow: 0 0 0 4px rgba(78, 203, 160, 0.18); }

/* The ring he lands in (matches the chat button) */
.pg-dock {
  position: absolute;
  border-radius: 50%;
  background: #0D1117;
  border: 1.5px solid #4ECBA0;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.45);
  opacity: 0;
}
.pg-dock--rim { background: none; box-shadow: none; } /* drawn over him, so he drops into it */

/* Patch himself */
.pg-patch {
  position: absolute;
  top: 0;
  left: 0;
  display: block;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  pointer-events: none;
  visibility: hidden;
  -webkit-tap-highlight-color: transparent;
}
.pg-patch.is-out { visibility: visible; pointer-events: auto; }
.pg-patch:focus-visible { outline: 2px solid #4ECBA0; outline-offset: 6px; border-radius: 12px; }
.pg-clip { display: block; }
.pg-figure { display: block; position: relative; aspect-ratio: 208 / 312; transform-origin: 50% 100%; }
.pg-bob { position: absolute; inset: 0; animation: pg-bob 4.5s ease-in-out infinite; }
.pg-patch.is-docking .pg-bob { animation-play-state: paused; }
@keyframes pg-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-4%); } }
.pg-pose { position: absolute; inset: 0; opacity: 0; transition: opacity 0.12s linear; }
.pg-pose.is-on { opacity: 1; }
.pg-pose svg { width: 100%; height: 100%; display: block; overflow: visible; }

/* What he says when you point at him */
.pg-say {
  position: absolute;
  right: calc(100% + 12px);
  top: 22%;
  width: max-content;
  max-width: 230px;
  padding: 10px 14px;
  background: #1E2328;
  border: 1px solid rgba(78, 203, 160, 0.32);
  border-radius: 14px 14px 4px 14px;
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.45);
  color: #E8F4F0;
  font: 500 14px/1.4 Figtree, -apple-system, "Segoe UI", sans-serif;
  text-align: left;
  opacity: 0;
  transform: translateX(8px) scale(0.97);
  transform-origin: right center;
  transition: opacity 0.2s ease, transform 0.25s var(--ease, ease);
  pointer-events: none;
}
.pg-say b { display: block; margin-top: 3px; font-weight: 600; font-size: 12.5px; color: #4ECBA0; }
.pg-patch.is-riding:hover .pg-say,
.pg-patch.is-riding:focus-visible .pg-say { opacity: 1; transform: none; }

/* Narrower screens: the chat button carries the reactions and a progress ring */
.pg-ring {
  position: absolute;
  right: -6px;
  bottom: -6px;
  width: calc(var(--pc-size) + 12px);
  height: calc(var(--pc-size) + 12px);
  transform: rotate(-90deg);
  pointer-events: none;
  display: none;
}
.pg-dockmode .pg-ring { display: block; }
.pg-ring circle { fill: none; stroke-width: 2.5; }
.pg-ring .pg-ring-track { stroke: rgba(78, 203, 160, 0.12); }
.pg-ring .pg-ring-bar { stroke: #4ECBA0; stroke-linecap: round; }
.patch-chat-btn.pg-hop { animation: pg-hop 0.6s cubic-bezier(0.22, 1, 0.36, 1); }
@keyframes pg-hop {
  0%   { transform: translateY(0) scale(1); }
  30%  { transform: translateY(-9px) scale(1.05); }
  62%  { transform: translateY(0) scale(0.97); }
  100% { transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .pg, .pg-ring { display: none !important; }
}
