/* ============================================================================
   Homepage motion — CSS side.
   Everything here only applies while <html> has the class "m-on", which the
   inline script in <head> adds when the visitor allows motion.

   - The hero intro is pure CSS (keyframes) so it starts on the very first
     frame without waiting for any JavaScript — this keeps LCP fast.
   - Section entrances and line drawing are CSS transitions; js/motion.js only
     adds the class "is-in" when an element scrolls into view.
   - The pinned/scrubbed effects (K reveal on desktop, chip parallax) are
     driven by GSAP in js/motion.js.

   Safety:
   - No JS, or prefers-reduced-motion → "m-on" is never added → static page.
   - Scripts fail within 3 s          → inline script swaps "m-on" for "m-off".
   ========================================================================== */

:root {
  --m-ease: cubic-bezier(.2, .7, .2, 1);   /* soft "expo-out" feel */
  --m-ease-in-out: cubic-bezier(.65, 0, .35, 1);
  --m-fade: .8s;                            /* section entrance duration */
  --m-stagger: 90ms;                        /* delay between staggered items */
  --m-draw: 1.4s;                           /* line-drawing duration */
}

/* 1. HERO INTRO (CSS only) -------------------------------------------------- */
@keyframes mLineUp { from { transform: translateY(110%); } to { transform: none; } }
@keyframes mFadeUp { from { opacity: 0; transform: translateY(20px); } to { opacity: 1; transform: none; } }
@keyframes mSettle { from { transform: scale(1.08); } to { transform: scale(1); } }

.m-on [data-m-hero-line] { animation: mLineUp 1.05s cubic-bezier(.16, 1, .3, 1) both; animation-delay: .12s; }
.m-on .mline + .mline [data-m-hero-line] { animation-delay: .24s; }
.m-on [data-m-hero-fade] { animation: mFadeUp .8s var(--m-ease) both; animation-delay: .7s; }
.m-on .hero2__content > [data-m-hero-fade]:first-child { animation-delay: 0s; }   /* kicker */
.m-on .hero2__ctas[data-m-hero-fade] { animation-delay: .82s; }
.m-on .hero2__note[data-m-hero-fade] { animation-delay: .94s; }
.m-on [data-hero-img] { animation: mSettle 2.4s cubic-bezier(.25, .1, .25, 1) both; }

/* 2. SECTION ENTRANCES — fade + 20px slide-up, staggered ---------------------- */
.m-on [data-m-fade],
.m-on [data-m-stagger] > * {
  opacity: 0; transform: translateY(20px);
  transition: opacity var(--m-fade) var(--m-ease), transform var(--m-fade) var(--m-ease);
}
.m-on [data-m-stagger] > * { transition-delay: calc(var(--i, 0) * var(--m-stagger)); }
.m-on [data-m-fade].is-in,
.m-on [data-m-stagger].is-in > * { opacity: 1; transform: none; }

/* 3. SELF-DRAWING LINES — js/motion.js sets each path's length once ---------- */
.m-on [data-m-draw] path { transition: stroke-dashoffset var(--m-draw) var(--m-ease-in-out); transition-delay: calc(var(--i, 0) * 120ms); }
.m-on [data-m-draw]:not(.is-measured) path { opacity: 0; }   /* avoid a flash before measuring */
.m-on [data-m-draw].is-in path { stroke-dashoffset: 0 !important; }

/* 4. K-LOGO OVERLAY — visible from the first frame on motion-enabled devices
      (prevents a white flash); js/motion.js runs and then removes it. ------- */
.m-on .kmask { display: block; }

/* Motion off: never hide content */
.m-off [data-m-hero-line], .m-off [data-m-hero-fade], .m-off [data-hero-img] { animation: none !important; }
.m-off [data-m-fade], .m-off [data-m-stagger] > * { opacity: 1 !important; transform: none !important; }
.m-off [data-m-draw] path { stroke-dasharray: none !important; stroke-dashoffset: 0 !important; opacity: 1 !important; }
.m-off .kmask { display: none !important; }

@media (prefers-reduced-motion: reduce) {
  .kmask { display: none !important; }
  .scard__media > img, .chip, .scard__arrow { transition: none !important; }
  .annbar__dot { animation: none; }
}

/* 5. STAGE 2 ---------------------------------------------------------------- */
/* Project images open from an inset mask */
.m-on [data-m-mask] { clip-path: inset(10% 8% 10% 8% round 12px); transition: clip-path 1.2s var(--m-ease); }
.m-on .is-in [data-m-mask], .m-on [data-m-mask].is-in { clip-path: inset(0 0 0 0 round 12px); }

/* "How it works" connecting line: draws once in view (desktop: scrubbed by GSAP) */
.m-on [data-how-line] { transform: scaleY(0); transition: transform 1.6s var(--m-ease-in-out) .2s; }
@media (min-width: 900px) { .m-on [data-how-line] { transform: scaleX(0); } }
.m-on [data-how].is-in [data-how-line] { transform: none; }

/* Testimonial slider: no sliding animation for reduced-motion users */
@media (prefers-reduced-motion: reduce) { .js .tslider__track { transition: none; } }

.m-off [data-m-mask] { clip-path: none !important; }
.m-off [data-how-line] { transform: none !important; }

/* K reveal: stats are hidden while the logo zooms (js/motion.js adds .k-pending), then fade in and count up.
   Gated by .m-on, so with reduced motion / no JS / the 3s safety net they are always visible. */
.m-on [data-kreveal].k-pending .statgrid { opacity: 0; visibility: hidden; }
.m-on [data-kreveal] .statgrid { transition: opacity .6s ease, visibility .6s; }
