/* ===================================
   Advanced Scroll Icon Animation - CSS
   8 Stages of transformation
   Stage 6: Settle above name with spin
   Stage 7: Morph to contact icons (clickable)
   =================================== */

/* The stacked icons container */
.scroll-icons-stack {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 70px;
    min-width: 70px;
    margin-top: 10px;
    pointer-events: none;
}

/* ==========================================
   Base Clone Styles
   ========================================== */
.scroll-icon-clone {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    will-change: transform, top, left, opacity;
    /* Prevent clipping by parent overflow */
    contain: none;
}

.scroll-icon-clone .float-element {
    width: 55px;
    height: 55px;
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--accent-primary);
    font-size: 1.5rem;
    box-shadow: var(--orbit-glow);
    transition: background 0.4s ease, border-color 0.4s ease, color 0.4s ease, box-shadow 0.4s ease, border-radius 0.4s ease;
}

/* ==========================================
   STAGE 0: Hidden (in orbit)
   ========================================== */
.scroll-icon-clone.stage-0 {
    display: none;
}

/* ==========================================
   STAGE 1: Flying from hero to about title - stacking
   ========================================== */
.scroll-icon-clone.stage-1 .float-element {
    box-shadow: var(--orbit-glow);
}

.scroll-icon-clone.stage-1 .float-element i {
    animation: iconSpinFast 0.6s linear infinite;
}

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

/* ==========================================
   STAGE 2: At about-info, replacing icons
   5th icon becomes butterfly
   ========================================== */
.scroll-icon-clone.stage-2 .float-element {
    border-radius: var(--radius-full);
    box-shadow: 
        var(--orbit-glow),
        0 4px 15px rgba(0, 0, 0, 0.3);
}

.scroll-icon-clone.stage-2 .float-element i {
    animation: none;
}

.scroll-icon-clone.butterfly-mode .float-element {
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--accent-primary), var(--accent-secondary));
    color: var(--bg-primary);
    border-color: var(--accent-secondary);
}

.scroll-icon-clone.butterfly-mode .float-element i {
    animation: butterflyWing 0.8s ease-in-out infinite;
}

@keyframes butterflyWing {
    0%, 100% { transform: scaleX(1) rotate(0deg); }
    25% { transform: scaleX(0.7) rotate(5deg); }
    50% { transform: scaleX(1) rotate(0deg); }
    75% { transform: scaleX(0.7) rotate(-5deg); }
}

/* ==========================================
   STAGE 3: Orbiting around services title like moons
   ========================================== */
.scroll-icon-clone.stage-3 .float-element {
    border-radius: var(--radius-md);
    box-shadow: var(--orbit-glow);
}

.scroll-icon-clone.stage-3 .float-element i {
    animation: iconSpinSlow 3s linear infinite;
}

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

/* ==========================================
   STAGE 4: Side by side under portfolio title, floating
   ========================================== */
.scroll-icon-clone.stage-4 .float-element {
    border-radius: var(--radius-md);
    box-shadow: 
        var(--orbit-glow),
        0 4px 20px rgba(0, 0, 0, 0.2);
}

.scroll-icon-clone.stage-4 .float-element i {
    animation: gentleFloat 2s ease-in-out infinite;
}

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

/* ==========================================
   STAGE 5: Review icons descend around testimonials title
   Icons settle in arc formation with gentle floating
   ========================================== */
.scroll-icon-clone.stage-5 .float-element {
    border-radius: var(--radius-full);
    background: linear-gradient(135deg, var(--bg-card), var(--bg-card-hover));
    border-color: var(--accent-primary);
    box-shadow: 
        0 0 20px var(--glow-primary),
        0 0 40px var(--glow-secondary);
}

.scroll-icon-clone.stage-5 .float-element i {
    animation: gentleSettledPulse 2s ease-in-out infinite;
}

@keyframes gentleSettledPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

/* ==========================================
   STAGE 6: Settle above "Mohamed Yusri" in footer
   Icons fly in, rotate 360°, and rest in a row above the name
   Gentle floating animation once settled
   ========================================== */
.scroll-icon-clone.stage-6 .float-element {
    border-radius: var(--radius-md);
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: 
        var(--orbit-glow),
        0 0 20px var(--glow-primary),
        0 0 40px var(--glow-secondary);
}

