document.addEventListener('DOMContentLoaded', () => {
  const canvas = document.getElementById('fx-particles');
  if (canvas) {
    const ctx = canvas.getContext('2d');
    let w = canvas.width = window.innerWidth;
    let h = canvas.height = window.innerHeight;
    const count = Math.min(55, Math.max(22, Math.round(w / 28)));
    const dots = Array.from({length: count}, () => ({x: Math.random()*w, y: Math.random()*h, r: Math.random()*1.8+0.6, dx:(Math.random()-.5)*0.25, dy:(Math.random()-.5)*0.25}));
    function draw(){ ctx.clearRect(0,0,w,h); ctx.fillStyle='rgba(255,146,77,.8)'; dots.forEach(d => { d.x += d.dx; d.y += d.dy; if (d.x<0||d.x>w) d.dx*=-1; if (d.y<0||d.y>h) d.dy*=-1; ctx.beginPath(); ctx.arc(d.x,d.y,d.r,0,Math.PI*2); ctx.fill();}); ctx.strokeStyle='rgba(255,255,255,.05)'; for(let i=0;i<dots.length;i++){ for(let j=i+1;j<dots.length;j++){ const a=dots[i], b=dots[j]; const dist=Math.hypot(a.x-b.x,a.y-b.y); if(dist<150){ ctx.globalAlpha = 1 - dist/150; ctx.beginPath(); ctx.moveTo(a.x,a.y); ctx.lineTo(b.x,b.y); ctx.stroke(); ctx.globalAlpha = 1; }}} requestAnimationFrame(draw);} draw(); window.addEventListener('resize',()=>{w=canvas.width=window.innerWidth; h=canvas.height=window.innerHeight;});
  }
  const tabs = document.querySelectorAll('#scheduleTabs [data-day]');
  tabs.forEach(btn => btn.addEventListener('click', () => {
    tabs.forEach(b => b.classList.remove('is-active')); btn.classList.add('is-active');
    document.querySelectorAll('[data-day-panel]').forEach(panel => panel.classList.toggle('is-active', panel.dataset.dayPanel === btn.dataset.day));
  }));
  const djSearch = document.getElementById('djSearch');
  if (djSearch) {
    djSearch.addEventListener('input', () => {
      const q = djSearch.value.trim().toLowerCase();
      document.querySelectorAll('.dj-card-item').forEach(card => {
        const hay = card.dataset.search || '';
        card.style.display = !q || hay.includes(q) ? '' : 'none';
      });
    });
  }
});
