// Mobile Menu Toggle const mobileMenuBtn = document.getElementById('mobile-menu-btn'); const mobileMenu = document.getElementById('mobile-menu'); mobileMenuBtn.addEventListener('click', () => { mobileMenu.classList.toggle('hidden'); const icon = mobileMenuBtn.querySelector('i'); if (mobileMenu.classList.contains('hidden')) { icon.setAttribute('data-lucide', 'menu'); } else { icon.setAttribute('data-lucide', 'x'); } lucide.createIcons(); }); // Smooth Scroll for Navigation Links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function (e) { e.preventDefault(); const target = document.querySelector(this.getAttribute('href')); if (target) { target.scrollIntoView({ behavior: 'smooth', block: 'start' }); // Close mobile menu if open mobileMenu.classList.add('hidden'); } }); }); // Countdown Timer function updateCountdown() { // Set next match date (3 days from now for demo) const nextMatch = new Date(); nextMatch.setDate(nextMatch.getDate() + 3); nextMatch.setHours(15, 0, 0, 0); const now = new Date().getTime(); const distance = nextMatch - now; const days = Math.floor(distance / (1000 * 60 * 60 * 24)); const hours = Math.floor((distance % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); const minutes = Math.floor((distance % (1000 * 60 * 60)) / (1000 * 60)); const seconds = Math.floor((distance % (1000 * 60)) / 1000); document.getElementById('days').textContent = String(days).padStart(2, '0'); document.getElementById('hours').textContent = String(hours).padStart(2, '0'); document.getElementById('minutes').textContent = String(minutes).padStart(2, '0'); document.getElementById('seconds').textContent = String(seconds).padStart(2, '0'); } setInterval(updateCountdown, 1000); updateCountdown(); // Navbar Scroll Effect let lastScroll = 0; const navbar = document.querySelector('nav'); window.addEventListener('scroll', () => { const currentScroll = window.pageYOffset; if (currentScroll > 100) { navbar.classList.add('shadow-lg'); } else { navbar.classList.remove('shadow-lg'); } lastScroll = currentScroll; }); // Intersection Observer for Fade-in Animations const observerOptions = { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('opacity-100', 'translate-y-0'); entry.target.classList.remove('opacity-0', 'translate-y-10'); } }); }, observerOptions); // Apply animation classes to sections document.querySelectorAll('section').forEach(section => { section.classList.add('transition-all', 'duration-1000', 'opacity-0', 'translate-y-10'); observer.observe(section); }); // Form Submission Handler document.querySelector('form').addEventListener('submit', (e) => { e.preventDefault(); const btn = e.target.querySelector('button[type="submit"]'); const originalText = btn.textContent; btn.textContent = 'Message Sent!'; btn.classList.add('bg-green-600'); btn.classList.remove('bg-rugby-primary'); setTimeout(() => { btn.textContent = originalText; btn.classList.remove('bg-green-600'); btn.classList.add('bg-rugby-primary'); e.target.reset(); }, 3000); }); // Newsletter Form Handler document.querySelector('footer form').addEventListener('submit', (e) => { e.preventDefault(); const input = e.target.querySelector('input'); const btn = e.target.querySelector('button'); input.value = 'Subscribed!'; input.disabled = true; btn.innerHTML = ''; lucide.createIcons(); setTimeout(() => { input.value = ''; input.disabled = false; input.placeholder = 'Your email'; btn.innerHTML = ''; lucide.createIcons(); }, 3000); });