/* ========================================
   QUIZ ENGAGEMENT ANIMATIONS
   Feedback messages, streaks, and visual effects
   ======================================== */

/* ========================================
   FEEDBACK MESSAGE ANIMATIONS (0.5 seconds)
   ======================================== */

@keyframes feedbackBounceIn {
    0% {
        transform: scale(0.3) translateY(20px);
        opacity: 0;
    }
    50% {
        transform: scale(1.05);
    }
    100% {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

@keyframes feedbackSlideIn {
    0% {
        transform: translateX(-100%);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes feedbackPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.08);
    }
}

@keyframes successGlow {
    0% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    70% {
        box-shadow: 0 0 0 15px rgba(76, 175, 80, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0);
    }
}

@keyframes errorShake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

@keyframes feedbackFadeOut {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    100% {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Feedback Container */
.feedback-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.feedback-container.show {
    opacity: 1;
    visibility: visible;
}

.feedback-message {
    padding: 20px 40px;
    border-radius: 15px;
    font-size: 1.4em;
    font-weight: bold;
    text-align: center;
    min-width: 300px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    backdrop-filter: blur(10px);
    animation: feedbackBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.feedback-message.success {
    background: linear-gradient(135deg, #4CAF50 0%, #45a049 100%);
    color: white;
    border: 2px solid #2E7D32;
    animation: feedbackBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
              successGlow 1.5s ease-out 0.3s;
}

.feedback-message.error {
    background: linear-gradient(135deg, #f44336 0%, #da190b 100%);
    color: white;
    border: 2px solid #c62828;
    animation: feedbackBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
              errorShake 0.4s ease-in-out;
}

.feedback-message.info {
    background: linear-gradient(135deg, #2196F3 0%, #1976D2 100%);
    color: white;
    border: 2px solid #1565C0;
    animation: feedbackSlideIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.feedback-message.warning {
    background: linear-gradient(135deg, #FF9800 0%, #F57C00 100%);
    color: white;
    border: 2px solid #E65100;
    animation: feedbackBounceIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.feedback-message.hide {
    animation: feedbackFadeOut 0.3s ease-out forwards;
}

/* ========================================
   STREAK CELEBRATION ANIMATIONS
   ======================================== */

@keyframes confettiPop {
    0% {
        transform: translate(0, 0) rotate(0deg) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) rotate(360deg) scale(0);
        opacity: 0;
    }
}

@keyframes starBurst {
    0% {
        transform: scale(0);
        opacity: 1;
    }
    50% {
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

@keyframes rainbowWave {
    0% { background-position: 0% 50%; }
    100% { background-position: 100% 50%; }
}

.streak-celebration {
    position: fixed;
    top: 50%;
    left: 50%;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 8000;
}

.confetti {
    position: absolute;
    width: 10px;
    height: 10px;
    pointer-events: none;
}

.confetti.red { background: #f44336; }
.confetti.green { background: #4CAF50; }
.confetti.blue { background: #2196F3; }
.confetti.yellow { background: #FFC107; }
.confetti.pink { background: #E91E63; }
.confetti.purple { background: #9C27B0; }

.star {
    position: absolute;
    font-size: 2em;
    animation: starBurst 1s ease-out forwards;
}

/* ========================================
   ANSWER HIGHLIGHTING ANIMATIONS
   ======================================== */

@keyframes correctPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0.2);
    }
}

@keyframes wrongShake {
    0%, 100% { transform: translateX(0) rotate(0deg); }
    25% { transform: translateX(-8px) rotate(-1deg); }
    75% { transform: translateX(8px) rotate(1deg); }
}

.option-item.correct-answer {
    background: linear-gradient(135deg, rgba(76, 175, 80, 0.3) 0%, rgba(76, 175, 80, 0.1) 100%);
    border: 2px solid #4CAF50;
    animation: correctPulse 0.6s ease-out;
}

.option-item.wrong-answer {
    background: linear-gradient(135deg, rgba(244, 67, 54, 0.3) 0%, rgba(244, 67, 54, 0.1) 100%);
    border: 2px solid #f44336;
    animation: wrongShake 0.4s ease-in-out;
}

/* ========================================
   QUESTION TRANSITION ANIMATIONS
   ======================================== */

@keyframes questionSlideIn {
    0% {
        opacity: 0;
        transform: translateY(30px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes questionSlideOut {
    0% {
        opacity: 1;
        transform: translateY(0);
    }
    100% {
        opacity: 0;
        transform: translateY(-30px);
    }
}

.question.entering {
    animation: questionSlideIn 0.4s ease-out forwards;
}

.question.leaving {
    animation: questionSlideOut 0.3s ease-in forwards;
}

/* ========================================
   PROGRESS BAR ANIMATIONS
   ======================================== */

@keyframes progressPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(33, 150, 243, 0.7);
    }
    50% {
        box-shadow: 0 0 0 8px rgba(33, 150, 243, 0);
    }
}

@keyframes progressFill {
    0% {
        width: 0%;
    }
    100% {
        width: var(--progress-width);
    }
}

.quiz-progress {
    animation: progressPulse 2s infinite;
}

.progress-fill {
    animation: progressFill 0.8s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

/* ========================================
   STREAK INDICATOR ANIMATIONS
   ======================================== */

@keyframes streakFlash {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.15);
        opacity: 0.8;
    }
}

@keyframes streakRise {
    0% {
        transform: translateY(20px);
        opacity: 0;
    }
    100% {
        transform: translateY(-30px);
        opacity: 0;
    }
}

.streak-indicator {
    position: fixed;
    font-size: 2em;
    font-weight: bold;
    animation: streakRise 1.5s ease-out forwards;
    pointer-events: none;
    z-index: 5000;
}

.streak-indicator.fire {
    color: #FF6F00;
    text-shadow: 0 0 20px rgba(255, 111, 0, 0.8);
}

.streak-indicator.lightning {
    color: #FFD700;
    text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

.streak-badge {
    display: inline-block;
    padding: 8px 16px;
    border-radius: 20px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 100%);
    color: #333;
    font-weight: bold;
    font-size: 1.1em;
    animation: streakFlash 1s ease-in-out;
    box-shadow: 0 4px 15px rgba(255, 165, 0, 0.4);
}

/* ========================================
   BUTTON PRESS ANIMATIONS
   ======================================== */

@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

@keyframes buttonGlow {
    0%, 100% {
        box-shadow: 0 0 5px rgba(33, 150, 243, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(33, 150, 243, 0.8);
    }
}

.start-quiz-btn:active,
.next-button:active,
.prev-button:active,
.submit-button:active {
    animation: buttonPress 0.2s ease-out;
}

.start-quiz-btn {
    animation: buttonGlow 2s ease-in-out infinite;
}

/* ========================================
   MILESTONE CELEBRATION ANIMATIONS
   ======================================== */

@keyframes milestonePop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

@keyframes milestoneGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(255, 215, 0, 0.5));
    }
    50% {
        filter: drop-shadow(0 0 20px rgba(255, 215, 0, 1));
    }
}

.milestone-badge {
    display: inline-block;
    padding: 15px 30px;
    border-radius: 50px;
    background: linear-gradient(135deg, #FFD700 0%, #FFA500 50%, #FF6F00 100%);
    color: white;
    font-weight: bold;
    font-size: 1.2em;
    text-align: center;
    animation: milestonePop 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
              milestoneGlow 1.5s ease-in-out infinite 0.7s;
    box-shadow: 0 8px 25px rgba(255, 165, 0, 0.4);
}

/* ========================================
   RESULT SCREEN ANIMATIONS
   ======================================== */

@keyframes resultSlideDown {
    0% {
        opacity: 0;
        transform: translateY(-50px);
    }
    100% {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scoreCounter {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
        opacity: 1;
    }
}

@keyframes ribbonWave {
    0%, 100% {
        transform: rotateZ(-1deg);
    }
    50% {
        transform: rotateZ(1deg);
    }
}

.quiz-results {
    animation: resultSlideDown 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.result-score {
    animation: scoreCounter 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.result-ribbon {
    animation: ribbonWave 1.5s ease-in-out infinite;
}

/* ========================================
   ENGAGEMENT PULSES
   ======================================== */

@keyframes subtlePulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.7;
    }
}

@keyframes counterPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.question-counter {
    animation: counterPulse 0.3s ease-out;
}

.quiz-progress-indicator {
    animation: subtlePulse 1s ease-in-out;
}

/* ========================================
   TIMER WARNING ANIMATIONS
   ======================================== */

@keyframes timerWarning {
    0%, 100% {
        color: #FF9800;
    }
    50% {
        color: #FF5722;
        text-shadow: 0 0 10px rgba(255, 87, 34, 0.6);
    }
}

@keyframes timerCritical {
    0%, 100% {
        color: #f44336;
        text-shadow: 0 0 10px rgba(244, 67, 54, 0.6);
    }
    50% {
        color: #d32f2f;
        text-shadow: 0 0 20px rgba(244, 67, 54, 1);
    }
}

.quiz-timer.warning {
    animation: timerWarning 0.8s ease-in-out infinite;
}

.quiz-timer.critical {
    animation: timerCritical 0.4s ease-in-out infinite;
}

/* ========================================
   RESPONSIVE ADJUSTMENTS
   ======================================== */

@media (max-width: 768px) {
    .feedback-message {
        min-width: 250px;
        padding: 15px 30px;
        font-size: 1.1em;
    }

    .milestone-badge {
        padding: 12px 24px;
        font-size: 1em;
    }

    .confetti {
        width: 8px;
        height: 8px;
    }

    .star {
        font-size: 1.5em;
    }
}

@media (max-width: 480px) {
    .feedback-message {
        min-width: 90vw;
        padding: 12px 20px;
        font-size: 0.95em;
    }

    .streak-indicator {
        font-size: 1.5em;
    }
}
