/* Shared page behaviour, ported from the original inline script. * The peacock marks are inlined at build time (see Mark.astro), so only the * scroll reveals and the path spine remain. */ (function () { var reduce = matchMedia("(prefers-reduced-motion: reduce)").matches; // scroll reveals var els = [].slice.call(document.querySelectorAll(".reveal")); if (reduce) { els.forEach(function (e) { e.classList.add("in"); }); } else if ("IntersectionObserver" in window) { var io = new IntersectionObserver(function (en) { en.forEach(function (x) { if (x.isIntersecting) x.target.classList.add("in"); }); }, { threshold: .15 }); els.forEach(function (e) { io.observe(e); }); } // The spine "draws" as you scroll. Nodes mirror the fill: a node lights when // the fill reaches it and dims again if you scroll back above it, so the two // always tell the same story. A 6px deadband keeps tiny scroll jitter from // flickering the state. var fill = document.getElementById("spineFill"), sw = document.querySelector(".spine-wrap"), stages = sw ? [].slice.call(sw.querySelectorAll(".stage")) : [], tick = false; function spine() { tick = false; if (!sw) return; var r = sw.getBoundingClientRect(), h = r.height, spineTop = 10, spineH = Math.max(1, h - 20), p = (innerHeight * 0.5 - r.top - spineTop) / spineH; p = Math.max(0, Math.min(1, p)); if (fill) fill.style.height = (p * 100) + "%"; var fillY = spineTop + p * spineH; stages.forEach(function (stage) { var nodeY = stage.getBoundingClientRect().top - r.top + 18; // node top (7) + radius (11) var on = stage.classList.contains("lit"); var next = on ? fillY >= nodeY - 6 : fillY >= nodeY; if (next !== on) stage.classList.toggle("lit", next); }); } if (sw) { var onsc = function () { if (!tick) { tick = true; requestAnimationFrame(spine); } }; addEventListener("scroll", onsc, { passive: true }); addEventListener("resize", onsc); addEventListener("load", onsc); if ("ResizeObserver" in window) new ResizeObserver(onsc).observe(sw); spine(); } })();