/**
 * FILE LOCATION: /blocks/masonry-gallery/masonry-gallery.css
 * Enqueued automatically by ACF only when the block is present on the page.
 */

.masonry-gallery {
	--masonry-columns: 3;
	--masonry-gap: 15px;

	column-count: var(--masonry-columns);
	column-gap: var(--masonry-gap);
	width: 100%;
}

.masonry-gallery__item {
	display: inline-block;
	width: 100%;
	margin: 0 0 var(--masonry-gap);
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
}

.masonry-gallery__link {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: 8px;
	line-height: 0;
}

.masonry-gallery__link:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.masonry-gallery__img {
	display: block;
	width: 100%;
	height: auto;
	transition: transform .4s ease;
}

.masonry-gallery__link:hover .masonry-gallery__img,
.masonry-gallery__link:focus-visible .masonry-gallery__img {
	transform: scale(1.06);
}

.masonry-gallery-placeholder {
	padding: 24px;
	border: 2px dashed #ccc;
	border-radius: 8px;
	text-align: center;
	color: #666;
}

/* Responsive column count */
@media (max-width: 1024px) {
	.masonry-gallery {
		--masonry-columns: 2 !important;
	}
}

@media (max-width: 600px) {
	.masonry-gallery {
		--masonry-columns: 1 !important;
	}
}

/* ------------------------------------------------------------------ */
/* Single row layout — used automatically when exactly 3 images exist  */
/* ------------------------------------------------------------------ */

.masonry-gallery--row {
	display: flex;
	column-count: unset;
	column-gap: unset;
	gap: var(--masonry-gap);
	align-items: stretch;
}

.masonry-gallery--row .masonry-gallery__item {
	flex: 1 1 0;
	width: auto;
	margin: 0;
	break-inside: unset;
}

.masonry-gallery--row .masonry-gallery__link {
	height: 100%;
}

.masonry-gallery--row .masonry-gallery__img {
	height: 320px;
	width: 100%;
	object-fit: cover;
}

/* On mobile, always stack one photo per row — same for all column options */
@media (max-width: 600px) {
	.masonry-gallery--row {
		flex-direction: column;
	}

	.masonry-gallery--row .masonry-gallery__item {
		flex: 1 1 100%;
	}

	.masonry-gallery--row .masonry-gallery__img {
		height: 220px;
	}
}

/* ------------------------------------------------------------------ */
/* Lightbox                                                            */
/* ------------------------------------------------------------------ */

.masonry-gallery-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, .92);
	opacity: 0;
	visibility: hidden;
	transition: opacity .25s ease;
}

.masonry-gallery-lightbox.is-active {
	opacity: 1;
	visibility: visible;
}

.masonry-gallery-lightbox__img {
	max-width: 90vw;
	max-height: 85vh;
	border-radius: 6px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, .5);
}

.masonry-gallery-lightbox__close,
.masonry-gallery-lightbox__nav {
	position: absolute;
	background: none;
	border: 0;
	color: #fff;
	cursor: pointer;
	line-height: 1;
	padding: 10px;
}

.masonry-gallery-lightbox__close {
	top: 16px;
	right: 20px;
	font-size: 2rem;
}

.masonry-gallery-lightbox__nav {
	top: 50%;
	transform: translateY(-50%);
	font-size: 2rem;
}

.masonry-gallery-lightbox__prev {
	left: 10px;
}

.masonry-gallery-lightbox__next {
	right: 10px;
}

.masonry-gallery-lightbox__close:hover,
.masonry-gallery-lightbox__nav:hover {
	opacity: .7;
}

@media (max-width: 600px) {
	.masonry-gallery-lightbox__nav {
		font-size: 1.5rem;
	}

	.masonry-gallery-lightbox__close {
		font-size: 1.6rem;
	}
}