/* global React */
// Scroll reveal effects (cursor trail removed per user request)


// Scroll-reveal via IntersectionObserver — looks for .reveal class
(function ScrollReveal() {
  if (typeof window === 'undefined') return;
  if (!('IntersectionObserver' in window)) return;

  const io = new IntersectionObserver((entries) => {
    entries.forEach(e => {
      if (e.isIntersecting) {
        e.target.classList.add('visible');
        io.unobserve(e.target);
      }
    });
  }, { rootMargin: '0px 0px -10% 0px', threshold: 0.05 });

  function attach() {
    document.querySelectorAll('.reveal:not(.visible)').forEach(el => io.observe(el));
  }

  // Observe at start + on DOM changes (since React mounts after)
  if (document.readyState !== 'loading') attach();
  else document.addEventListener('DOMContentLoaded', attach);

  // Re-attach periodically as React mounts more
  let retries = 0;
  const id = setInterval(() => {
    attach();
    retries++;
    if (retries > 20) clearInterval(id);
  }, 250);

  window.__bobaxReveal = attach;
})();
