/* Swirl Animation for Element Combination */

/* Swirl container - hidden by default, shown when ready */
.swirl-container {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 300px;
    height: 300px;
    z-index: 10003;
    display: none;
    align-items: center;
    justify-content: center;
    pointer-events: none;
}

.swirl-container.ready {
    display: flex !important;
    background-image: url('../images/activated_merge.png');
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    animation: spinGolden 1.04s linear infinite; /* Reduced by 48% total (was 2s → 1.3s → 1.04s) */
}

@keyframes spinGolden {
    from {
        transform: translate(-50%, -50%) rotate(0deg);
    }
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* Swirl elements - keep hidden, only show golden spinner */
.swirl-element,
#swirl-element-1,
#swirl-element-2 {
    position: absolute;
    width: 80px;
    height: 80px;
    opacity: 0 !important;
    display: none !important;
    transform: scale(0);
}

.swirl-element.ready {
    opacity: 0 !important;
    display: none !important;
}

/* Swirl result */
.swirl-result,
#swirl-result {
    position: absolute;
    width: 120px;
    height: 120px;
    opacity: 0;
    transform: scale(0);
}
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255,215,0,0.2) 0%, transparent 70%);
    box-shadow: 0 0 30px rgba(255,215,0,0.3);
}

.swirl-element img {
    width: 60px;
    height: 60px;
    object-fit: contain;
}

#swirl-element-1 {
    transform: translateX(-60px);
}

#swirl-element-2 {
    transform: translateX(60px);
}

/* Swirl animation keyframes */
@keyframes swirlIn1 {
    0% {
        transform: translateX(-60px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateX(0) rotate(360deg) scale(0.8);
        opacity: 0.8;
    }
}

@keyframes swirlIn2 {
    0% {
        transform: translateX(60px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateX(0) rotate(-360deg) scale(0.8);
        opacity: 0.8;
    }
}

/* Mobile-specific vertical animations */
@keyframes swirlInVertical1 {
    0% {
        transform: translateY(-50px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotate(360deg) scale(0.8);
        opacity: 0.8;
    }
}

@keyframes swirlInVertical2 {
    0% {
        transform: translateY(50px) rotate(0deg);
        opacity: 1;
    }
    100% {
        transform: translateY(0) rotate(-360deg) scale(0.8);
        opacity: 0.8;
    }
}

@keyframes spiralMerge {
    0% {
        transform: rotate(0deg) scale(0.8);
        opacity: 0.8;
    }
    50% {
        transform: rotate(180deg) scale(1.2);
        opacity: 1;
        filter: blur(2px);
    }
    100% {
        transform: rotate(360deg) scale(0);
        opacity: 0;
        filter: blur(5px);
    }
}

@keyframes resultAppear {
    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;
    }
}

@keyframes resultFail {
    0% {
        transform: scale(0);
        opacity: 0;
    }
    50% {
        transform: scale(1.2);
        opacity: 0.8;
        filter: grayscale(100%) brightness(0.5);
    }
    100% {
        transform: scale(0);
        opacity: 0;
    }
}

/* Active states */
.swirl-element.ready {
    opacity: 1;
}

.swirl-element.swirling1 {
    animation: swirlIn1 0.8s ease-in-out forwards; /* Sped up by 20% */
}

.swirl-element.swirling2 {
    animation: swirlIn2 0.8s ease-in-out forwards; /* Sped up by 20% */
}

.swirl-element.merging {
    animation: spiralMerge 0.8s ease-in-out forwards; /* Sped up by 20% */
}

.swirl-result {
    position: absolute;
    width: 100px;
    height: 100px;
    border-radius: 50%;
    opacity: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle, rgba(255,215,0,0.4) 0%, transparent 70%);
    box-shadow: 0 0 50px rgba(255,215,0,0.5);
}

.swirl-result img {
    width: 80px;
    height: 80px;
    object-fit: contain;
}

.swirl-result.success {
    animation: resultAppear 0.8s ease-out forwards; /* Sped up by 20% */
}

.swirl-result.fail {
    animation: resultFail 0.8s ease-out forwards; /* Sped up by 20% */
}

/* Particle effects */
.magic-particle {
    position: absolute;
    width: 4px;
    height: 4px;
    background: #ffd700;
    border-radius: 50%;
    pointer-events: none;
    animation: particleFloat 1.6s ease-out forwards; /* Sped up by 20% */
}

@keyframes particleFloat {
    0% {
        transform: translate(0, 0) scale(1);
        opacity: 1;
    }
    100% {
        transform: translate(var(--tx), var(--ty)) scale(0);
        opacity: 0;
    }
}

/* Glow effect during combination */
.combining-glow {
    position: absolute;
    width: 250px;
    height: 250px;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(255,215,0,0.3) 0%, transparent 60%);
    animation: pulseGlow 0.8s ease-in-out infinite; /* Sped up by 20% */
    pointer-events: none;
}

@keyframes pulseGlow {
    0%, 100% {
        transform: scale(1);
        opacity: 0.5;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.8;
    }
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .swirl-container {
        width: 150px;
        height: 150px;
    }
    
    .swirl-element {
        width: 60px;
        height: 60px;
    }
    
    .swirl-element img {
        width: 45px;
        height: 45px;
    }
    
    /* Change to vertical positioning for mobile */
    #swirl-element-1 {
        transform: translateY(-50px);
    }
    
    #swirl-element-2 {
        transform: translateY(50px);
    }
    
    .swirl-result {
        width: 80px;
        height: 80px;
    }
    
    .swirl-result img {
        width: 60px;
        height: 60px;
    }
    
    /* Use vertical animations on mobile */
    .swirl-element.swirling1 {
        animation: swirlInVertical1 0.8s ease-in-out forwards; /* Sped up by 20% */
    }
    
    .swirl-element.swirling2 {
        animation: swirlInVertical2 0.8s ease-in-out forwards; /* Sped up by 20% */
    }
}