/* ================================
   Keyframe Animations
   ================================ */

/* Pulse glow for mystery icon */
@keyframes pulse-glow {
  0%, 100% {
    transform: scale(1);
    text-shadow:
      0 0 20px var(--color-primary-glow),
      0 0 40px var(--color-primary-glow),
      0 4px 8px rgba(0, 0, 0, 0.5);
  }
  50% {
    transform: scale(1.05);
    text-shadow:
      0 0 30px var(--color-primary-glow),
      0 0 60px var(--color-primary-glow),
      0 0 80px var(--color-primary-glow),
      0 4px 8px rgba(0, 0, 0, 0.5);
  }
}

/* Fade pulse for hint text */
@keyframes fade-pulse {
  0%, 100% {
    opacity: 0.6;
  }
  50% {
    opacity: 1;
  }
}

/* Rainbow border for legendary cards */
@keyframes rainbow-border {
  0% {
    border-color: #ff44ff;
  }
  25% {
    border-color: #44ffff;
  }
  50% {
    border-color: #ffff44;
  }
  75% {
    border-color: #44ff44;
  }
  100% {
    border-color: #ff44ff;
  }
}

/* Gradient shift for legendary glow */
@keyframes gradient-shift {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Holographic shimmer */
@keyframes holographic {
  0% {
    background-position: 200% 200%;
  }
  100% {
    background-position: -200% -200%;
  }
}

/* Card entrance animation */
@keyframes card-enter {
  0% {
    opacity: 0;
    transform: scale(0.8) rotateY(-10deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotateY(0);
  }
}

/* Card exit animation */
@keyframes card-exit {
  0% {
    opacity: 1;
    transform: scale(1) rotateY(0);
  }
  100% {
    opacity: 0;
    transform: scale(0.8) rotateY(10deg);
  }
}

/* Slide in from left */
@keyframes slide-in-left {
  0% {
    opacity: 0;
    transform: translateX(-100px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Slide in from right */
@keyframes slide-in-right {
  0% {
    opacity: 0;
    transform: translateX(100px);
  }
  100% {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Bounce in */
@keyframes bounce-in {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    opacity: 1;
    transform: scale(1);
  }
}

/* Shake animation for wrong answer */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-5px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(5px);
  }
}

/* Celebrate animation for correct answer */
@keyframes celebrate {
  0% {
    transform: scale(1);
  }
  25% {
    transform: scale(1.2) rotate(-5deg);
  }
  50% {
    transform: scale(1.2) rotate(5deg);
  }
  75% {
    transform: scale(1.1) rotate(-3deg);
  }
  100% {
    transform: scale(1) rotate(0);
  }
}

/* Stat bar fill animation */
@keyframes stat-fill {
  0% {
    width: 0;
  }
}

/* Float animation */
@keyframes float {
  0%, 100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-10px);
  }
}

/* Sparkle effect */
@keyframes sparkle {
  0%, 100% {
    opacity: 0;
    transform: scale(0) rotate(0deg);
  }
  50% {
    opacity: 1;
    transform: scale(1) rotate(180deg);
  }
}

/* ================================
   Animation Utility Classes
   ================================ */
.animate-card-enter {
  animation: card-enter 0.4s ease-out forwards;
}

.animate-card-exit {
  animation: card-exit 0.3s ease-in forwards;
}

.animate-slide-left {
  animation: slide-in-left 0.4s ease-out forwards;
}

.animate-slide-right {
  animation: slide-in-right 0.4s ease-out forwards;
}

.animate-bounce-in {
  animation: bounce-in 0.5s ease-out forwards;
}

.animate-shake {
  animation: shake 0.5s ease-in-out;
}

.animate-celebrate {
  animation: celebrate 0.6s ease-in-out;
}

.animate-float {
  animation: float 3s ease-in-out infinite;
}

/* Stagger animation delays for collection grid */
.collection-card:nth-child(1) { animation-delay: 0.05s; }
.collection-card:nth-child(2) { animation-delay: 0.1s; }
.collection-card:nth-child(3) { animation-delay: 0.15s; }
.collection-card:nth-child(4) { animation-delay: 0.2s; }
.collection-card:nth-child(5) { animation-delay: 0.25s; }
.collection-card:nth-child(6) { animation-delay: 0.3s; }
.collection-card:nth-child(7) { animation-delay: 0.35s; }
.collection-card:nth-child(8) { animation-delay: 0.4s; }
.collection-card:nth-child(9) { animation-delay: 0.45s; }
.collection-card:nth-child(10) { animation-delay: 0.5s; }

/* ================================
   Transitions
   ================================ */
.card-transitioning {
  pointer-events: none;
}

.card-transitioning.to-next .card-inner {
  animation: card-exit 0.2s ease-in forwards;
}

.card-transitioning.from-next .card-inner {
  animation: slide-in-right 0.3s ease-out forwards;
}

.card-transitioning.to-prev .card-inner {
  animation: card-exit 0.2s ease-in forwards;
}

.card-transitioning.from-prev .card-inner {
  animation: slide-in-left 0.3s ease-out forwards;
}

/* ================================
   Reduced Motion Support
   ================================ */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .card-inner {
    transition: none;
  }
}

/* ================================
   Particle/Confetti Container
   ================================ */
.particles-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.particle {
  position: absolute;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  animation: particle-fall 2s ease-in forwards;
}

@keyframes particle-fall {
  0% {
    opacity: 1;
    transform: translateY(0) rotate(0deg);
  }
  100% {
    opacity: 0;
    transform: translateY(100vh) rotate(720deg);
  }
}

/* ================================
   Loading States
   ================================ */
.loading {
  position: relative;
  overflow: hidden;
}

.loading::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.1) 50%,
    transparent 100%
  );
  animation: shimmer 1.5s infinite;
}

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

