// ===== PROMO BANNER ===== function closePromoBanner() { const banner = document.getElementById('promo-banner'); banner.style.maxHeight = banner.offsetHeight + 'px'; requestAnimationFrame(() => { banner.style.maxHeight = '0'; banner.style.padding = '0'; banner.style.opacity = '0'; banner.style.overflow = 'hidden'; }); setTimeout(() => { banner.style.display = 'none'; }, 400); } // ===== MOBILE MENU ===== const mobileMenuBtn = document.getElementById('mobile-menu-btn'); const mobileMenu = document.getElementById('mobile-menu'); let isMenuOpen = false; mobileMenuBtn.addEventListener('click', () => { isMenuOpen = !isMenuOpen; if (isMenuOpen) { mobileMenu.classList.add('open'); mobileMenuBtn.innerHTML = ''; } else { mobileMenu.classList.remove('open'); mobileMenuBtn.innerHTML = ''; } lucide.createIcons(); }); // Fechar menu ao clicar em um link mobileMenu.querySelectorAll('a').forEach(link => { link.addEventListener('click', () => { isMenuOpen = false; mobileMenu.classList.remove('open'); mobileMenuBtn.innerHTML = ''; lucide.createIcons(); }); }); // ===== HEADER SCROLL EFFECT ===== const header = document.getElementById('header'); window.addEventListener('scroll', () => { if (window.scrollY > 50) { header.classList.add('scrolled'); } else { header.classList.remove('scrolled'); } }); // ===== CUPOM FLUTUANTE ===== const coupon = document.getElementById('coupon-float'); let couponDismissed = false; function showCoupon() { if (!couponDismissed) { setTimeout(() => { coupon.style.display = 'block'; coupon.style.opacity = '1'; coupon.style.transform = 'translateY(0)'; }, 4000); } } function closeCoupon() { couponDismissed = true; coupon.style.opacity = '0'; coupon.style.transform = 'translateY(20px)'; setTimeout(() => { coupon.style.display = 'none'; }, 400); } // Reaparecer cupom após scroll até procedimentos let couponReappear = false; const proceduresSection = document.getElementById('procedures'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting && !couponReappear) { couponReappear = true; couponDismissed = false; showCoupon(); } }); }, { threshold: 0.3 }); if (proceduresSection) { observer.observe(proceduresSection); } // Mostrar cupom inicialmente showCoupon(); // ===== TESTIMONIAL CAROUSEL ===== const track = document.getElementById('testimonial-track'); const prevBtn = document.getElementById('testimonial-prev'); const nextBtn = document.getElementById('testimonial-next'); if (track && prevBtn && nextBtn) { const scrollAmount = 370; prevBtn.addEventListener('click', () => { track.scrollBy({ left: -scrollAmount, behavior: 'smooth' }); }); nextBtn.addEventListener('click', () => { track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); }); // Auto scroll every 5 seconds let autoScrollInterval = setInterval(() => { const maxScroll = track.scrollWidth - track.clientWidth; if (track.scrollLeft >= maxScroll - 10) { track.scrollTo({ left: 0, behavior: 'smooth' }); } else { track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); } }, 5000); // Pause auto scroll on hover track.addEventListener('mouseenter', () => clearInterval(autoScrollInterval)); track.addEventListener('mouseleave', () => { autoScrollInterval = setInterval(() => { const maxScroll = track.scrollWidth - track.clientWidth; if (track.scrollLeft >= maxScroll - 10) { track.scrollTo({ left: 0, behavior: 'smooth' }); } else { track.scrollBy({ left: scrollAmount, behavior: 'smooth' }); } }, 5000); }); } // ===== FORM SUBMISSION ===== const contactForm = document.getElementById('contact-form'); if (contactForm) { contactForm.addEventListener('submit', (e) => { e.preventDefault(); const submitBtn = contactForm.querySelector('button[type="submit"]'); const originalText = submitBtn.innerHTML; // Feedback visual submitBtn.innerHTML = ' Enviando...'; submitBtn.disabled = true; setTimeout(() => { submitBtn.innerHTML = ' Mensagem Enviada!'; submitBtn.classList.add('bg-green-400', 'hover:bg-green-400'); lucide.createIcons(); // Reset form contactForm.reset(); // Reset button after delay setTimeout(() => { submitBtn.innerHTML = originalText; submitBtn.classList.remove('bg-green-400', 'hover:bg-green-400'); submitBtn.disabled = false; lucide.createIcons(); }, 3000); }, 1500); }); } // ===== SMOOTH SCROLL FOR ANCHOR LINKS ===== document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { const headerOffset = 80; const elementPosition = target.getBoundingClientRect().top; const offsetPosition = elementPosition + window.pageYOffset - headerOffset; window.scrollTo({ top: offsetPosition, behavior: 'smooth' }); } }); }); // ===== FADE IN ON SCROLL ===== const fadeElements = document.querySelectorAll('.fade-in-on-scroll'); const fadeObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('visible'); fadeObserver.unobserve(entry.target); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); fadeElements.forEach(el => fadeObserver.observe(el)); // ===== WHATSAPP BUTTON PULSE ON SCROLL ===== const whatsappBtn = document.querySelector('a[href*="wa.me"]'); if (whatsappBtn) { window.addEventListener('scroll', () => { const scrollPercent = window.scrollY / (document.documentElement.scrollHeight - window.innerHeight); if (scrollPercent > 0.3) { whatsappBtn.classList.add('animate-pulse-soft'); } }); } // ===== NAVEGAÇÃO ATIVA ===== const sections = document.querySelectorAll('section[id]'); const navLinks = document.querySelectorAll('header nav a[href^="#"]'); window.addEventListener('scroll', () => { let current = ''; sections.forEach(section => { const sectionTop = section.offsetTop - 100; if (window.scrollY >= sectionTop) { current = section.getAttribute('id'); } }); navLinks.forEach(link => { link.classList.remove('text-olive'); if (link.getAttribute('href') === '#' + current) { link.classList.add('text-olive'); } }); }); // ===== INICIALIZAÇÃO ===== document.addEventListener('DOMContentLoaded', () => { console.log('✨ Zays Clinic - Site carregado com sucesso!'); console.log('💫 Revele sua melhor versão.'); });