// Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); document.querySelector(this.getAttribute('href')).scrollIntoView({ behavior: 'smooth' }); }); }); // Sticky navbar window.addEventListener('scroll', function() { const navbar = document.querySelector('custom-navbar'); if (window.scrollY > 50) { navbar.classList.add('scrolled'); } else { navbar.classList.remove('scrolled'); } }); // Animation 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('animate-fadeIn'); } }); }, observerOptions); document.querySelectorAll('.feature-card, .testimonial-card').forEach(card => { observer.observe(card); }); // Form validation for transport quote document.addEventListener('DOMContentLoaded', function() { const quoteForm = document.querySelector('#transport-quote form'); if (quoteForm) { quoteForm.addEventListener('submit', function(e) { e.preventDefault(); // Simple validation let isValid = true; const inputs = this.querySelectorAll('input'); inputs.forEach(input => { if (!input.value.trim()) { isValid = false; input.classList.add('border-red-500'); } else { input.classList.remove('border-red-500'); } }); if (isValid) { // In a real app, this would submit to a server alert('Quote calculated! In a real application, this would show your personalized quote.'); } }); } }); // Parallax effect for hero section document.addEventListener('mousemove', (e) => { const hero = document.querySelector('.parallax'); if (!hero) return; const xAxis = (window.innerWidth / 2 - e.pageX) / 25; const yAxis = (window.innerHeight / 2 - e.pageY) / 25; hero.style.transform = `rotateY(${xAxis}deg) rotateX(${yAxis}deg)`; });