/* Skeleton loader for cards */
.skeleton-card {
  background: var(--color-surface-elevated);
  border-radius: var(--radius-xl);
  position: relative;
  overflow: hidden;
}

.skeleton-card::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    90deg,
    transparent 0%,
    rgba(255, 255, 255, 0.05) 50%,
    transparent 100%
  );
  animation: shimmer 2s infinite;
}

/* ================================
   LASER LIGHT SHOW Celebration
   ================================ */
.laser-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.3);
}

.laser-beam {
  position: absolute;
  width: 4px;
  height: 100vh;
  transform-origin: top center;
  animation: laser-sweep 0.8s ease-in-out infinite alternate;
}

.laser-beam:nth-child(1) { left: 20%; background: linear-gradient(to bottom, #ff0044, transparent); animation-delay: 0s; }
.laser-beam:nth-child(2) { left: 35%; background: linear-gradient(to bottom, #00ff88, transparent); animation-delay: 0.1s; }
.laser-beam:nth-child(3) { left: 50%; background: linear-gradient(to bottom, #0088ff, transparent); animation-delay: 0.2s; }
.laser-beam:nth-child(4) { left: 65%; background: linear-gradient(to bottom, #ff00ff, transparent); animation-delay: 0.3s; }
.laser-beam:nth-child(5) { left: 80%; background: linear-gradient(to bottom, #ffff00, transparent); animation-delay: 0.4s; }

@keyframes laser-sweep {
  0% { transform: rotate(-30deg) scaleY(0.5); opacity: 0.8; }
  50% { transform: rotate(0deg) scaleY(1); opacity: 1; }
  100% { transform: rotate(30deg) scaleY(0.5); opacity: 0.8; }
}

.laser-flash {
  position: absolute;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at center, rgba(255,255,255,0.4) 0%, transparent 70%);
  animation: laser-flash-pulse 0.3s ease-out infinite;
}

@keyframes laser-flash-pulse {
  0%, 100% { opacity: 0; }
  50% { opacity: 1; }
}

/* ================================
   FIREWORKS Celebration
   ================================ */
.fireworks-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.2);
}

.firework {
  position: absolute;
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.firework-trail {
  position: absolute;
  width: 4px;
  height: 60px;
  background: linear-gradient(to top, transparent, #ffd700);
  border-radius: 2px;
  animation: firework-launch 0.8s ease-out forwards;
}

@keyframes firework-launch {
  0% { transform: translateY(100vh) scaleY(1); opacity: 1; }
  80% { opacity: 1; }
  100% { transform: translateY(0) scaleY(0.3); opacity: 0; }
}

.firework-burst {
  position: absolute;
  width: 200px;
  height: 200px;
  transform: translate(-50%, -50%);
}

.firework-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  left: 50%;
  top: 50%;
  animation: firework-explode 1.2s ease-out forwards;
}

@keyframes firework-explode {
  0% { transform: translate(-50%, -50%) scale(0); opacity: 1; }
  20% { opacity: 1; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0.5); opacity: 0; }
}

/* ================================
   WHIPPED CREAM WITH SPARKLES Celebration
   ================================ */
.cream-container {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9999;
  overflow: hidden;
}

.cream-splat {
  position: absolute;
  background: radial-gradient(ellipse at center,
    #fffef5 0%,
    #fff8e7 30%,
    #f5f0e0 60%,
    transparent 70%);
  border-radius: 50%;
  filter: blur(2px);
  animation: cream-splat-appear 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes cream-splat-appear {
  0% { transform: scale(0) rotate(0deg); opacity: 0; }
  50% { opacity: 1; }
  100% { transform: scale(1) rotate(var(--rot, 15deg)); opacity: 1; }
}

.cream-drip {
  position: absolute;
  width: 20px;
  height: 40px;
  background: linear-gradient(to bottom, #fffef5, #fff8e7);
  border-radius: 0 0 50% 50%;
  animation: cream-drip-fall 1.5s ease-in forwards;
}

@keyframes cream-drip-fall {
  0% { transform: translateY(0) scaleY(1); opacity: 1; }
  100% { transform: translateY(100px) scaleY(1.5); opacity: 0; }
}

.cream-sparkle {
  position: absolute;
  width: 12px;
  height: 12px;
  animation: cream-sparkle-twinkle 0.6s ease-in-out infinite;
}

.cream-sparkle::before,
.cream-sparkle::after {
  content: '';
  position: absolute;
  background: #ffd700;
  border-radius: 2px;
}

.cream-sparkle::before {
  width: 100%;
  height: 3px;
  top: 50%;
  transform: translateY(-50%);
}

.cream-sparkle::after {
  width: 3px;
  height: 100%;
  left: 50%;
  transform: translateX(-50%);
}

@keyframes cream-sparkle-twinkle {
  0%, 100% { transform: scale(0.5) rotate(0deg); opacity: 0.5; }
  50% { transform: scale(1.2) rotate(45deg); opacity: 1; }
}

.cream-star {
  position: absolute;
  font-size: 24px;
  animation: cream-star-pop 1s ease-out forwards;
}

@keyframes cream-star-pop {
  0% { transform: scale(0) rotate(-30deg); opacity: 0; }
  30% { transform: scale(1.3) rotate(10deg); opacity: 1; }
  100% { transform: scale(1) rotate(0deg) translateY(-20px); opacity: 0; }
}
