/**
 * animations.css - 영어 챌린지 애니메이션
 * Antigravity Effects: Confetti Burst, Particle Bounce, Glitter Storm
 */

/* ============================================
   Base Animations
   ============================================ */

/* Fade In */
@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* Fade Out */
@keyframes fade-out {
    from { opacity: 1; }
    to { opacity: 0; }
}

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

/* Slide In Down */
@keyframes slide-in-down {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

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

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

/* Slide In Left */
@keyframes slide-in-left {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

/* Slide In Right */
@keyframes slide-in-right {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

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

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

.bounce-in {
    animation: bounce-in 0.5s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

/* Pop In */
@keyframes pop-in {
    0% {
        opacity: 0;
        transform: scale(0);
    }
    80% {
        transform: scale(1.1);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

.pop-in {
    animation: pop-in 0.3s ease forwards;
}

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

.shake {
    animation: shake 0.5s ease;
}

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

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

/* Heartbeat */
@keyframes heartbeat {
    0%, 100% { transform: scale(1); }
    14% { transform: scale(1.3); }
    28% { transform: scale(1); }
    42% { transform: scale(1.3); }
    70% { transform: scale(1); }
}

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

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

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

/* Glow */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.8), 0 0 30px rgba(102, 126, 234, 0.6);
    }
}

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

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

.shimmer {
    background: linear-gradient(90deg,
        var(--bg-tertiary) 25%,
        var(--bg-secondary) 50%,
        var(--bg-tertiary) 75%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

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

.spin {
    animation: spin 1s linear infinite;
}

/* ============================================
   Quiz Specific Animations
   ============================================ */

/* Correct Answer */
@keyframes correct-pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(16, 185, 129, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(16, 185, 129, 0);
    }
}

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

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

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

/* Timer Warning */
@keyframes timer-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.quiz-timer.danger {
    animation: timer-pulse 0.5s ease infinite;
}

/* Question Appear */
@keyframes question-appear {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.quiz-question-card.appear {
    animation: question-appear 0.4s ease forwards;
}

/* Score Increment */
@keyframes score-pop {
    0% {
        opacity: 0;
        transform: translateY(10px) scale(0.5);
    }
    50% {
        opacity: 1;
        transform: translateY(-10px) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px) scale(1);
    }
}

.score-popup {
    position: absolute;
    font-size: var(--font-xl);
    font-weight: 700;
    color: var(--game-exp);
    animation: score-pop 1s ease forwards;
    pointer-events: none;
}

/* ============================================
   Trophy & Ranking Animations
   ============================================ */

/* Crown Bounce */
@keyframes crown-bounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    25% { transform: translateY(-5px) rotate(5deg); }
    50% { transform: translateY(0) rotate(-5deg); }
    75% { transform: translateY(-3px) rotate(3deg); }
}

.podium-crown {
    animation: crown-bounce 2s ease-in-out infinite;
}

/* Rank Entry */
@keyframes rank-entry {
    0% {
        opacity: 0;
        transform: translateX(-20px);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

.ranking-item {
    animation: rank-entry 0.3s ease forwards;
}

.ranking-item:nth-child(1) { animation-delay: 0.05s; }
.ranking-item:nth-child(2) { animation-delay: 0.1s; }
.ranking-item:nth-child(3) { animation-delay: 0.15s; }
.ranking-item:nth-child(4) { animation-delay: 0.2s; }
.ranking-item:nth-child(5) { animation-delay: 0.25s; }
.ranking-item:nth-child(n+6) { animation-delay: 0.3s; }

/* Trophy Shine */
@keyframes trophy-shine {
    0% {
        background-position: -100% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.trophy-shine {
    position: relative;
    overflow: hidden;
}

.trophy-shine::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.4) 50%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: trophy-shine 3s ease-in-out infinite;
}

/* ============================================
   ANTIGRAVITY EFFECTS
   ============================================ */

/* 1. Confetti Burst - 축하 효과 */
.confetti-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
    overflow: hidden;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confetti-fall linear forwards;
}

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

.confetti.square { border-radius: 0; }
.confetti.circle { border-radius: 50%; }
.confetti.triangle {
    width: 0;
    height: 0;
    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-bottom: 10px solid currentColor;
    background: transparent !important;
}

/* 2. Particle Bounce - 입자 바운스 효과 */
.particle-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9998;
}

.particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: particle-bounce 2s ease-in-out infinite;
}

@keyframes particle-bounce {
    0%, 100% {
        transform: translateY(0) scale(1);
        opacity: 0.8;
    }
    50% {
        transform: translateY(-100px) scale(1.2);
        opacity: 1;
    }
}

/* 3. Glitter Storm - 반짝임 폭풍 효과 */
.glitter-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9997;
}

.glitter {
    position: absolute;
    width: 4px;
    height: 4px;
    background: white;
    border-radius: 50%;
    animation: glitter-sparkle 1.5s ease-in-out infinite;
}

@keyframes glitter-sparkle {
    0%, 100% {
        opacity: 0;
        transform: scale(0) rotate(0deg);
    }
    50% {
        opacity: 1;
        transform: scale(1) rotate(180deg);
    }
}

/* Glitter variations */
.glitter:nth-child(odd) {
    animation-delay: 0.5s;
}

.glitter:nth-child(3n) {
    animation-duration: 2s;
}

.glitter:nth-child(4n) {
    width: 6px;
    height: 6px;
}

/* ============================================
   Achievement Unlock Animations
   ============================================ */

@keyframes achievement-unlock {
    0% {
        opacity: 0;
        transform: scale(0) rotate(-180deg);
    }
    50% {
        opacity: 1;
        transform: scale(1.2) rotate(10deg);
    }
    75% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.achievement-unlock {
    animation: achievement-unlock 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55) forwards;
}

@keyframes achievement-glow {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
    }
    50% {
        box-shadow: 0 0 30px 10px rgba(251, 191, 36, 0.5);
    }
}

