(function () {
'use strict';

const qs  = s => document.querySelector(s);
const qsa = s => [...document.querySelectorAll(s)];

/* ── Process node: activate when step scrolls into view */
const processNodes = qsa('.process-node');
const processSteps = qsa('.process-step:not([aria-hidden])');

if (processNodes.length && processSteps.length) {
  const stepObs = new IntersectionObserver(entries => {
    entries.forEach(e => {
      if (!e.isIntersecting) return;
      const idx = processSteps.indexOf(e.target);
      if (idx < 0) return;
      processNodes.forEach((n, i) => {
        n.classList.toggle('active', i <= idx);
      });
    });
  }, { threshold: 0.5 });

  processSteps.forEach(step => stepObs.observe(step));
}

})();
