/* Badge Reveal System CSS - Treasure Chest Animations & Custom Badges */

/* Modal Overlay and Base Structure */
.badge-reveal-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.badge-reveal-modal.show {
    opacity: 1;
    pointer-events: all;
}

.badge-reveal-modal.closing {
    opacity: 0;
}

.badge-reveal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
}

.badge-reveal-content {
    position: relative;
    z-index: 2;
    text-align: center;
    max-width: 500px;
    width: 90%;
}


/* Gift Box Glow Effect */
.box-glow {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 250px;
    height: 200px;
    border-radius: 50%;
    opacity: 0;
    transition: opacity 0.8s ease;
    pointer-events: none;
}

.gift-box.opening .box-glow {
    opacity: 0.6;
    animation: boxGlow 2s ease-in-out;
}

/* Confetti Effect */
.confetti {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: hidden;
}

.confetti.active {
    animation: confettiBurst 2s ease-out;
}

.confetti::before,
.confetti::after {
    content: '';
    position: absolute;
    width: 6px;
    height: 6px;
    background: #ffd700;
    opacity: 0;
    border-radius: 50%;
}

.confetti.active::before {
    animation: confettiPiece1 1.5s ease-out;
}

.confetti.active::after {
    animation: confettiPiece2 1.8s ease-out;
}

/* Rarity-specific gift box colors */
.gift-box.common .box-glow {
    background: radial-gradient(circle, rgba(0, 255, 0, 0.3) 0%, transparent 70%);
    box-shadow: 0 0 50px rgba(0, 255, 0, 0.5);
}

.gift-box.uncommon .box-glow {
    background: radial-gradient(circle, rgba(0, 153, 255, 0.3) 0%, transparent 70%);
    box-shadow: 0 0 50px rgba(0, 153, 255, 0.5);
}

.gift-box.rare .box-glow {
    background: radial-gradient(circle, rgba(218, 112, 214, 0.3) 0%, transparent 70%);
    box-shadow: 0 0 50px rgba(218, 112, 214, 0.5);
}

.gift-box.legendary .box-glow {
    background: radial-gradient(circle, rgba(255, 255, 0, 0.4) 0%, transparent 70%);
    box-shadow: 0 0 80px rgba(255, 215, 0, 0.8);
}

.gift-box.mythic .box-glow {
    background: radial-gradient(circle, rgba(255, 0, 255, 0.4) 0%, transparent 70%);
    box-shadow: 0 0 100px rgba(255, 0, 255, 0.9);
    animation: mythicPulse 1.5s ease-in-out infinite;
}

/* Chest lock and details */
.chest-base::before {
    content: '';
    position: absolute;
    top: -15px;
    left: 50%;
    transform: translateX(-50%);
    width: 30px;
    height: 25px;
    background: linear-gradient(135deg, #DAA520, #FFD700);
    border-radius: 5px;
    border: 3px solid #B8860B;
    box-shadow: inset 0 2px 5px rgba(255,255,255,0.3);
}

.chest-base::after {
    content: '';
    position: absolute;
    top: -5px;
    left: 50%;
    transform: translateX(-50%);
    width: 6px;
    height: 6px;
    background: #2F4F4F;
    border-radius: 50%;
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.5);
}

/* Smoke Effect Container */
.chest-smoke {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
}

/* Chest Prompt */
.chest-prompt {
    color: white;
    animation: promptPulse 2s ease-in-out infinite;
}

.chest-prompt h3 {
    font-size: 28px;
    margin-bottom: 10px;
    background: linear-gradient(45deg, #FFD700, #FFA500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.chest-prompt p {
    font-size: 18px;
    color: #CCCCCC;
    margin-bottom: 20px;
}

/* Mystery Badge */
.custom-badge.mystery {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(circle, #444444 0%, #666666 40%, #888888 70%, #AAAAAA 100%);
    border: 3px solid rgba(255,255,255,0.4);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.3),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(100, 100, 100, 0.6),
        0 8px 32px rgba(100, 100, 100, 0.3);
    animation: badgeFloat 3s ease-in-out infinite, mysteryPulse 2s ease-in-out infinite;
    transition: all 0.3s ease;
}

.custom-badge.building-suspense {
    animation: badgeFloat 3s ease-in-out infinite, suspenseBuild 0.8s ease-in-out infinite;
    transform: scale(1.1);
}

.custom-badge.revealing {
    animation: dramaticReveal 1.5s ease-in-out;
    transform-origin: center;
}

.custom-badge.revealed {
    animation: finalGlow 1s ease-out, badgeFloat 3s ease-in-out infinite 1s;
}

/* Smoother button states */
.btn-claim-badge:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: scale(0.95);
    transition: all 0.3s ease;
}

