/* =============================================
   animations.css - アニメーション専用CSS
   ============================================= */

/* --- ボタンのpulse（はじめるボタン用） --- */
@keyframes pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(91, 106, 240, 0.35);
  }
  50% {
    transform: scale(1.05);
    box-shadow: 0 0 0 15px rgba(91, 106, 240, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(91, 106, 240, 0);
  }
}

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

/* --- 正解時のconfetti風パーティクル（純CSS実装） --- */
.confetti-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
  z-index: 1000;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-10px) rotate(0deg) scale(1);
    opacity: 1;
  }
  25% {
    transform: translateY(25vh) rotate(180deg) scale(0.9);
    opacity: 1;
  }
  50% {
    transform: translateY(50vh) rotate(360deg) scale(0.8);
    opacity: 0.8;
  }
  75% {
    transform: translateY(75vh) rotate(540deg) scale(0.7);
    opacity: 0.5;
  }
  100% {
    transform: translateY(105vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

@keyframes confetti-sway-left {
  0%, 100% {
    margin-left: 0;
  }
  25% {
    margin-left: -20px;
  }
  50% {
    margin-left: 10px;
  }
  75% {
    margin-left: -15px;
  }
}

@keyframes confetti-sway-right {
  0%, 100% {
    margin-left: 0;
  }
  25% {
    margin-left: 20px;
  }
  50% {
    margin-left: -10px;
  }
  75% {
    margin-left: 15px;
  }
}

.confetti-piece {
  position: absolute;
  top: -10px;
  width: 8px;
  height: 8px;
  animation: confetti-fall 2.5s ease-in forwards;
}

.confetti-piece::before,
.confetti-piece::after {
  content: '';
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
}

.confetti-piece::before {
  background: currentColor;
  border-radius: 1px;
}

.confetti-piece::after {
  background: currentColor;
  opacity: 0.6;
  border-radius: 50%;
  width: 6px;
  height: 6px;
  top: 2px;
  left: 2px;
}

/* confettiの各ピースの位置・色・タイミング */
.confetti-piece:nth-child(1) {
  left: 5%;
  color: #FF6B6B;
  animation-delay: 0s;
  animation-duration: 2.2s;
}
.confetti-piece:nth-child(1)::before {
  animation: confetti-sway-left 1s ease-in-out infinite;
}

.confetti-piece:nth-child(2) {
  left: 15%;
  color: #FDCB6E;
  animation-delay: 0.1s;
  animation-duration: 2.6s;
}
.confetti-piece:nth-child(2)::before {
  animation: confetti-sway-right 1.2s ease-in-out infinite;
}

.confetti-piece:nth-child(3) {
  left: 25%;
  color: #00B894;
  animation-delay: 0.2s;
  animation-duration: 2.0s;
}
.confetti-piece:nth-child(3)::before {
  animation: confetti-sway-left 0.8s ease-in-out infinite;
}

.confetti-piece:nth-child(4) {
  left: 35%;
  color: #6C5CE7;
  animation-delay: 0.05s;
  animation-duration: 2.8s;
}
.confetti-piece:nth-child(4)::before {
  animation: confetti-sway-right 1.1s ease-in-out infinite;
}

.confetti-piece:nth-child(5) {
  left: 45%;
  color: #A29BFE;
  animation-delay: 0.3s;
  animation-duration: 2.4s;
}
.confetti-piece:nth-child(5)::before {
  animation: confetti-sway-left 1.3s ease-in-out infinite;
}

.confetti-piece:nth-child(6) {
  left: 55%;
  color: #FF6B6B;
  animation-delay: 0.15s;
  animation-duration: 2.3s;
}
.confetti-piece:nth-child(6)::before {
  animation: confetti-sway-right 0.9s ease-in-out infinite;
}

.confetti-piece:nth-child(7) {
  left: 65%;
  color: #FDCB6E;
  animation-delay: 0.25s;
  animation-duration: 2.7s;
}
.confetti-piece:nth-child(7)::before {
  animation: confetti-sway-left 1.1s ease-in-out infinite;
}

.confetti-piece:nth-child(8) {
  left: 75%;
  color: #00B894;
  animation-delay: 0.1s;
  animation-duration: 2.1s;
}
.confetti-piece:nth-child(8)::before {
  animation: confetti-sway-right 1.4s ease-in-out infinite;
}

.confetti-piece:nth-child(9) {
  left: 85%;
  color: #6C5CE7;
  animation-delay: 0.35s;
  animation-duration: 2.5s;
}
.confetti-piece:nth-child(9)::before {
  animation: confetti-sway-left 1.0s ease-in-out infinite;
}

.confetti-piece:nth-child(10) {
  left: 95%;
  color: #A29BFE;
  animation-delay: 0.2s;
  animation-duration: 2.9s;
}
.confetti-piece:nth-child(10)::before {
  animation: confetti-sway-right 1.2s ease-in-out infinite;
}

.confetti-piece:nth-child(11) {
  left: 10%;
  color: #FF6B6B;
  animation-delay: 0.4s;
  animation-duration: 2.0s;
  width: 6px;
  height: 6px;
}

.confetti-piece:nth-child(12) {
  left: 50%;
  color: #FDCB6E;
  animation-delay: 0.45s;
  animation-duration: 2.3s;
  width: 10px;
  height: 10px;
}

/* --- 不正解時のshake --- */
@keyframes shake {
  0%, 100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-10px);
  }
  40% {
    transform: translateX(10px);
  }
  60% {
    transform: translateX(-8px);
  }
  80% {
    transform: translateX(8px);
  }
}

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

