/* Gallery lightbox (native <dialog>, built by gallery-lightbox.js).
   Same overlay and green round buttons as the video popup. The dialog
   covers the viewport and paints the overlay (--ate-lb-overlay). */

html.ate-lb-lock {
	overflow: hidden;
}

.ate-lb {
	box-sizing: border-box;
	position: fixed;
	inset: 0;
	width: 100vw;
	max-width: none;
	height: 100vh;
	height: 100dvh;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	background: var(--ate-lb-overlay, rgba(6, 12, 29, 0.92));
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
	color: #ffffff;
	overflow: hidden;
}

.ate-lb[open] {
	display: grid;
	grid-template-rows: auto minmax(0, 1fr);
	animation: ate-lb-fade 0.2s ease-out;
}

.ate-lb::backdrop {
	background: transparent;
}

.ate-lb * {
	box-sizing: border-box;
}

/* Top bar: counter left, close right. */
.ate-lb__bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	padding: 16px 16px 8px;
}

.ate-lb__counter {
	margin: 0;
	font-family: "Barlow Condensed", sans-serif;
	font-weight: 600;
	font-size: 18px;
	letter-spacing: 0.04em;
	color: #ffffff;
}

/* Stage: the image, centred, as large as fits between the side buttons. */
.ate-lb__stage {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 0;
	padding: 8px 88px 24px;
	touch-action: pan-y pinch-zoom;
}

.ate-lb__figure {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 12px;
	max-width: 100%;
	max-height: 100%;
	margin: 0;
}

.ate-lb__img {
	display: block;
	max-width: 100%;
	max-height: calc(100vh - 140px);
	max-height: calc(100dvh - 140px);
	width: auto;
	height: auto;
	border-radius: 16px;
	border: 4px solid #abff4f;
	background: rgba(255, 255, 255, 0.06);
	object-fit: contain;
	transition: opacity 0.2s ease;
}

.ate-lb--has-caption .ate-lb__img {
	max-height: calc(100vh - 200px);
	max-height: calc(100dvh - 200px);
}

.ate-lb--loading .ate-lb__img {
	opacity: 0;
}

.ate-lb__caption {
	max-width: 70ch;
	margin: 0;
	color: #ffffff;
	font-family: "DM Sans", sans-serif;
	font-size: 16px;
	line-height: 1.4;
	text-align: center;
}

.ate-lb__caption:empty {
	display: none;
}

/* Spinner while the full-size image loads. */
.ate-lb__spinner {
	position: absolute;
	top: 50%;
	left: 50%;
	width: 44px;
	height: 44px;
	margin: -22px 0 0 -22px;
	border: 4px solid rgba(255, 255, 255, 0.25);
	border-top-color: #abff4f;
	border-radius: 50%;
	opacity: 0;
	pointer-events: none;
	animation: ate-lb-spin 0.8s linear infinite;
}

.ate-lb--loading .ate-lb__spinner {
	opacity: 1;
}

.ate-lb__error {
	margin: 0;
	padding: 24px;
	color: #ffffff;
	font-family: "DM Sans", sans-serif;
	text-align: center;
}

/* Round buttons (close + arrows), same look as the video popup's close. */
.ate-lb__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	width: 48px;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 2px solid #060c1d;
	border-radius: 50%;
	background: #abff4f;
	color: #060c1d;
	cursor: pointer;
	transition: background-color 0.2s, transform 0.2s, opacity 0.2s;
}

.ate-lb__btn:hover {
	background: #75f000;
	transform: scale(1.06);
}

.ate-lb__btn:focus-visible {
	outline: 3px solid #ffffff;
	outline-offset: 3px;
	box-shadow: 0 0 0 7px #2667ff;
}

.ate-lb__btn[aria-disabled="true"] {
	opacity: 0.35;
	cursor: default;
	transform: none;
}

.ate-lb__btn svg {
	display: block;
	width: 20px;
	height: 20px;
}

.ate-lb__nav {
	position: absolute;
	top: 50%;
	z-index: 1;
	margin-top: -24px;
}

.ate-lb__prev {
	left: 20px;
}

.ate-lb__next {
	right: 20px;
}

.ate-lb--single .ate-lb__nav,
.ate-lb--single .ate-lb__counter {
	display: none;
}

/* Phones: arrows move below the image so the photo gets the full width. */
@media (max-width: 767px) {
	.ate-lb[open] {
		grid-template-rows: auto minmax(0, 1fr) auto;
	}

	.ate-lb__stage {
		padding: 8px 12px;
	}

	.ate-lb__img {
		max-height: calc(100vh - 170px);
		max-height: calc(100dvh - 170px);
		border-width: 3px;
		border-radius: 12px;
	}

	.ate-lb--has-caption .ate-lb__img {
		max-height: calc(100vh - 230px);
		max-height: calc(100dvh - 230px);
	}

	.ate-lb__nav {
		position: static;
		margin: 0;
	}

	.ate-lb__navbar {
		display: flex;
		justify-content: center;
		gap: 24px;
		padding: 8px 16px 20px;
		padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px));
	}

	.ate-lb--single .ate-lb__navbar {
		display: none;
	}
}

@media (min-width: 768px) {
	/* On wider screens the nav wrapper is transparent to layout. */
	.ate-lb__navbar {
		display: contents;
	}
}

@keyframes ate-lb-fade {
	from {
		opacity: 0;
	}
}

@keyframes ate-lb-spin {
	to {
		transform: rotate(360deg);
	}
}

@media (prefers-reduced-motion: reduce) {
	.ate-lb[open] {
		animation: none;
	}

	.ate-lb__img,
	.ate-lb__btn {
		transition: none;
	}

	.ate-lb__btn:hover {
		transform: none;
	}

	.ate-lb__spinner {
		animation-duration: 2.4s;
	}
}

@media (forced-colors: active) {
	.ate-lb {
		border: 2px solid CanvasText;
	}

	.ate-lb__btn {
		border-color: ButtonText;
	}
}
