document.addEventListener('DOMContentLoaded', function() { const lightbox = document.getElementById('lightbox'); const lightboxImg = document.getElementById('lightbox-img'); const closeBtn = document.getElementById('lightbox-close'); document.querySelectorAll('.gallery-item img').forEach(img => { img.addEventListener('click', () => { lightboxImg.src = img.dataset.large; lightbox.classList.add('active'); }); }); closeBtn.addEventListener('click', () => lightbox.classList.remove('active')); lightbox.addEventListener('click', e => { if (e.target === lightbox) lightbox.classList.remove('active'); }); });