/* ========================================
   CHALLENGE CARD GAMIFICATION ANIMATIONS
   ======================================== */

/* === HOURGLASS COUNTDOWN ANIMATION === */
.countdown-hourglass {
    display: inline-block;
    animation: hourglass-rotate 2s ease-in-out infinite;
}

@keyframes hourglass-rotate {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(180deg); }
}

/* Dynamic hourglass based on urgency */
.countdown-urgent .countdown-hourglass {
    animation: hourglass-rotate-fast 1s ease-in-out infinite;
}

@keyframes hourglass-rotate-fast {
    0%, 100% { transform: rotate(0deg) scale(1.1); }
    50% { transform: rotate(180deg) scale(1.1); }
}

/* === PROGRESS BAR GLOW EFFECTS === */
.progress-bar-glow {
    position: relative;
    overflow: hidden;
}

.progress-bar-glow::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.6), transparent);
    animation: shimmer-progress 2s infinite;
}

@keyframes shimmer-progress {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Dynamic progress bar colors with glow */
.progress-fill-open {
    background: linear-gradient(90deg, #10b981, #059669);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.6);
}

.progress-fill-almost-full {
    background: linear-gradient(90deg, #f59e0b, #d97706);
    box-shadow: 0 0 15px rgba(245, 158, 11, 0.6);
}

.progress-fill-full {
    background: linear-gradient(90deg, #ef4444, #dc2626);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.6);
}

/* === PULSATING BADGES === */
.badge-pulse-urgent {
    animation: badge-pulse-urgent 1.5s ease-in-out infinite;
}

@keyframes badge-pulse-urgent {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(249, 115, 22, 0.7);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 10px rgba(249, 115, 22, 0);
    }
}

.badge-pulse-warning {
    animation: badge-pulse-warning 2s ease-in-out infinite;
}

@keyframes badge-pulse-warning {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(234, 179, 8, 0.7);
    }
    50% {
        transform: scale(1.03);
        box-shadow: 0 0 0 8px rgba(234, 179, 8, 0);
    }
}

/* === XP BADGE ANIMATIONS === */
.xp-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: xp-bounce-in 0.6s cubic-bezier(0.68, -0.55, 0.265, 1.55);
}

@keyframes xp-bounce-in {
    0% {
        transform: scale(0) rotate(-45deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.2) rotate(10deg);
    }
    100% {
        transform: scale(1) rotate(0deg);
        opacity: 1;
    }
}

/* === CONFETTI BURST === */
.confetti-particle {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    pointer-events: none;
    z-index: 9999;
}

/* Various confetti colors */
.confetti-green { background: #10b981; }
.confetti-blue { background: #3b82f6; }
.confetti-yellow { background: #fbbf24; }
.confetti-purple { background: #a855f7; }
.confetti-orange { background: #f97316; }

/* === PLAYER AVATAR ANIMATIONS === */
.player-avatar {
    position: relative;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.player-avatar:hover {
    transform: translateY(-4px) scale(1.1);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.2);
    z-index: 10;
}

.player-avatar-tooltip {
    position: absolute;
    bottom: 120%;
    left: 50%;
    transform: translateX(-50%) scale(0);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
    z-index: 1000;
}

.player-avatar:hover .player-avatar-tooltip {
    opacity: 1;
    transform: translateX(-50%) scale(1);
}

/* Rank badges */
.rank-badge-bronze {
    background: linear-gradient(135deg, #cd7f32, #8b5a2b);
    box-shadow: 0 0 10px rgba(205, 127, 50, 0.5);
}

.rank-badge-silver {
    background: linear-gradient(135deg, #c0c0c0, #808080);
    box-shadow: 0 0 10px rgba(192, 192, 192, 0.5);
}

.rank-badge-gold {
    background: linear-gradient(135deg, #ffd700, #ffa500);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
}

/* === CARD ENTRANCE ANIMATIONS === */
.challenge-card-entrance {
    animation: card-entrance 0.5s ease-out backwards;
}

@keyframes card-entrance {
    0% {
        opacity: 0;
        transform: translateY(30px) scale(0.95);
    }
    100% {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* Stagger effect - applied via JS */
.challenge-card-entrance:nth-child(1) { animation-delay: 0.05s; }
.challenge-card-entrance:nth-child(2) { animation-delay: 0.1s; }
.challenge-card-entrance:nth-child(3) { animation-delay: 0.15s; }
.challenge-card-entrance:nth-child(4) { animation-delay: 0.2s; }
.challenge-card-entrance:nth-child(5) { animation-delay: 0.25s; }
.challenge-card-entrance:nth-child(6) { animation-delay: 0.3s; }

/* === BUTTON HOVER EFFECTS === */
.challenge-join-btn {
    position: relative;
    overflow: hidden;
    transition: all 0.3s ease;
}

.challenge-join-btn::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 0;
    height: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.3);
    transform: translate(-50%, -50%);
    transition: width 0.6s ease, height 0.6s ease;
}

.challenge-join-btn:hover::before {
    width: 300px;
    height: 300px;
}

.challenge-join-btn:active {
    transform: scale(0.95);
}

/* === URGENCY GRADIENT BORDER === */
.urgency-border-green {
    border-image: linear-gradient(135deg, #10b981, #059669) 1;
}

.urgency-border-yellow {
    border-image: linear-gradient(135deg, #fbbf24, #f59e0b) 1;
    animation: border-pulse-yellow 2s ease-in-out infinite;
}

.urgency-border-orange {
    border-image: linear-gradient(135deg, #f97316, #ea580c) 1;
    animation: border-pulse-orange 1.5s ease-in-out infinite;
}

.urgency-border-red {
    border-image: linear-gradient(135deg, #ef4444, #dc2626) 1;
    animation: border-pulse-red 1s ease-in-out infinite;
}

@keyframes border-pulse-yellow {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.1); }
}

@keyframes border-pulse-orange {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.2); }
}

@keyframes border-pulse-red {
    0%, 100% { filter: brightness(1); }
    50% { filter: brightness(1.3); }
}

/* === COMMUNITY STATS TICKER === */
.community-stats {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    animation: stats-slide-in 0.8s ease-out;
}

@keyframes stats-slide-in {
    0% {
        transform: translateX(-20px);
        opacity: 0;
    }
    100% {
        transform: translateX(0);
        opacity: 1;
    }
}

.community-stats-icon {
    animation: icon-bounce 2s ease-in-out infinite;
}

@keyframes icon-bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

/* === RESPONSIVE OPTIMIZATIONS === */
@media (max-width: 768px) {
    .player-avatar:hover {
        transform: translateY(-2px) scale(1.05);
    }

    .challenge-card-entrance {
        animation-duration: 0.3s;
    }
}

/* === ACCESSIBILITY === */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
