/* ========================================
   GLOBAL PAGE ANIMATIONS - SERUNAI
   ======================================== */

/* ====== HERO LOAD ANIMATIONS ====== */

/* Bupati image - slide from left */
@keyframes slideInFromLeft {
    from {
        opacity: 0;
        transform: translateX(-100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Wakil image - slide from right */
@keyframes slideInFromRight {
    from {
        opacity: 0;
        transform: translateX(100%);
    }

    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* Main caption - fade in up */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Info cards - fade in with scale */
@keyframes fadeInScale {
    from {
        opacity: 0;
        transform: scale(0.9);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ====== APPLY HERO ANIMATIONS ====== */

/* Bupati & Wakil initial state - OUTSIDE viewport */
.hero-overlay-left,
.hero-overlay-right {
    opacity: 0;
}

/* Bupati initial position - LEFT outside */
.hero-overlay-left {
    transform: translateX(-100%);
        /* Start completely off-screen left */
    animation: slideInFromLeft 1s ease-out 0.3s forwards;
}

/* Wakil initial position - RIGHT outside */
.hero-overlay-right {
    transform: translateX(100%);
        /* Start completely off-screen right */
    animation: slideInFromRight 1s ease-out 0.3s forwards;
}

/* Main caption animation */
.main-caption {
    opacity: 0;
    animation: fadeInUp 0.8s ease-out 0.5s forwards;
}

/* Info items staggered animation */
.info-item-compact {
    opacity: 0;
    animation: fadeInScale 0.6s ease-out forwards;
}

.info-item-compact:nth-child(1) {
    animation-delay: 0.7s;
}

.info-item-compact:nth-child(2) {
    animation-delay: 0.8s;
}

.info-item-compact:nth-child(3) {
    animation-delay: 0.9s;
}

.info-item-compact:nth-child(4) {
    animation-delay: 1s;
}

/* Main button animation */
.main-button-compact {
    opacity: 0;
    animation: fadeInScale 0.6s ease-out 1s forwards;
}

/* ====== MOBILE HERO OVERLAY ====== */

/* Hide mobile overlay on desktop */
.hero-overlay-mobile {
    display: none;
}

/* Mobile overlay styling */
@media screen and (max-width: 768px) {

    /* Hide desktop overlays on mobile */
    .hero-overlay-left,
    .hero-overlay-right {
        display: none !important;
    }

    /* Show and style mobile overlay */
    .hero-overlay-mobile {
        display: block;
        position: absolute;
        top: 70px;
        /* Lowered more for bigger image */
        left: 50%;
        transform: translateX(-50%);
        max-width: 336px;
        /* 1.2x bigger (280 * 1.2) */
        width: 90%;
        height: auto;
        z-index: 10;
        pointer-events: none;
        object-fit: contain;
        filter: drop-shadow(0px 5px 15px rgba(0, 0, 0, 0.2));

        /* Animation */
        opacity: 0;
        animation: slideInFromTop 1s ease-out 0.3s forwards;
    }

    /* Swap title order on mobile - big title on top */
    .main-caption {
        display: flex;
        flex-direction: column-reverse;
        /* h1 goes on top, h2 below */
    }
        /* Keep button at bottom (don't swap) */
        .main-caption .border-button {
            order: -1;
            /* Puts button at bottom of reversed column */
        }
    
        /* Reduce h1 margin on mobile */
        .main-caption h1 {
            margin-bottom: 10px !important;
            /* Tighter spacing */
        }
        }
    
        /* Slide from top animation for mobile */
        @keyframes slideInFromTop {
    from {
        opacity: 0;
        transform: translateX(-50%) translateY(-50px);
    }

    to {
        opacity: 1;
        transform: translateX(-50%) translateY(0);
        }
        }
        
        /* Extra adjustments for very small mobile */
        @media screen and (max-width: 480px) {
            .hero-overlay-mobile {
                max-width: 264px;
                /* 1.2x of 220 */
                top: 50px;
                /* Adjusted for smaller screens */
    }
}

@media screen and (max-width: 375px) {
    .hero-overlay-mobile {
        max-width: 216px;
        /* 1.2x of 180 */
        top: 40px;
        /* Adjusted for very small screens */
    }
}

/* ====== SCROLL ANIMATIONS ====== */

/* Fade in from bottom - SMOOTH */
@keyframes scrollFadeInUp {
    from {
        opacity: 0;
        transform: translate3d(0, 20px, 0);
        
            /* GPU accelerated, smaller distance */
            to {
                opacity: 1;
                transform: translate3d(0, 0, 0);
            }
        }

/* Fade in from left - SMOOTH */
@keyframes scrollFadeInLeft {
    from {
        opacity: 0;
        transform: translate3d(-20px, 0, 0);
        /* GPU accelerated, smaller distance */
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Fade in from right - SMOOTH */
@keyframes scrollFadeInRight {
    from {
        opacity: 0;
        transform: translate3d(20px, 0, 0);
            /* GPU accelerated, smaller distance */
    to {
        opacity: 1;
        transform: translate3d(0, 0, 0);
    }
}

/* Scale fade in - SMOOTH */
@keyframes scrollFadeInScale {
    from {
        opacity: 0;
        transform: scale3d(0.96, 0.96, 1);
            /* GPU accelerated, subtle scale */
    to {
        opacity: 1;
        transform: scale3d(1, 1, 1);
    }
}

/* ====== SCROLL ANIMATION CLASSES ====== */

/* Initial hidden state - Smooth setup */
.scroll-animate {
    opacity: 0;
    transform: translate3d(0, 20px, 0);
        /* Match animation starting point */
        will-change: opacity, transform;
        /* Optimize for animation */
}

/* Animated state when visible - Buttery smooth */
.scroll-animate.scroll-visible {
    opacity: 1 !important;
        transform: translate3d(0, 0, 0) !important;
        animation: scrollFadeInUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
        will-change: auto;
        /* Remove after animation */
}

/* Specific animation variants with smooth easing */
.scroll-fade-up.scroll-visible {
    animation: scrollFadeInUp 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.scroll-fade-left.scroll-visible {
    animation: scrollFadeInLeft 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.scroll-fade-right.scroll-visible {
    animation: scrollFadeInRight 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}

.scroll-fade-scale.scroll-visible {
    animation: scrollFadeInScale 0.9s cubic-bezier(0.16, 1, 0.3, 1) forwards !important;
}


/* ====== RESPONSIVE OPTIMIZATIONS ====== */

@media screen and (max-width: 768px) {

    /* Faster animations on mobile */
    .hero-overlay-left,
    .hero-overlay-right {
        animation-duration: 0.7s;
    }

    .main-caption,
    .info-item-compact,
    .main-button-compact {
        animation-duration: 0.5s;
    }

    /* Reduce scroll animation distance on mobile */
    @keyframes scrollFadeInUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    @keyframes scrollFadeInLeft {
        from {
            opacity: 0;
            transform: translateX(0);
            /* No horizontal movement on mobile */
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }

    @keyframes scrollFadeInRight {
        from {
            opacity: 0;
            transform: translateX(0);
            /* No horizontal movement on mobile */
        }

        to {
            opacity: 1;
            transform: translateX(0);
        }
    }
}

/* Reduced motion for accessibility */
@media (prefers-reduced-motion: reduce) {

    .hero-overlay-left,
    .hero-overlay-right,
    .main-caption,
    .info-item-compact,
    .main-button-compact,
    .scroll-animate {
        animation: none !important;
        opacity: 1 !important;
        transform: none !important;
    }
}

/* ====== PERFORMANCE OPTIMIZATIONS ====== */

/* Use will-change for animations */
.hero-overlay-left,
.hero-overlay-right,
.scroll-animate {
    will-change: opacity, transform;
}

/* Remove will-change after animation */
.scroll-animate.scroll-visible {
    will-change: auto;
}

/* ====== FOOTER FIX ====== */

/* Ensure footer and call-to-action are NEVER animated - High specificity */
.call-to-action,
footer,
.call-to-action *,
footer * {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

/* Remove scroll-animate class from footer if accidentally added */
.call-to-action.scroll-animate,
footer.scroll-animate {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

/* Ensure footer children don't get animated */
.call-to-action .scroll-animate,
footer .scroll-animate {
    opacity: 1 !important;
    transform: none !important;
    animation: none !important;
}

/* Prevent footer from being inside animated sections */
body>.call-to-action {
    margin-top: 0;
    clear: both;
        position: relative;
        z-index: 1;
}