const modal = document.getElementById("imgModal");
const modalImg = document.getElementById("modalImg");
const thumbnails = document.querySelectorAll(".gallery-img");

// Open image in fixed modal
thumbnails.forEach(img => {
    img.addEventListener("click", () => {
        modal.style.display = "flex";
        modalImg.src = img.src;
        modalImg.classList.remove("zoomed");
    });
});

// Second click to zoom
modalImg.addEventListener("click", (e) => {
    e.stopPropagation(); // Stops it from closing
    modalImg.classList.toggle("zoomed");
});

// Click background to close
modal.addEventListener("click", () => {
    modal.style.display = "none";
});