/* ==========================================================================
   Motion Architecture — Lenis Smooth Scroll + GSAP ScrollTrigger Choreography
   كلية علوم الحاسوب والرياضيات — جامعة الموصل
   ========================================================================== */

/* 1. Lenis Core Styles (Prevents double-smoothing & ensures crisp scroll) */
html.lenis,
html.lenis body {
  height: auto;
}

.lenis.lenis-smooth {
  scroll-behavior: auto !important;
}

.lenis.lenis-smooth [data-lenis-prevent] {
  overscroll-behavior: contain;
}

.lenis.lenis-stopped {
  overflow: clip;
}

.lenis.lenis-smooth iframe {
  pointer-events: none;
}

/* Override native CSS smooth scroll when Lenis is active */
html {
  scroll-behavior: auto;
}

/* 2. Reading Progress Bar (GPU-accelerated scaleX) */
.reading-progress-bar {
  width: 100% !important;
  transform: scaleX(0);
  transform-origin: right center;
  will-change: transform;
  transition: none !important;
}

[dir="rtl"] .reading-progress-bar {
  transform-origin: right center;
}

/* 3. Ambient Scroll-Parallax Glow Orbs (Uses existing site palette) */
.motion-ambient-layer {
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  overflow: hidden;
}

.motion-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(90px);
  opacity: 0.14;
  will-change: transform;
  pointer-events: none;
}

.motion-orb-1 {
  width: 44vw;
  height: 44vw;
  max-width: 620px;
  max-height: 620px;
  top: -10%;
  right: -8%;
  background: radial-gradient(circle, rgba(77, 210, 200, 0.55) 0%, transparent 70%);
}

.motion-orb-2 {
  width: 38vw;
  height: 38vw;
  max-width: 540px;
  max-height: 540px;
  top: 42%;
  left: -10%;
  background: radial-gradient(circle, rgba(61, 76, 154, 0.55) 0%, transparent 70%);
}

.motion-orb-3 {
  width: 34vw;
  height: 34vw;
  max-width: 480px;
  max-height: 480px;
  bottom: -12%;
  right: 18%;
  background: radial-gradient(circle, rgba(244, 237, 224, 0.22) 0%, transparent 70%);
}

/* 4. GSAP-Controlled Reveal Overrides
   Disable CSS transition on .reveal-on-scroll when motion engine is active
   so GSAP drives 60/120fps transforms without CSS transition fighting. */
html.motion-ready .reveal-on-scroll {
  transition: none !important;
  will-change: transform, opacity;
}

/* Safety: if motion-ready is not set (e.g. script blocked), keep normal visibility */
html:not(.motion-ready) .reveal-on-scroll {
  opacity: 1;
  transform: none;
}

/* 5. Interactive Card Spotlight & 3D Tilt Sheen */
.motion-card-interactive {
  position: relative;
  transform-style: preserve-3d;
  will-change: transform;
  --mx: 50%;
  --my: 50%;
  --spotlight-opacity: 0;
}

.motion-card-interactive::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  pointer-events: none;
  z-index: 1;
  opacity: var(--spotlight-opacity);
  transition: opacity 0.35s ease;
  background: radial-gradient(
    420px circle at var(--mx) var(--my),
    rgba(77, 210, 200, 0.14),
    rgba(244, 237, 224, 0.04) 40%,
    transparent 70%
  );
}

.motion-card-interactive::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  padding: 1px;
  pointer-events: none;
  z-index: 1;
  opacity: var(--spotlight-opacity);
  transition: opacity 0.35s ease;
  background: radial-gradient(
    300px circle at var(--mx) var(--my),
    rgba(77, 210, 200, 0.55),
    transparent 65%
  );
  -webkit-mask: linear-gradient(#fff 0 0) content-box, linear-gradient(#fff 0 0);
  -webkit-mask-composite: xor;
  mask-composite: exclude;
}

/* 6. Primary Button Sheen Sweep */
.btn-primary {
  position: relative;
  overflow: hidden;
}

