// Makes the overlay appear on first click on mobile
// Second click opens the image link
document.querySelectorAll('.gallery-link').forEach(link => {
	let tapped = false;

	link.addEventListener('click', function (e) {
		// Only on touch devices
		if (window.matchMedia('(hover: none)').matches) {
			console.log("clicked on mobile");
			if (!tapped) {
				e.preventDefault();
				tapped = true;
				link.classList.add('active');
			}
		}
	});

	// Reset when tapping elsewhere
	document.addEventListener('touchstart', function (e) {
		if (!link.contains(e.target)) {
			tapped = false;
			link.classList.remove('active');
		}
	});
});
