/* Visa Signal Matrix — theme switcher (dark/light, persisted per browser). */ (function () { function apply(theme) { document.documentElement.setAttribute("data-theme", theme); var btn = document.querySelector(".theme-toggle"); if (btn) { btn.textContent = theme === "light" ? "☾" : "☀"; btn.title = theme === "light" ? "Switch to dark mode" : "Switch to light mode"; btn.setAttribute("aria-label", btn.title); } } window.usvToggleTheme = function () { var cur = document.documentElement.getAttribute("data-theme") === "light" ? "light" : "dark"; var next = cur === "light" ? "dark" : "light"; try { localStorage.setItem("usv-theme", next); } catch (e) { /* private mode */ } apply(next); }; document.addEventListener("DOMContentLoaded", function () { var saved = null; try { saved = localStorage.getItem("usv-theme"); } catch (e) { /* private mode */ } apply(saved === "light" ? "light" : "dark"); var t = document.querySelector(".nav-toggle"); if (t) { t.addEventListener("click", function () { var nav = document.querySelector(".module-nav"); var sw = document.querySelector(".module-switch"); if (nav) nav.classList.toggle("open"); if (sw) sw.classList.toggle("open"); }); } }); })();