<script>
document.addEventListener("DOMContentLoaded", function () {
const body = document.body;
const themeToggle = document.querySelector(".toggle-theme");
const themeIcon = document.getElementById("theme-icon");
function applyTheme(theme) {
if (theme === "dark") {
body.classList.add("dark-mode");
body.classList.remove("light-mode");
themeIcon.src = "https://static1.squarespace.com/static/687ef780975ca439086ca848/t/68c60ad24dc1134228278e8e/1757809362614/Mode+sombreppp.png";
} else {
body.classList.add("light-mode");
body.classList.remove("dark-mode");
themeIcon.src = "https://static1.squarespace.com/static/687ef780975ca439086ca848/t/68c60a7710324e064706cab9/1757809271942/MODE+CLAIRE+PPP.png";
}
}
const savedTheme = localStorage.getItem("theme");
if (savedTheme) {
applyTheme(savedTheme);
} else {
applyTheme("light");
}
themeToggle.addEventListener("click", function () {
const currentTheme = body.classList.contains("dark-mode") ? "dark" : "light";
const newTheme = currentTheme === "dark" ? "light" : "dark";
applyTheme(newTheme);
localStorage.setItem("theme", newTheme);
});
});
</script>