/* ============================================================================
   Motion styles for /static/js/motion/ (anime.js scroll motion).
   Start states apply only while html.has-motion is set (boot.js) and the
   user has no reduced-motion preference. JS adds .motion-done after a
   reveal and drops its inline styles, so normal CSS (hover) takes over.
   Subtrees inside [data-motion-skip] belong to a page module: the shared
   start states below exclude them with :not([data-motion-skip] *).
   ========================================================================== */

/* ── SCROLL PROGRESS BAR ── */
#scroll-progress {
  position: fixed; top: 0; left: 0; width: 100%; height: 2px;
  z-index: 1001; /* above the nav (z-index 1000) */
  background: linear-gradient(90deg, var(--cyan), var(--red));
  transform: scaleX(0); transform-origin: left;
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  /* ── REVEAL START STATES ── */
  /* no transitions while JS drives the frames; hover transitions return with .motion-done */
  html.has-motion :is(
    [data-motion^="reveal-"], .fade-slide-up, .fade-slide-left, .fade-slide-right,
    [data-motion-stagger] > *, .svc-card, .why-card, .loc-card, .partner-card
  ):not(.motion-done, [data-motion-skip] *) {
    opacity: 0;
    transition: none;
  }

  html.has-motion :is(
    [data-motion="reveal-up"], .fade-slide-up,
    [data-motion-stagger]:not([data-motion-stagger="left"], [data-motion-stagger="right"], [data-motion-stagger="scale"]) > *,
    .svc-card, .loc-card
  ):not(.motion-done, [data-motion-skip] *) {
    transform: translateY(40px);
  }

  html.has-motion :is(
    [data-motion="reveal-left"], .fade-slide-left, [data-motion-stagger="left"] > *, .why-card
  ):not(.motion-done, [data-motion-skip] *) {
    transform: translateX(-40px);
  }

  html.has-motion :is(
    [data-motion="reveal-right"], .fade-slide-right, [data-motion-stagger="right"] > *
  ):not(.motion-done, [data-motion-skip] *) {
    transform: translateX(40px);
  }

  html.has-motion :is(
    [data-motion="reveal-scale"], [data-motion-stagger="scale"] > *, .partner-card
  ):not(.motion-done, [data-motion-skip] *) {
    transform: scale(0.92);
  }

  /* ── SPLIT HEADINGS ── */
  /* hide the heading until splitText runs, then hide each word below its mask */
  html.has-motion [data-motion="split"]:not(.is-split) { opacity: 0; }
  html.has-motion [data-motion="split"]:not(.motion-done) [data-word] { transform: translateY(100%); }

  /* ── HOME: HERO INTRO (home/hero.js adds .motion-done to #hero at the end) ──
     scoped to the home page: the blog hero reuses .hero-tag and .hero-btns */
  /* .hero-text > h1 and > p stay visible: the LCP element must paint at first paint */
  html.has-motion [data-page="home"] #hero:not(.motion-done) :is(
    .hero-tag, .hero-sub, .hero-btns, .hero-stats, .holo-panel, .svc-row
  ) {
    opacity: 0;
  }
  /* background-clip: text on the h1 skips transformed children, so while the
     intro moves the chars, each char carries the headline gradient itself */
  html.has-motion [data-page="home"] #hero:not(.motion-done) .hero-text h1.is-split [data-char] {
    background: linear-gradient(135deg, #fff 0%, var(--cyan) 60%, var(--cyan2) 100%) fixed;
    -webkit-background-clip: text; background-clip: text;
  }
  /* the JS intro replaces the CSS row entrance; a CSS animation would override it */
  html.has-motion [data-page="home"] #hero .svc-row { animation: none; }

  /* ── HOME: SERVICES ON MOBILE (home/services.js reveals them) ── */
  @media (max-width: 768px) {
    html.has-motion .svc-stack > .svc-card:not(.motion-done) {
      opacity: 0;
      transform: translateY(40px);
      transition: none;
    }
  }

  /* ── HOME: CTA BANNERS (home/accents.js draws the line, then the content) ── */
  html.has-motion .cta-banner:not(.motion-done) .cta-banner-line { transform: scaleY(0); }
  html.has-motion .cta-banner:not(.motion-done) :is(.cta-banner-text, .cta-banner-btns) { opacity: 0; }
}

/* word mask: each word rises inside a clipped box; the padding keeps descenders */
.motion-word-mask {
  overflow: clip;
  padding-bottom: 0.1em; margin-bottom: -0.1em;
}
