/* ============================================================
   Vaishiga Kids - Animations
   Intersection Observer driven. GPU-accelerated only.
   ============================================================ */

/* ============================================================
   FADE-IN CLASSES (toggled by JS IntersectionObserver)
   ============================================================ */
.fade-in,
.fade-in-up,
.fade-in-left,
.fade-in-right,
.fade-in-scale {
  opacity: 0;
  transition: opacity 0.6s ease, transform 0.6s ease;
  will-change: opacity, transform;
}

.fade-in        { transform: none; }
.fade-in-up     { transform: translateY(30px); }
.fade-in-left   { transform: translateX(-30px); }
.fade-in-right  { transform: translateX(30px); }
.fade-in-scale  { transform: scale(0.92); }

.fade-in.is-visible,
.fade-in-up.is-visible,
.fade-in-left.is-visible,
.fade-in-right.is-visible,
.fade-in-scale.is-visible {
  opacity: 1;
  transform: none;
}

/* Stagger delays for grid children */
.stagger-children > *:nth-child(1)  { transition-delay: 0.05s; }
.stagger-children > *:nth-child(2)  { transition-delay: 0.10s; }
.stagger-children > *:nth-child(3)  { transition-delay: 0.15s; }
.stagger-children > *:nth-child(4)  { transition-delay: 0.20s; }
.stagger-children > *:nth-child(5)  { transition-delay: 0.25s; }
.stagger-children > *:nth-child(6)  { transition-delay: 0.30s; }
.stagger-children > *:nth-child(7)  { transition-delay: 0.35s; }
.stagger-children > *:nth-child(8)  { transition-delay: 0.40s; }

/* ============================================================
   PAGE TRANSITION
   ============================================================ */
.page-transition-enter {
  opacity: 0;
  transform: translateY(8px);
}
.page-transition-enter-active {
  opacity: 1;
  transform: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

/* ============================================================
   SKELETON SHIMMER
   ============================================================ */
@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ============================================================
   PRODUCT CARD HOVER LIFT
   ============================================================ */
.product-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  will-change: transform;
}

/* ============================================================
   IMAGE HOVER ZOOM (applied to .img-zoom containers)
   ============================================================ */
.img-zoom {
  overflow: hidden;
}
.img-zoom img {
  transition: transform 0.5s ease;
  will-change: transform;
}
.img-zoom:hover img {
  transform: scale(1.06);
}

/* ============================================================
   SWATCH BOUNCE ON SELECT
   ============================================================ */
@keyframes swatch-bounce {
  0%   { transform: scale(1); }
  40%  { transform: scale(1.35); }
  70%  { transform: scale(0.92); }
  100% { transform: scale(1.15); }
}

.swatch.is-active {
  animation: swatch-bounce 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   BUTTON RIPPLE
   ============================================================ */
@keyframes ripple {
  0%   { transform: scale(0); opacity: 0.5; }
  100% { transform: scale(4); opacity: 0; }
}

.btn .ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,0.35);
  transform: scale(0);
  animation: ripple 0.6s linear;
  pointer-events: none;
}

/* ============================================================
   HERO CONTENT ENTER
   ============================================================ */
@keyframes hero-enter {
  from {
    opacity: 0;
    transform: translateY(24px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

/* ============================================================
   COUNTER ANIMATION (JS-driven, class toggled)
   ============================================================ */
.counter-value {
  display: inline-block;
  transition: transform 0.3s ease;
}

/* ============================================================
   WISHLIST HEART BEAT
   ============================================================ */
@keyframes heart-beat {
  0%   { transform: scale(1); }
  25%  { transform: scale(1.35); }
  50%  { transform: scale(0.95); }
  75%  { transform: scale(1.15); }
  100% { transform: scale(1); }
}

.product-card__wishlist.is-animating {
  animation: heart-beat 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================================
   CART ADD SUCCESS (bouncing cart icon)
   ============================================================ */
@keyframes cart-bounce {
  0%   { transform: scale(1); }
  30%  { transform: scale(1.3) rotate(-10deg); }
  60%  { transform: scale(0.9) rotate(5deg); }
  100% { transform: scale(1) rotate(0); }
}

.header-icon.cart-updated .header-icon__symbol {
  animation: cart-bounce 0.5s ease;
}

/* ============================================================
   TOAST ENTER/EXIT
   ============================================================ */
@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

@keyframes toast-out {
  from {
    opacity: 1;
    transform: translateX(0);
  }
  to {
    opacity: 0;
    transform: translateX(100%);
  }
}

/* ============================================================
   SECTION HEADER UNDERLINE GROW
   ============================================================ */
.section-title::after {
  transform-origin: left;
  /* The width is already set in style.css; animation via is-visible */
}

.section-header.is-visible .section-title::after {
  animation: underline-grow 0.6s ease 0.3s both;
}

@keyframes underline-grow {
  from { width: 0; opacity: 0; }
  to   { width: 60px; opacity: 1; }
}

/* ============================================================
   FLOATING DECORATIVE ELEMENTS
   ============================================================ */
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

.float-anim {
  animation: float 4s ease-in-out infinite;
}

@keyframes spin-slow {
  to { transform: rotate(360deg); }
}

.spin-slow {
  animation: spin-slow 12s linear infinite;
}

/* ============================================================
   MOBILE SIDEBAR SLIDE
   ============================================================ */
.mobile-sidebar {
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* ============================================================
   SEARCH DROPDOWN APPEAR
   ============================================================ */
@keyframes dropdown-appear {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.search-dropdown.is-visible {
  animation: dropdown-appear 0.2s ease both;
}

/* ============================================================
   PRODUCT BADGE ENTRANCE
   ============================================================ */
@keyframes badge-pop {
  0%   { transform: scale(0); opacity: 0; }
  70%  { transform: scale(1.1); }
  100% { transform: scale(1); opacity: 1; }
}

.product-card .badge {
  animation: badge-pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}

/* ============================================================
   STICKY NAV SHRINK
   ============================================================ */
.main-nav {
  transition: box-shadow 0.3s ease;
}

/* ============================================================
   REDUCE MOTION
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }

  .fade-in,
  .fade-in-up,
  .fade-in-left,
  .fade-in-right,
  .fade-in-scale {
    opacity: 1;
    transform: none;
    transition: none;
  }
}
