document.addEventListener('DOMContentLoaded', function() { // Initialize feather icons feather.replace(); // Mobile menu toggle const menuButton = document.querySelector('custom-header').shadowRoot.querySelector('.mobile-menu-button'); const mobileMenu = document.querySelector('mobile-menu').shadowRoot.querySelector('.mobile-menu'); const overlay = document.querySelector('custom-header').shadowRoot.querySelector('.overlay'); if (menuButton && mobileMenu) { menuButton.addEventListener('click', () => { mobileMenu.classList.add('open'); overlay.classList.add('active'); document.body.style.overflow = 'hidden'; }); overlay.addEventListener('click', () => { mobileMenu.classList.remove('open'); overlay.classList.remove('active'); document.body.style.overflow = ''; }); } // Set active nav link based on current page const currentPath = window.location.pathname.split('/').pop() || 'index.html'; const navLinks = document.querySelectorAll('custom-header nav a, mobile-menu nav a'); navLinks.forEach(link => { const linkPath = link.getAttribute('href'); if (currentPath === linkPath) { link.classList.add('active'); } else { link.classList.remove('active'); } }); // Copy bonus code functionality document.querySelectorAll('.copy-bonus').forEach(button => { button.addEventListener('click', function() { const code = this.getAttribute('data-code'); navigator.clipboard.writeText(code).then(() => { const originalText = this.textContent; this.textContent = 'Copied!'; setTimeout(() => { this.textContent = originalText; }, 2000); }); }); }); // Quiz evaluation functionality const evaluateBtn = document.getElementById('evaluate-btn'); if (evaluateBtn) { evaluateBtn.addEventListener('click', function() { const q1 = document.querySelector('input[name="q1"]:checked'); const q2 = document.querySelector('input[name="q2"]:checked'); const q3 = document.querySelector('input[name="q3"]:checked'); if (!q1 || !q2 || !q3) { alert('Please answer all questions before evaluating.'); return; } const answers = { q1: q1.nextElementSibling.textContent.toLowerCase(), q2: q2.nextElementSibling.textContent.toLowerCase(), q3: q3.nextElementSibling.textContent.toLowerCase() }; let score = 0; if (answers.q1 === 'sometimes') score += 1; if (answers.q1 === 'often') score += 2; if (answers.q2 === 'sometimes') score += 1; if (answers.q2 === 'often') score += 2; if (answers.q3 === 'sometimes') score += 1; if (answers.q3 === 'often') score += 2; let riskLevel, message; if (score <= 2) { riskLevel = "Low Risk"; message = "Your answers suggest your gambling habits are currently low risk. Continue to gamble responsibly and be aware of warning signs."; } else if (score <= 4) { riskLevel = "Moderate Risk"; message = "Your answers indicate some potential risk factors. Consider setting stricter limits and monitoring your gambling more carefully."; } else { riskLevel = "High Risk"; message = "Your answers suggest behaviors associated with problem gambling. We strongly recommend seeking support and considering self-exclusion tools."; } const modal = document.querySelector('custom-modal'); modal.openModal(riskLevel, message); }); } // Sticky header const header = document.querySelector('custom-header'); if (header) { window.addEventListener('scroll', function() { if (window.scrollY > 50) { header.style.boxShadow = '0 2px 10px rgba(0, 0, 0, 0.1)'; } else { header.style.boxShadow = 'none'; } }); } });