// ============================================ // MENU MOBILE // ============================================ const menuToggle = document.getElementById('menuToggle'); const mainNav = document.getElementById('mainNav'); if (menuToggle && mainNav) { menuToggle.addEventListener('click', function() { mainNav.classList.toggle('open'); const icon = this.querySelector('i'); if (mainNav.classList.contains('open')) { icon.className = 'fas fa-times'; } else { icon.className = 'fas fa-bars'; } }); // Fechar menu ao clicar em um link const navLinks = mainNav.querySelectorAll('a'); navLinks.forEach(link => { link.addEventListener('click', function() { mainNav.classList.remove('open'); const icon = menuToggle.querySelector('i'); if (icon) { icon.className = 'fas fa-bars'; } }); }); } // ============================================ // HEADER SCROLL EFFECT // ============================================ const header = document.querySelector('.header'); window.addEventListener('scroll', function() { if (window.scrollY > 50) { header.classList.add('scrolled'); } else { header.classList.remove('scrolled'); } }); // ============================================ // ANIMAÇÃO DE ESTATÍSTICAS (OPCIONAL) // ============================================ const statNumbers = document.querySelectorAll('.stat-number'); const animateNumbers = (entries) => { entries.forEach(entry => { if (entry.isIntersecting) { const el = entry.target; const text = el.textContent; const num = parseFloat(text.replace(/[^0-9.]/g, '')); if (!isNaN(num)) { let current = 0; const increment = num / 40; const timer = setInterval(() => { current += increment; if (current >= num) { el.textContent = text; clearInterval(timer); } else { if (Number.isInteger(num)) { el.textContent = Math.floor(current); } else { el.textContent = current.toFixed(1); } } }, 30); } observer.unobserve(el); } }); }; const observer = new IntersectionObserver(animateNumbers, { threshold: 0.5 }); statNumbers.forEach(el => observer.observe(el)); // ============================================ // SUAVIZAR NAVEGAÇÃO PARA ÂNCORAS // ============================================ document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { const href = this.getAttribute('href'); if (href !== '#' && href !== '#!') { const target = document.querySelector(href); if (target) { e.preventDefault(); const headerHeight = header ? header.offsetHeight : 0; const targetPosition = target.getBoundingClientRect().top + window.pageYOffset - headerHeight - 20; window.scrollTo({ top: targetPosition, behavior: 'smooth' }); } } }); }); console.log('🚀 Site da Deputada Detinha carregado com sucesso!');