document.addEventListener("DOMContentLoaded", () => {
    const hamburger = document.querySelector("#hamburger");
    const menuMobile = document.querySelector("#menu-mobile");
    const header = document.querySelector("#header");

    const html = document.querySelector('html');
    const body = document.querySelector('body');

    const menuClose = () => {
        hamburger.classList.remove('active');
        menuMobile.classList.remove('open');

        html.removeAttribute('style');
        body.removeAttribute('style');
    };

    hamburger.addEventListener('click', () => {
        if (menuMobile.classList.contains('open')) {
            menuClose();
        } else {
            hamburger.classList.add('active');
            menuMobile.classList.add('open');

            html.style.overflow = 'hidden';
            body.style.overflow = 'hidden';
        }
    });

    menuMobile.querySelectorAll('a').forEach((link) => {
        link.addEventListener('click', () => menuClose());
    });

    header.addEventListener('click', (e) => {
        if (e.target.closest('#hamburger')) {
            return;
        }

        menuClose();
    });

    const cookiesNotification = document.querySelector("#cookies-notification");
    const cookiesCloseButton = document.querySelector("#cookies-close");
    cookiesCloseButton.addEventListener('click', () => {
        cookiesNotification.classList.remove('open');
        localStorage.setItem('cookies-notification', 'true');
    });

    if (localStorage.getItem('cookies-notification') !== 'true') {
        cookiesNotification.classList.add('open');
    }
});