/* Mosaic Gallery — front-end styles */

.mosaic-gallery {
	--mosaic-columns: 4;
	--mosaic-gap: 8px;
	--mosaic-row-height: 400px;

	display: grid;
	grid-template-columns: repeat(var(--mosaic-columns), 1fr);
	grid-auto-rows: var(--mosaic-row-height);
	grid-auto-flow: dense;
	gap: var(--mosaic-gap);
	width: 100%;
	box-sizing: border-box;
}

.mosaic-item {
	position: relative;
	display: block;
	overflow: hidden;
	border-radius: 6px;
	background: #eee;
	grid-column: span 1;
	grid-row: span 1;
	cursor: pointer;
}

.mosaic-item img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
	backface-visibility: hidden;
}

.mosaic-item:hover img {
	transform: scale(1.06);
}

.mosaic-item::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0);
	transition: background 0.25s ease;
	pointer-events: none;
}

.mosaic-item:hover::after {
	background: rgba(0, 0, 0, 0.12);
}

.mosaic-item--wide {
	grid-column: span 2;
}

.mosaic-item--tall {
	grid-row: span 2;
}

.mosaic-item--big {
	grid-column: span 2;
	grid-row: span 2;
}

/* Fit: contain — show the full image, fill leftover space with a blurred backdrop */
.mosaic-gallery--fit-contain .mosaic-item {
	background: #111;
}

.mosaic-gallery--fit-contain .mosaic-item__backdrop {
	position: absolute;
	inset: -10px;
	background-size: cover;
	background-position: center;
	filter: blur(18px) brightness(0.6);
	transform: scale(1.1);
}

.mosaic-gallery--fit-contain .mosaic-item img {
	object-fit: contain;
	z-index: 1;
}

/* --- Custom: force exactly-2-image galleries into an equal-height rectangle --- */
.mosaic-gallery:has(> .mosaic-item:first-child:nth-last-child(2)) {
	grid-template-columns: repeat(2, 1fr) !important;
	--mosaic-row-height: 450px;
}

.mosaic-gallery > .mosaic-item:first-child:nth-last-child(2),
.mosaic-gallery > .mosaic-item:first-child:nth-last-child(2) ~ .mosaic-item {
	grid-column: span 1 !important;
	grid-row: span 1 !important;
}
/* --- end custom --- */

.mosaic-gallery-empty {
	opacity: 0.7;
	font-style: italic;
}

/* Responsive collapse for smaller screens */
@media (max-width: 900px) {
	.mosaic-gallery {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 600px) {
	.mosaic-gallery {
		grid-template-columns: repeat(2, 1fr);
		--mosaic-row-height: 110px;
	}
	.mosaic-item--big,
	.mosaic-item--wide {
		grid-column: span 2;
	}
}

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

.mosaic-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.9);
	padding: 40px;
	box-sizing: border-box;
}

.mosaic-lightbox.is-open {
	display: flex;
}

.mosaic-lightbox__figure {
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
}

.mosaic-lightbox__image {
	max-width: 100%;
	max-height: 80vh;
	object-fit: contain;
	border-radius: 4px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.2s ease;
}

.mosaic-lightbox__image.is-loaded {
	opacity: 1;
}

.mosaic-lightbox__caption {
	color: #f1f1f1;
	margin-top: 14px;
	text-align: center;
	font-size: 14px;
	max-width: 60ch;
}

.mosaic-lightbox__close,
.mosaic-lightbox__prev,
.mosaic-lightbox__next {
	position: absolute;
	background: transparent;
	border: none;
	color: #fff;
	font-size: 34px;
	line-height: 1;
	cursor: pointer;
	padding: 10px 16px;
	opacity: 0.8;
	transition: opacity 0.2s ease;
}

.mosaic-lightbox__close:hover,
.mosaic-lightbox__prev:hover,
.mosaic-lightbox__next:hover {
	opacity: 1;
}

.mosaic-lightbox__close {
	top: 10px;
	right: 10px;
}

.mosaic-lightbox__prev {
	left: 10px;
	top: 50%;
	transform: translateY(-50%);
}

.mosaic-lightbox__next {
	right: 10px;
	top: 50%;
	transform: translateY(-50%);
}

@media (max-width: 600px) {
	.mosaic-lightbox {
		padding: 16px;
	}
	.mosaic-lightbox__close,
	.mosaic-lightbox__prev,
	.mosaic-lightbox__next {
		font-size: 26px;
		padding: 8px 12px;
	}
}
