/* Enhanced Animations and Progress Bars */

/* ============================================
   SMOOTH PROGRESS BAR ANIMATIONS
   ============================================ */

/* Linear Progress Bar */
.progress-bar {
    position: relative;
    width: 100%;
    height: 8px;
    background: var(--neutral-200);
    border-radius: var(--radius-full);
    overflow: hidden;
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-500), var(--secondary-500));
    border-radius: var(--radius-full);
    transition: width 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
    transform-origin: left center;
}

/* Shimmer effect on progress bar */
.progress-fill::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    right: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 100%
    );
    animation: progressShimmer 2s ease-in-out infinite;
}

/* Circular Progress Indicator */
.circular-progress {
    position: relative;
    width: 60px;
    height: 60px;
}

.circular-progress svg {
    transform: rotate(-90deg);
    width: 100%;
    height: 100%;
}

.circular-progress-bg {
    fill: none;
    stroke: var(--neutral-200);
    stroke-width: 4;
}

.circular-progress-fill {
    fill: none;
    stroke: url(#progressGradient);
    stroke-width: 4;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    filter: drop-shadow(0 0 4px rgba(102, 126, 234, 0.3));
}

.circular-progress-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: var(--text-sm);
    font-weight: var(--font-semibold);
    color: var(--text-primary);
}

/* Question Counter with Animation */
.question-counter {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-4);
    background: var(--surface-variant);
    border-radius: var(--radius-full);
    font-size: var(--text-sm);
    font-weight: var(--font-medium);
    color: var(--text-secondary);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-counter.updating {
    animation: questionNumberRotate 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-counter-current {
    color: var(--primary-500);
    font-weight: var(--font-bold);
    font-size: var(--text-base);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.question-counter-current.increment {
    animation: countUp 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ============================================
   ENHANCED BUTTON ANIMATIONS
   ============================================ */

/* Smooth hover lift */
.menu-btn,
.option-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

.menu-btn:hover,
.option-btn:hover {
    transform: translateY(-4px) scale(1.01);
    box-shadow: 
        0 12px 24px rgba(0, 0, 0, 0.15),
        0 0 0 1px rgba(255, 255, 255, 0.1);
}

.menu-btn:active,
.option-btn:active {
    transform: translateY(-2px) scale(0.99);
    transition-duration: 0.1s;
}

/* Ripple effect container */
.ripple-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
    pointer-events: none;
    border-radius: inherit;
}

.ripple {
    position: absolute;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.4);
    transform: scale(0);
    animation: rippleEffect 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    pointer-events: none;
}

@keyframes rippleEffect {
    to {
        transform: scale(4);
        opacity: 0;
    }
}

/* ============================================
   ENHANCED ANSWER FEEDBACK ANIMATIONS
   ============================================ */

/* Correct answer - smooth celebration */
.option-btn.correct {
    background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%) !important;
    color: white !important;
    animation: correctCelebrationSmooth 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    box-shadow: 
        0 8px 24px rgba(17, 153, 142, 0.4),
        0 0 40px rgba(17, 153, 142, 0.3),
        0 0 0 4px rgba(17, 153, 142, 0.2);
}

@keyframes correctCelebrationSmooth {
    0% {
        transform: scale(0.95);
    }
    40% {
        transform: scale(1.08);
    }
    60% {
        transform: scale(1.02);
    }
    80% {
        transform: scale(1.06);
    }
    100% {
        transform: scale(1.05);
    }
}

