(function(){
    var menu = document.querySelector('.nav-links');
    var btn = document.querySelector('.nav-hamburger');
    if (!menu || !btn) return;
    btn.addEventListener('click', function() {
        menu.classList.toggle('open');
    });
    document.addEventListener('click', function(e) {
        if (!menu.contains(e.target) && !btn.contains(e.target)) {
            menu.classList.remove('open');
        }
    });
    menu.querySelectorAll('a').forEach(function(a) {
        a.addEventListener('click', function() { menu.classList.remove('open'); });
    });
})();
