/* Ultra UX Enhancements - Fire Emojis, Celebrations, Smooth Interactions */

/* Fire Emoji Animations for Leaderboard Top 3 */
.fire-emoji {
    display: inline-block;
    animation: fireFlicker 1.5s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.6));
    font-size: 1.5em;
    margin-left: 8px;
}

@keyframes fireFlicker {
    0%, 100% {
        transform: scale(1) rotate(-5deg);
        filter: drop-shadow(0 0 10px rgba(255, 107, 107, 0.6));
    }
    25% {
        transform: scale(1.1) rotate(5deg);
        filter: drop-shadow(0 0 15px rgba(255, 193, 7, 0.8));
    }
    50% {
        transform: scale(1.15) rotate(-3deg);
        filter: drop-shadow(0 0 20px rgba(255, 87, 34, 0.9));
    }
    75% {
        transform: scale(1.05) rotate(3deg);
        filter: drop-shadow(0 0 12px rgba(255, 152, 0, 0.7));
    }
}

/* Leaderboard Rank Badges with Gradients */
.rank-1 {
    background: var(--gold-gradient) !important;
    color: #000 !important;
    font-weight: 900 !important;
    box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 4px 20px rgba(0, 0, 0, 0.3);
    animation: goldShine 3s ease-in-out infinite;
    border: 2px solid rgba(255, 215, 0, 0.8);
}

.rank-2 {
    background: var(--silver-gradient) !important;
    color: #000 !important;
    font-weight: 800 !important;
    box-shadow: 0 0 25px rgba(192, 192, 192, 0.5), 0 4px 15px rgba(0, 0, 0, 0.3);
    animation: silverShine 3s ease-in-out infinite;
    border: 2px solid rgba(192, 192, 192, 0.8);
}

.rank-3 {
    background: var(--bronze-gradient) !important;
    color: #fff !important;
    font-weight: 700 !important;
    box-shadow: 0 0 20px rgba(205, 127, 50, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: bronzeShine 3s ease-in-out infinite;
    border: 2px solid rgba(205, 127, 50, 0.8);
}

@keyframes goldShine {
    0%, 100% { box-shadow: 0 0 30px rgba(255, 215, 0, 0.6), 0 4px 20px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.9), 0 6px 25px rgba(0, 0, 0, 0.4); }
}

@keyframes silverShine {
    0%, 100% { box-shadow: 0 0 25px rgba(192, 192, 192, 0.5), 0 4px 15px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 35px rgba(192, 192, 192, 0.8), 0 6px 20px rgba(0, 0, 0, 0.4); }
}

@keyframes bronzeShine {
    0%, 100% { box-shadow: 0 0 20px rgba(205, 127, 50, 0.5), 0 4px 12px rgba(0, 0, 0, 0.3); }
    50% { box-shadow: 0 0 30px rgba(205, 127, 50, 0.8), 0 6px 18px rgba(0, 0, 0, 0.4); }
}

/* Crown for #1 */
.crown-icon {
    display: inline-block;
    animation: crownBounce 2s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
}

@keyframes crownBounce {
    0%, 100% { transform: translateY(0) rotate(-5deg); }
    50% { transform: translateY(-5px) rotate(5deg); }
}

/* Trophy Emojis with Animations */
.trophy-emoji {
    display: inline-block;
    animation: trophyShine 2s ease-in-out infinite;
    font-size: 1.8em;
}

@keyframes trophyShine {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 8px rgba(255, 215, 0, 0.5));
    }
    50% {
        transform: scale(1.15) rotate(10deg);
        filter: drop-shadow(0 0 15px rgba(255, 215, 0, 0.9));
    }
}

/* Confetti Animation */
.confetti {
    position: fixed;
    width: 10px;
    height: 10px;
    background: var(--primary-gradient);
    top: -10px;
    z-index: 9999;
    animation: confettiFall 3s linear;
    pointer-events: none;
}

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

/* Success Flag Animation */
.success-flag {
    display: inline-block;
    animation: flagWave 1s ease-in-out infinite;
    font-size: 2em;
}

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

/* Challenge Card Enhanced Hover */
.challenge-card {
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
}

.challenge-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 60px rgba(102, 126, 234, 0.4);
}

.challenge-card:active {
    transform: translateY(-4px) scale(1.01);
}

