/* ===== Card Flip (handled by .flipped class in styles.css) ===== */

/* ===== Correct Answer Bounce ===== */
@keyframes bounce-correct {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateY(-8px); }
  40% { transform: translateY(-4px); }
  60% { transform: translateY(-2px); }
}

.quiz-option--correct {
  animation: bounce-correct 0.5s ease;
}

/* ===== Wrong Answer Shake ===== */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  15% { transform: translateX(-8px); }
  30% { transform: translateX(8px); }
  45% { transform: translateX(-6px); }
  60% { transform: translateX(6px); }
  75% { transform: translateX(-3px); }
  90% { transform: translateX(3px); }
}

.quiz-option--incorrect {
  animation: shake 0.5s ease;
}

/* ===== Pulse Animation ===== */
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

.home-btn {
  animation: pulse 2.5s ease-in-out infinite;
}

.home-btn:nth-child(2) {
  animation-delay: 0.3s;
}

.home-btn:nth-child(3) {
  animation-delay: 0.6s;
}

.home-btn:hover {
  animation: none;
}

/* ===== Fade In Up ===== */
@keyframes fade-in-up {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.fade-in-up {
  animation: fade-in-up 0.4s ease forwards;
}

/* ===== Staggered Leaderboard Row Fade In ===== */
@keyframes row-fade-in {
  from {
    opacity: 0;
    transform: translateX(-20px);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

.leaderboard-row {
  opacity: 0;
  animation: row-fade-in 0.4s ease forwards;
}

/* Stagger each row's animation */
.leaderboard-row:nth-child(1) { animation-delay: 0.05s; }
.leaderboard-row:nth-child(2) { animation-delay: 0.1s; }
.leaderboard-row:nth-child(3) { animation-delay: 0.15s; }
.leaderboard-row:nth-child(4) { animation-delay: 0.2s; }
.leaderboard-row:nth-child(5) { animation-delay: 0.25s; }
.leaderboard-row:nth-child(6) { animation-delay: 0.3s; }
.leaderboard-row:nth-child(7) { animation-delay: 0.35s; }
.leaderboard-row:nth-child(8) { animation-delay: 0.4s; }
.leaderboard-row:nth-child(9) { animation-delay: 0.45s; }
.leaderboard-row:nth-child(10) { animation-delay: 0.5s; }
.leaderboard-row:nth-child(11) { animation-delay: 0.55s; }
.leaderboard-row:nth-child(12) { animation-delay: 0.6s; }
.leaderboard-row:nth-child(13) { animation-delay: 0.65s; }
.leaderboard-row:nth-child(14) { animation-delay: 0.7s; }
.leaderboard-row:nth-child(15) { animation-delay: 0.75s; }
.leaderboard-row:nth-child(16) { animation-delay: 0.8s; }
.leaderboard-row:nth-child(17) { animation-delay: 0.85s; }
.leaderboard-row:nth-child(18) { animation-delay: 0.9s; }
.leaderboard-row:nth-child(19) { animation-delay: 0.95s; }
.leaderboard-row:nth-child(20) { animation-delay: 1.0s; }
.leaderboard-row:nth-child(n+21) { animation-delay: 1.05s; }

/* ===== Scale In ===== */
@keyframes scale-in {
  from {
    opacity: 0;
    transform: scale(0.8);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.scale-in {
  animation: scale-in 0.4s ease forwards;
}

/* ===== Score Count Up ===== */
@keyframes score-pop {
  0% { transform: scale(0.5); opacity: 0; }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); opacity: 1; }
}

.results-score {
  animation: score-pop 0.6s ease forwards;
}

/* ===== Star Twinkle ===== */
@keyframes twinkle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.3); }
}

.results-stars span {
  display: inline-block;
  animation: twinkle 0.6s ease forwards;
}

.results-stars span:nth-child(2) { animation-delay: 0.1s; }
.results-stars span:nth-child(3) { animation-delay: 0.2s; }
.results-stars span:nth-child(4) { animation-delay: 0.3s; }
.results-stars span:nth-child(5) { animation-delay: 0.4s; }

/* ===== Book Card Hover Glow ===== */
.book-card {
  transition: transform 0.3s ease, box-shadow 0.3s ease, filter 0.3s ease;
}

.book-card:hover {
  filter: brightness(1.1);
}

/* ===== Flashcard Tap Hint ===== */
@keyframes hint-fade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

.flashcard-hint {
  animation: hint-fade 2s ease-in-out infinite;
}

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