const mobileNavToggle = document.querySelector('.mobile-nav-toggle'); const navLinks = document.querySelector('.nav-links'); mobileNavToggle.addEventListener('click', () => { navLinks.classList.toggle('active'); mobileNavToggle.classList.toggle('active'); }); document.addEventListener('click', (e) => { if (!e.target.closest('.nav') && navLinks.classList.contains('active')) { navLinks.classList.remove('active'); mobileNavToggle.classList.remove('active'); } }); document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); const form = document.querySelector('.contact-form'); form.addEventListener('submit', (e) => { e.preventDefault(); const formData = new FormData(form); const data = Object.fromEntries(formData); console.log('Form submitted:', data); form.reset(); }); let lastScroll = 0; window.addEventListener('load', () => { setTimeout(() => { document.querySelector('.loading').classList.add('loaded'); }, 500); }); const scrollTopBtn = document.querySelector('.scroll-top'); scrollTopBtn.addEventListener('click', () => { window.scrollTo({ top: 0, behavior: 'smooth' }); }); const observeElements = () => { const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; } }); }, { threshold: 0.1 }); document.querySelectorAll('.feature-card').forEach(card => { observer.observe(card); card.style.opacity = '0'; card.style.transform = 'translateY(20px)'; card.style.transition = 'all 0.6s ease'; }); }; document.addEventListener('DOMContentLoaded', observeElements); window.addEventListener('scroll', () => { scrollTopBtn.classList.toggle('visible', window.scrollY > 500); const header = document.querySelector('.header'); const currentScroll = window.pageYOffset; if (currentScroll <= 0) { header.classList.remove('scrolled'); return; } if (currentScroll > lastScroll && !header.classList.contains('scrolled')) { header.classList.add('scrolled'); } else if (currentScroll < lastScroll && header.classList.contains('scrolled')) { header.classList.remove('scrolled'); } lastScroll = currentScroll; });