/* ============================================================ C2 — Products mega dropdown behaviour (append to main.js end) ============================================================ */ (function () { 'use strict'; function init() { var mq = window.matchMedia('(max-width: 720px)'); /* Mobile accordion: tapping "Products" toggles the panel (no jump) */ document.querySelectorAll('.nav-item.has-mega').forEach(function (item) { var link = item.querySelector('.nav-drop'); if (!link) return; link.addEventListener('click', function (e) { if (!mq.matches) return; e.preventDefault(); var open = item.classList.toggle('open'); link.setAttribute('aria-expanded', open ? 'true' : 'false'); }); }); /* Choosing a group link closes the mobile overlay menu */ document.querySelectorAll('.mega-link').forEach(function (l) { l.addEventListener('click', function () { var nav = document.getElementById('siteNav'); var tg = document.getElementById('navToggle'); if (nav) nav.classList.remove('open'); if (tg) tg.setAttribute('aria-expanded', 'false'); document.querySelectorAll('.nav-item.has-mega.open').forEach(function (i) { i.classList.remove('open'); }); }); }); } if (document.readyState === 'loading') { document.addEventListener('DOMContentLoaded', init); } else { init(); } })();