/* Dhakadigitalsurvey — shared front-end behavior - Auto-marks the active nav link based on the current filename - Mobile menu toggle - Newsletter form prevent-default */ (function () { const path = window.location.pathname.split('/').pop() || 'index.html'; document.querySelectorAll('[data-nav]').forEach((a) => { const target = a.getAttribute('data-nav'); if (target === path || (path === '' && target === 'index.html')) { a.setAttribute('aria-current', 'page'); } }); // Mobile menu toggle const toggle = document.querySelector('[data-menu-toggle]'); const menu = document.querySelector('[data-mobile-menu]'); if (toggle && menu) { toggle.addEventListener('click', () => { menu.classList.toggle('open'); }); menu.querySelectorAll('a').forEach((a) => { a.addEventListener('click', () => menu.classList.remove('open')); }); } // Newsletter form (demo) document.querySelectorAll('form[data-newsletter]').forEach((f) => { f.addEventListener('submit', (e) => { e.preventDefault(); const input = f.querySelector('input[type=email]'); if (input && input.value) { input.value = ''; const btn = f.querySelector('button'); if (btn) { const original = btn.textContent; btn.textContent = 'JOINED ✓'; setTimeout(() => (btn.textContent = original), 1800); } } }); }); })();