document.querySelectorAll(".copy-url").forEach((button) => { button.addEventListener("click", async () => { const url = button.getAttribute("data-url"); if (!url) return; try { await navigator.clipboard.writeText(url); const hint = button.parentElement.querySelector(".copied-hint"); if (hint) { hint.hidden = false; setTimeout(() => { hint.hidden = true; }, 1500); } } catch (err) { console.error("copy failed", err); } }); }); (function setupLightbox() { const lightbox = document.getElementById("lightbox"); const lightboxImg = document.getElementById("lightbox-img"); if (!lightbox || !lightboxImg) { console.warn("[RCS] lightbox elements missing"); return; } function openLightbox(src) { lightboxImg.src = src; lightbox.hidden = false; lightbox.setAttribute("aria-hidden", "false"); document.body.classList.add("lightbox-open"); } function closeLightbox() { lightbox.hidden = true; lightbox.setAttribute("aria-hidden", "true"); lightboxImg.removeAttribute("src"); document.body.classList.remove("lightbox-open"); } // Event delegation so thumbs work even if markup is re-rendered later. document.addEventListener("click", (event) => { const thumb = event.target.closest(".shot-thumb"); if (thumb) { event.preventDefault(); const src = thumb.getAttribute("data-full") || (thumb.querySelector("img") && thumb.querySelector("img").src); if (src) openLightbox(src); return; } if (event.target === lightbox || event.target.classList.contains("lightbox-close")) { closeLightbox(); } }); document.addEventListener("keydown", (event) => { if (event.key === "Escape" && !lightbox.hidden) { closeLightbox(); } }); })();