/* ============================================================
   ANIMATIONS.CSS — Butterflies, Petals, Particles & Transitions
   ============================================================ */

/* ======================== PETAL SYSTEM (MOBILE) ======================== */
.petal {
  position: absolute;
  pointer-events: none;
  will-change: transform, opacity;
  z-index: var(--z-canvas);
}

/* Petal shapes using CSS */
.petal-shape {
  width: 12px;
  height: 18px;
  border-radius: 50% 50% 50% 0;
  transform: rotate(-45deg);
  opacity: 0.3;
  background: var(--color-glow);
  transition: background var(--transition-theme);
}

.petal:nth-child(odd) .petal-shape {
  width: 10px;
  height: 15px;
  border-radius: 50%;
}

.petal:nth-child(3n) .petal-shape {
  width: 14px;
  height: 20px;
}

/* Petal falling animations */
@keyframes petal-fall-1 {
  0% {
    transform: translateY(-5vh) translateX(0) rotate(0deg) scale(0.8);
    opacity: 0;
  }
  5% { opacity: 0.3; }
  50% {
    transform: translateY(50vh) translateX(60px) rotate(180deg) scale(1);
    opacity: 0.25;
  }
  95% { opacity: 0.15; }
  100% {
    transform: translateY(105vh) translateX(30px) rotate(360deg) scale(0.6);
    opacity: 0;
  }
}

@keyframes petal-fall-2 {
  0% {
    transform: translateY(-5vh) translateX(0) rotate(45deg) scale(0.7);
    opacity: 0;
  }
  5% { opacity: 0.25; }
  40% {
    transform: translateY(40vh) translateX(-50px) rotate(200deg) scale(1.1);
    opacity: 0.3;
  }
  95% { opacity: 0.1; }
  100% {
    transform: translateY(105vh) translateX(-20px) rotate(400deg) scale(0.5);
    opacity: 0;
  }
}

@keyframes petal-fall-3 {
  0% {
    transform: translateY(-5vh) translateX(0) rotate(-30deg) scale(0.9);
    opacity: 0;
  }
  8% { opacity: 0.35; }
  60% {
    transform: translateY(60vh) translateX(80px) rotate(250deg) scale(0.8);
    opacity: 0.2;
  }
  95% { opacity: 0.1; }
  100% {
    transform: translateY(105vh) translateX(50px) rotate(450deg) scale(0.4);
    opacity: 0;
  }
}

.petal:nth-child(1) { animation: petal-fall-1 10s ease-in-out infinite; right: 10%; animation-delay: 0s; }
.petal:nth-child(2) { animation: petal-fall-2 12s ease-in-out infinite; right: 25%; animation-delay: -2s; }
.petal:nth-child(3) { animation: petal-fall-3 11s ease-in-out infinite; right: 40%; animation-delay: -4s; }
.petal:nth-child(4) { animation: petal-fall-1 13s ease-in-out infinite; right: 55%; animation-delay: -1s; }
.petal:nth-child(5) { animation: petal-fall-2 9s  ease-in-out infinite; right: 70%; animation-delay: -6s; }
.petal:nth-child(6) { animation: petal-fall-3 14s ease-in-out infinite; right: 85%; animation-delay: -3s; }
.petal:nth-child(7) { animation: petal-fall-1 11s ease-in-out infinite; right: 15%; animation-delay: -8s; }
.petal:nth-child(8) { animation: petal-fall-2 10s ease-in-out infinite; right: 60%; animation-delay: -5s; }

/* ======================== GLOWING PARTICLES ======================== */
.particle {
  position: absolute;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: var(--color-glow);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
  transition: background var(--transition-theme);
}

@keyframes particle-float-1 {
  0% {
    transform: translate(0, 0) scale(0.5);
    opacity: 0;
  }
  20% { opacity: 0.4; }
  50% {
    transform: translate(30px, -60px) scale(1);
    opacity: 0.6;
  }
  80% { opacity: 0.3; }
  100% {
    transform: translate(-20px, -120px) scale(0.3);
    opacity: 0;
  }
}

@keyframes particle-float-2 {
  0% {
    transform: translate(0, 0) scale(0.3);
    opacity: 0;
  }
  30% { opacity: 0.5; }
  60% {
    transform: translate(-40px, -80px) scale(0.8);
    opacity: 0.4;
  }
  100% {
    transform: translate(20px, -150px) scale(0.2);
    opacity: 0;
  }
}

