/* ==========================================================================
   Xenotech Chess Academy — Scroll Effects & Motion System (styles.scroll-fx.css)
   Modular, performant, GPU-accelerated scroll enhancements.
   Safe by design: Initial hidden states ONLY activate when html.has-scroll-fx is present.
   ========================================================================== */

/* 1. Laser Scroll Progress Indicator (Top of Viewport) */
.scroll-progress-beam {
  position: fixed;
  top: 0;
  left: 0;
  width: 0%;
  height: 2.5px;
  background: linear-gradient(90deg, #FF7A00 0%, #FFA43A 60%, #FFD699 100%);
  box-shadow: 0 0 10px rgba(255, 122, 0, 0.7), 0 0 4px rgba(255, 164, 58, 0.9);
  z-index: 9999;
  pointer-events: none;
  transition: width 0.1s linear;
  will-change: width;
}

/* 2. Progressive Enhancement Base (Only active when JS is enabled) */
html.has-scroll-fx [data-scroll-reveal] {
  opacity: 0;
  will-change: transform, opacity;
  transition: opacity 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.65s cubic-bezier(0.16, 1, 0.3, 1),
              filter 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Variant: Default Fade Up */
html.has-scroll-fx [data-scroll-reveal="fade-up"],
html.has-scroll-fx [data-scroll-reveal=""] {
  transform: translateY(22px);
}

/* Variant: Scale Up (Great for mockups, banners, key stats) */
html.has-scroll-fx [data-scroll-reveal="scale-up"] {
  transform: translateY(18px) scale(0.96);
}

/* Variant: Fade Left / Right */
html.has-scroll-fx [data-scroll-reveal="fade-left"] {
  transform: translateX(-24px);
}
html.has-scroll-fx [data-scroll-reveal="fade-right"] {
  transform: translateX(24px);
}

/* Active State: Revealed */
html.has-scroll-fx [data-scroll-reveal].is-revealed {
  opacity: 1;
  transform: translate(0, 0) scale(1);
  filter: none;
}

/* 3. Stagger System for Grids & Lists */
html.has-scroll-fx [data-scroll-stagger] > * {
  opacity: 0;
  transform: translateY(20px);
  will-change: transform, opacity;
  transition: opacity 0.6s cubic-bezier(0.16, 1, 0.3, 1),
              transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(1) { transition-delay: 0.04s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(2) { transition-delay: 0.12s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(3) { transition-delay: 0.20s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(4) { transition-delay: 0.28s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(5) { transition-delay: 0.36s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(6) { transition-delay: 0.44s; }
html.has-scroll-fx [data-scroll-stagger].is-revealed > *:nth-child(n+7) { transition-delay: 0.50s; }

html.has-scroll-fx [data-scroll-stagger].is-revealed > * {
  opacity: 1;
  transform: translateY(0);
}

/* 4. Subtle Card Stacking (Smooth Sticky Overlap) */
/* Applied to stacked card columns like .platform-feature-stacked-cards */
@media (min-width: 992px) {
  html.has-scroll-fx [data-scroll-stack] {
    position: relative;
  }
  html.has-scroll-fx [data-scroll-stack] > * {
    position: sticky;
    top: calc(100px + var(--stack-offset, 0px));
    transition: transform 0.3s ease, box-shadow 0.3s ease;
  }
  html.has-scroll-fx [data-scroll-stack] > *:nth-child(1) {
    --stack-offset: 0px;
    z-index: 1;
  }
  html.has-scroll-fx [data-scroll-stack] > *:nth-child(2) {
    --stack-offset: 14px;
    z-index: 2;
  }
  html.has-scroll-fx [data-scroll-stack] > *:nth-child(3) {
    --stack-offset: 28px;
    z-index: 3;
  }
}

/* 5. Ambient Parallax (Soft background movement) */
html.has-scroll-fx [data-scroll-parallax] {
  will-change: transform;
  transition: transform 0.1s cubic-bezier(0, 0, 0.2, 1);
}

/* 6. Learning Loop Glowing Connection Line on Student Platform */
html.has-scroll-fx .platform-loop-track::after {
  transition: transform 0.8s cubic-bezier(0.16, 1, 0.3, 1);
}

/* 7. Accessibility: Complete Motion Safety Override */
@media (prefers-reduced-motion: reduce) {
  .scroll-progress-beam {
    display: none !important;
  }
  html.has-scroll-fx [data-scroll-reveal],
  html.has-scroll-fx [data-scroll-stagger] > *,
  html.has-scroll-fx [data-scroll-parallax] {
    opacity: 1 !important;
    transform: none !important;
    filter: none !important;
    transition: none !important;
  }
  html.has-scroll-fx [data-scroll-stack] > * {
    position: static !important;
    transform: none !important;
  }
}
