/* ===================================================================
   IEP COMPASS — MOTION ENHANCEMENTS (added 2026-05-17)
   ---------------------------------------------------------------------
   Everything in this file is gated behind `body.motion-on`.
   TO DISABLE ALL MOTION: remove `motion-on` from <body class="motion-on">
   TO REVERT FULLY:       delete motion.css + motion.js + their <link>/<script> tags
   prefers-reduced-motion is respected at the bottom of this file.
   =================================================================== */

/* --- 0. Fail-safe rollback: hide motion-only DOM elements by default ---
   These elements only make sense when motion-on is active. Without the
   gating below, removing `motion-on` from body would leave the sticky
   CTA and stats strip dangling as unstyled raw HTML. Hide them here so
   the page degrades cleanly when motion is toggled off. */
.mx-progress,
.mx-sticky-cta,
.mx-cycle-line,
.mx-stats {
  display: none;
}

/* --- 1. Reading progress bar (top of viewport) --- */
body.motion-on .mx-progress {
  display: block;
  position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--gold), var(--gold-lt));
  z-index: 9999;
  transition: width 0.08s linear;
  pointer-events: none;
}

/* --- 2. Sticky App Store CTA (appears after scrolling past hero) --- */
body.motion-on .mx-sticky-cta {
  position: fixed; bottom: 18px; right: 18px; z-index: 9998;
  display: inline-flex; align-items: center; gap: 10px;
  background: var(--navy-dark); color: white;
  padding: 12px 20px 12px 16px;
  border-radius: 50px;
  text-decoration: none;
  box-shadow: 0 12px 40px rgba(18,21,58,0.35), 0 0 0 1px rgba(255,255,255,0.05);
  opacity: 0; transform: translateY(20px) scale(0.94);
  transition: opacity 0.28s ease, transform 0.28s ease;
  pointer-events: none;
}
body.motion-on .mx-sticky-cta.is-visible {
  opacity: 1; transform: translateY(0) scale(1);
  pointer-events: auto;
}
body.motion-on .mx-sticky-cta__icon { color: white; display: inline-flex; }
body.motion-on .mx-sticky-cta__text { display: flex; flex-direction: column; line-height: 1.1; }
body.motion-on .mx-sticky-cta__text small { font-size: 9px; opacity: 0.65; letter-spacing: 0.2px; }
body.motion-on .mx-sticky-cta__text strong { font-size: 14px; font-weight: 800; letter-spacing: 0.1px; }
body.motion-on .mx-sticky-cta__arrow {
  color: var(--gold-lt); font-weight: 800; font-size: 15px;
  transition: transform 0.2s ease;
}
body.motion-on .mx-sticky-cta:hover .mx-sticky-cta__arrow { transform: translateX(3px); }
@media (max-width: 540px) {
  body.motion-on .mx-sticky-cta { bottom: 12px; right: 12px; left: 12px; justify-content: center; padding: 14px 22px; }
}

/* --- 3. Aurora hero background (slow drifting radial gradients) --- */
body.motion-on .hero { position: relative; overflow: hidden; }
body.motion-on .hero::before,
body.motion-on .hero::after {
  content: ""; position: absolute; pointer-events: none;
  width: 720px; height: 720px; border-radius: 50%;
  filter: blur(80px); opacity: 0.55;
  z-index: 0;
}
body.motion-on .hero::before {
  top: -200px; left: -200px;
  background: radial-gradient(circle, rgba(200,146,58,0.30), transparent 60%);
  animation: mxAuroraA 18s ease-in-out infinite alternate;
}
body.motion-on .hero::after {
  bottom: -240px; right: -180px;
  background: radial-gradient(circle, rgba(44,49,112,0.40), transparent 60%);
  animation: mxAuroraB 22s ease-in-out infinite alternate;
}
body.motion-on .hero > * { position: relative; z-index: 1; }
@keyframes mxAuroraA {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(80px, 60px) scale(1.15); }
}
@keyframes mxAuroraB {
  0%   { transform: translate(0,0) scale(1); }
  100% { transform: translate(-60px, -40px) scale(1.12); }
}

/* --- 4. Diagnosis-aware cycling tagline --- */
body.motion-on .mx-cycle-line {
  display: block;
  font-size: 15px; color: var(--text-muted);
  margin: 6px 0 28px; line-height: 1.5;
  max-width: 520px;
}
body.motion-on .mx-cycle-line .mx-cycle-es {
  display: block; font-size: 13px; color: #9a8060;
  font-style: italic; margin-top: 4px;
}
body.motion-on .mx-cycle {
  display: inline-block;
  color: var(--navy);
  font-weight: 700;
  border-bottom: 2px solid var(--gold);
  padding-bottom: 1px;
  transition: opacity 0.35s ease, transform 0.35s ease;
}
body.motion-on .mx-cycle.is-leaving { opacity: 0; transform: translateY(-6px); }
body.motion-on .mx-cycle-line .mx-cycle-es .mx-cycle { color: var(--gold); border-color: var(--navy); }

