// Mobile menu toggle
document.addEventListener('DOMContentLoaded', function() {
    const hamburger = document.querySelector('.hamburger');
    const navMenu = document.querySelector('.nav-menu');

    if (hamburger && navMenu) {
        hamburger.addEventListener('click', () => {
            hamburger.classList.toggle('active');
            navMenu.classList.toggle('active');
        });
    }

    // Close mobile menu when clicking on a link
    document.querySelectorAll('.nav-menu a').forEach(link => {
        link.addEventListener('click', () => {
            if (hamburger && navMenu) {
                hamburger.classList.remove('active');
                navMenu.classList.remove('active');
            }
        });
    });

    // Header scroll effect
    const header = document.querySelector('.header');
    if (header) {
        window.addEventListener('scroll', () => {
            if (window.scrollY > 100) {
                header.classList.add('scrolled');
            } else {
                header.classList.remove('scrolled');
            }
        });
    }

    // Hero background slider (gambar di belakang teks hero)
    const heroBgSlides = document.querySelectorAll('.hero-bg-slide');
    if (heroBgSlides.length > 1) {
        let currentHeroSlide = 0;

        function showHeroSlide(index) {
            heroBgSlides.forEach((slide, i) => {
                slide.classList.toggle('active', i === index);
            });
            currentHeroSlide = index;
        }

        function nextHeroSlide() {
            const next = (currentHeroSlide + 1) % heroBgSlides.length;
            showHeroSlide(next);
        }

        setInterval(nextHeroSlide, 7000);
    }
});

