// Theme toggle functionality document.addEventListener('DOMContentLoaded', function() { // Check for saved theme preference or use preferred color scheme const savedTheme = localStorage.getItem('theme') || (window.matchMedia('(prefers-color-scheme: dark)').matches ? 'dark' : 'light'); // Apply the saved theme document.documentElement.classList.add(savedTheme); localStorage.setItem('theme', savedTheme); // Update the toggle button state updateThemeToggle(savedTheme); // Smooth scroll for anchor 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) { targetElement.scrollIntoView({ behavior: 'smooth' }); } }); }); }); // Function to update theme toggle button function updateThemeToggle(theme) { const toggleBtn = document.querySelector('.theme-toggle'); if (toggleBtn) { if (theme === 'dark') { toggleBtn.innerHTML = ''; } else { toggleBtn.innerHTML = ''; } // Initialize feather icons document.addEventListener('DOMContentLoaded', function() { feather.replace(); // Scroll reveal animation const sr = ScrollReveal({ origin: 'bottom', distance: '60px', duration: 1000, delay: 200, reset: true }); sr.reveal('.mission-item', { interval: 200, origin: 'bottom', distance: '40px' }); }); } } // Function to toggle between light and dark theme function toggleTheme() { const html = document.documentElement; const currentTheme = localStorage.getItem('theme') || 'light'; const newTheme = currentTheme === 'light' ? 'dark' : 'light'; html.classList.remove(currentTheme); html.classList.add(newTheme); localStorage.setItem('theme', newTheme); updateThemeToggle(newTheme); } // Form submission handling document.querySelector('form')?.addEventListener('submit', function(e) { e.preventDefault(); // Get form values const name = document.getElementById('name').value; const email = document.getElementById('email').value; const subject = document.getElementById('subject').value; const message = document.getElementById('message').value; // Simple validation if (!name || !email || !message) { alert('Please fill in all required fields.'); return; } // Here you would typically send the form data to a server console.log('Form submitted:', { name, email, subject, message }); // Show success message alert('Thank you for your message! We will get back to you soon.'); // Reset form this.reset(); });