(function () { 'use strict'; // --- Nav scroll state --- var nav = document.getElementById('nav'); if (nav) { window.addEventListener('scroll', function () { if (window.scrollY > 40) { nav.classList.add('nav--scrolled'); } else { nav.classList.remove('nav--scrolled'); } }, { passive: true }); } // --- Terminal animations via IntersectionObserver --- var animatedEls = document.querySelectorAll('[data-animate]'); if (animatedEls.length) { var animObserver = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { entry.target.classList.add('play'); animObserver.unobserve(entry.target); } }); }, { threshold: 0.3 }); animatedEls.forEach(function (el) { animObserver.observe(el); }); } // --- Fade-in elements via IntersectionObserver --- var fadeEls = document.querySelectorAll('.fade-in'); if (fadeEls.length) { var fadeObserver = new IntersectionObserver(function (entries) { entries.forEach(function (entry) { if (entry.isIntersecting) { entry.target.classList.add('visible'); fadeObserver.unobserve(entry.target); } }); }, { threshold: 0.1 }); fadeEls.forEach(function (el) { fadeObserver.observe(el); }); } // --- Clipboard copy --- document.addEventListener('click', function (e) { var btn = e.target.closest('[data-copy], .copy-btn'); if (!btn) return; var text = btn.getAttribute('data-copy'); if (!text) { var block = btn.closest('.code-block'); if (block) text = block.getAttribute('data-copy'); } if (!text) return; var original = btn.textContent; navigator.clipboard.writeText(text).then(function () { btn.textContent = 'Copied!'; btn.classList.add('copied'); setTimeout(function () { btn.textContent = original; btn.classList.remove('copied'); }, 1500); }); }); // --- Sidebar filter (features page) --- var filterInput = document.getElementById('sidebar-filter'); if (filterInput) { filterInput.addEventListener('input', function () { var query = filterInput.value.toLowerCase(); var links = document.querySelectorAll('.sidebar__link'); links.forEach(function (link) { link.style.display = link.textContent.toLowerCase().includes(query) ? 'block' : 'none'; }); }); } })();