@keyframes particle-float-3 {
  0% {
    transform: translate(0, 0) scale(0.6);
    opacity: 0;
  }
  25% { opacity: 0.3; }
  75% {
    transform: translate(50px, -100px) scale(1.2);
    opacity: 0.5;
  }
  100% {
    transform: translate(10px, -180px) scale(0.1);
    opacity: 0;
  }
}

.particle:nth-child(3n+1) { animation: particle-float-1 6s ease-in-out infinite; }
.particle:nth-child(3n+2) { animation: particle-float-2 8s ease-in-out infinite; }
.particle:nth-child(3n+3) { animation: particle-float-3 7s ease-in-out infinite; }

/* ======================== CURTAIN TRANSITION ======================== */
.curtain-transition {
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ======================== SONG CARD ANIMATIONS ======================== */
.song-card {
  animation: card-appear 0.5s ease backwards;
}

.song-card:nth-child(1) { animation-delay: 0.05s; }
.song-card:nth-child(2) { animation-delay: 0.1s; }
.song-card:nth-child(3) { animation-delay: 0.15s; }
.song-card:nth-child(4) { animation-delay: 0.2s; }
.song-card:nth-child(5) { animation-delay: 0.25s; }
.song-card:nth-child(6) { animation-delay: 0.3s; }
.song-card:nth-child(7) { animation-delay: 0.35s; }
.song-card:nth-child(8) { animation-delay: 0.4s; }

@keyframes card-appear {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* ======================== VIEW TRANSITIONS ======================== */
.view {
  animation: view-enter 0.5s ease;
}

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

/* ======================== GLOW TEXT ANIMATION ======================== */
@keyframes text-glow {
  0%, 100% {
    text-shadow: 0 0 20px rgba(var(--color-primary-rgb), 0.3);
  }
  50% {
    text-shadow: 0 0 40px rgba(var(--color-primary-rgb), 0.5),
                 0 0 60px rgba(var(--color-primary-rgb), 0.2);
  }
}

/* ======================== PLAYING INDICATOR ======================== */
.now-playing-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 16px;
}

.now-playing-bars span {
  display: block;
  width: 3px;
  background: var(--color-primary);
  border-radius: 2px;
  animation: playing-bar 0.8s ease-in-out infinite;
  transition: background var(--transition-theme);
}

.now-playing-bars span:nth-child(1) { animation-delay: 0s; height: 60%; }
.now-playing-bars span:nth-child(2) { animation-delay: 0.15s; height: 100%; }
.now-playing-bars span:nth-child(3) { animation-delay: 0.3s; height: 40%; }

@keyframes playing-bar {
  0%, 100% { transform: scaleY(0.3); }
  50% { transform: scaleY(1); }
}

/* ======================== SKELETON LOADING ======================== */
.skeleton {
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0.03) 25%,
    rgba(255, 255, 255, 0.06) 50%,
    rgba(255, 255, 255, 0.03) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ======================== UPLOAD DRAG OVER ======================== */
.upload-zone.drag-over {
  border-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.08);
  animation: drag-pulse 1s ease-in-out infinite;
}

@keyframes drag-pulse {
  0%, 100% { border-color: rgba(var(--color-primary-rgb), 0.3); }
  50% { border-color: rgba(var(--color-primary-rgb), 0.6); }
}

/* ======================== HERO TITLE ENTRANCE ======================== */
.hero-eyebrow {
  animation: hero-fade-up 0.8s ease 0.2s backwards;
}

.hero-title {
  animation: hero-fade-up 0.8s ease 0.4s backwards;
}

.hero-subtitle {
  animation: hero-fade-up 0.8s ease 0.6s backwards;
}

.hero-stats {
  animation: hero-fade-up 0.8s ease 0.8s backwards;
}

.hero .btn-primary {
  animation: hero-fade-up 0.8s ease 1s backwards;
}

@keyframes hero-fade-up {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ======================== REDUCED MOTION ======================== */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  
  .petal, .particle {
    display: none !important;
  }
  
  .butterfly-canvas {
    display: none !important;
  }
}
