// Lovable.dev inspired functionality document.addEventListener('DOMContentLoaded', function() { // Mobile menu toggle const mobileMenuBtn = document.getElementById('mobile-menu-btn'); const mobileMenu = document.getElementById('mobile-menu'); if (mobileMenuBtn && mobileMenu) { mobileMenuBtn.addEventListener('click', function() { mobileMenu.classList.toggle('hidden'); const icon = mobileMenuBtn.querySelector('i'); if (icon.classList.contains('fa-bars')) { icon.classList.remove('fa-bars'); icon.classList.add('fa-times'); } else { icon.classList.remove('fa-times'); icon.classList.add('fa-bars'); } }); } // FAQ accordion const faqHeaders = document.querySelectorAll('.faq-toggle'); faqHeaders.forEach(header => { header.addEventListener('click', function() { const content = this.nextElementSibling; const icon = this.querySelector('i'); // Toggle current FAQ content.classList.toggle('hidden'); icon.classList.toggle('fa-chevron-down'); icon.classList.toggle('fa-chevron-up'); // Close other FAQs (optional) faqHeaders.forEach(otherHeader => { if (otherHeader !== this) { const otherContent = otherHeader.nextElementSibling; const otherIcon = otherHeader.querySelector('i'); otherContent.classList.add('hidden'); otherIcon.classList.remove('fa-chevron-up'); otherIcon.classList.add('fa-chevron-down'); } }); }); }); // Pricing toggle const pricingToggleBtns = document.querySelectorAll('.pricing-toggle-btn'); pricingToggleBtns.forEach(btn => { btn.addEventListener('click', function() { const period = this.dataset.period; const monthlyPrices = document.querySelectorAll('.monthly-price'); const annualPrices = document.querySelectorAll('.annual-price'); const savings = document.querySelectorAll('.savings-badge'); pricingToggleBtns.forEach(b => { b.classList.remove('active'); b.classList.add('text-gray-600'); b.classList.remove('text-white'); b.classList.remove('bg-primary'); }); this.classList.add('active'); this.classList.remove('text-gray-600'); this.classList.add('text-white'); this.classList.add('bg-primary'); if (period === 'monthly') { monthlyPrices.forEach(el => el.classList.remove('hidden')); annualPrices.forEach(el => el.classList.add('hidden')); savings.forEach(el => el.classList.add('hidden')); } else { monthlyPrices.forEach(el => el.classList.add('hidden')); annualPrices.forEach(el => el.classList.remove('hidden')); savings.forEach(el => el.classList.remove('hidden')); } }); }); // Smooth scroll for navigation links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); if (targetId === '#') return; const targetElement = document.querySelector(targetId); if (targetElement) { window.scrollTo({ top: targetElement.offsetTop - 80, behavior: 'smooth' }); // Close mobile menu if open if (mobileMenu && !mobileMenu.classList.contains('hidden')) { mobileMenu.classList.add('hidden'); const icon = mobileMenuBtn.querySelector('i'); icon.classList.remove('fa-times'); icon.classList.add('fa-bars'); } } }); }); // Testimonial slider navigation const testimonialSlider = document.querySelector('.testimonial-slider'); const prevBtn = document.getElementById('prev-testimonial'); const nextBtn = document.getElementById('next-testimonial'); if (testimonialSlider && prevBtn && nextBtn) { const cardWidth = 320 + 24; // card width + gap const maxScroll = testimonialSlider.scrollWidth - testimonialSlider.clientWidth; prevBtn.addEventListener('click', () => { testimonialSlider.scrollLeft -= cardWidth; }); nextBtn.addEventListener('click', () => { testimonialSlider.scrollLeft += cardWidth; }); testimonialSlider.addEventListener('scroll', () => { prevBtn.classList.toggle('opacity-50', testimonialSlider.scrollLeft <= 0); nextBtn.classList.toggle('opacity-50', testimonialSlider.scrollLeft >= maxScroll - 10); }); } // Add animation classes on scroll const observerOptions = { root: null, rootMargin: '0px', threshold: 0.1 }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('fade-in-up'); } }); }, observerOptions); // Observe elements for animation document.querySelectorAll('.animate-on-scroll').forEach(el => { observer.observe(el); }); // Initialize Lucide icons if (typeof lucide !== 'undefined') { lucide.createIcons(); } });