/* badges.css - Badge System Styles with Animations */

/* Badge Item Base */
.badge-item {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    border: 3px solid;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    background: rgba(0, 0, 0, 0.2);
    overflow: hidden;
}

.badge-item img {
    pointer-events: none;
    transition: transform 0.4s ease;
}

.badge-item:hover {
    transform: scale(1.15) rotate(5deg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.4);
    z-index: 10;
}

.badge-item:hover img {
    transform: scale(1.1);
}

/* Shimmer effect on hover */
.badge-item::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent 30%,
        rgba(255, 255, 255, 0.3) 50%,
        transparent 70%
    );
    transform: translateX(-100%) rotate(45deg);
    transition: transform 0.6s ease;
    z-index: 2;
    pointer-events: none;
}

.badge-item:hover::before {
    transform: translateX(100%) rotate(45deg);
}

/* Locked Badge */
.badge-locked {
    filter: grayscale(100%) brightness(0.4);
    cursor: default;
    opacity: 0.6;
}

.badge-locked:hover {
    transform: none;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.badge-locked:hover img {
    transform: none;
}

.badge-locked::before {
    display: none;
}

.badge-lock-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(255, 255, 255, 0.9);
    font-size: 1.5rem;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    z-index: 5;
    animation: lockPulse 2s ease-in-out infinite;
}

@keyframes lockPulse {
    0%, 100% { opacity: 0.7; transform: translate(-50%, -50%) scale(1); }
    50% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
}

/* ========== RARITY ANIMATIONS ========== */

/* Common - Subtle pulse */
.badge-item[data-rarity="common"] {
    box-shadow: 0 0 10px rgba(156, 163, 175, 0.4);
    animation: commonPulse 4s ease-in-out infinite;
}

@keyframes commonPulse {
    0%, 100% { box-shadow: 0 0 8px rgba(156, 163, 175, 0.3); }
    50% { box-shadow: 0 0 15px rgba(156, 163, 175, 0.5); }
}

/* Uncommon - Green glow */
.badge-item[data-rarity="uncommon"] {
    box-shadow: 0 0 12px rgba(16, 185, 129, 0.5);
    animation: uncommonGlow 3s ease-in-out infinite;
}

@keyframes uncommonGlow {
    0%, 100% { box-shadow: 0 0 10px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 20px rgba(16, 185, 129, 0.7); }
}

/* Rare - Blue electric */
.badge-item[data-rarity="rare"] {
    box-shadow: 0 0 15px rgba(59, 130, 246, 0.5);
    animation: rareElectric 2.5s ease-in-out infinite;
}

@keyframes rareElectric {
    0%, 100% { 
        box-shadow: 0 0 10px rgba(59, 130, 246, 0.4),
                    0 0 20px rgba(59, 130, 246, 0.2);
    }
    50% { 
        box-shadow: 0 0 20px rgba(59, 130, 246, 0.7),
                    0 0 35px rgba(59, 130, 246, 0.4);
    }
}

/* Epic - Purple pulsing ring */
.badge-item[data-rarity="epic"] {
    box-shadow: 0 0 18px rgba(168, 85, 247, 0.6);
    animation: epicRing 2s ease-in-out infinite;
}

.badge-item[data-rarity="epic"]::after {
    content: '';
    position: absolute;
    top: -4px;
    left: -4px;
    right: -4px;
    bottom: -4px;
    border-radius: 50%;
    border: 2px solid rgba(168, 85, 247, 0.6);
    animation: epicRingExpand 2s ease-out infinite;
    pointer-events: none;
}

@keyframes epicRing {
    0%, 100% { 
        box-shadow: 0 0 15px rgba(168, 85, 247, 0.5),
                    inset 0 0 10px rgba(168, 85, 247, 0.2);
    }
    50% { 
        box-shadow: 0 0 30px rgba(168, 85, 247, 0.8),
                    inset 0 0 15px rgba(168, 85, 247, 0.3);
    }
}

