const hamburger = document.querySelector('.hamburger');
const mobileMenu = document.querySelector('.mobile-menu');

const year = document.getElementById('year');
const currentYear = new Date().getFullYear();
year.textContent = currentYear;

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


window.addEventListener('resize', () => {
    if (window.innerWidth > 1300) {
        mobileMenu.classList.remove('active');
    }
});

// ---------------- del carrusel ----------------
let index = 0;

function showSlide(n) {
    const slides = document.querySelectorAll('.slide');
    if (n >= slides.length) index = 0;
    if (n < 0) index = slides.length - 1;

    const newTransformValue = -index * 100 + '%';
    document.querySelector('.slider-container').style.transform = `translateX(${newTransformValue})`;
}

function moveSlide(step) {
    showSlide(index += step);
}

showSlide(index);
setInterval(() => moveSlide(1), 8000);


window.onscroll = function() {
    let scrollBtn = document.getElementById("scrollToTopBtn");
    if (document.body.scrollTop > 100 || document.documentElement.scrollTop > 100) {
        scrollBtn.style.display = "block"; 
    } else {
        scrollBtn.style.display = "none"; 
    }
};

function scrollToTop() {
    window.scrollTo({ top: 0, behavior: 'smooth' }); 
}
