/* Discovery Animation - Element flies to belt */

@keyframes spinAndFly {
    0% {
        transform: translate(-50%, -50%) rotate(0deg) scale(1.5);
        opacity: 1;
    }
    20% {
        transform: translate(-50%, -50%) rotate(720deg) scale(2);
        opacity: 1;
    }
    100% {
        transform: translate(var(--target-x), var(--target-y)) rotate(1440deg) scale(0.8);
        opacity: 0;
    }
}

@keyframes glowPulse {
    0%, 100% {
        box-shadow: 
            0 0 20px rgba(255, 215, 0, 0.8),
            0 0 40px rgba(255, 215, 0, 0.6),
            0 0 60px rgba(255, 215, 0, 0.4);
    }
    50% {
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 1),
            0 0 60px rgba(255, 215, 0, 0.8),
            0 0 90px rgba(255, 215, 0, 0.6);
    }
}

/* Flying element */
.flying-element {
    position: fixed;
    width: 120px;
    height: 120px;
    z-index: 10000;
    pointer-events: none;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    overflow: hidden;
    animation: spinAndFly 2s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
}

.flying-element img {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.8));
}

/* Glowing trail effect */
.flying-element::before {
    content: '';
    position: absolute;
    width: 150%;
    height: 150%;
    border-radius: 50%;
    background: radial-gradient(circle, 
        rgba(255, 215, 0, 0.6) 0%, 
        rgba(255, 193, 7, 0.3) 40%, 
        transparent 70%);
    animation: glowPulse 0.5s ease-in-out infinite;
    z-index: -1;
}

/* Belt highlight animation */
@keyframes beltCelebrate {
    0% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(255, 215, 0, 0);
        box-shadow: none;
    }
    20% {
        background: linear-gradient(90deg, 
            rgba(255, 215, 0, 0.3) 0%, 
            rgba(255, 193, 7, 0.2) 50%, 
            rgba(255, 215, 0, 0.3) 100%);
        border-color: rgba(255, 215, 0, 0.8);
        box-shadow: 
            0 0 30px rgba(255, 215, 0, 0.6),
            inset 0 0 20px rgba(255, 215, 0, 0.2);
    }
    40%, 60% {
        background: linear-gradient(90deg, 
            rgba(255, 215, 0, 0.4) 0%, 
            rgba(255, 193, 7, 0.3) 50%, 
            rgba(255, 215, 0, 0.4) 100%);
        border-color: rgba(255, 215, 0, 1);
        box-shadow: 
            0 0 50px rgba(255, 215, 0, 0.8),
            inset 0 0 30px rgba(255, 215, 0, 0.3);
    }
    100% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(255, 215, 0, 0);
        box-shadow: none;
    }
}

.element-group.celebrating {
    animation: beltCelebrate 3s ease-in-out;
}

/* Shimmer effect on belt during celebration */
@keyframes shimmerWave {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

.element-group.celebrating::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent 0%,
        rgba(255, 255, 255, 0.1) 25%,
        rgba(255, 255, 255, 0.2) 50%,
        rgba(255, 255, 255, 0.1) 75%,
        transparent 100%
    );
    background-size: 200% 100%;
    animation: shimmerWave 2s linear;
    pointer-events: none;
    border-radius: 12px;
}

/* New element appears with special glow */
@keyframes elementAppear {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 0;
    }
    50% {
        transform: scale(1.3) rotate(180deg);
        opacity: 1;
    }
    100% {
        transform: scale(1) rotate(360deg);
        opacity: 1;
    }
}

.derived-element.just-added {
    animation: elementAppear 0.8s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    position: relative;
}

.derived-element.just-added::before {
    content: '';
    position: absolute;
    inset: -10px;
    background: radial-gradient(circle, 
        rgba(255, 215, 0, 0.6) 0%, 
        rgba(255, 193, 7, 0.3) 40%, 
        transparent 70%);
    animation: glowPulse 1s ease-in-out 3;
    pointer-events: none;
    z-index: -1;
}

/* Starburst effect */
@keyframes starburst {
    0% {
        transform: scale(0) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: scale(3) rotate(180deg);
        opacity: 0;
    }
}