@keyframes epicRingExpand {
    0% { transform: scale(1); opacity: 0.8; }
    100% { transform: scale(1.5); opacity: 0; }
}

/* Legendary - Golden rotating glow with particles */
.badge-item[data-rarity="legendary"] {
    box-shadow: 0 0 25px rgba(245, 158, 11, 0.7);
    animation: legendaryGlow 2s ease-in-out infinite;
}

.badge-item[data-rarity="legendary"]::after {
    content: '';
    position: absolute;
    top: -6px;
    left: -6px;
    right: -6px;
    bottom: -6px;
    border-radius: 50%;
    background: conic-gradient(
        from 0deg,
        transparent,
        rgba(245, 158, 11, 0.4),
        transparent,
        rgba(245, 158, 11, 0.4),
        transparent
    );
    animation: legendaryRotate 3s linear infinite;
    pointer-events: none;
    z-index: -1;
}

@keyframes legendaryGlow {
    0%, 100% { 
        box-shadow: 0 0 20px rgba(245, 158, 11, 0.6),
                    0 0 40px rgba(245, 158, 11, 0.3),
                    inset 0 0 10px rgba(245, 158, 11, 0.2);
    }
    50% { 
        box-shadow: 0 0 35px rgba(245, 158, 11, 0.9),
                    0 0 60px rgba(245, 158, 11, 0.5),
                    inset 0 0 20px rgba(245, 158, 11, 0.4);
    }
}

@keyframes legendaryRotate {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ========== BADGES SECTION (Profile Page) ========== */

.badges-section-inner {
    padding: 0;
}

.badges-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.badges-header h3 {
    color: var(--crisp-white);
    font-size: 1.3rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.badges-header h3 i {
    color: var(--gold);
    animation: iconBounce 2s ease-in-out infinite;
}

@keyframes iconBounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-3px); }
}

.badges-count {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.3), rgba(245, 158, 11, 0.1));
    color: var(--gold);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    border: 1px solid rgba(245, 158, 11, 0.3);
}

.badges-unlocked,
.badges-locked {
    margin-bottom: 1.5rem;
}

.badges-unlocked h4,
.badges-locked h4 {
    color: var(--medium-gray);
    font-size: 0.85rem;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.badges-unlocked h4 {
    color: var(--seafoam);
}

.badges-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 1.25rem;
    justify-items: center;
}

.no-badges {
    color: var(--medium-gray);
    font-style: italic;
    text-align: center;
    padding: 2rem;
    grid-column: 1 / -1;
}

/* ========== BADGE SELECTOR (Profile Settings) ========== */

.badge-selector {
    background: linear-gradient(145deg, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.1));
    border-radius: var(--radius-md);
    padding: 1.25rem;
    margin-top: 1.5rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.badge-selector-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.badge-selector-header h4 {
    color: var(--crisp-white);
    font-size: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin: 0;
}

.badge-selector-header h4 i {
    color: var(--gold);
}

.selection-count {
    background: linear-gradient(135deg, rgba(0, 191, 255, 0.3), rgba(0, 191, 255, 0.1));
    color: var(--electric-blue);
    padding: 0.3rem 0.6rem;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 600;
    border: 1px solid rgba(0, 191, 255, 0.3);
}

.badge-selector-info {
    color: var(--medium-gray);
    font-size: 0.85rem;
    margin-bottom: 1rem;
}

.badge-selector-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(90px, 1fr));
    gap: 0.75rem;
    max-height: 350px;
    overflow-y: auto;
    padding: 0.5rem;
}

.badge-selector-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.75rem;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    background: rgba(255, 255, 255, 0.02);
    border: 2px solid transparent;
}

.badge-selector-item:hover {
    background: rgba(0, 191, 255, 0.1);
    border-color: rgba(0, 191, 255, 0.3);
    transform: translateY(-2px);
}

.badge-selector-item.selected {
    background: rgba(46, 196, 182, 0.15);
    border-color: var(--seafoam);
    box-shadow: 0 0 15px rgba(46, 196, 182, 0.3);
}

