document.addEventListener('DOMContentLoaded', function() { // Mobile menu toggle const menuToggle = document.getElementById('menu-toggle'); const navLinks = document.querySelector('nav .hidden.md\\:flex'); menuToggle.addEventListener('click', function() { navLinks.classList.toggle('hidden'); navLinks.classList.toggle('flex'); navLinks.classList.toggle('flex-col'); navLinks.classList.toggle('absolute'); navLinks.classList.toggle('top-full'); navLinks.classList.toggle('left-0'); navLinks.classList.toggle('w-full'); navLinks.classList.toggle('bg-black'); navLinks.classList.toggle('bg-opacity-95'); navLinks.classList.toggle('p-4'); navLinks.classList.toggle('z-50'); }); // Matrix effect const canvas = document.getElementById('matrix'); const ctx = canvas.getContext('2d'); canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight; const characters = "01"; const fontSize = 14; const columns = canvas.width / fontSize; const drops = []; for (let i = 0; i < columns; i++) { drops[i] = Math.random() * -100; } function drawMatrix() { ctx.fillStyle = 'rgba(0, 0, 0, 0.05)'; ctx.fillRect(0, 0, canvas.width, canvas.height); ctx.fillStyle = '#10B981'; ctx.font = fontSize + 'px monospace'; for (let i = 0; i < drops.length; i++) { const text = characters.charAt(Math.floor(Math.random() * characters.length)); ctx.fillText(text, i * fontSize, drops[i] * fontSize); if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) { drops[i] = 0; } drops[i]++; } } // Handle window resize window.addEventListener('resize', function() { canvas.width = canvas.offsetWidth; canvas.height = canvas.offsetHeight; const newColumns = canvas.width / fontSize; // Adjust drops array to new column count if (newColumns > drops.length) { for (let i = drops.length; i < newColumns; i++) { drops[i] = Math.random() * -100; } } else if (newColumns < drops.length) { drops.length = newColumns; } }); // Start the matrix animation setInterval(drawMatrix, 33); // Smooth scrolling for anchor links document.querySelectorAll('a[href^="#"]').forEach(anchor => { anchor.addEventListener('click', function(e) { e.preventDefault();