// ===== CUSTOM CURSOR ===== const cursor = document.getElementById('cursor'); const cursorTrail = document.getElementById('cursorTrail'); document.addEventListener('mousemove', e => { cursor.style.left = e.clientX + 'px'; cursor.style.top = e.clientY + 'px'; cursorTrail.style.left = e.clientX + 'px'; cursorTrail.style.top = e.clientY + 'px'; }); document.querySelectorAll('a, button, .glass-card, input, textarea').forEach(el => { el.addEventListener('mouseenter', () => { cursor.style.width = '20px'; cursor.style.height = '20px'; cursor.style.background = 'var(--cyan)'; cursorTrail.style.width = '50px'; cursorTrail.style.height = '50px'; }); el.addEventListener('mouseleave', () => { cursor.style.width = '12px'; cursor.style.height = '12px'; cursor.style.background = 'var(--purple)'; cursorTrail.style.width = '36px'; cursorTrail.style.height = '36px'; }); }); // ===== PARTICLE CANVAS ===== const canvas = document.getElementById('particleCanvas'); const ctx = canvas.getContext('2d'); let particles = []; let W, H; function resize() { W = canvas.width = window.innerWidth; H = canvas.height = window.innerHeight; } resize(); window.addEventListener('resize', resize); class Particle { constructor() { this.reset(); } reset() { this.x = Math.random() * W; this.y = Math.random() * H; this.size = Math.random() * 1.5 + 0.3; this.speedX = (Math.random() - 0.5) * 0.4; this.speedY = (Math.random() - 0.5) * 0.4; this.opacity = Math.random() * 0.5 + 0.1; this.color = Math.random() > 0.5 ? '245,158,11' : '14,165,233'; } update() { this.x += this.speedX; this.y += this.speedY; if (this.x < 0 || this.x > W || this.y < 0 || this.y > H) this.reset(); } draw() { ctx.beginPath(); ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2); ctx.fillStyle = `rgba(${this.color},${this.opacity})`; ctx.fill(); } } // Optimized particle count for buttery smooth 60 FPS performance for (let i = 0; i < 45; i++) particles.push(new Particle()); function connectParticles() { for (let i = 0; i < particles.length; i++) { for (let j = i + 1; j < particles.length; j++) { const dx = particles[i].x - particles[j].x; const dy = particles[i].y - particles[j].y; const distSq = dx * dx + dy * dy; if (distSq < 10000) { const dist = Math.sqrt(distSq); ctx.beginPath(); ctx.strokeStyle = `rgba(245,158,11,${0.15 * (1 - dist / 100)})`; ctx.lineWidth = 0.5; ctx.moveTo(particles[i].x, particles[i].y); ctx.lineTo(particles[j].x, particles[j].y); ctx.stroke(); } } } } function animateParticles() { ctx.clearRect(0, 0, W, H); particles.forEach(p => { p.update(); p.draw(); }); connectParticles(); requestAnimationFrame(animateParticles); } animateParticles(); // ===== NAVBAR SCROLL (Cached DOM queries & throttling) ===== const navbar = document.getElementById('navbar'); const cachedSections = document.querySelectorAll('section[id]'); let isScrolling = false; window.addEventListener('scroll', () => { if (!isScrolling) { window.requestAnimationFrame(() => { navbar.classList.toggle('scrolled', window.scrollY > 50); updateActiveLink(); isScrolling = false; }); isScrolling = true; } }); function updateActiveLink() { const scrollY = window.scrollY + 100; cachedSections.forEach(sec => { const top = sec.offsetTop; const height = sec.offsetHeight; const id = sec.getAttribute('id'); const link = document.querySelector(`.nav-link[href="#${id}"]`); if (link) { if (scrollY >= top && scrollY < top + height) { document.querySelectorAll('.nav-link').forEach(l => l.classList.remove('active')); link.classList.add('active'); } } }); } // ===== TYPEWRITER ===== const words = ['AI Systems 🤖', 'ML Models 🧠', 'Data Science Pipelines 📊', 'Deep Learning Architectures ⚡', 'Predictive Analytics 📈']; let wordIndex = 0, charIndex = 0, isDeleting = false; const typeEl = document.getElementById('typewriter'); function type() { const current = words[wordIndex]; if (isDeleting) { typeEl.textContent = current.substring(0, charIndex--); if (charIndex < 0) { isDeleting = false; wordIndex = (wordIndex + 1) % words.length; setTimeout(type, 400); return; } setTimeout(type, 60); } else { typeEl.textContent = current.substring(0, charIndex++); if (charIndex > current.length) { isDeleting = true; setTimeout(type, 1800); return; } setTimeout(type, 90); } } type(); // ===== SCROLL REVEAL ===== const revealObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.classList.add('revealed'); } }); }, { threshold: 0.1, rootMargin: '0px 0px -50px 0px' }); document.querySelectorAll('.reveal-up, .reveal-left, .reveal-right').forEach(el => { revealObserver.observe(el); }); // ===== STAT COUNTER ===== const statObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { const el = entry.target; const target = parseInt(el.dataset.target); let count = 0; const step = target / 40; const timer = setInterval(() => { count += step; if (count >= target) { count = target; clearInterval(timer); } el.textContent = Math.floor(count); }, 40); statObserver.unobserve(el); } }); }, { threshold: 0.5 }); document.querySelectorAll('.stat-number').forEach(el => statObserver.observe(el)); // ===== SKILL BARS ===== const skillObserver = new IntersectionObserver((entries) => { entries.forEach(entry => { if (entry.isIntersecting) { entry.target.querySelectorAll('.skill-fill').forEach(bar => { bar.style.width = bar.dataset.width + '%'; }); skillObserver.unobserve(entry.target); } }); }, { threshold: 0.3 }); document.querySelectorAll('.skill-category').forEach(el => skillObserver.observe(el)); // ===== CONTACT FORM ===== const form = document.getElementById('contactForm'); form.addEventListener('submit', e => { e.preventDefault(); const btn = document.getElementById('sendBtn'); const originalHTML = btn.innerHTML; btn.innerHTML = 'Sending...'; btn.disabled = true; setTimeout(() => { btn.innerHTML = '✓ Message Sent!'; btn.style.background = 'linear-gradient(135deg,#22c55e,#16a34a)'; form.reset(); setTimeout(() => { btn.innerHTML = originalHTML; btn.style.background = ''; btn.disabled = false; }, 3000); }, 1500); }); // ===== HAMBURGER MENU ===== const hamburger = document.getElementById('hamburger'); hamburger.addEventListener('click', () => { const links = document.querySelector('.nav-links'); const cta = document.querySelector('.nav-cta'); if (links.style.display === 'flex') { links.style.display = 'none'; cta.style.display = 'none'; } else { links.style.cssText = 'display:flex;flex-direction:column;position:absolute;top:70px;left:0;right:0;background:rgba(255,253,246,0.95);padding:20px;gap:20px;backdrop-filter:blur(20px);border-bottom:1px solid rgba(0,0,0,0.08);'; cta.style.display = 'none'; } }); // ===== SMOOTH SCROLL FOR ANCHOR LINKS ===== document.querySelectorAll('a[href^="#"]').forEach(a => { a.addEventListener('click', e => { e.preventDefault(); const target = document.querySelector(a.getAttribute('href')); if (target) target.scrollIntoView({ behavior: 'smooth' }); }); }); // ===== TILT EFFECT ON PROJECT CARDS ===== document.querySelectorAll('.project-card').forEach(card => { card.addEventListener('mousemove', e => { const rect = card.getBoundingClientRect(); const x = (e.clientX - rect.left) / rect.width - 0.5; const y = (e.clientY - rect.top) / rect.height - 0.5; card.style.transform = `perspective(600px) rotateY(${x * 8}deg) rotateX(${-y * 8}deg) translateY(-4px)`; }); card.addEventListener('mouseleave', () => { card.style.transform = ''; }); }); // ===== PARALLAX ON HERO GLOWS (Cached DOM queries) ===== const glow1 = document.querySelector('.glow-1'); const glow2 = document.querySelector('.glow-2'); document.addEventListener('mousemove', e => { const xp = (e.clientX / window.innerWidth - 0.5) * 30; const yp = (e.clientY / window.innerHeight - 0.5) * 30; if (glow1) glow1.style.transform = `translate(${xp}px,${yp}px)`; if (glow2) glow2.style.transform = `translate(${-xp}px,${-yp}px)`; }); // ===== RESUME BUTTON HANDLER ===== const resumeBtn = document.getElementById('resumeBtn'); if (resumeBtn) { resumeBtn.addEventListener('click', e => { e.preventDefault(); const originalHTML = resumeBtn.innerHTML; resumeBtn.innerHTML = 'Downloading...'; setTimeout(() => { resumeBtn.innerHTML = '✓ Resume Downloaded'; resumeBtn.style.background = 'linear-gradient(135deg,#22c55e,#16a34a)'; alert("Thank you for downloading my resume! Let's connect to discuss opportunities."); setTimeout(() => { resumeBtn.innerHTML = originalHTML; resumeBtn.style.background = ''; }, 3000); }, 1500); }); }