/**
 * Jewaar landing motion styles — companion to js/motion.js.
 *
 * Everything here is scoped behind .motion-on (set by motion.js only when GSAP
 * loaded and the visitor has not asked for reduced motion), so the base
 * experience in css/styles.css is untouched when motion is off.
 */

/*
 * Lenis drives scrolling — native smooth scroll would fight it.
 * vendor/lenis.css supplies Lenis's own required rules (height:auto on
 * html/body, scroll-behavior:auto, overflow:clip when stopped). These are the
 * Jewaar-side additions only.
 *
 * The hook class is `motion-lenis`, deliberately NOT `lenis-*`: Lenis reserves
 * that namespace and strips /lenis(-\w+)?/g from <html> on every class update.
 */
html.motion-lenis,
html.motion-lenis body {
  overscroll-behavior-y: none;
}

/* ───────────────────────────── Scroll progress ──────────────────────────── */

.motion-progress {
  position: fixed;
  inset-block-start: 0;
  inset-inline: 0;
  height: 3px;
  z-index: 1000;
  pointer-events: none;
  background: transparent;
}

.motion-progress__fill {
  display: block;
  height: 100%;
  /* RTL: grow from the right edge. */
  transform-origin: right center;
  transform: scaleX(0);
  background: linear-gradient(
    90deg,
    var(--primary) 0%,
    var(--primary-muted) 55%,
    var(--accent-yellow) 100%
  );
  box-shadow: 0 0 12px rgba(27, 67, 50, 0.45);
  will-change: transform;
}

[dir="ltr"] .motion-progress__fill {
  transform-origin: left center;
}

/* ─────────────────────────────── Aurora ─────────────────────────────────── */

.motion-aurora {
  position: absolute;
  inset: -20%;
  z-index: 0;
  pointer-events: none;
  filter: blur(68px) saturate(1.15);
  opacity: 0.85;
}

.motion-aurora__layer {
  position: absolute;
  display: block;
  border-radius: 50%;
  mix-blend-mode: multiply;
  will-change: transform;
}

.motion-aurora__layer--1 {
  inset-block-start: 4%;
  inset-inline-end: 6%;
  width: 46vw;
  height: 46vw;
  max-width: 620px;
  max-height: 620px;
  background: radial-gradient(
    circle at 35% 35%,
    rgba(45, 106, 79, 0.42),
    rgba(45, 106, 79, 0) 68%
  );
}

.motion-aurora__layer--2 {
  inset-block-end: -6%;
  inset-inline-start: -4%;
  width: 52vw;
  height: 52vw;
  max-width: 680px;
  max-height: 680px;
  background: radial-gradient(
    circle at 60% 40%,
    rgba(245, 200, 66, 0.3),
    rgba(245, 200, 66, 0) 70%
  );
}

.motion-aurora__layer--3 {
  inset-block-start: 26%;
  inset-inline-start: 28%;
  width: 38vw;
  height: 38vw;
  max-width: 520px;
  max-height: 520px;
  background: radial-gradient(
    circle at 50% 50%,
    rgba(27, 67, 50, 0.28),
    rgba(27, 67, 50, 0) 72%
  );
}

/* Keep the aurora from washing out foreground copy on small screens. */
@media (max-width: 720px) {
  .motion-aurora {
    filter: blur(52px);
    opacity: 0.6;
  }
}

/* ─────────────────── SplitText (word-level, Arabic-safe) ───────────────── */

/*
 * Arabic is cursive, so words are never split into characters — only whole
 * words are wrapped. The outer span clips, the inner span is what animates.
 */
.motion-word {
  display: inline-block;
  overflow: hidden;
  /* Descenders (ـج ـع ـي) must not get clipped by the overflow. */
  padding-block-end: 0.18em;
  margin-block-end: -0.18em;
  vertical-align: top;
}

.motion-word > span {
  display: inline-block;
  will-change: transform, opacity;
}

/* ───────────────────────────── Spotlight ───────────────────────────────── */

.motion-on .motion-spotlight {
  position: relative;
  isolation: isolate;
}

.motion-on .motion-spotlight::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  border-radius: inherit;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.35s ease;
  background: radial-gradient(
    220px circle at var(--mx, 50%) var(--my, 50%),
    rgba(45, 106, 79, 0.14),
    transparent 62%
  );
}

.motion-on .motion-spotlight:hover::after {
  opacity: 1;
}

/* ───────────────────── Magnet / tilt compositing hints ─────────────────── */

.motion-on .hero-actions .btn,
.motion-on .cta-section .store-badge,
.motion-on .app-showcase-cta {
  will-change: transform;
}

.motion-on .phone-center .phone-frame {
  transform-style: preserve-3d;
  will-change: transform;
}

/*
 * GSAP owns the grid reveals when motion is on.
 *
 * styles.css hides these cards with `opacity: 0` and reveals them via a CSS
 * keyframe animation gated on `.in-view`. GSAP's `from()` tween reads the
 * element's *current* value as the end state, so leaving `opacity: 0` in place
 * would animate 0 -> 0 and `clearProps` would restore 0 — cards would never
 * appear. Reset the base state to visible here and let GSAP animate in from
 * its own `from` values instead.
 */
.motion-on .features-grid-animated .feature-card,
.motion-on .steps-animated .step-card,
.motion-on .stats-grid-animated .stat-card,
.motion-on .post-types-animated .post-type-card,
.motion-on .discover-grid-animated .discover-card,
.motion-on .testimonials-animated .testimonial-card,
.motion-on .faq-list-animated .faq-item,
.motion-on .animate-on-scroll .stat-card,
.motion-on .animate-on-scroll .post-type-card,
.motion-on .animate-on-scroll .discover-card,
.motion-on .animate-on-scroll .testimonial-card,
.motion-on .animate-on-scroll .faq-item,
.motion-on .animate-on-scroll .feature-card,
.motion-on .animate-on-scroll .step-card {
  opacity: 1;
  transform: none;
  animation: none !important;
  transition: none;
}

/*
 * The hero <h1> is the one heading GSAP fully owns (word stagger), so its CSS
 * entrance is neutralised to avoid animating the element and its words at the
 * same time. The other .hero-enter items keep their tuned CSS stagger.
 *
 * Section <h2>s intentionally keep `.reveal`: the container fades via CSS while
 * GSAP staggers the words inside it, which composes rather than conflicts.
 */
.motion-on .hero-copy h1.hero-enter,
.motion-on .hero-ready .hero-copy h1.hero-enter {
  opacity: 1;
  transform: none;
  animation: none !important;
}

/* Reduced motion wins over everything above. */
@media (prefers-reduced-motion: reduce) {
  .motion-progress,
  .motion-aurora {
    display: none;
  }

  .motion-word,
  .motion-word > span {
    overflow: visible;
    transform: none !important;
    opacity: 1 !important;
  }
}
