/* ============================================================
   BIRTHDAY KARTS — Animations CSS
   View Timeline + Scroll-Driven + Keyframes
   ============================================================ */

/* ── Scroll-Driven Animations ── */
@supports (animation-timeline: scroll()) {
  .scroll-fade-in {
    animation: scroll-fade linear both;
    animation-timeline: view();
    animation-range: entry 0% entry 25%;
  }
  @keyframes scroll-fade {
    from { opacity: 0; transform: translateY(40px); }
    to { opacity: 1; transform: translateY(0); }
  }
}

/* ── Page Transition ── */
.barba-leave-active { transition: opacity 0.4s var(--ease-in), transform 0.4s var(--ease-in); }
.barba-leave-to { opacity: 0; transform: translateY(-20px); }
.barba-enter-active { transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out); }
.barba-enter-from { opacity: 0; transform: translateY(20px); }

/* ── Text Reveal (Splitting.js) ── */
.reveal-text .char {
  display: inline-block;
  opacity: 0;
  transform: translateY(80%) rotateX(-60deg);
  transform-origin: top center;
  transition: opacity 0.5s var(--ease-out), transform 0.5s var(--ease-out);
}
.reveal-text.is-revealed .char { opacity: 1; transform: none; }
.reveal-text .char:nth-child(n+2) { transition-delay: calc(n * 0.03s); }

/* Generate stagger delays for up to 60 chars */
.reveal-text .char:nth-child(1)  { transition-delay: 0.02s; }
.reveal-text .char:nth-child(2)  { transition-delay: 0.04s; }
.reveal-text .char:nth-child(3)  { transition-delay: 0.06s; }
.reveal-text .char:nth-child(4)  { transition-delay: 0.08s; }
.reveal-text .char:nth-child(5)  { transition-delay: 0.10s; }
.reveal-text .char:nth-child(6)  { transition-delay: 0.12s; }
.reveal-text .char:nth-child(7)  { transition-delay: 0.14s; }
.reveal-text .char:nth-child(8)  { transition-delay: 0.16s; }
.reveal-text .char:nth-child(9)  { transition-delay: 0.18s; }
.reveal-text .char:nth-child(10) { transition-delay: 0.20s; }
.reveal-text .char:nth-child(11) { transition-delay: 0.22s; }
.reveal-text .char:nth-child(12) { transition-delay: 0.24s; }
.reveal-text .char:nth-child(13) { transition-delay: 0.26s; }
.reveal-text .char:nth-child(14) { transition-delay: 0.28s; }
.reveal-text .char:nth-child(15) { transition-delay: 0.30s; }
.reveal-text .char:nth-child(16) { transition-delay: 0.32s; }
.reveal-text .char:nth-child(17) { transition-delay: 0.34s; }
.reveal-text .char:nth-child(18) { transition-delay: 0.36s; }
.reveal-text .char:nth-child(19) { transition-delay: 0.38s; }
.reveal-text .char:nth-child(20) { transition-delay: 0.40s; }

/* ── Blob Morph ── */
@keyframes morph {
  0%, 100% { border-radius: 60% 40% 30% 70% / 60% 30% 70% 40%; }
  25%       { border-radius: 30% 60% 70% 40% / 50% 60% 30% 60%; }
  50%       { border-radius: 50% 60% 30% 70% / 40% 50% 60% 30%; }
  75%       { border-radius: 40% 60% 70% 30% / 60% 40% 30% 70%; }
}
.blob-morph {
  animation: morph 12s ease-in-out infinite;
}

/* ── Particle Pulse ── */
@keyframes particle-float {
  0%, 100% { transform: translateY(0) translateX(0) scale(1); opacity: 0.4; }
  25% { transform: translateY(-20px) translateX(10px) scale(1.1); opacity: 0.8; }
  50% { transform: translateY(-35px) translateX(-5px) scale(0.9); opacity: 0.5; }
  75% { transform: translateY(-15px) translateX(-15px) scale(1.05); opacity: 0.7; }
}

/* ── Ripple ── */
@keyframes ripple {
  0% { transform: scale(0); opacity: 0.6; }
  100% { transform: scale(4); opacity: 0; }
}
.ripple-effect {
  position: absolute;
  border-radius: 50%;
  width: 20px; height: 20px;
  background: rgba(108,99,255,0.4);
  animation: ripple 0.8s ease-out forwards;
  pointer-events: none;
  transform-origin: center;
  margin: -10px;
}

