/* ============================================================
   Animation Definitions — Keyframes & Scroll-Triggered Classes
   ============================================================ */

/* ---- Keyframe Definitions ---- */

/* Fade In Up */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fade In */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Fade In Left */
@keyframes fadeInLeft {
  from {
    opacity: 0;
    transform: translateX(-30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Fade In Right */
@keyframes fadeInRight {
  from {
    opacity: 0;
    transform: translateX(30px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Scale In */
@keyframes scaleIn {
  from {
    opacity: 0;
    transform: scale(0.9);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Blur In */
@keyframes blurIn {
  from {
    opacity: 0;
    filter: blur(10px);
  }
  to {
    opacity: 1;
    filter: blur(0);
  }
}

/* Slide Down (for navbar) */
@keyframes slideDown {
  from {
    opacity: 0;
    transform: translateY(-100%);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Pulse glow */
@keyframes pulseGlow {
  0%, 100% {
    box-shadow: 0 0 20px rgba(0, 113, 227, 0.3);
  }
  50% {
    box-shadow: 0 0 40px rgba(0, 113, 227, 0.5);
  }
}

/* Float (subtle hover-like floating) */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}

/* Gradient shift for backgrounds */
@keyframes gradientShift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* ---- Scroll-Triggered Animation Classes ---- */

/* Base state: hidden.
   will-change: transform, opacity tells the browser to promote this element
   to its own composite layer before animation starts — avoids triggering
   layout/paint on neighbour elements during scroll-reveal. */
.animate-on-scroll {
  opacity: 0;
  will-change: transform, opacity;
}

/* Visible state: guarantee visibility first, then animate.
   The opacity:1 acts as an immediate CSS fallback so the element
   is never silently hidden even if the animation is skipped
   (e.g. prefers-reduced-motion, or fill-mode not yet applied). */
.animate-on-scroll.is-visible {
  opacity: 1;
  animation-fill-mode: forwards;
}

/* Animation variants */
.animate-on-scroll.is-visible.fade-in-up {
  animation: fadeInUp 0.6s var(--transition-smooth) forwards;
}

.animate-on-scroll.is-visible.fade-in {
  animation: fadeIn 0.6s var(--transition-smooth) forwards;
}

.animate-on-scroll.is-visible.fade-in-left {
  animation: fadeInLeft 0.6s var(--transition-smooth) forwards;
}

.animate-on-scroll.is-visible.fade-in-right {
  animation: fadeInRight 0.6s var(--transition-smooth) forwards;
}

.animate-on-scroll.is-visible.scale-in {
  animation: scaleIn 0.5s var(--transition-bounce) forwards;
}

.animate-on-scroll.is-visible.blur-in {
  animation: blurIn 0.6s var(--transition-smooth) forwards;
}

/* ---- Stagger Animation Delays ---- */
/* NOTE: transition-delay has no effect on CSS @keyframe animations.
         Only animation-delay, applied to the .is-visible state, creates
         the cascade effect. The rules below are the authoritative ones. */

/* Stagger delays for is-visible animation */
.stagger-children > .animate-on-scroll.is-visible:nth-child(1) {
  animation-delay: 0ms;
}
.stagger-children > .animate-on-scroll.is-visible:nth-child(2) {
  animation-delay: 100ms;
}
.stagger-children > .animate-on-scroll.is-visible:nth-child(3) {
  animation-delay: 200ms;
}
.stagger-children > .animate-on-scroll.is-visible:nth-child(4) {
  animation-delay: 300ms;
}
.stagger-children > .animate-on-scroll.is-visible:nth-child(5) {
  animation-delay: 400ms;
}
.stagger-children > .animate-on-scroll.is-visible:nth-child(6) {
  animation-delay: 500ms;
}

/* ---- Smooth Hover Transitions ---- */
.hover-lift {
  transition: transform var(--transition-base), box-shadow var(--transition-base);
}

.hover-lift:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.hover-scale {
  transition: transform var(--transition-base);
}

.hover-scale:hover {
  transform: scale(1.05);
}

.hover-glow {
  transition: box-shadow var(--transition-base);
}

.hover-glow:hover {
  box-shadow: var(--shadow-glow);
}

/* ---- Page Load Animations ---- */
.animate-on-load {
  animation: fadeInUp 0.8s var(--transition-smooth) forwards;
  opacity: 0;
}

.animate-on-load--delay-1 {
  animation-delay: 0.2s;
}

.animate-on-load--delay-2 {
  animation-delay: 0.4s;
}

.animate-on-load--delay-3 {
  animation-delay: 0.6s;
}

.animate-on-load--delay-4 {
  animation-delay: 0.8s;
}