.scroll-icon-clone.stage-6 .float-element i {
    animation: none; /* JS handles rotation during fly-in */
}

/* Settled state: gentle glow pulse */
@keyframes settledGlow {
    0%, 100% {
        box-shadow: 
            var(--orbit-glow),
            0 0 15px var(--glow-primary);
    }
    50% {
        box-shadow: 
            var(--orbit-glow),
            0 0 25px var(--glow-primary),
            0 0 45px var(--glow-secondary);
    }
}

/* ==========================================
   STAGE 7: Morph into contact/social icons
   Icons transform, fly to social positions, become clickable
   ========================================== */
.scroll-icon-clone.stage-7 .float-element {
    width: 62px;
    height: 62px;
    border-radius: var(--radius-full);
    font-size: 1.6rem;
    background: var(--bg-card);
    border: 2px solid var(--accent-primary);
    color: var(--accent-primary);
    box-shadow: var(--orbit-glow);
    transition: all 0.3s ease, transform 0.3s ease;
}

.scroll-icon-clone.stage-7 .float-element i {
    animation: none;
    transition: transform 0.3s ease;
}

/* Hover effect for clickable social icons (Stage 7 only) */
.scroll-icon-clone.landed-final {
    pointer-events: auto !important;
    cursor: pointer !important;
}

.scroll-icon-clone.landed-final .float-element {
    transition: all 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

.scroll-icon-clone.landed-final:hover .float-element {
    background: var(--accent-primary);
    color: var(--bg-primary);
    transform: translateY(-5px) scale(1.15) !important;
    box-shadow: 
        0 0 20px var(--glow-strong),
        0 0 40px var(--glow-primary),
        0 10px 30px rgba(0, 0, 0, 0.3);
}

.scroll-icon-clone.landed-final:hover .float-element i {
    transform: scale(1.1);
}

/* Glow when fully landed */
.scroll-icon-clone.landed-glow .float-element {
    box-shadow: 
        0 0 15px var(--glow-strong),
        0 0 30px var(--glow-primary),
        0 0 60px var(--glow-secondary);
    animation: landedPulse 2s ease-in-out infinite;
}

@keyframes landedPulse {
    0%, 100% {
        box-shadow: 
            0 0 15px var(--glow-strong),
            0 0 30px var(--glow-primary),
            0 0 60px var(--glow-secondary);
    }
    50% {
        box-shadow: 
            0 0 25px var(--glow-strong),
            0 0 50px var(--glow-primary),
            0 0 80px var(--glow-secondary),
            0 0 100px var(--glow-secondary);
    }
}

/* Arrival burst animation */
@keyframes arrivalBurst {
    0% {
        box-shadow: 0 0 0 0 var(--glow-primary);
    }
    50% {
        box-shadow: 
            0 0 30px 10px var(--glow-primary),
            0 0 60px 20px var(--glow-secondary);
    }
    100% {
        box-shadow: 
            0 0 15px var(--glow-strong),
            0 0 30px var(--glow-primary);
    }
}

.scroll-icon-clone.landed-final .float-element {
    animation: arrivalBurst 0.6s ease-out forwards, landedPulse 2s ease-in-out 0.6s infinite;
}

/* ==========================================
   Hide original orbit items when clones active
   ========================================== */
.orbit-item.cloned-active {
    opacity: 0 !important;
    pointer-events: none !important;
}

/* Section header positioning */
#about .section-header {
    position: relative;
}

/* ==========================================
   Responsive Styles
   ========================================== */
@media (max-width: 768px) {
    .scroll-icon-clone .float-element {
        width: 42px;
        height: 42px;
        font-size: 1.1rem;
    }

    .scroll-icon-clone.stage-7 .float-element {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }

    .scroll-icons-stack {
        height: 50px;
        min-width: 50px;
    }
}

@media (max-width: 480px) {
    .scroll-icon-clone .float-element {
        width: 36px;
        height: 36px;
        font-size: 0.95rem;
    }

    .scroll-icon-clone.stage-7 .float-element {
        width: 44px;
        height: 44px;
        font-size: 1.05rem;
    }
}
