/* ==========================================================================
   KUDA & TERERAI - PREMIUM INTERACTIVE WEDDING INVITATION
   Animations CSS - assets/css/animations.css
   ========================================================================== */

/* --------------------------------------------------------------------------
   1. KEYFRAMES
   -------------------------------------------------------------------------- */

/* Wax Seal Breathe/Pulse Hover Effect */
@keyframes breathe {
  0% {
    transform: scale(1);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.05);
    opacity: 1;
    text-shadow: 0 0 8px rgba(212, 175, 106, 0.4);
  }
  100% {
    transform: scale(1);
    opacity: 0.8;
  }
}

/* Scroll Arrow Down Loop */
@keyframes scrollDown {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translateY(20px);
    opacity: 0;
  }
}

/* Envelope Flaps Slide Out */
@keyframes slideLeft {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(-100%);
  }
}

@keyframes slideRight {
  0% {
    transform: translateX(0);
  }
  100% {
    transform: translateX(100%);
  }
}

/* Success Heart Beat */
@keyframes heartbeat {
  0% { transform: scale(1); }
  14% { transform: scale(1.12); }
  28% { transform: scale(1); }
  42% { transform: scale(1.12); }
  70% { transform: scale(1); }
}

/* Smooth zoom-out for the opening sequence backdrop */
@keyframes zoomOutBg {
  from {
    transform: scale(1.1);
    opacity: 0;
  }
  to {
    transform: scale(1);
    opacity: 1;
  }
}

/* --------------------------------------------------------------------------
   2. ANIMATION UTILITY CLASSES
   -------------------------------------------------------------------------- */
.scale-pulse {
  animation: heartbeat 1.5s infinite ease-in-out;
}

/* --------------------------------------------------------------------------
   3. OPENING SCREEN TRANSITIONS
   -------------------------------------------------------------------------- */
.opening-screen.is-opened {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}

.opening-screen.is-opened .left-flap {
  animation: slideLeft 1.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.opening-screen.is-opened .right-flap {
  animation: slideRight 1.6s cubic-bezier(0.77, 0, 0.175, 1) forwards;
}

.opening-screen.is-opened .wax-seal-wrapper {
  transform: translate(-50%, -50%) scale(0.6) rotate(-15deg);
  opacity: 0;
  pointer-events: none;
}

/* Hero reveal triggered by opening class */
body.invitation-open .hero-bg-overlay {
  animation: zoomOutBg 2s cubic-bezier(0.25, 1, 0.5, 1) forwards;
}

/* --------------------------------------------------------------------------
   4. MODERN CSS SCROLL-DRIVEN ANIMATIONS
   -------------------------------------------------------------------------- */
@media (prefers-reduced-motion: no-preference) {
  @supports ((animation-timeline: view()) and (animation-range: entry)) {
    
    /* Scroll Fade Up keyframes */
    @keyframes fadeUpIn {
      from {
        opacity: 0;
        transform: translateY(40px);
      }
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }
    
    /* Zoom In keyframes for grid images */
    @keyframes scaleUpIn {
      from {
        opacity: 0.6;
        transform: scale(0.9);
      }
      to {
        opacity: 1;
        transform: scale(1);
      }
    }

    /* Apply scroll-driven animations on headings, timelines & gallery cards */
    .section-heading,
    .details-card,
    .story-content,
    .story-img-wrapper,
    .timeline-item,
    .bridal-avatar-wrapper,
    .gallery-card {
      animation: fadeUpIn auto linear backwards;
      animation-timeline: view();
      animation-range: entry 5% cover 30%;
    }

    .gallery-img {
      animation: scaleUpIn auto linear backwards;
      animation-timeline: view();
      animation-range: entry 0% cover 40%;
    }
  }
}

/* --------------------------------------------------------------------------
   5. PERSONALIZED GUEST & DATE SHIMMER KEYFRAMES
   -------------------------------------------------------------------------- */
@keyframes revealName {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes revealMessage {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes shineGoldDate {
  0% {
    text-shadow: 0 0 0 rgba(212, 175, 106, 0);
  }
  50% {
    text-shadow: 0 0 20px rgba(212, 175, 106, 0.7);
    color: var(--champagne-gold);
  }
  100% {
    text-shadow: 0 0 2px rgba(212, 175, 106, 0.1);
  }
}