/* Text transition effects */
.badge-name, .badge-description {
    transition: all 0.5s ease-in-out;
}

.badge-name {
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
}

.badge-description {
    opacity: 0.9;
}

/* Badge Display Section */
.badge-display {
    animation: badgeRevealIn 0.8s ease-out;
}

.badge-display.badge-revealed {
    animation: badgeRevealIn 0.8s ease-out;
}

.badge-rarity-banner {
    font-size: 24px;
    font-weight: bold;
    padding: 10px 30px;
    margin-bottom: 20px;
    border-radius: 25px;
    display: inline-block;
    letter-spacing: 2px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.badge-rarity-banner.common {
    background: linear-gradient(45deg, #228B22, #32CD32);
    color: white;
}

.badge-rarity-banner.uncommon {
    background: linear-gradient(45deg, #4169E1, #0099FF);
    color: white;
}

.badge-rarity-banner.rare {
    background: linear-gradient(45deg, #8A2BE2, #DA70D6);
    color: white;
}

.badge-rarity-banner.legendary {
    background: linear-gradient(45deg, #FFD700, #FFA500);
    color: #8B4513;
    animation: legendaryShine 2s ease-in-out infinite;
}

.badge-rarity-banner.mythic {
    background: linear-gradient(45deg, #FF0080, #8000FF, #0080FF, #00FF80, #FF8000);
    background-size: 300% 300%;
    color: white;
    animation: mythicRainbow 3s ease-in-out infinite;
}

/* Custom Badge Container */
.custom-badge-container {
    margin: 30px auto;
    position: relative;
}

.custom-badge {
    width: 120px;
    height: 120px;
    border-radius: 50%;
    margin: 0 auto;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 48px;
    box-shadow: 0 0 30px rgba(0,0,0,0.5);
    animation: badgeFloat 3s ease-in-out infinite;
}

/* Rarity-specific badge styling */
.custom-badge.common {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(circle, #228B22 0%, #32CD32 40%, #00FF00 70%, #90EE90 100%);
    border: 3px solid rgba(255,255,255,0.4);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.3),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(0, 170, 0, 0.6),
        0 8px 32px rgba(0, 170, 0, 0.3);
}

.custom-badge.uncommon {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(circle, #1E3A8A 0%, #3B82F6 40%, #60A5FA 70%, #BFDBFE 100%);
    border: 3px solid rgba(255,255,255,0.4);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.3),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(0, 102, 204, 0.6),
        0 8px 32px rgba(0, 102, 204, 0.3);
}

.custom-badge.rare {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.3) 0%, transparent 50%),
        radial-gradient(circle, #6B21A8 0%, #9333EA 40%, #C084FC 70%, #E9D5FF 100%);
    border: 3px solid rgba(255,255,255,0.4);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.3),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(153, 50, 204, 0.6),
        0 8px 32px rgba(153, 50, 204, 0.3);
}

.custom-badge.legendary {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.4) 0%, transparent 50%),
        radial-gradient(circle, #B45309 0%, #F59E0B 30%, #FCD34D 60%, #FEF3C7 90%);
    border: 3px solid rgba(255,255,255,0.6);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.4),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(255, 215, 0, 0.8),
        0 8px 32px rgba(255, 215, 0, 0.4);
    animation: badgeFloat 3s ease-in-out infinite, legendaryPulse 2s ease-in-out infinite;
}

.custom-badge.mythic {
    background: 
        radial-gradient(ellipse at top, rgba(255,255,255,0.4) 0%, transparent 50%),
        conic-gradient(from 0deg, #FF1493, #FF4500, #FFD700, #32CD32, #00BFFF, #8A2BE2, #FF1493);
    border: 3px solid rgba(255,255,255,0.6);
    box-shadow: 
        inset 0 2px 8px rgba(255,255,255,0.4),
        inset 0 -2px 8px rgba(0,0,0,0.3),
        0 4px 16px rgba(255, 0, 255, 0.8),
        0 8px 32px rgba(255, 0, 255, 0.4);
    animation: badgeFloat 3s ease-in-out infinite, mythicRainbow 2s linear infinite, mythicPulse 1.5s ease-in-out infinite;
}

.badge-placeholder {
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    filter: drop-shadow(0 0 10px rgba(255,255,255,0.5));
}

/* Custom Badge SVG Styling */
.custom-badge-svg {
    width: 100%;
    height: 100%;
    object-fit: contain;
    filter: none;
}

.custom-badge.common .custom-badge-svg {
    filter: none;
}

.custom-badge.uncommon .custom-badge-svg {
    filter: none;
}

.custom-badge.rare .custom-badge-svg {
    filter: none;
}

.custom-badge.legendary .custom-badge-svg {
    filter: none;
}

.custom-badge.mythic .custom-badge-svg {
    filter: none;
}

/* Badge Info */
.badge-name {
    font-size: 32px;
    font-weight: bold;
    margin: 20px 0 10px;
    color: white;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
}

.badge-description {
    font-size: 18px;
    color: #CCCCCC;
    margin-bottom: 30px;
    line-height: 1.4;
}

/* Rewards Container */
.rewards-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin: 20px auto;
    max-width: 300px;
    position: relative;
}

.reward-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    margin: 0 20px;
}

/* Coin Reward Styles */
.coin-reward .coin-icon {
    color: #FFD700;
    font-size: 32px;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.coin-animation {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
}

.flying-coin {
    position: absolute;
    color: #FFD700;
    font-size: 24px;
    animation: coinFly 0.96s ease-out;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    transition: all 0.96s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* XP Reward Styles */
.xp-reward .xp-icon {
    color: #00BFFF;
    font-size: 32px;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

.xp-animation {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 10;
}

.flying-xp {
    position: absolute;
    color: #00BFFF;
    font-size: 20px;
    animation: xpFly 0.96s ease-out;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    transition: all 0.96s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Reward Amount Display */
.reward-amount {
    color: white;
    font-size: 24px;
    font-weight: bold;
    text-shadow: 0 2px 4px rgba(0,0,0,0.7);
    min-height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Claim Badge Button */
.btn-claim-badge {
    background: linear-gradient(135deg, #0033CC, #0066FF);
    color: white;
    border: none;
    padding: 15px 40px;
    font-size: 18px;
    font-weight: bold;
    border-radius: 30px;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 5px 15px rgba(0, 51, 204, 0.4);
}

.btn-claim-badge:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 82, 255, 0.6);
}

.btn-claim-badge:active {
    transform: translateY(0);
}

/* Animations */
@keyframes boxGlow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0.3; transform: translate(-50%, -50%) scale(1); }
}

@keyframes confettiBurst {
    0% { opacity: 1; }
    100% { opacity: 0; }
}

@keyframes confettiPiece1 {
    0% { top: 50%; left: 45%; opacity: 1; transform: scale(0) rotate(0deg); }
    20% { opacity: 1; transform: scale(1) rotate(90deg); }
    100% { top: 120%; left: 20%; opacity: 0; transform: scale(0.5) rotate(360deg); }
}

@keyframes confettiPiece2 {
    0% { top: 50%; left: 55%; opacity: 1; transform: scale(0) rotate(0deg); }
    25% { opacity: 1; transform: scale(1) rotate(-90deg); }
    100% { top: 120%; left: 80%; opacity: 0; transform: scale(0.3) rotate(-360deg); }
}


@keyframes chestGlow {
    0% { opacity: 0; transform: translate(-50%, -50%) scale(0.8); }
    50% { opacity: 0.8; transform: translate(-50%, -50%) scale(1.2); }
    100% { opacity: 0.6; transform: translate(-50%, -50%) scale(1); }
}

@keyframes promptPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes badgeRevealIn {
    0% { 
        opacity: 0; 
        transform: translateY(50px) scale(0.5); 
    }
    100% { 
        opacity: 1; 
        transform: translateY(0) scale(1); 
    }
}

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

@keyframes legendaryShine {
    0%, 100% { box-shadow: 0 0 20px rgba(255, 215, 0, 0.5); }
    50% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.9); }
}

@keyframes legendaryPulse {
    0%, 100% { box-shadow: 0 0 40px rgba(255, 215, 0, 0.8); }
    50% { box-shadow: 0 0 60px rgba(255, 215, 0, 1); }
}

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

@keyframes mythicPulse {
    0%, 100% { 
        box-shadow: 0 0 50px rgba(255, 0, 255, 0.9);
        transform: scale(1);
    }
    50% { 
        box-shadow: 0 0 80px rgba(255, 0, 255, 1);
        transform: scale(1.05);
    }
}

@keyframes smokeRise {
    0% {
        opacity: 0.8;
        transform: translateY(0) scale(0.5);
    }
    50% {
        opacity: 0.6;
        transform: translateY(-50px) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateY(-150px) scale(1.5);
    }
}

@keyframes confettiFall {
    0% {
        transform: translateY(-10px) rotateZ(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(100vh) rotateZ(720deg);
        opacity: 0;
    }
}

@keyframes mysteryPulse {
    0%, 100% {
        box-shadow: 
            inset 0 2px 8px rgba(255,255,255,0.3),
            inset 0 -2px 8px rgba(0,0,0,0.3),
            0 4px 16px rgba(100, 100, 100, 0.6),
            0 8px 32px rgba(100, 100, 100, 0.3);
        filter: brightness(1);
    }
    50% {
        box-shadow: 
            inset 0 2px 8px rgba(255,255,255,0.5),
            inset 0 -2px 8px rgba(0,0,0,0.3),
            0 4px 16px rgba(150, 150, 150, 0.8),
            0 8px 32px rgba(150, 150, 150, 0.5);
        filter: brightness(1.1);
    }
}

@keyframes suspenseBuild {
    0%, 100% {
        box-shadow: 
            inset 0 2px 8px rgba(255,255,255,0.4),
            inset 0 -2px 8px rgba(0,0,0,0.4),
            0 4px 20px rgba(200, 200, 200, 0.8),
            0 8px 40px rgba(200, 200, 200, 0.6);
        filter: brightness(1.2) saturate(1.1);
    }
    50% {
        box-shadow: 
            inset 0 2px 12px rgba(255,255,255,0.6),
            inset 0 -2px 12px rgba(0,0,0,0.4),
            0 4px 30px rgba(255, 255, 255, 1),
            0 8px 60px rgba(255, 255, 255, 0.8);
        filter: brightness(1.4) saturate(1.3);
    }
}

@keyframes dramaticReveal {
    0% {
        transform: scale(1.1) rotate(0deg);
        filter: blur(0px) brightness(1);
        opacity: 1;
    }
    25% {
        transform: scale(1.3) rotate(90deg);
        filter: blur(2px) brightness(1.1);
        opacity: 0.9;
    }
    50% {
        transform: scale(0.8) rotate(180deg);
        filter: blur(3px) brightness(1.2);
        opacity: 0.8;
    }
    75% {
        transform: scale(1.2) rotate(270deg);
        filter: blur(2px) brightness(1.1);
        opacity: 0.9;
    }
    100% {
        transform: scale(1) rotate(360deg);
        filter: blur(0px) brightness(1);
        opacity: 1;
    }
}

@keyframes finalGlow {
    0% {
        filter: brightness(1.2) saturate(1.2);
        transform: scale(1.05);
    }
    50% {
        filter: brightness(1.3) saturate(1.4);
        transform: scale(1.1);
    }
    100% {
        filter: brightness(1) saturate(1);
        transform: scale(1);
    }
}

/* Coin and XP Flying Animations */
@keyframes coinFly {
    0% {
        transform: translateX(-200px) translateY(-100px) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    30% {
        opacity: 1;
        transform: translateX(-100px) translateY(-50px) scale(0.8) rotate(180deg);
    }
    100% {
        transform: translateX(0px) translateY(0px) scale(1) rotate(360deg);
        opacity: 1;
    }
}

@keyframes xpFly {
    0% {
        transform: translateX(200px) translateY(-100px) scale(0.5) rotate(0deg);
        opacity: 0;
    }
    30% {
        opacity: 1;
        transform: translateX(100px) translateY(-50px) scale(0.8) rotate(-180deg);
    }
    100% {
        transform: translateX(0px) translateY(0px) scale(1) rotate(-360deg);
        opacity: 1;
    }
}

/* Enhanced Confetti Burst Animation */
@keyframes confettiBurst {
    0% {
        transform: translate(0, 0) scale(1) rotate(0deg);
        opacity: 1;
    }
    50% {
        transform: translate(
            calc(cos(var(--angle)) * var(--velocity) * 0.8), 
            calc(sin(var(--angle)) * var(--velocity) * 0.8)
        ) scale(1.2) rotate(720deg);
        opacity: 0.8;
    }
    100% {
        transform: translate(
            calc(cos(var(--angle)) * var(--velocity)), 
            calc(sin(var(--angle)) * var(--velocity) + 200px)
        ) scale(0.3) rotate(1080deg);
        opacity: 0;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .badge-reveal-content {
        width: 95%;
        padding: 20px;
    }
    
    
    .custom-badge {
        width: 100px;
        height: 100px;
        font-size: 36px;
    }
    
    .badge-name {
        font-size: 24px;
    }
    
    .badge-description {
        font-size: 16px;
    }
    
}