.badge-selector-image {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.2);
    background: rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.badge-selector-item:hover .badge-selector-image {
    border-color: var(--electric-blue);
    transform: scale(1.05);
}

.badge-selector-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.badge-selector-check {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    background: linear-gradient(135deg, var(--seafoam), #1a9085);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(46, 196, 182, 0.5);
    animation: checkPop 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

@keyframes checkPop {
    0% { transform: scale(0); }
    100% { transform: scale(1); }
}

.badge-selector-check i {
    color: white;
    font-size: 0.7rem;
}

.badge-selector-item.selected .badge-selector-check {
    display: flex;
}

.badge-selector-name {
    color: var(--light-gray);
    font-size: 0.75rem;
    text-align: center;
    margin-top: 0.5rem;
    max-width: 80px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ========== LEADERBOARD BADGE DISPLAY ========== */

.leaderboard-badge {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    border: 2px solid;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    position: relative;
    z-index: 1;
    overflow: visible;
    background: rgba(0, 0, 0, 0.3);
}

.leaderboard-badge img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
    pointer-events: none;
}

.leaderboard-badge:hover {
    transform: scale(3.5);
    z-index: 100;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.7);
}

/* Leaderboard badge rarity effects (smaller scale) */
.leaderboard-badge[data-rarity="common"] {
    animation: commonPulseSmall 4s ease-in-out infinite;
}

@keyframes commonPulseSmall {
    0%, 100% { box-shadow: 0 0 5px rgba(156, 163, 175, 0.3); }
    50% { box-shadow: 0 0 10px rgba(156, 163, 175, 0.5); }
}

.leaderboard-badge[data-rarity="uncommon"] {
    animation: uncommonGlowSmall 3s ease-in-out infinite;
}

@keyframes uncommonGlowSmall {
    0%, 100% { box-shadow: 0 0 6px rgba(16, 185, 129, 0.4); }
    50% { box-shadow: 0 0 12px rgba(16, 185, 129, 0.7); }
}

.leaderboard-badge[data-rarity="rare"] {
    animation: rareElectricSmall 2.5s ease-in-out infinite;
}

@keyframes rareElectricSmall {
    0%, 100% { box-shadow: 0 0 6px rgba(59, 130, 246, 0.4); }
    50% { box-shadow: 0 0 14px rgba(59, 130, 246, 0.7); }
}

.leaderboard-badge[data-rarity="epic"] {
    animation: epicRingSmall 2s ease-in-out infinite;
}

@keyframes epicRingSmall {
    0%, 100% { box-shadow: 0 0 8px rgba(168, 85, 247, 0.5); }
    50% { box-shadow: 0 0 18px rgba(168, 85, 247, 0.8); }
}

.leaderboard-badge[data-rarity="legendary"] {
    animation: legendaryGlowSmall 2s ease-in-out infinite;
}

@keyframes legendaryGlowSmall {
    0%, 100% { box-shadow: 0 0 10px rgba(245, 158, 11, 0.5); }
    50% { box-shadow: 0 0 20px rgba(245, 158, 11, 0.9); }
}

.leaderboard-badge:hover[data-rarity="legendary"],
.leaderboard-badge:hover[data-rarity="epic"],
.leaderboard-badge:hover[data-rarity="rare"],
.leaderboard-badge:hover[data-rarity="uncommon"],
.leaderboard-badge:hover[data-rarity="common"] {
    animation: none;
}

.leaderboard-badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    justify-content: center;
    margin: 0.75rem 0;
    padding: 0.6rem 0.8rem;
    background: linear-gradient(145deg, rgba(245, 158, 11, 0.15), rgba(245, 158, 11, 0.05));
    border: 1px solid rgba(245, 158, 11, 0.25);
    border-radius: 12px;
    min-height: 44px;
}

/* ========== BADGE TOOLTIP ========== */

