/* =========================================================
   MOTION LAYER (Phase 2 visual upgrades)
   Shared by index, team and provider pages. Pairs with motion.js.
   Every effect is opt-in via prefers-reduced-motion: no-preference,
   so visitors who ask for less motion get a static, fully visible page.
   Only transform / opacity / clip-path are animated (GPU friendly).
========================================================= */

:root {
  --ease-out-soft: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in-out-soft: cubic-bezier(0.65, 0, 0.35, 1);
}

/* ---- Scroll progress hairline (element injected by motion.js) ---- */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 2px;
  z-index: 2000;
  background: var(--gold, #B8975A);
  transform-origin: 0 50%;
  transform: scaleX(0);
  pointer-events: none;
}

/* Parallax wrappers must fill their frame even when motion is off */
[data-parallax] { height: 100%; }
[data-parallax] > img { width: 100%; height: 100%; object-fit: cover; }

@media (prefers-reduced-motion: no-preference) {
  html { scroll-behavior: smooth; }

  /* ---- Generic reveal (data-reveal set in markup or by motion.js) ---- */
  .js-motion [data-reveal],
  .js-motion .provider-bio > :not(.gold-rule) {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
    transition: opacity 0.9s var(--ease-out-soft), transform 0.9s var(--ease-out-soft);
    transition-delay: calc(var(--reveal-i, 0) * 90ms);
  }
  .js-motion [data-reveal="fade"] { transform: none; }
  .js-motion .provider-bio > .btn-gold.is-revealed:hover { opacity: 0.85; }
  .js-motion [data-reveal].is-revealed,
  .js-motion .provider-bio > .is-revealed {
    opacity: 1;
    transform: none;
  }

  /* ---- Image curtain reveal: photo unmasks bottom-up while settling from a slight zoom.
     The clip sits on the frame's child, not the frame itself, because
     IntersectionObserver treats a fully clipped element as never visible. ---- */
  .js-motion [data-reveal="image"] {
    opacity: 1;
    transform: none;
  }
  .js-motion [data-reveal="image"] > * {
    clip-path: inset(100% 0 0 0);
    transition: clip-path 1.2s var(--ease-in-out-soft);
    transition-delay: calc(var(--reveal-i, 0) * 120ms);
  }
  .js-motion [data-reveal="image"] img {
    transform: scale(1.12);
    transition: transform 1.6s var(--ease-out-soft);
    transition-delay: calc(var(--reveal-i, 0) * 120ms);
  }
  .js-motion [data-reveal="image"].is-revealed > * { clip-path: inset(0 0 0 0); }
  .js-motion [data-reveal="image"].is-revealed img { transform: scale(1); }

  /* ---- Gold hairlines draw in from the left ---- */
  .js-motion .gold-rule,
  .js-motion .about-divider,
  .js-motion .hero-rule {
    transform: scaleX(0);
    transform-origin: 0 50%;
    transition: transform 1.1s var(--ease-out-soft) 0.2s;
  }
  .js-motion .about-divider { transform-origin: 50% 50%; }
  .js-motion .gold-rule.is-revealed,
  .js-motion .about-divider.is-revealed,
  .js-motion .hero-rule.is-revealed { transform: scaleX(1); }

  /* ---- Home hero: staggered entrance on load ---- */
  .js-motion .hero-inner > * {
    opacity: 0;
    transform: translate3d(0, 22px, 0);
    animation: motion-rise 1s var(--ease-out-soft) forwards;
  }
  .js-motion .hero-inner > *:nth-child(2) { animation-delay: 0.12s; }
  .js-motion .hero-inner > *:nth-child(3) { animation-delay: 0.24s; }
  .js-motion .hero-inner > *:nth-child(4) { animation-delay: 0.36s; }
  .js-motion .hero-inner > *:nth-child(5) { animation-delay: 0.48s; }
  .js-motion .hero-inner > .hero-rule { transform: scaleX(0); animation: motion-draw 1.1s var(--ease-out-soft) forwards; }

  /* ---- Provider pages: hero portrait settles in, text rises ---- */
  .js-motion .provider-hero-bg {
    animation: motion-settle 1.8s var(--ease-out-soft) both;
  }
  .js-motion .provider-hero-content > * {
    opacity: 0;
    animation: motion-rise 1s var(--ease-out-soft) forwards;
  }
  .js-motion .provider-hero-content > *:nth-child(2) { animation-delay: 0.12s; }
  .js-motion .provider-hero-content > *:nth-child(3) { animation-delay: 0.24s; }
  .js-motion .provider-hero-content > *:nth-child(4) { animation-delay: 0.36s; }

  /* ---- Provider avatars: soft zoom and gold ring on hover ---- */
  .provider-avatar {
    transition: box-shadow 0.5s var(--ease-out-soft);
  }
  .provider-avatar img {
    transition: transform 0.9s var(--ease-out-soft);
  }
  .provider-card:hover .provider-avatar,
  .provider-card:focus-visible .provider-avatar {
    box-shadow: 0 0 0 2px rgba(250, 247, 242, 0.9), 0 0 0 5px var(--gold, #B8975A);
  }
  .provider-card:hover .provider-avatar img,
  .provider-card:focus-visible .provider-avatar img { transform: scale(1.06); }

  /* ---- Parallax: a wrapper inside a clipped frame drifts slower than the page.
     motion.js sets --parallax-y; the 1.1 scale keeps the frame edges covered. ---- */
  [data-parallax] {
    transform: translate3d(0, var(--parallax-y, 0px), 0) scale(1.1);
    will-change: transform;
  }
}

@keyframes motion-rise {
  from { opacity: 0; transform: translate3d(0, 22px, 0); }
  to { opacity: 1; transform: none; }
}
@keyframes motion-draw {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
@keyframes motion-settle {
  from { opacity: 0; transform: scale(1.06); }
  to { opacity: 1; transform: scale(1); }
}

/* Reduced motion: show everything, including the legacy .fade-up blocks on index */
@media (prefers-reduced-motion: reduce) {
  .fade-up { opacity: 1 !important; transform: none !important; transition: none !important; }
  .scroll-progress { display: none; }
}