.btn-primary::after {
  content: "";
  position: absolute;
  top: -50%;
  left: -75%;
  width: 50%;
  height: 200%;
  background: linear-gradient(
    115deg,
    transparent 0%,
    rgba(255, 255, 255, 0.24) 50%,
    transparent 100%
  );
  transform: skewX(-22deg);
  pointer-events: none;
  transition: left 0.65s cubic-bezier(0.16, 1, 0.3, 1);
}

.btn-primary:hover::after {
  left: 135%;
}

/* 7. Active Navigation Link Indicator */
.nav-menu-desktop .nav-link {
  position: relative;
}

.nav-menu-desktop .nav-link::after {
  content: "";
  position: absolute;
  bottom: -4px;
  right: 0;
  left: 0;
  height: 2px;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent-violet), var(--accent-violet-light));
  transform: scaleX(0);
  transform-origin: center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

.nav-menu-desktop .nav-link.is-active-section {
  color: var(--text-primary);
}

.nav-menu-desktop .nav-link.is-active-section::after {
  transform: scaleX(1);
}

/* 8. Course Item Micro-Lift */
.course-item {
  transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1),
              background-color 0.25s ease,
              border-color 0.25s ease;
}

.course-item:hover {
  transform: translateX(-4px);
}

/* 9. Velocity-Reactive Section Tag */
.section-tag {
  display: inline-block;
  will-change: transform;
}

/* 10. Hero News-Ticker Marquee Bar */
.hero-ticker-wrap {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  max-width: 52rem;
  margin: 0 auto 2.25rem;
  padding: 0.45rem 0.55rem 0.45rem 0.75rem;
  border-radius: var(--radius-full);
  background: var(--bg-glass-card);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm), inset 0 1px 0 rgba(244, 237, 224, 0.08);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  overflow: hidden;
}

.hero-ticker-label {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.3rem 0.85rem;
  border-radius: var(--radius-full);
  background: rgba(77, 210, 200, 0.14);
  border: 1px solid rgba(77, 210, 200, 0.35);
  color: var(--accent-violet);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

.hero-ticker-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-violet);
  box-shadow: 0 0 8px var(--accent-violet);
  animation: tickerPulse 2s ease-in-out infinite;
}

@keyframes tickerPulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.45; transform: scale(0.8); }
}

.hero-ticker-viewport {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  direction: ltr;
  -webkit-mask-image: linear-gradient(90deg, transparent 0%, #000 7%, #000 93%, transparent 100%);
  mask-image: linear-gradient(90deg, transparent 0%, #000 7%, #000 93%, transparent 100%);
}

.hero-ticker-track {
  display: flex;
  align-items: center;
  width: max-content;
  will-change: transform;
  animation: heroTickerLoop 38s linear infinite;
}

.hero-ticker-wrap:hover .hero-ticker-track {
  animation-play-state: paused;
}

.hero-ticker-group {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding-right: 1.5rem;
  flex-shrink: 0;
}

.hero-ticker-item {
  direction: rtl;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: color 0.25s ease;
}

.hero-ticker-wrap:hover .hero-ticker-item:hover {
  color: var(--text-primary);
}

.hero-ticker-sep {
  font-size: 0.6rem;
  color: var(--accent-violet);
  opacity: 0.85;
  flex-shrink: 0;
}

@keyframes heroTickerLoop {
  0%   { transform: translate3d(-50%, 0, 0); }
  100% { transform: translate3d(0, 0, 0); }
}

@media (max-width: 640px) {
  .hero-ticker-wrap {
    padding: 0.4rem 0.5rem;
    gap: 0.5rem;
  }

  .hero-ticker-label {
    padding: 0.25rem 0.65rem;
    font-size: 0.72rem;
  }

  .hero-ticker-item {
    font-size: 0.8rem;
  }
}

/* 11. Reduced Motion Accessibility */
@media (prefers-reduced-motion: reduce) {
  .motion-orb,
  .motion-card-interactive::before,
  .motion-card-interactive::after,
  .btn-primary::after {
    display: none !important;
  }

  .reveal-on-scroll {
    opacity: 1 !important;
    transform: none !important;
  }
}
