/*
 * Event photo galleries — grid + lightbox.
 *
 * Loaded only on pages that actually contain a baltimore-station/gallery block
 * (enqueued from the render_block filter in inc/galleries.php).
 *
 * Accessibility notes: tiles are real <button>s, so focus rings matter — the
 * outline is drawn outside the tile so it stays visible against a photo. Hit
 * targets stay >=44px because the grid never goes below 2 columns.
 */

.bs-gallery {
	--bs-gallery-cols: 4;
	--bs-gallery-gap: clamp(0.5rem, 1.2vw, 0.875rem);
	margin-block: clamp(1.5rem, 4vw, 2.5rem);
}

.bs-gallery__title {
	font-size: var(--wp--preset--font-size--2xl);
	margin: 0 0 clamp(0.75rem, 2vw, 1.25rem);
}

.bs-gallery__grid {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--bs-gallery-gap);
}

@media (min-width: 600px) {
	.bs-gallery__grid {
		grid-template-columns: repeat(3, minmax(0, 1fr));
	}
}

@media (min-width: 900px) {
	.bs-gallery__grid {
		grid-template-columns: repeat(var(--bs-gallery-cols), minmax(0, 1fr));
	}
}

.bs-gallery__item {
	position: relative;
	display: block;
	width: 100%;
	aspect-ratio: 3 / 2;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 4px;
	/* aspect-ratio needs both of these or a portrait photo stretches its box
	   and the tiles stop lining up. */
	overflow: hidden;
	min-height: 0;
	background: var(--wp--preset--color--gray-100);
	cursor: zoom-in;
}

.bs-gallery__item img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transition: transform 0.35s ease;
}

@media (prefers-reduced-motion: reduce) {
	.bs-gallery__item img {
		transition: none;
	}
}

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

.bs-gallery__item:focus-visible {
	outline: 3px solid var(--wp--preset--color--brand-red);
	outline-offset: 3px;
}

.bs-gallery__foot {
	display: flex;
	justify-content: center;
	margin-top: clamp(1rem, 2.5vw, 1.5rem);
}

.bs-gallery__more {
	font: inherit;
	font-weight: 700;
	padding: 0.75rem 1.5rem;
	min-height: 48px;
	border: 2px solid var(--wp--preset--color--brand-maroon);
	border-radius: 999px;
	background: transparent;
	color: var(--wp--preset--color--brand-maroon);
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.bs-gallery__more:hover:not(:disabled),
.bs-gallery__more:focus-visible {
	background: var(--wp--preset--color--brand-maroon);
	color: var(--wp--preset--color--white);
}

.bs-gallery__more:disabled {
	opacity: 0.6;
	cursor: progress;
}

.bs-gallery__count {
	font-weight: 400;
	opacity: 0.75;
}

/* ------------------------------------------------------------- lightbox */

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

.bs-lightbox {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(0.75rem, 3vw, 2.5rem);
	background: rgba(10, 10, 10, 0.94);
}

body.bs-lightbox-open {
	overflow: hidden;
}

.bs-lightbox__figure {
	margin: 0;
	max-width: min(100%, 1400px);
	max-height: 100%;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 0.75rem;
}

.bs-lightbox__img {
	max-width: 100%;
	/* leave room for the caption line under the photo */
	max-height: calc(100vh - 8rem);
	width: auto;
	height: auto;
	object-fit: contain;
	border-radius: 4px;
}

.bs-lightbox__caption {
	color: var(--wp--preset--color--white);
	font-size: var(--wp--preset--font-size--sm);
	opacity: 0.8;
}

.bs-lightbox__close,
.bs-lightbox__nav {
	position: absolute;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: var(--wp--preset--color--white);
	cursor: pointer;
	transition: background-color 0.2s ease;
}

.bs-lightbox__close:hover,
.bs-lightbox__nav:hover,
.bs-lightbox__close:focus-visible,
.bs-lightbox__nav:focus-visible {
	background: rgba(255, 255, 255, 0.28);
}

.bs-lightbox__close:focus-visible,
.bs-lightbox__nav:focus-visible {
	outline: 3px solid var(--wp--preset--color--white);
	outline-offset: 2px;
}

.bs-lightbox__close {
	top: clamp(0.5rem, 2vw, 1.25rem);
	right: clamp(0.5rem, 2vw, 1.25rem);
	font-size: 1.75rem;
	line-height: 1;
}

.bs-lightbox__nav svg {
	width: 24px;
	height: 24px;
}

.bs-lightbox__nav--prev {
	left: clamp(0.25rem, 1.5vw, 1.25rem);
}

.bs-lightbox__nav--next {
	right: clamp(0.25rem, 1.5vw, 1.25rem);
}

@media (max-width: 599px) {
	.bs-lightbox__nav {
		top: auto;
		bottom: clamp(0.5rem, 2vw, 1rem);
	}

	.bs-lightbox__nav--prev {
		left: 25%;
	}

	.bs-lightbox__nav--next {
		right: 25%;
	}

	.bs-lightbox__img {
		max-height: calc(100vh - 11rem);
	}
}