/* --- 5. Scroll-reveal (specific element selectors, no markup change needed) --- */
body.motion-on h2.section-title,
body.motion-on h2.testimonials-title,
body.motion-on h2.compare-title,
body.motion-on h2.kit-headline,
body.motion-on h2.resources-title,
body.motion-on h2.scholarship-title,
body.motion-on h2.faq-title,
body.motion-on .feature-card,
body.motion-on .testimonial-card,
body.motion-on .resource-card,
body.motion-on .faq-item,
body.motion-on .scholarship-step,
body.motion-on .criteria-item,
body.motion-on .screen-card,
body.motion-on .compare-table-wrap,
body.motion-on .closing,
body.motion-on .kit-checklist li {
  opacity: 0;
  transform: translateY(24px);
  transition: opacity 0.7s cubic-bezier(0.2, 0.7, 0.2, 1), transform 0.7s cubic-bezier(0.2, 0.7, 0.2, 1);
  will-change: opacity, transform;
}
body.motion-on .mx-revealed {
  opacity: 1 !important;
  transform: translateY(0) !important;
}
/* Staggered children within shared grids */
body.motion-on .resources-grid .resource-card:nth-child(2) { transition-delay: 0.07s; }
body.motion-on .resources-grid .resource-card:nth-child(3) { transition-delay: 0.14s; }
body.motion-on .resources-grid .resource-card:nth-child(4) { transition-delay: 0.21s; }
body.motion-on .resources-grid .resource-card:nth-child(5) { transition-delay: 0.28s; }
body.motion-on .faq-grid .faq-item:nth-child(even) { transition-delay: 0.08s; }
body.motion-on .scholarship-criteria .criteria-item:nth-child(2) { transition-delay: 0.06s; }
body.motion-on .scholarship-criteria .criteria-item:nth-child(3) { transition-delay: 0.12s; }
body.motion-on .scholarship-criteria .criteria-item:nth-child(4) { transition-delay: 0.18s; }
body.motion-on .scholarship-criteria .criteria-item:nth-child(5) { transition-delay: 0.24s; }

/* --- 6. Phone tilt + screen carousel --- */
body.motion-on .phone-frame {
  transition: transform 0.4s cubic-bezier(0.2, 0.7, 0.2, 1);
  transform: perspective(1200px) rotateY(0deg) rotateX(0deg);
  will-change: transform;
}
body.motion-on .phone-frame img {
  transition: opacity 0.5s ease;
}
body.motion-on .phone-frame img.is-fading { opacity: 0; }

/* --- 7. Count-up stats strip (new component for scholarship section) ---
   Scholarship section bg is #f9f7ff (near-white), so stats use dark text
   on a white card with gold accents. */
body.motion-on .mx-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 18px;
  max-width: 880px;
  margin: 0 auto 36px;
  padding: 22px 28px;
  background: white;
  border: 1px solid rgba(200,146,58,0.35);
  border-radius: 16px;
  box-shadow: 0 8px 28px rgba(22,30,75,0.06);
}
body.motion-on .mx-stat {
  text-align: center;
  padding: 4px 6px;
  border-right: 1px solid rgba(22,30,75,0.06);
}
body.motion-on .mx-stat:last-child { border-right: none; }
body.motion-on .mx-stat-num {
  font-size: 32px; font-weight: 900;
  color: var(--gold); line-height: 1; letter-spacing: -0.5px;
  font-variant-numeric: tabular-nums;
  display: inline;
}
body.motion-on .mx-stat-suffix {
  font-size: 18px; color: var(--gold); font-weight: 700;
}
body.motion-on .mx-stat-label {
  font-size: 11px; font-weight: 800; letter-spacing: 0.9px;
  color: var(--navy-dark); text-transform: uppercase;
  margin-top: 8px;
  line-height: 1.3;
}
@media (max-width: 600px) {
  body.motion-on .mx-stats { grid-template-columns: 1fr 1fr; padding: 16px 18px; }
  body.motion-on .mx-stat { border-right: none; border-bottom: 1px solid rgba(22,30,75,0.06); padding-bottom: 10px; }
  body.motion-on .mx-stat:nth-last-child(-n+2) { border-bottom: none; }
  body.motion-on .mx-stat-num { font-size: 26px; }
}

/* --- 8. Respect reduced-motion preference (kill all decorative animation) --- */
@media (prefers-reduced-motion: reduce) {
  body.motion-on .hero::before,
  body.motion-on .hero::after { animation: none !important; }
  body.motion-on h2.section-title,
  body.motion-on h2.testimonials-title,
  body.motion-on h2.compare-title,
  body.motion-on h2.kit-headline,
  body.motion-on h2.resources-title,
  body.motion-on h2.scholarship-title,
  body.motion-on h2.faq-title,
  body.motion-on .feature-card,
  body.motion-on .testimonial-card,
  body.motion-on .resource-card,
  body.motion-on .faq-item,
  body.motion-on .scholarship-step,
  body.motion-on .criteria-item,
  body.motion-on .screen-card,
  body.motion-on .compare-table-wrap,
  body.motion-on .closing,
  body.motion-on .kit-checklist li {
    opacity: 1 !important; transform: none !important;
  }
  body.motion-on .mx-cycle { transition: none !important; }
  body.motion-on .phone-frame { transition: none !important; transform: none !important; }
  body.motion-on .mx-sticky-cta { transition: opacity 0.15s linear !important; transform: none !important; }
  body.motion-on .mx-progress { transition: none !important; }
}