.achievement-glow {
    animation: achievement-glow 1.5s ease-in-out infinite;
}

/* ============================================
   Button Animations
   ============================================ */

@keyframes button-ripple {
    0% {
        transform: scale(0);
        opacity: 0.5;
    }
    100% {
        transform: scale(4);
        opacity: 0;
    }
}

.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::after {
    content: '';
    position: absolute;
    width: 100px;
    height: 100px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    transform: scale(0);
    animation: button-ripple 0.6s ease-out;
    pointer-events: none;
}

/* Loading Button */
@keyframes loading-dots {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.btn-loading {
    position: relative;
    color: transparent !important;
}

.btn-loading::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: white;
    border-radius: 50%;
    left: calc(50% - 15px);
    animation: loading-dots 1.4s infinite ease-in-out;
    animation-delay: -0.32s;
    box-shadow: 15px 0 0 -1px white, 30px 0 0 -1px white;
}

/* ============================================
   Page Transitions
   ============================================ */

@keyframes page-enter {
    0% {
        opacity: 0;
        transform: translateY(20px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

.page-enter {
    animation: page-enter 0.4s ease forwards;
}

@keyframes page-exit {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-20px);
    }
}

.page-exit {
    animation: page-exit 0.3s ease forwards;
}

/* ============================================
   Staggered Animations
   ============================================ */

.stagger-children > * {
    opacity: 0;
    animation: slide-in-up 0.4s ease forwards;
}

.stagger-children > *:nth-child(1) { animation-delay: 0.1s; }
.stagger-children > *:nth-child(2) { animation-delay: 0.2s; }
.stagger-children > *:nth-child(3) { animation-delay: 0.3s; }
.stagger-children > *:nth-child(4) { animation-delay: 0.4s; }
.stagger-children > *:nth-child(5) { animation-delay: 0.5s; }
.stagger-children > *:nth-child(6) { animation-delay: 0.6s; }
.stagger-children > *:nth-child(7) { animation-delay: 0.7s; }
.stagger-children > *:nth-child(8) { animation-delay: 0.8s; }

/* ============================================
   Number Counter Animation (CSS only fallback)
   ============================================ */

@keyframes count-up {
    0% { content: '0'; }
    10% { content: '10'; }
    20% { content: '20'; }
    30% { content: '30'; }
    40% { content: '40'; }
    50% { content: '50'; }
    60% { content: '60'; }
    70% { content: '70'; }
    80% { content: '80'; }
    90% { content: '90'; }
    100% { content: '100'; }
}

/* ============================================
   3D Card Flip
   ============================================ */

.flip-card {
    perspective: 1000px;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s;
    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;
}

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

/* ============================================
   Typing Effect
   ============================================ */

@keyframes typing {
    from { width: 0; }
    to { width: 100%; }
}

@keyframes blink-caret {
    from, to { border-color: transparent; }
    50% { border-color: var(--primary); }
}

.typing-effect {
    overflow: hidden;
    white-space: nowrap;
    border-right: 2px solid var(--primary);
    animation:
        typing 3s steps(40, end),
        blink-caret 0.75s step-end infinite;
}

/* ============================================
   Notification Badge Pulse
   ============================================ */

@keyframes notification-pulse {
    0% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    70% {
        transform: scale(1.1);
        box-shadow: 0 0 0 10px rgba(239, 68, 68, 0);
    }
    100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0);
    }
}

.notification-badge {
    animation: notification-pulse 2s infinite;
}

/* ============================================
   Cosmic Background Animation
   ============================================ */

@keyframes cosmic-flow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.cosmic-bg {
    background: linear-gradient(-45deg, #667eea, #764ba2, #f093fb, #667eea);
    background-size: 400% 400%;
    animation: cosmic-flow 15s ease infinite;
}

/* ============================================
   Star Twinkle
   ============================================ */

@keyframes twinkle {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50% { opacity: 1; transform: scale(1.2); }
}

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

.star:nth-child(1) { animation-delay: 0s; }
.star:nth-child(2) { animation-delay: 0.3s; }
.star:nth-child(3) { animation-delay: 0.6s; }
.star:nth-child(4) { animation-delay: 0.9s; }
.star:nth-child(5) { animation-delay: 1.2s; }