.starburst {
    position: fixed;
    width: 200px;
    height: 200px;
    pointer-events: none;
    z-index: 9999;
}

.starburst::before,
.starburst::after {
    content: '✦';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 100px;
    color: rgba(255, 215, 0, 0.8);
    animation: starburst 1s ease-out forwards;
}

.starburst::after {
    animation-delay: 0.2s;
    transform: translate(-50%, -50%) rotate(45deg);
}

/* Particle effects */
.particle {
    position: fixed;
    width: 10px;
    height: 10px;
    background: radial-gradient(circle, 
        rgba(255, 215, 0, 1) 0%, 
        rgba(255, 193, 7, 0.8) 50%, 
        transparent 100%);
    border-radius: 50%;
    pointer-events: none;
    z-index: 9998;
}

@keyframes particleFly {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--particle-x), var(--particle-y)) scale(0);
        opacity: 0;
    }
}

/* Color variations for different element types */
.flying-element.fire-type {
    background: radial-gradient(circle at center,
        rgba(255, 87, 34, 0.1) 0%,
        transparent 50%);
}

.flying-element.fire-type img {
    filter: drop-shadow(0 0 20px rgba(255, 87, 34, 0.8));
}

.flying-element.water-type {
    background: radial-gradient(circle at center,
        rgba(33, 150, 243, 0.1) 0%,
        transparent 50%);
}

.flying-element.water-type img {
    filter: drop-shadow(0 0 20px rgba(33, 150, 243, 0.8));
}

.flying-element.earth-type {
    background: radial-gradient(circle at center,
        rgba(139, 69, 19, 0.1) 0%,
        transparent 50%);
}

.flying-element.earth-type img {
    filter: drop-shadow(0 0 20px rgba(139, 69, 19, 0.8));
}

.flying-element.air-type {
    background: radial-gradient(circle at center,
        rgba(150, 200, 255, 0.1) 0%,
        transparent 50%);
}

.flying-element.air-type img {
    filter: drop-shadow(0 0 20px rgba(150, 200, 255, 0.8));
}

/* Belt-specific celebration colors */
.element-group.fire-group.celebrating {
    animation: beltCelebrateFire 3s ease-in-out;
}

@keyframes beltCelebrateFire {
    0%, 100% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(255, 87, 34, 0.4);
    }
    50% {
        background: rgba(255, 87, 34, 0.2);
        border-color: rgba(255, 87, 34, 1);
        box-shadow: 
            0 0 50px rgba(255, 87, 34, 0.8),
            inset 0 0 30px rgba(255, 87, 34, 0.3);
    }
}

.element-group.water-group.celebrating {
    animation: beltCelebrateWater 3s ease-in-out;
}

@keyframes beltCelebrateWater {
    0%, 100% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(33, 150, 243, 0.4);
    }
    50% {
        background: rgba(33, 150, 243, 0.2);
        border-color: rgba(33, 150, 243, 1);
        box-shadow: 
            0 0 50px rgba(33, 150, 243, 0.8),
            inset 0 0 30px rgba(33, 150, 243, 0.3);
    }
}

.element-group.earth-group.celebrating {
    animation: beltCelebrateEarth 3s ease-in-out;
}

@keyframes beltCelebrateEarth {
    0%, 100% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(139, 69, 19, 0.4);
    }
    50% {
        background: rgba(139, 69, 19, 0.2);
        border-color: rgba(139, 69, 19, 1);
        box-shadow: 
            0 0 50px rgba(139, 69, 19, 0.8),
            inset 0 0 30px rgba(139, 69, 19, 0.3);
    }
}

.element-group.air-group.celebrating {
    animation: beltCelebrateAir 3s ease-in-out;
}

@keyframes beltCelebrateAir {
    0%, 100% {
        background: rgba(20, 20, 30, 0.6);
        border-color: rgba(150, 200, 255, 0.4);
    }
    50% {
        background: rgba(150, 200, 255, 0.2);
        border-color: rgba(150, 200, 255, 1);
        box-shadow: 
            0 0 50px rgba(150, 200, 255, 0.8),
            inset 0 0 30px rgba(150, 200, 255, 0.3);
    }
}