const hamburger = document.querySelector('.hamburger-menu');
const nav = document.querySelector('.main-nav');
if (hamburger && nav) {
    hamburger.addEventListener('click', (e) => {
        e.stopPropagation();
        nav.classList.toggle('nav-open');
        hamburger.classList.toggle('is-active');
    });
    // Chiudi il menu quando clicchi fuori dal nav su mobile
    document.addEventListener('click', (e) => {
        if (window.innerWidth < 992 && nav.classList.contains('nav-open')) {
            if (!nav.contains(e.target) && !hamburger.contains(e.target)) {
                nav.classList.remove('nav-open');
                hamburger.classList.remove('is-active');
            }
        }
    });
    // Chiudi il menu al resize sopra 992px
    window.addEventListener('resize', () => {
        if (window.innerWidth >= 992) {
            nav.classList.remove('nav-open');
            hamburger.classList.remove('is-active');
        }
    });
}

// Inizializza Swiper
var swiper = new Swiper('.testimonial-slider', {
    slidesPerView: 1,
    spaceBetween: 10,
    navigation: {
        nextEl: '.swiper-button-next',
        prevEl: '.swiper-button-prev',
    },
    pagination: {
        el: '.swiper-pagination',
        clickable: true,
    },
});