/* ==========================================================================
   LUMI Motion System — Native CSS Scroll-Driven Animations + Progressive Enhancement
   All spatial motion is strictly gated behind prefers-reduced-motion: no-preference.
   Elements default to fully visible so failed scripts never hide content.
   ========================================================================== */

/* Top Prism Scroll Progress Bar */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  z-index: 150;
  background: var(--lumi-prism);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

@media (prefers-reduced-motion: no-preference) {
  /* 1. Native Scroll Progress Bar (scroll()) */
  @supports (animation-timeline: scroll()) {
    @keyframes lumi-progress {
      from {
        transform: scaleX(0);
      }
      to {
        transform: scaleX(1);
      }
    }

    .scroll-progress {
      animation: lumi-progress auto linear both;
      animation-timeline: scroll(block root);
    }
  }

  /* 2. Shrinking Glass Header & Kinetic Hero Aura on Scroll (scroll() + range) */
  @supports ((animation-timeline: scroll()) and (animation-range: 0% 100%)) {
    @keyframes header-compact {
      from {
        min-height: calc(var(--header-height) + env(safe-area-inset-top, 0px));
        background-color: rgba(255, 255, 255, 0.76);
        box-shadow: 0 0 0 rgba(11, 18, 34, 0);
      }
      to {
        min-height: calc(var(--header-height-compact) + env(safe-area-inset-top, 0px));
        background-color: rgba(255, 255, 255, 0.94);
        box-shadow: 0 12px 32px -18px rgba(11, 18, 34, 0.16);
      }
    }

    @keyframes aura-drift {
      from {
        transform: translate3d(0, 0, 0) scale(1);
        opacity: 0.85;
      }
      to {
        transform: translate3d(0, 68px, 0) scale(1.12);
        opacity: 0.42;
      }
    }

    .site-header {
      animation: header-compact auto linear both;
      animation-timeline: scroll(block root);
      animation-range: 0px 150px;
    }

    .hero-aura {
      animation: aura-drift auto linear both;
      animation-timeline: scroll(block root);
      animation-range: 0px 620px;
    }
  }

  /* 3. Native Scroll-Driven Viewport Reveals (view() + entry range) */
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    @keyframes reveal-rise {
      from {
        opacity: 0.18;
        transform: translate3d(0, 34px, 0) scale(0.985);
      }
      to {
        opacity: 1;
        transform: translate3d(0, 0, 0) scale(1);
      }
    }

    @keyframes reveal-clip {
      from {
        opacity: 0.25;
        clip-path: inset(0 0 22% 0 round 20px);
        transform: translate3d(0, 22px, 0);
      }
      to {
        opacity: 1;
        clip-path: inset(0 0 0% 0 round 20px);
        transform: translate3d(0, 0, 0);
      }
    }

    @keyframes reveal-slide-inline {
      from {
        opacity: 0.22;
        transform: translate3d(-24px, 0, 0);
      }
      to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
      }
    }

    .reveal-rise {
      animation: reveal-rise auto linear both;
      animation-timeline: view();
      animation-range: entry 4% cover 28%;
    }

    .reveal-clip {
      animation: reveal-clip auto linear both;
      animation-timeline: view();
      animation-range: entry 4% cover 30%;
    }

    .reveal-slide {
      animation: reveal-slide-inline auto linear both;
      animation-timeline: view();
      animation-range: entry 6% cover 28%;
    }
  }

  /* 4. Authored Hero First-Paint Entrance (short, confident exponential ease-out) */
  @keyframes hero-enter {
    from {
      opacity: 0;
      transform: translate3d(0, 18px, 0);
    }
    to {
      opacity: 1;
      transform: translate3d(0, 0, 0);
    }
  }

  .hero-animate {
    animation: hero-enter var(--dur-hero) var(--ease-out-expo) both;
  }

  .hero-animate-delay-1 {
    animation-delay: 80ms;
  }

  .hero-animate-delay-2 {
    animation-delay: 160ms;
  }

  .hero-animate-delay-3 {
    animation-delay: 230ms;
  }

  /* 5. Native FAQ Accordion Smooth Expand/Collapse */
  .faq-item summary::before {
    transition: rotate 220ms var(--ease-out-expo);
  }

  .faq-item::details-content {
    interpolate-size: allow-keywords;
    overflow: clip;
    contain: layout;
    transition:
      block-size var(--dur-base) var(--ease-in-out-smooth),
      content-visibility var(--dur-base) var(--ease-in-out-smooth),
      opacity var(--dur-base) ease;
    transition-behavior: allow-discrete;
  }

  .faq-item:not([open])::details-content {
    block-size: 0;
    opacity: 0;
  }

  .faq-item[open]::details-content {
    opacity: 1;
  }

  /* 6. Interactive Spotlight Surface on Fine Pointers */
  @media (hover: hover) and (pointer: fine) {
    .spotlight-card::after {
      content: "";
      position: absolute;
      inset: 0;
      pointer-events: none;
      opacity: 0;
      background: radial-gradient(
        340px circle at var(--spot-x, 50%) var(--spot-y, 50%),
        rgba(109, 74, 255, 0.08),
        rgba(236, 47, 150, 0.04) 42%,
        transparent 72%
      );
      transition: opacity var(--dur-base) ease;
    }

    .spotlight-card:hover::after {
      opacity: 1;
    }
  }

  /* 7. Fallback states when JS IntersectionObserver handles scroll reveals */
  .js-scroll-fallback .reveal-rise,
  .js-scroll-fallback .reveal-clip,
  .js-scroll-fallback .reveal-slide {
    opacity: 0;
    transform: translate3d(0, 26px, 0);
    transition:
      opacity 560ms var(--ease-out-expo),
      transform 560ms var(--ease-out-expo);
  }

  .js-scroll-fallback .reveal-rise.is-visible,
  .js-scroll-fallback .reveal-clip.is-visible,
  .js-scroll-fallback .reveal-slide.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0);
  }
}

/* New lead arrival micro-animation inside CRM */
@keyframes lead-pop {
  from {
    opacity: 0;
    transform: translate3d(0, -10px, 0) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
  }
}

@media (prefers-reduced-motion: no-preference) {
  .lead-just-added {
    animation: lead-pop 380ms var(--ease-out-expo) both;
  }
}
