document.addEventListener('DOMContentLoaded', function() { // Mobile menu toggle const header = document.querySelector('custom-header'); if (header) { const mobileMenuBtn = header.shadowRoot.querySelector('.mobile-menu-btn'); const navLinks = header.shadowRoot.querySelector('.nav-links'); mobileMenuBtn.addEventListener('click', function() { navLinks.classList.toggle('show'); }); } // Smooth scroll for navigation links document.querySelectorAll('custom-header').forEach(header => { header.shadowRoot.querySelectorAll('.nav-link').forEach(link => { link.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); const targetElement = document.querySelector(targetId); if (targetElement) { targetElement.scrollIntoView({ behavior: 'smooth' }); // Close mobile menu if open const header = document.querySelector('custom-header'); const mobileMenuBtn = header.shadowRoot.querySelector('.mobile-menu-btn'); const navLinks = header.shadowRoot.querySelector('.nav-links'); navLinks.classList.remove('show'); mobileMenuBtn.classList.remove('active'); } }); }); }); // Responsive adjustments for sections function handleResize() { const width = window.innerWidth; // Adjust header padding based on screen size const header = document.querySelector('custom-header').shadowRoot.querySelector('.header-content'); if (width < 768) { header.style.padding = '1rem'; } else { header.style.padding = '1rem 2rem'; } // Adjust hero section text size const heroText = document.querySelector('.container.mx-auto.text-center h1'); if (width < 640) { heroText.style.fontSize = '2.2rem'; } else if (width < 1024) { heroText.style.fontSize = '2.8rem'; } else { heroText.style.fontSize = '3.5rem'; } } // Initialize on load handleResize(); // Add event listener for resize window.addEventListener('resize', handleResize); // Add fade-in animation to sections const sections = document.querySelectorAll('section'); const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fade-in'); } }); }, { threshold: 0.1 }); sections.forEach(section => { observer.observe(section); }); // Make all buy buttons redirect to WhatsApp const buyButtons = document.querySelectorAll('.animate-buy-btn'); buyButtons.forEach(button => { button.addEventListener('click', function() { window.open('https://wa.me/237693930778?text=Bonjour%20%F0%9F%91%8B%2C%20je%20veux%20acheter%20cette%20%C3%A9pulcheuse', '_blank'); }); }); // WhatsApp button hover effect const whatsappBtn = document.querySelector('.fixed.bottom-6.right-6 a'); whatsappBtn.addEventListener('mouseenter', function() { this.classList.add('animate-bounce'); }); whatsappBtn.addEventListener('mouseleave', function() { this.classList.remove('animate-bounce'); }); });