/* Animations - 動畫效果 */

/* 淡入淡出 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
  }
  to {
    opacity: 0;
  }
}

/* 脈衝效果 */
@keyframes pulse {
  0%, 100% {
    transform: scale(1);
    opacity: 1;
  }
  50% {
    transform: scale(1.1);
    opacity: 0.8;
  }
}

/* 彈跳進入 */
@keyframes bounceIn {
  0% {
    opacity: 0;
    transform: scale(0.3);
  }
  50% {
    opacity: 1;
    transform: scale(1.1);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
  }
}

/* 搖晃效果（錯誤時） */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  10%, 30%, 50%, 70%, 90% {
    transform: translateX(-10px);
  }
  20%, 40%, 60%, 80% {
    transform: translateX(10px);
  }
}

/* 向上飛出（分數） */
@keyframes flyUp {
  0% {
    opacity: 0;
    transform: translateY(20px) scale(0.5);
  }
  50% {
    opacity: 1;
    transform: translateY(-10px) scale(1.2);
  }
  100% {
    opacity: 0;
    transform: translateY(-50px) scale(1);
  }
}

/* 閃爍效果（正確答案） */
@keyframes flash {
  0%, 50%, 100% {
    opacity: 1;
  }
  25%, 75% {
    opacity: 0.5;
  }
}

/* 放大縮小 */
@keyframes scaleUp {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.2);
  }
  100% {
    transform: scale(1);
  }
}

/* 旋轉 */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* 彈跳（圖示） */
@keyframes bounce {
  0%, 20%, 50%, 80%, 100% {
    transform: translateY(0);
  }
  40% {
    transform: translateY(-20px);
  }
  60% {
    transform: translateY(-10px);
  }
}

/* 彩虹效果 */
@keyframes rainbow {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* 應用動畫的 class */
.animate-correct {
  animation: flash 0.6s ease, scaleUp 0.6s ease;
}

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

.animate-score {
  animation: flyUp 1s ease-out;
}

.animate-bounce {
  animation: bounce 1s ease infinite;
}

.animate-pulse {
  animation: pulse 1.5s ease-in-out infinite;
}

/* 正確答案回饋 */
.feedback.correct {
  color: var(--color-success);
  animation: bounceIn 0.5s ease;
}

.feedback.wrong {
  color: var(--color-danger);
  animation: shake 0.5s ease;
}

/* 分數動畫 */
.score-popup {
  position: absolute;
  font-size: 2rem;
  font-weight: 700;
  color: var(--color-success);
  animation: flyUp 1s ease-out forwards;
  pointer-events: none;
  z-index: 1000;
}

/* 連擊效果 */
.streak-display {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 3rem;
  font-weight: 700;
  color: var(--color-warning);
  text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
  animation: scaleUp 0.8s ease, fadeOut 0.8s ease 0.5s forwards;
  pointer-events: none;
  z-index: 1000;
}

/* 星星爆炸效果 */
.star-burst {
  position: absolute;
  font-size: 2rem;
  animation: burst 1s ease-out forwards;
  pointer-events: none;
}

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

/* 過渡效果 */
.fade-in {
  animation: fadeIn 0.5s ease;
}

.fade-out {
  animation: fadeOut 0.5s ease;
}

/* 載入動畫 */
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading {
  display: inline-block;
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: white;
  animation: spin 1s linear infinite;
}

/* 彩紙效果（慶祝） */
.confetti {
  position: fixed;
  width: 10px;
  height: 10px;
  background: var(--color-success);
  animation: confetti-fall 3s linear forwards;
  pointer-events: none;
  z-index: 1000;
}

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

/* 成功回饋綠色閃爍 */
.success-flash {
  animation: success-pulse 0.6s ease;
}

@keyframes success-pulse {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(126, 211, 33, 0.2);
  }
}

/* 錯誤回饋紅色閃爍 */
.error-flash {
  animation: error-pulse 0.6s ease;
}

@keyframes error-pulse {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(255, 107, 107, 0.2);
  }
}

/* 等級晉升通知 */
.level-up-notification {
  position: fixed;
  top: 15%;
  left: 50%;
  transform: translate(-50%, 0);
  background: linear-gradient(135deg, #F5A623, #FF8C00);
  color: white;
  padding: 30px 50px;
  border-radius: 20px;
  font-size: 2.5rem;
  font-weight: 700;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
  animation: levelUpBounce 1.2s ease;
  z-index: 2000;
  pointer-events: none;
}

@keyframes levelUpBounce {
  0% {
    opacity: 0;
    transform: translate(-50%, 0) scale(0.3);
  }
  40% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1.2);
  }
  60% {
    opacity: 1;
    transform: translate(-50%, 0) scale(0.9);
  }
  85% {
    opacity: 1;
    transform: translate(-50%, 0) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, 0) scale(1);
  }
}