/* --- フェードイン --- */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.fade-in {
  animation: fadeIn 0.3s ease-out;
}

/* --- スライドアップ（解説表示用） --- */
@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.slide-up {
  animation: slideUp 0.3s ease-out;
}

/* --- スコアカウントアップ（JS制御用） --- */
.count-up {
  display: inline-block;
  transition: transform 0.1s;
}

.count-up--tick {
  transform: scale(1.1);
}

/* --- 星の表示アニメーション --- */
@keyframes starPop {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.3);
    opacity: 1;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.star-pop {
  animation: starPop 0.4s ease-out both;
}

.star-pop:nth-child(2) {
  animation-delay: 0.15s;
}

.star-pop:nth-child(3) {
  animation-delay: 0.3s;
}

/* --- パーフェクト演出 --- */
@keyframes rainbow {
  0% {
    color: #FF6B6B;
  }
  25% {
    color: #FDCB6E;
  }
  50% {
    color: #00B894;
  }
  75% {
    color: #A29BFE;
  }
  100% {
    color: #6C5CE7;
  }
}

.perfect-text {
  animation: rainbow 1s linear infinite;
}

/* --- ストリーク炎の拡大 --- */
@keyframes fireGrow {
  0% {
    transform: scale(1);
  }
  30% {
    transform: scale(1.4);
  }
  50% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(1.35);
  }
  100% {
    transform: scale(1);
  }
}

.fire-grow {
  display: inline-block;
  animation: fireGrow 0.5s ease-out;
}

/* --- カードのホバー浮き上がり --- */
.card-hover {
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-hover:active {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(45, 49, 66, 0.12);
}

@media (hover: hover) {
  .card-hover:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(45, 49, 66, 0.12);
  }
}

/* --- ページ遷移: スライドイン --- */
@keyframes slideInRight {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

@keyframes slideInLeft {
  from {
    transform: translateX(-100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.slide-in-right {
  animation: slideInRight 0.3s ease-out;
}

.slide-in-left {
  animation: slideInLeft 0.3s ease-out;
}

/* --- タイマーの点滅（残り5秒以下） --- */
@keyframes timerBlink {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.timer-blink {
  animation: timerBlink 0.5s ease-in-out infinite;
}

/* --- デイリーチャレンジカードの虹色ボーダー --- */
@keyframes rainbowBorder {
  0% {
    border-color: #FF6B6B;
  }
  16% {
    border-color: #FDCB6E;
  }
  33% {
    border-color: #00B894;
  }
  50% {
    border-color: #6C5CE7;
  }
  66% {
    border-color: #A29BFE;
  }
  83% {
    border-color: #FF6B6B;
  }
  100% {
    border-color: #FF6B6B;
  }
}

.daily-card {
  border: 2px solid;
  animation: rainbowBorder 3s linear infinite;
}

/* --- レベルアップ演出 --- */
@keyframes levelUp {
  0% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(91, 106, 240, 0);
  }
  25% {
    transform: scale(1.2);
    text-shadow: 0 0 20px rgba(91, 106, 240, 0.6);
  }
  50% {
    transform: scale(1.4);
    text-shadow: 0 0 40px rgba(139, 149, 247, 0.7);
  }
  75% {
    transform: scale(1.2);
    text-shadow: 0 0 20px rgba(91, 106, 240, 0.4);
  }
  100% {
    transform: scale(1);
    text-shadow: 0 0 0 rgba(91, 106, 240, 0);
  }
}

.level-up {
  display: inline-block;
  animation: levelUp 1s ease-out;
}

/* --- 正解時のポイントフライ --- */
@keyframes pointsFly {
  0% {
    transform: translateY(0);
    opacity: 1;
  }
  100% {
    transform: translateY(-40px);
    opacity: 0;
  }
}

.points-fly {
  animation: pointsFly 0.8s ease-out forwards;
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--primary);
  pointer-events: none;
}

/* --- スケールイン（結果画面のスコア表示用） --- */
@keyframes scaleIn {
  0% {
    transform: scale(0.5);
    opacity: 0;
  }
  60% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.scale-in {
  animation: scaleIn 0.5s ease-out;
}
