class ParticleBackground extends HTMLElement { constructor() { super(); this.particles = []; this.mouse = { x: 0, y: 0 }; } connectedCallback() { this.attachShadow({ mode: 'open' }); this.shadowRoot.innerHTML = `
`; this.container = this.shadowRoot.querySelector('.particles-container'); this.initParticles(); this.initQuantumOrbs(); this.animate(); // Track mouse movement for interaction document.addEventListener('mousemove', (e) => { this.mouse.x = e.clientX; this.mouse.y = e.clientY; }); // Handle window resize window.addEventListener('resize', () => { this.particles.forEach(p => p.element.remove()); this.particles = []; this.initParticles(); }); } initParticles() { const particleCount = Math.min(50, Math.floor(window.innerWidth / 20)); for (let i = 0; i < particleCount; i++) { const particle = document.createElement('div'); particle.className = 'particle'; // Random size and position const size = 2 + Math.random() * 4; const x = Math.random() * 100; const y = Math.random() * 100; // Random color (quantum blue or neural purple) const colors = [ 'rgba(14, 165, 233, 0.4)', 'rgba(168, 85, 247, 0.4)', 'rgba(14, 165, 233, 0.2)', 'rgba(168, 85, 247, 0.2)' ]; const color = colors[Math.floor(Math.random() * colors.length)]; particle.style.width = `${size}px`; particle.style.height = `${size}px`; particle.style.left = `${x}%`; particle.style.top = `${y}%`; particle.style.backgroundColor = color; particle.style.background = `radial-gradient(circle, ${color} 0%, transparent 70%)`; // Random movement const speedX = (Math.random() - 0.5) * 0.3; const speedY = (Math.random() - 0.5) * 0.3; this.container.appendChild(particle); this.particles.push({ element: particle, x: x, y: y, speedX: speedX, speedY: speedY, size: size, color: color, originalX: x, originalY: y, waveOffset: Math.random() * Math.PI * 2 }); } } initQuantumOrbs() { // Create large quantum orbs for background const orbCount = 3; for (let i = 0; i < orbCount; i++) { const orb = document.createElement('div'); orb.className = 'quantum-orb'; const size = 200 + Math.random() * 300; const x = Math.random() * 100; const y = Math.random() * 100; // Gradient colors const colors = i % 2 === 0 ? ['rgba(14, 165, 233, 0.1)', 'rgba(14, 165, 233, 0.05)'] : ['rgba(168, 85, 247, 0.1)', 'rgba(168, 85, 247, 0.05)']; orb.style.width = `${size}px`; orb.style.height = `${size}px`; orb.style.left = `${x}%`; orb.style.top = `${y}%`; orb.style.background = `radial-gradient(circle, ${colors[0]} 0%, ${colors[1]} 50%, transparent 70%)`; orb.style.animationDelay = `${i * 3}s`; this.container.appendChild(orb); } } animate() { const time = Date.now() * 0.001; this.particles.forEach(particle => { // Calculate wave movement const waveX = Math.sin(time + particle.waveOffset) * 0.5; const waveY = Math.cos(time * 0.7 + particle.waveOffset) * 0.5; // Mouse interaction const dx = this.mouse.x - (particle.x / 100 * window.innerWidth); const dy = this.mouse.y - (particle.y / 100 * window.innerHeight); const distance = Math.sqrt(dx *