/* Incorrect answer - gentle shake */
.option-btn.incorrect {
    background: linear-gradient(135deg, #ee0979 0%, #ff6a00 100%) !important;
    color: white !important;
    animation: incorrectShakeSmooth 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes incorrectShakeSmooth {
    0%, 100% {
        transform: translateX(0);
    }
    15%, 45%, 75% {
        transform: translateX(-6px);
    }
    30%, 60%, 90% {
        transform: translateX(6px);
    }
}

/* Checkmark animation */
.checkmark-icon {
    display: inline-block;
    animation: checkmarkPopSmooth 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes checkmarkPopSmooth {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Cross icon animation */
.cross-icon {
    display: inline-block;
    animation: crossShake 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes crossShake {
    0%, 100% {
        transform: rotate(0deg);
    }
    25% {
        transform: rotate(-10deg);
    }
    75% {
        transform: rotate(10deg);
    }
}

/* ============================================
   SCORE AND STREAK ANIMATIONS
   ============================================ */

/* Score counter animation */
.score-display {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.score-display.updating {
    animation: scoreUpdate 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes scoreUpdate {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.3);
        color: var(--primary-500);
    }
    100% {
        transform: scale(1);
    }
}

/* Streak indicator */
.streak-indicator {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2) var(--space-3);
    background: linear-gradient(135deg, #ff6b35 0%, #f7931e 100%);
    border-radius: var(--radius-full);
    color: white;
    font-weight: var(--font-semibold);
    box-shadow: 0 4px 12px rgba(255, 107, 53, 0.3);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.streak-indicator.milestone {
    animation: streakMilestoneSmooth 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes streakMilestoneSmooth {
    0% {
        transform: scale(1);
    }
    30% {
        transform: scale(1.2) rotate(5deg);
    }
    50% {
        transform: scale(1.1) rotate(-5deg);
    }
    70% {
        transform: scale(1.15) rotate(3deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
    }
}

.streak-icon {
    font-size: var(--text-lg);
    animation: streakIconPulse 2s ease-in-out infinite;
}

@keyframes streakIconPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
}

/* ============================================
   LOADING STATES
   ============================================ */

/* Smooth spinner */
.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--neutral-200);
    border-top-color: var(--primary-500);
    border-radius: 50%;
    animation: spinnerRotate 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes spinnerRotate {
    to {
        transform: rotate(360deg);
    }
}

/* Dots loading */
.loading-dots {
    display: inline-flex;
    gap: var(--space-2);
}

.loading-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-500);
    border-radius: 50%;
    animation: dotBounce 1.4s ease-in-out infinite;
}

.loading-dot:nth-child(1) {
    animation-delay: 0s;
}

.loading-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.loading-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes dotBounce {
    0%, 80%, 100% {
        transform: scale(0.8);
        opacity: 0.5;
    }
    40% {
        transform: scale(1.2);
        opacity: 1;
    }
}

/* ============================================
   PAGE TRANSITIONS
   ============================================ */

/* Smooth fade transitions */
.fade-enter {
    animation: fadeInSmooth 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

.fade-exit {
    animation: fadeOutSmooth 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes fadeInSmooth {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOutSmooth {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(-10px);
    }
}

/* Slide transitions */
.slide-up-enter {
    animation: slideUpSmooth 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes slideUpSmooth {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* ============================================
   CONFETTI ENHANCEMENTS
   ============================================ */

.confetti-burst {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 9999;
}

.confetti-piece {
    position: absolute;
    width: 10px;
    height: 10px;
    animation: confettiFallSmooth 3s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

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

/* ============================================
   MICRO-INTERACTIONS
   ============================================ */

/* Button press feedback */
.btn-press {
    animation: buttonPress 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes buttonPress {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(0.95);
    }
    100% {
        transform: scale(1);
    }
}

/* Tooltip fade in */
.tooltip {
    animation: tooltipFadeIn 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes tooltipFadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Badge pulse */
.badge-pulse {
    animation: badgePulse 2s cubic-bezier(0.4, 0, 0.2, 1) infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(102, 126, 234, 0.4);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 8px rgba(102, 126, 234, 0);
    }
}

/* ============================================
   RESULTS SCREEN ANIMATIONS
   ============================================ */

/* Trophy bounce in */
.trophy-icon {
    animation: trophyBounceIn 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes trophyBounceIn {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    60% {
        transform: scale(1.2) rotate(10deg);
    }
    80% {
        transform: scale(0.9) rotate(-5deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Perfect score glow */
.perfect-score {
    animation: perfectScoreGlowSmooth 2s ease-in-out infinite;
}

@keyframes perfectScoreGlowSmooth {
    0%, 100% {
        filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.5));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 30px rgba(255, 215, 0, 0.9));
        transform: scale(1.02);
    }
}

/* Stats bar grow */
.stats-bar {
    animation: statsBarGrow 0.8s cubic-bezier(0.4, 0, 0.2, 1) forwards;
}

@keyframes statsBarGrow {
    from {
        transform: scaleX(0);
        opacity: 0;
    }
    to {
        transform: scaleX(1);
        opacity: 1;
    }
}

/* ============================================
   ACCESSIBILITY - REDUCED MOTION
   ============================================ */

@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
    
    .progress-fill::after,
    .ripple,
    .confetti-piece,
    .loading-dot,
    .streak-icon {
        animation: none !important;
    }
    
    .menu-btn:hover,
    .option-btn:hover {
        transform: none;
    }
}

/* ============================================
   DARK MODE ADJUSTMENTS
   ============================================ */

body.dark-mode .progress-bar {
    background: var(--neutral-700);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.3);
}

body.dark-mode .circular-progress-bg {
    stroke: var(--neutral-700);
}

body.dark-mode .question-counter {
    background: var(--neutral-800);
}

body.dark-mode .spinner {
    border-color: var(--neutral-700);
    border-top-color: var(--primary-400);
}