/* ── Typewriter ── */
.typewriter-text::after {
  content: '|';
  color: var(--primary);
  animation: blink 1s ease infinite;
}

/* ── API Flow Animation ── */
@keyframes flow-pulse {
  0%, 100% { stroke-dashoffset: 1000; opacity: 0.5; }
  50% { stroke-dashoffset: 0; opacity: 1; }
}
.flow-path {
  stroke-dasharray: 1000;
  animation: flow-pulse 3s ease-in-out infinite;
}

/* ── Number Count ── */
@keyframes count-up-pop {
  0% { transform: scale(0.8); opacity: 0; }
  70% { transform: scale(1.05); }
  100% { transform: scale(1); opacity: 1; }
}
.counter-animated { animation: count-up-pop 0.4s var(--spring) both; }

/* ── Glow Pulse ── */
@keyframes glow-pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(108,99,255,0.3); }
  50% { box-shadow: 0 0 50px rgba(108,99,255,0.6); }
}
.glow-pulse { animation: glow-pulse 3s ease-in-out infinite; }

/* ── Section Entry Stagger ── */
.stagger-children > * {
  opacity: 0;
  transform: translateY(24px);
}
.stagger-children.is-visible > *:nth-child(1) { animation: fade-up 0.6s var(--ease-out) 0.0s forwards; }
.stagger-children.is-visible > *:nth-child(2) { animation: fade-up 0.6s var(--ease-out) 0.1s forwards; }
.stagger-children.is-visible > *:nth-child(3) { animation: fade-up 0.6s var(--ease-out) 0.2s forwards; }
.stagger-children.is-visible > *:nth-child(4) { animation: fade-up 0.6s var(--ease-out) 0.3s forwards; }
.stagger-children.is-visible > *:nth-child(5) { animation: fade-up 0.6s var(--ease-out) 0.4s forwards; }
.stagger-children.is-visible > *:nth-child(6) { animation: fade-up 0.6s var(--ease-out) 0.5s forwards; }
.stagger-children.is-visible > *:nth-child(7) { animation: fade-up 0.6s var(--ease-out) 0.6s forwards; }
.stagger-children.is-visible > *:nth-child(8) { animation: fade-up 0.6s var(--ease-out) 0.7s forwards; }
.stagger-children.is-visible > *:nth-child(9) { animation: fade-up 0.6s var(--ease-out) 0.8s forwards; }
.stagger-children.is-visible > *:nth-child(10) { animation: fade-up 0.6s var(--ease-out) 0.9s forwards; }
.stagger-children.is-visible > *:nth-child(11) { animation: fade-up 0.6s var(--ease-out) 1.0s forwards; }
.stagger-children.is-visible > *:nth-child(12) { animation: fade-up 0.6s var(--ease-out) 1.1s forwards; }
.stagger-children.is-visible > *:nth-child(n+13) { animation: fade-up 0.6s var(--ease-out) 1.2s forwards; }

/* ── Reveal Line ── */
.reveal-line {
  position: relative;
  overflow: hidden;
}
.reveal-line::after {
  content: '';
  position: absolute;
  top: 0; right: 0; bottom: 0; left: 0;
  background: var(--bg);
  transform: scaleX(1);
  transform-origin: left;
  transition: transform 0.8s var(--ease-out);
}
.reveal-line.is-visible::after { transform: scaleX(0); transform-origin: right; }

/* ── Orbit Ring ── */
@keyframes orbit {
  from { transform: rotate(0deg) translateX(80px) rotate(0deg); }
  to { transform: rotate(360deg) translateX(80px) rotate(-360deg); }
}
.orbit-element { animation: orbit 8s linear infinite; }

/* ── Tilt Shadow ── */
.tilt-card {
  transform-style: preserve-3d;
  perspective: 1000px;
  transition: transform 0.1s var(--ease-out);
}
.tilt-card .tilt-inner {
  transform: translateZ(20px);
  pointer-events: none;
}

/* ── Magnetic Button State ── */
.magnetic-btn {
  transition: transform 0.3s var(--spring);
}

/* ── Mobile — disable heavy animations ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
