/* ============================================
   WalkieTalk French Games — Animations
   ============================================ */

/* Page Transitions */
.page-enter {
  animation: fadeIn 0.3s ease forwards;
}

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

/* Card Flip */
.flip-card {
  perspective: 1000px;
  cursor: pointer;
}

.flip-card-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}

.flip-card.flipped .flip-card-inner {
  transform: rotateY(180deg);
}

.flip-card-front,
.flip-card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.flip-card-back {
  transform: rotateY(180deg);
}

/* Correct Answer */
@keyframes correctPulse {
  0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(45, 147, 108, 0.4); }
  50% { transform: scale(1.02); box-shadow: 0 0 0 10px rgba(45, 147, 108, 0); }
  100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(45, 147, 108, 0); }
}

.correct-pulse {
  animation: correctPulse 0.5s ease;
}

/* Wrong Answer Shake */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

.shake {
  animation: shake 0.4s ease;
}

/* Bounce In */
@keyframes bounceIn {
  0% { transform: scale(0.3); opacity: 0; }
  50% { transform: scale(1.05); }
  70% { transform: scale(0.95); }
  100% { transform: scale(1); opacity: 1; }
}

.bounce-in {
  animation: bounceIn 0.5s ease;
}

/* Slide Up */
@keyframes slideUp {
  from { transform: translateY(30px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.slide-up {
  animation: slideUp 0.4s ease forwards;
}

/* Stagger children */
.stagger-children > * {
  opacity: 0;
  animation: slideUp 0.4s ease forwards;
}

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

/* Floating Animation (Landing Page) */
@keyframes float {
  0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.15; }
  50% { transform: translateY(-20px) rotate(5deg); opacity: 0.25; }
}

.floating-word {
  position: absolute;
  font-size: 1.2rem;
  font-style: italic;
  color: var(--accent-primary);
  opacity: 0.15;
  pointer-events: none;
  animation: float 6s ease-in-out infinite;
  user-select: none;
}

.floating-word:nth-child(2) { animation-delay: 1s; animation-duration: 7s; }
.floating-word:nth-child(3) { animation-delay: 2s; animation-duration: 8s; }
.floating-word:nth-child(4) { animation-delay: 0.5s; animation-duration: 5s; }
.floating-word:nth-child(5) { animation-delay: 1.5s; animation-duration: 9s; }
.floating-word:nth-child(6) { animation-delay: 3s; animation-duration: 6s; }
.floating-word:nth-child(7) { animation-delay: 2.5s; animation-duration: 7.5s; }
.floating-word:nth-child(8) { animation-delay: 0.8s; animation-duration: 8.5s; }

/* Confetti */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 500;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 10px;
  top: -10px;
  border-radius: 2px;
  animation: confettiFall 3s ease-in forwards;
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* Pulse Glow (for audio button) */
@keyframes pulseGlow {
  0%, 100% { box-shadow: 0 0 0 0 rgba(27, 42, 74, 0.3); }
  50% { box-shadow: 0 0 0 12px rgba(27, 42, 74, 0); }
}

.pulse-glow {
  animation: pulseGlow 2s ease infinite;
}

/* Score Pop */
@keyframes scorePop {
  0% { transform: scale(0) translateY(0); opacity: 1; }
  50% { transform: scale(1.2) translateY(-20px); opacity: 1; }
  100% { transform: scale(1) translateY(-40px); opacity: 0; }
}

.score-pop {
  position: absolute;
  font-weight: 700;
  color: var(--xp-gold);
  animation: scorePop 0.8s ease forwards;
  pointer-events: none;
}

/* Waveform (Listening) */
.waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 40px;
}

.waveform-bar {
  width: 4px;
  background: var(--accent-primary);
  border-radius: 2px;
  animation: waveformPulse 1s ease-in-out infinite;
}

.waveform-bar:nth-child(1) { animation-delay: 0s; height: 20px; }
.waveform-bar:nth-child(2) { animation-delay: 0.1s; height: 30px; }
.waveform-bar:nth-child(3) { animation-delay: 0.2s; height: 15px; }
.waveform-bar:nth-child(4) { animation-delay: 0.3s; height: 35px; }
.waveform-bar:nth-child(5) { animation-delay: 0.4s; height: 25px; }
.waveform-bar:nth-child(6) { animation-delay: 0.15s; height: 18px; }
.waveform-bar:nth-child(7) { animation-delay: 0.25s; height: 32px; }

@keyframes waveformPulse {
  0%, 100% { transform: scaleY(0.5); }
  50% { transform: scaleY(1); }
}

/* Progress bar fill */
@keyframes progressFill {
  from { width: 0; }
}

.progress-bar {
  height: 8px;
  background: var(--bg-tertiary);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--accent-primary));
  border-radius: 4px;
  transition: width 0.5s ease;
  animation: progressFill 0.8s ease;
}

/* Streak flame */
@keyframes flamePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

.streak-flame {
  animation: flamePulse 1s ease infinite;
  display: inline-block;
}
