/* Stay gallery — preview grid + modal lightbox. */

/* ── Preview grid ─────────────────────────────────────────────────────────── */

.ecsc-gallery {
	margin: 0 0 1.5rem;
}

.ecsc-gallery__preview {
	display: grid;
	gap: 0.5rem;
	grid-template-columns: repeat(4, 1fr);
}

.ecsc-gallery__preview--n1 {
	grid-template-columns: 1fr;
}

.ecsc-gallery__preview--n2 {
	grid-template-columns: repeat(2, 1fr);
}

.ecsc-gallery__preview--n3 {
	grid-template-columns: repeat(3, 1fr);
}

.ecsc-gallery__tile {
	display: block;
	padding: 0;
	margin: 0;
	border: 0;
	background: none;
	cursor: pointer;
	overflow: hidden;
	aspect-ratio: 4 / 3;
	border-radius: 2px;
}

.ecsc-gallery__preview--n1 .ecsc-gallery__tile {
	aspect-ratio: 16 / 9;
}

.ecsc-gallery__tile img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform 0.3s ease;
}

.ecsc-gallery__tile:hover img,
.ecsc-gallery__tile:focus-visible img {
	transform: scale(1.04);
}

/* Medium screens and below: 2 across. */
@media (max-width: 900px) {

	.ecsc-gallery__preview--n3,
	.ecsc-gallery__preview--n4 {
		grid-template-columns: repeat(2, 1fr);
	}

	/* Odd one out spans the full width rather than leaving a gap. */
	.ecsc-gallery__preview--n3 .ecsc-gallery__tile:nth-child(3) {
		grid-column: span 2;
		aspect-ratio: 16 / 9;
	}
}

.ecsc-gallery__open {
	display: inline-block;
	margin-top: 0.75rem;
	padding: 0;
	border: 0;
	background: none;
	font: inherit;
	color: inherit;
	cursor: pointer;
	text-decoration: underline;
	text-underline-offset: 3px;
}

.ecsc-gallery__open:hover {
	opacity: 0.7;
}

/* ── Lightbox ─────────────────────────────────────────────────────────────── */

.ecsc-lb-open {
	overflow: hidden;
}

.ecsc-lightbox {
	position: fixed;
	inset: 0;
	z-index: 99999;
	background: rgba(0, 0, 0, 0.94);
	color: #fff;
	overflow-y: auto;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.ecsc-lightbox[hidden] {
	display: none;
}

.ecsc-lightbox__close {
	position: fixed;
	top: 0.75rem;
	right: 1rem;
	z-index: 3;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.5);
	color: #fff;
	font-size: 2rem;
	line-height: 1;
	cursor: pointer;
}

.ecsc-lightbox__close:hover {
	background: rgba(255, 255, 255, 0.18);
}

/* Masonry via CSS columns. */
.ecsc-lightbox__grid {
	column-count: 3;
	column-gap: 0.75rem;
	padding: 4.5rem 1.5rem 3rem;
	max-width: 1400px;
	margin: 0 auto;
}

.ecsc-lightbox__thumb {
	display: block;
	width: 100%;
	padding: 0;
	margin: 0 0 0.75rem;
	border: 0;
	background: none;
	cursor: pointer;
	break-inside: avoid;
	-webkit-column-break-inside: avoid;
}

.ecsc-lightbox__thumb img {
	display: block;
	width: 100%;
	height: auto;
	transition: opacity 0.2s ease;
}

.ecsc-lightbox__thumb:hover img,
.ecsc-lightbox__thumb:focus-visible img {
	opacity: 0.75;
}

@media (max-width: 900px) {

	.ecsc-lightbox__grid {
		column-count: 2;
		padding: 4.5rem 1rem 2rem;
	}
}

@media (max-width: 600px) {

	.ecsc-lightbox__grid {
		column-count: 1;
	}
}

/* ── Full-size viewer ─────────────────────────────────────────────────────── */

.ecsc-lightbox__viewer {
	position: fixed;
	inset: 0;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	background: rgba(0, 0, 0, 0.97);
	box-sizing: border-box;
	padding: 4rem 5rem 5rem;
}

.ecsc-lightbox__viewer[hidden] {
	display: none;
}

.ecsc-lightbox__figure {
	margin: 0;
	max-width: 100%;
	max-height: 100%;
	min-height: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

.ecsc-lightbox__figure img {
	display: block;
	flex: 0 1 auto;
	min-height: 0;
	max-width: 100%;
	max-height: 100%;
	width: auto;
	height: auto;
	object-fit: contain;
}

.ecsc-lightbox__figure figcaption {
	font-size: 0.875rem;
	line-height: 1.4;
	text-align: center;
	opacity: 0.8;
}

.ecsc-lightbox__figure figcaption:empty {
	display: none;
}

.ecsc-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	width: 56px;
	height: 56px;
	padding: 0 0 0.35rem;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.4);
	color: #fff;
	font-size: 2.5rem;
	line-height: 1;
	cursor: pointer;
}

.ecsc-lightbox__nav:hover {
	background: rgba(255, 255, 255, 0.18);
}

.ecsc-lightbox__nav--prev {
	left: 1rem;
}

.ecsc-lightbox__nav--next {
	right: 1rem;
}

.ecsc-lightbox__counter {
	position: absolute;
	bottom: 1.25rem;
	left: 50%;
	transform: translateX(-50%);
	font-size: 0.875rem;
	letter-spacing: 0.04em;
	opacity: 0.75;
}

@media (max-width: 600px) {

	.ecsc-lightbox__viewer {
		padding: 3rem 0.5rem 4rem;
	}

	.ecsc-lightbox__nav {
		width: 44px;
		height: 44px;
		font-size: 2rem;
	}

	.ecsc-lightbox__nav--prev {
		left: 0.25rem;
	}

	.ecsc-lightbox__nav--next {
		right: 0.25rem;
	}
}

.ecsc-lightbox :focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}
