/* ==========================================
   SCROLL ANIMATIONS - Modern & Smooth
   ========================================== */

/* Base animation states */
.animate-on-scroll {
  opacity: 0;
  transition: opacity 0.6s ease-out, transform 0.6s ease-out;
}

.animate-on-scroll.visible {
  opacity: 1;
}

/* Fade In Up */
.fade-in-up {
  transform: translateY(30px);
}

.fade-in-up.visible {
  transform: translateY(0);
}

/* Fade In Down */
.fade-in-down {
  transform: translateY(-30px);
}

.fade-in-down.visible {
  transform: translateY(0);
}

/* Fade In Left */
.fade-in-left {
  transform: translateX(-30px);
}

.fade-in-left.visible {
  transform: translateX(0);
}

/* Fade In Right */
.fade-in-right {
  transform: translateX(30px);
}

.fade-in-right.visible {
  transform: translateX(0);
}

/* Scale In */
.scale-in {
  transform: scale(0.9);
}

.scale-in.visible {
  transform: scale(1);
}

/* Rotate In */
.rotate-in {
  transform: rotate(-5deg) scale(0.9);
}

.rotate-in.visible {
  transform: rotate(0) scale(1);
}

/* Stagger children animation */
.stagger-children > * {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease-out, transform 0.5s ease-out;
  /* Safety net: content must never stay hidden. Containers that are
     re-rendered after data fetches can miss the IntersectionObserver
     `.visible` pass (observe-once + className rewrites), which used to
     leave cards at opacity 0. This animation force-reveals children
     ~1.2s after they mount even if the observer never fires; when the
     observer does fire first, both end states are identical. */
  animation: stagger-safety-in 0.5s ease-out 1.2s forwards;
}

@keyframes stagger-safety-in {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Fallback reveal path (see js/scroll-animations.js): hidden/prerendered
   pages freeze transitions and animations mid-flight, which would pin
   revealed content at opacity 0 — so the fallback strips them entirely. */
.anim-off,
.anim-off > * {
  transition: none !important;
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

.stagger-children.visible > * {
  opacity: 1;
  transform: translateY(0);
}

/* Add delays for stagger effect */
.stagger-children.visible > *:nth-child(1) { transition-delay: 0.1s; }
.stagger-children.visible > *:nth-child(2) { transition-delay: 0.2s; }
.stagger-children.visible > *:nth-child(3) { transition-delay: 0.3s; }
.stagger-children.visible > *:nth-child(4) { transition-delay: 0.4s; }
.stagger-children.visible > *:nth-child(5) { transition-delay: 0.5s; }
.stagger-children.visible > *:nth-child(6) { transition-delay: 0.6s; }
.stagger-children.visible > *:nth-child(7) { transition-delay: 0.7s; }
.stagger-children.visible > *:nth-child(8) { transition-delay: 0.8s; }

/* Bounce effect */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3) translateY(-30px);
  }
  50% {
    opacity: 1;
    transform: scale(1.05);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1) translateY(0);
  }
}

.bounce-in {
  animation: none;
}

.bounce-in.visible {
  animation: bounceIn 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

/* Slide and fade for cards */
.card-reveal {
  opacity: 0;
  transform: translateY(30px) scale(0.95);
  transition: all 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.card-reveal.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Number counter animation */
.counter {
  transition: all 0.3s ease;
}

/* Parallax effect for backgrounds */
.parallax-bg {
  transition: transform 0.1s ease-out;
}

/* Reduce motion for accessibility */
@media (prefers-reduced-motion: reduce) {
  .animate-on-scroll,
  .fade-in-up,
  .fade-in-down,
  .fade-in-left,
  .fade-in-right,
  .scale-in,
  .rotate-in,
  .stagger-children > *,
  .bounce-in,
  .card-reveal {
    transition: none !important;
    animation: none !important;
    opacity: 1 !important;
    transform: none !important;
  }
}

/* Smooth reveal for images */
.image-reveal {
  overflow: hidden;
  position: relative;
}

.image-reveal img {
  transform: scale(1.1);
  transition: transform 0.6s ease-out;
}

.image-reveal.visible img {
  transform: scale(1);
}

/* Text reveal with underline */
.text-reveal {
  position: relative;
  display: inline-block;
}

.text-reveal::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: currentColor;
  transition: width 0.6s ease-out;
}

.text-reveal.visible::after {
  width: 100%;
}
