// FAQ Accordion document.addEventListener('DOMContentLoaded', function() { const faqItems = document.querySelectorAll('.faq-item'); faqItems.forEach(item => { const question = item.querySelector('.faq-question'); question.addEventListener('click', () => { // Close all other FAQ items faqItems.forEach(otherItem => { if (otherItem !== item) { otherItem.classList.remove('active'); } }); // Toggle current item item.classList.toggle('active'); }); }); }); // Smooth scrolling for navigation links document.addEventListener('DOMContentLoaded', function() { const navLinks = document.querySelectorAll('a[href^="#"]'); navLinks.forEach(link => { link.addEventListener('click', function(e) { e.preventDefault(); const targetId = this.getAttribute('href'); const targetSection = document.querySelector(targetId); if (targetSection) { const headerHeight = document.querySelector('.header').offsetHeight; const targetPosition = targetSection.offsetTop - headerHeight - 20; window.scrollTo({ top: targetPosition, behavior: 'smooth' }); } }); }); }); // Header scroll effect window.addEventListener('scroll', function() { const header = document.querySelector('.header'); if (window.scrollY > 100) { header.style.background = 'rgba(102, 126, 234, 0.95)'; header.style.backdropFilter = 'blur(10px)'; } else { header.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'; header.style.backdropFilter = 'none'; } }); // Intersection Observer for animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver(function(entries) { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, observerOptions); // Observe elements for animation document.addEventListener('DOMContentLoaded', function() { const animatedElements = document.querySelectorAll('.product-card, .trust-item, .methodology-item'); animatedElements.forEach(el => { el.style.opacity = '0'; el.style.transform = 'translateY(30px)'; el.style.transition = 'opacity 0.6s ease, transform 0.6s ease'; observer.observe(el); }); }); // Product card hover effects document.addEventListener('DOMContentLoaded', function() { const productCards = document.querySelectorAll('.product-card'); productCards.forEach(card => { card.addEventListener('mouseenter', function() { this.style.transform = 'translateY(-10px)'; this.style.boxShadow = '0 20px 60px rgba(0,0,0,0.15)'; }); card.addEventListener('mouseleave', function() { this.style.transform = 'translateY(0)'; this.style.boxShadow = '0 10px 40px rgba(0,0,0,0.1)'; }); }); }); // Button click effects document.addEventListener('DOMContentLoaded', function() { const buttons = document.querySelectorAll('.btn-primary, .btn-secondary, .cta-button'); buttons.forEach(button => { button.addEventListener('click', function(e) { // Create ripple effect const ripple = document.createElement('span'); const rect = this.getBoundingClientRect(); const size = Math.max(rect.width, rect.height); const x = e.clientX - rect.left - size / 2; const y = e.clientY - rect.top - size / 2; ripple.style.width = ripple.style.height = size + 'px'; ripple.style.left = x + 'px'; ripple.style.top = y + 'px'; ripple.classList.add('ripple'); this.appendChild(ripple); setTimeout(() => { ripple.remove(); }, 600); }); }); }); // Add ripple effect CSS const style = document.createElement('style'); style.textContent = ` .btn-primary, .btn-secondary, .cta-button { position: relative; overflow: hidden; } .ripple { position: absolute; border-radius: 50%; background: rgba(255, 255, 255, 0.3); transform: scale(0); animation: ripple-animation 0.6s linear; pointer-events: none; } @keyframes ripple-animation { to { transform: scale(4); opacity: 0; } } `; document.head.appendChild(style); // Mobile menu toggle (if needed in future) function toggleMobileMenu() { const nav = document.querySelector('.nav'); nav.classList.toggle('mobile-active'); } // Lazy loading for images document.addEventListener('DOMContentLoaded', function() { const images = document.querySelectorAll('img[src]'); const imageObserver = new IntersectionObserver((entries, observer) => { entries.forEach(entry => { if (entry.isIntersecting) { const img = entry.target; img.style.transition = 'opacity 0.3s ease'; if (!img.complete) { img.style.opacity = '0'; img.onload = () => { img.style.opacity = '1'; }; } else { img.style.opacity = '1'; } observer.unobserve(img); } }); }); images.forEach(img => imageObserver.observe(img)); }); // Performance optimization: Debounce scroll events function debounce(func, wait) { let timeout; return function executedFunction(...args) { const later = () => { clearTimeout(timeout); func(...args); }; clearTimeout(timeout); timeout = setTimeout(later, wait); }; } // Apply debounce to scroll handler const debouncedScrollHandler = debounce(function() { const header = document.querySelector('.header'); if (window.scrollY > 100) { header.style.background = 'rgba(102, 126, 234, 0.95)'; header.style.backdropFilter = 'blur(10px)'; } else { header.style.background = 'linear-gradient(135deg, #667eea 0%, #764ba2 100%)'; header.style.backdropFilter = 'none'; } }, 10); window.addEventListener('scroll', debouncedScrollHandler);