.badge-tooltip {
    position: fixed;
    background: linear-gradient(145deg, rgba(10, 25, 41, 0.98), rgba(30, 58, 95, 0.98));
    border: 1px solid rgba(0, 191, 255, 0.4);
    border-radius: 12px;
    padding: 0.85rem 1.1rem;
    z-index: 10000;
    pointer-events: none;
    max-width: 250px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.6),
                0 0 20px rgba(0, 191, 255, 0.2);
    opacity: 0;
    transform: translateY(10px) scale(0.95);
    transition: opacity 0.25s, transform 0.25s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.badge-tooltip.visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.badge-tooltip-name {
    color: var(--crisp-white);
    font-weight: 700;
    font-size: 1rem;
    margin-bottom: 0.35rem;
}

.badge-tooltip-description {
    color: var(--light-gray);
    font-size: 0.85rem;
    line-height: 1.45;
}

.badge-tooltip-rarity {
    display: inline-block;
    padding: 0.25rem 0.6rem;
    border-radius: 12px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: 0.5rem;
}

.badge-tooltip-rarity.common { 
    background: rgba(156, 163, 175, 0.25); 
    color: #9CA3AF; 
    border: 1px solid rgba(156, 163, 175, 0.3);
}
.badge-tooltip-rarity.uncommon { 
    background: rgba(16, 185, 129, 0.25); 
    color: #10B981; 
    border: 1px solid rgba(16, 185, 129, 0.3);
}
.badge-tooltip-rarity.rare { 
    background: rgba(59, 130, 246, 0.25); 
    color: #3B82F6; 
    border: 1px solid rgba(59, 130, 246, 0.3);
}
.badge-tooltip-rarity.epic { 
    background: rgba(168, 85, 247, 0.25); 
    color: #A855F7; 
    border: 1px solid rgba(168, 85, 247, 0.3);
}
.badge-tooltip-rarity.legendary { 
    background: rgba(245, 158, 11, 0.25); 
    color: #F59E0B; 
    border: 1px solid rgba(245, 158, 11, 0.3);
    animation: legendaryTooltipGlow 2s ease-in-out infinite;
}

@keyframes legendaryTooltipGlow {
    0%, 100% { box-shadow: 0 0 5px rgba(245, 158, 11, 0.3); }
    50% { box-shadow: 0 0 15px rgba(245, 158, 11, 0.6); }
}

/* ========== USER MODAL BADGES ========== */

.user-modal-badges {
    padding: 0.75rem 2rem;
}

.user-modal-badges .leaderboard-badges-row {
    margin: 0;
}

/* ========== MOBILE RESPONSIVE ========== */

@media (max-width: 768px) {
    .badges-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
        gap: 1rem;
    }
    
    .badges-grid .badge-item {
        width: 70px !important;
        height: 70px !important;
    }
    
    .badge-selector-grid {
        grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    }
    
    .badge-selector-image {
        width: 50px;
        height: 50px;
    }
    
    .badges-header {
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    
    .leaderboard-badges-row {
        gap: 4px;
    }
    
    .leaderboard-badge {
        width: 26px;
        height: 26px;
    }
    
    .leaderboard-badge:hover {
        transform: scale(4);
    }
    
    .badge-lock-overlay {
        font-size: 1.2rem;
    }
    
    /* Reduce animation intensity on mobile */
    .badge-item[data-rarity="legendary"]::after,
    .badge-item[data-rarity="epic"]::after {
        display: none;
    }
}

@media (max-width: 400px) {
    .badges-grid .badge-item {
        width: 60px !important;
        height: 60px !important;
    }
    
    .badge-lock-overlay {
        font-size: 1rem;
    }
    
    .badge-selector-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/* ========== REDUCED MOTION ========== */

@media (prefers-reduced-motion: reduce) {
    .badge-item,
    .badge-item::before,
    .badge-item::after,
    .leaderboard-badge,
    .badge-lock-overlay,
    .badge-tooltip,
    .badge-selector-check {
        animation: none !important;
        transition: none !important;
    }
}
