document.addEventListener('DOMContentLoaded', function() { // Initialize Feather Icons feather.replace(); // Mobile Menu Toggle const mobileMenuBtn = document.getElementById('mobileMenuBtn'); const mobileNav = document.getElementById('mobileNav'); const mobileNavClose = document.getElementById('mobileNavClose'); if (mobileMenuBtn && mobileNav) { mobileMenuBtn.addEventListener('click', function() { mobileNav.classList.add('active'); document.body.style.overflow = 'hidden'; }); mobileNavClose.addEventListener('click', function() { mobileNav.classList.remove('active'); document.body.style.overflow = ''; }); } // Custom Cursor if (window.matchMedia('(pointer: fine)').matches) { const cursor = document.getElementById('cursor'); const cursorTrail = document.getElementById('cursorTrail'); if (cursor && cursorTrail) { document.body.classList.add('custom-cursor-enabled'); let mouseX = 0, mouseY = 0; let trailX = 0, trailY = 0; document.addEventListener('mousemove', (e) => { mouseX = e.clientX; mouseY = e.clientY; cursor.style.left = mouseX + 'px'; cursor.style.top = mouseY + 'px'; }); function animateTrail() { trailX += (mouseX - trailX) * 0.15; trailY += (mouseY - trailY) * 0.15; cursorTrail.style.left = trailX + 'px'; cursorTrail.style.top = trailY + 'px'; requestAnimationFrame(animateTrail); } animateTrail(); // Hover effects const hoverElements = document.querySelectorAll('a, button, [data-hover]'); hoverElements.forEach(el => { el.addEventListener('mouseenter', () => cursor.classList.add('cursor-hover')); el.addEventListener('mouseleave', () => cursor.classList.remove('cursor-hover')); }); } } // Nav scroll effect const nav = document.getElementById('nav'); if (nav) { window.addEventListener('scroll', function() { if (window.scrollY > 50) { nav.classList.add('nav-scrolled'); } else { nav.classList.remove('nav-scrolled'); } }); } // Smooth scrolling 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' }); // Close mobile menu if open if (mobileNav && mobileNav.classList.contains('active')) { mobileNav.classList.remove('active'); document.body.style.overflow = ''; } } }); }); // Intersection Observer for animations const animateOnScroll = function() { const elements = document.querySelectorAll('.animate-fade-up'); if (elements.length === 0) return; const observer = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.style.opacity = '1'; entry.target.style.transform = 'translateY(0)'; observer.unobserve(entry.target); } }); }, { threshold: 0.1 }); elements.forEach(element => { observer.observe(element); }); }; animateOnScroll(); // Form submission const contactForm = document.querySelector('form'); if (contactForm) { contactForm.addEventListener('submit', function(e) { e.preventDefault(); // Simple validation let isValid = true; const inputs = this.querySelectorAll('input, textarea'); inputs.forEach(input => { if (!input.value.trim()) { input.style.borderColor = '#FF5722'; isValid = false; } else { input.style.borderColor = ''; } }); if (isValid) { // Here you would typically send the form data to a server alert('Thank you for your message! I will get back to you soon.'); this.reset(); } }); } // Console easter egg console.log('%c👋 Looking for a digital strategist?', 'font-size: 18px; color: #FF5722;'); console.log('%cLet\'s build something amazing together!', 'font-size: 14px; color: #888;'); });