@import 'https://fonts.googleapis.com/css?family=Montserrat:300, 400, 700&display=swap';

#main_gallery {
	text-align: center;
}

.image-gallery * {
	box-sizing: border-box;
}

.image-gallery {
	font-family: 'Montserrat', sans-serif;
	margin: 0;
	padding: 1rem;
	min-height: 50vh;
	display: flex;
	justify-content: center;
	align-items: center;
}

.image-gallery img {
	width: 100%;
	display: block;
	aspect-ratio: 1 / 1;
	object-fit: cover;
	transition: transform 1000ms;
	cursor: pointer;
}

.image-gallery h1 {
	text-align: center;
}

.image-gallery ul {
	list-style: none;
	margin: 0 auto;
	padding: 0;
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	max-width: 70rem;
	width: 100%;
}

.image-gallery figure {
	margin: 0;
	position: relative;
	overflow: hidden;
}

.image-gallery figure::after {
	content: '';
	position: absolute;
	top: 50%;
	left: 50%;
	width: 200%;
	height: 200%;
	background: rgba(0, 0, 0, 0.5);
	transform-origin: center;
	opacity: 0;
	transform: scale(2);
	transition: opacity 300ms;
}

.image-gallery figcaption {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	display: flex;
	justify-content: center;
	place-items: center;
	text-align: center;
	padding: 1rem;
	color: white;
	font-size: 1.2rem;
	z-index: 1;
	opacity: 0;
	transition: opacity 600ms, transform 600ms;
}

.image-gallery figure:is(:hover, :focus) figure::after {
	opacity: 1;
}

.image-gallery figure:is(:hover, :focus) figcaption {
	opacity: 1;
	transition: opacity 600ms;
}

/* Modal styles */
.modal {
	display: none;
	position: fixed;
	z-index: 1000;
	left: 0;
	top: 0;
	width: 100%;
	height: 100%;
	background-color: rgba(0, 0, 0, 0.9);
	overflow: auto;
	opacity: 0;
	transition: opacity 0.3s ease;
	padding: 20px;
	box-sizing: border-box;
}

.modal.show {
	display: flex;
	justify-content: center;
	align-items: center;
	opacity: 1;
}

.modal-content {
	display: block;
	max-width: 90%;
	max-height: 80%;
	margin: auto;
	border-radius: 5px;
	box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
	animation: zoom 0.3s ease;
}

@keyframes zoom {
	from {
		transform: scale(0.9);
		opacity: 0;
	}

	to {
		transform: scale(1);
		opacity: 1;
	}
}

.modal-caption {
	display: block;
	width: 100%;
	text-align: center;
	color: white;
	padding: 10px 0;
	font-size: 1.2rem;
	margin-top: 10px;
}

.close {
	position: absolute;
	top: 20px;
	right: 30px;
	color: #f1f1f1;
	font-size: 40px;
	font-weight: bold;
	cursor: pointer;
	transition: 0.3s;
}

.close:hover {
	color: #bbb;
}

@media (prefers-reduced-motion: no-preference) {
	.image-gallery figcaption {
		transform: translate3d(0, 2rem, 0);
	}

	.image-gallery figure::after {
		border-radius: 50%;
		opacity: 1;
		transform: scale(0);
		transition: transform 900ms;
	}

	.image-gallery figure:is(:hover, :focus) figure::after {
		transform: scale(2.5);
	}

	.image-gallery figure:is(:hover, :focus) figcaption {
		opacity: 1;
		transform: translate3d(0, 0, 0);
		transition: opacity 600ms 400ms, transform 600ms 400ms;
	}

	.image-gallery figure:is(:hover, :focus) img {
		transform: scale(1.2);
	}
}

/* Responsive adjustments */
@media (max-width: 992px) {
	.image-gallery ul {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		max-width: 90%;
	}
}

@media (max-width: 576px) {
	.image-gallery ul {
		grid-template-columns: 1fr;
		max-width: 95%;
	}

	.modal-content {
		max-width: 95%;
	}

	.close {
		top: 10px;
		right: 15px;
		font-size: 30px;
	}
}