/* Solved Badge with Checkmark */
.solved-badge {
    position: absolute;
    top: 12px;
    right: 12px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 6px;
    box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    animation: solvedBadge 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes solvedBadge {
    0% { transform: scale(0) rotate(-180deg); opacity: 0; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.checkmark-icon {
    display: inline-block;
    animation: checkmarkPop 0.5s ease-out 0.3s both;
}

@keyframes checkmarkPop {
    0% { transform: scale(0); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Streak Fire Animation */
.streak-fire {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    animation: streakGlow 2s ease-in-out infinite;
}

.streak-fire::before {
    content: '🔥';
    font-size: 1.2em;
    animation: fireFlicker 1.5s ease-in-out infinite;
}

@keyframes streakGlow {
    0%, 100% { text-shadow: 0 0 10px rgba(255, 107, 107, 0.5); }
    50% { text-shadow: 0 0 20px rgba(255, 107, 107, 0.9); }
}

/* Progress Bar with Gradient Animation */
.progress-bar {
    position: relative;
    overflow: hidden;
    background: linear-gradient(90deg,
        #667eea 0%,
        #764ba2 25%,
        #667eea 50%,
        #764ba2 75%,
        #667eea 100%
    );
    background-size: 200% 100%;
    animation: progressShine 2s linear infinite;
    box-shadow: 0 0 20px rgba(102, 126, 234, 0.5);
}

@keyframes progressShine {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Button Ripple Effect */
.btn-ripple {
    position: relative;
    overflow: hidden;
}

.btn-ripple::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.6);
    transform: translate(-50%, -50%);
    transition: width 0.6s, height 0.6s;
}

.btn-ripple:active::before {
    width: 300px;
    height: 300px;
}

/* Loading Dots Animation */
.loading-dots {
    display: inline-flex;
    gap: 4px;
}

.loading-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-gradient);
    border-radius: 50%;
    animation: loadingDot 1.4s ease-in-out infinite;
}

.loading-dots span:nth-child(1) { animation-delay: 0s; }
.loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.loading-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* Smooth Scroll Indicator */
.scroll-indicator {
    position: fixed;
    top: 0;
    left: 0;
    height: 4px;
    background: var(--primary-gradient);
    z-index: 9999;
    transition: width 0.1s ease-out;
    box-shadow: var(--glow-primary);
}

/* Notification Badge Pulse */
.notification-badge {
    animation: badgePulse 2s ease-in-out infinite;
}

@keyframes badgePulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7);
    }
    50% {
        transform: scale(1.1);
        box-shadow: 0 0 0 6px rgba(239, 68, 68, 0);
    }
}

/* Enhanced Input Focus States */
.input-field:focus {
    border-color: #667eea;
    box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.2), 0 0 20px rgba(102, 126, 234, 0.3);
    transform: translateY(-2px);
}

/* Micro-interaction: Button Hover */
.btn-primary:hover, .btn-secondary:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 30px rgba(102, 126, 234, 0.4);
}

/* Category Badge Hover */
.category-badge {
    transition: all 0.3s ease;
    cursor: pointer;
}

.category-badge:hover {
    transform: translateY(-3px) scale(1.05);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.3);
}

/* Score Counter Animation */
.score-counter {
    transition: all 0.3s ease;
}

.score-update {
    animation: scorePopup 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: #4ade80;
}

@keyframes scorePopup {
    0% { transform: scale(1); }
    50% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* Level Up Celebration */
.level-up {
    animation: levelUp 1s ease-out;
}

@keyframes levelUp {
    0% { transform: scale(1) rotate(0deg); opacity: 1; }
    30% { transform: scale(1.3) rotate(-10deg); opacity: 1; }
    60% { transform: scale(1.2) rotate(10deg); opacity: 1; }
    100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

/* Hint Usage Indicator */
.hint-used {
    position: relative;
}

.hint-used::after {
    content: '💡';
    position: absolute;
    top: -10px;
    right: -10px;
    font-size: 1.2em;
    animation: hintGlow 2s ease-in-out infinite;
}

@keyframes hintGlow {
    0%, 100% {
        filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
        transform: scale(1);
    }
    50% {
        filter: drop-shadow(0 0 15px rgba(251, 191, 36, 0.9));
        transform: scale(1.15);
    }
}

/* Achievement Unlock Animation */
.achievement-unlock {
    animation: achievementPop 0.8s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes achievementPop {
    0% {
        transform: scale(0) rotate(-180deg);
        opacity: 0;
    }
    70% {
        transform: scale(1.1) rotate(10deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* Star Rating Animation */
.star-rating {
    display: inline-flex;
    gap: 4px;
}

.star-rating .star {
    display: inline-block;
    animation: starTwinkle 2s ease-in-out infinite;
}

.star-rating .star:nth-child(1) { animation-delay: 0s; }
.star-rating .star:nth-child(2) { animation-delay: 0.2s; }
.star-rating .star:nth-child(3) { animation-delay: 0.4s; }
.star-rating .star:nth-child(4) { animation-delay: 0.6s; }
.star-rating .star:nth-child(5) { animation-delay: 0.8s; }

@keyframes starTwinkle {
    0%, 100% {
        transform: scale(1) rotate(0deg);
        filter: drop-shadow(0 0 5px rgba(251, 191, 36, 0.5));
    }
    50% {
        transform: scale(1.2) rotate(72deg);
        filter: drop-shadow(0 0 10px rgba(251, 191, 36, 0.9));
    }
}

/* Responsive Animations - Respect User Preferences */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
