/**
 * Xtra Lightbox — overlay styles.
 *
 * Mobile-first; deliberately self-contained (raw colors, not theme tokens):
 * the overlay is a fixed dark surface that should look identical on every
 * page regardless of theme palette.
 */

.xtra-lightbox {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: none;
	/* Solid on purpose: translucent full-viewport fixed backgrounds hit
	   compositing glitches on some mobile renderers. */
	background: rgb(10, 12, 16);
}

.xtra-lightbox.is-open {
	display: block;
}

/* The buttons give their own pressed feedback — the mobile blue tap-highlight
   rectangle just reads as a glitchy invisible box, so kill it throughout. */
.xtra-lightbox,
.xtra-lightbox * {
	-webkit-tap-highlight-color: transparent;
}

.xtra-lightbox-lock,
.xtra-lightbox-lock body {
	overflow: hidden;
}

/* Stage */

.xtra-lightbox__stage {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	touch-action: none;
	cursor: zoom-in;
	overflow: hidden;
}

/* The frame carries the slide/fade transition between images (driven by
   inline styles from JS); the img carries the zoom/pan transform. Keeping
   them on separate elements means the two never fight over `transform`. */
.xtra-lightbox__frame {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	will-change: transform, opacity;
}

.xtra-lightbox__img {
	max-width: 100vw;
	max-height: 100vh;
	max-height: 100dvh;
	object-fit: contain;
	transition: transform 0.22s ease;
	user-select: none;
	-webkit-user-select: none;
}

.xtra-lightbox.is-zoomed .xtra-lightbox__stage {
	cursor: grab;
}

/* Loading spinner */

.xtra-lightbox.is-loading .xtra-lightbox__stage::after {
	content: "";
	position: absolute;
	width: 2rem;
	height: 2rem;
	border: 3px solid rgba(255, 255, 255, 0.25);
	border-top-color: rgba(255, 255, 255, 0.9);
	border-radius: 50%;
	animation: xtra-lightbox-spin 0.7s linear infinite;
}

@keyframes xtra-lightbox-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Buttons */

.xtra-lightbox__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 2.75rem;
	height: 2.75rem;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.12);
	color: #fff;
	cursor: pointer;
	transition: background 0.15s ease;
}

.xtra-lightbox__btn:hover,
.xtra-lightbox__btn:focus-visible {
	background: rgba(255, 255, 255, 0.28);
}

.xtra-lightbox__btn:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Only the buttons themselves are interactive. The toolbar's rectangle (the
   gap between buttons, the corners beyond the round shapes), the counter, and
   the caption pill must not swallow taps — a touch there falls through to the
   stage so tap-to-close works everywhere except on a control or the image. */
.xtra-lightbox__toolbar,
.xtra-lightbox__counter,
.xtra-lightbox__caption {
	pointer-events: none;
}

.xtra-lightbox__btn {
	pointer-events: auto;
}

.xtra-lightbox__toolbar {
	position: absolute;
	top: max(0.75rem, env(safe-area-inset-top));
	right: max(0.75rem, env(safe-area-inset-right));
	display: flex;
	gap: 0.5rem;
	z-index: 2;
}

/* Prev / next arrows */

.xtra-lightbox__nav {
	position: absolute;
	top: 50%;
	transform: translateY(-50%);
	z-index: 2;
}

.xtra-lightbox__prev {
	left: max(0.5rem, env(safe-area-inset-left));
}

.xtra-lightbox__next {
	right: max(0.5rem, env(safe-area-inset-right));
}

.xtra-lightbox__nav[hidden] {
	display: none;
}

/* Zoomed: arrows would fight the pan gesture — hide them. */

.xtra-lightbox.is-zoomed .xtra-lightbox__nav {
	display: none;
}

/* Counter & caption */

.xtra-lightbox__counter {
	position: absolute;
	top: max(1.35rem, env(safe-area-inset-top));
	left: max(1rem, env(safe-area-inset-left));
	z-index: 2;
	color: rgba(255, 255, 255, 0.85);
	font-size: 0.85rem;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.04em;
}

.xtra-lightbox__caption {
	position: absolute;
	bottom: max(0.75rem, env(safe-area-inset-bottom));
	left: 50%;
	transform: translateX(-50%);
	z-index: 2;
	max-width: min(90vw, 44rem);
	padding: 0.4rem 0.9rem;
	border-radius: 999px;
	background: rgba(10, 12, 16, 0.7);
	color: rgba(255, 255, 255, 0.92);
	font-size: clamp(0.8rem, 0.75rem + 0.25vw, 0.95rem);
	line-height: 1.4;
	text-align: center;
}

.xtra-lightbox__caption[hidden] {
	display: none;
}

@media (min-width: 782px) {
	.xtra-lightbox__nav {
		width: 3.25rem;
		height: 3.25rem;
	}

	.xtra-lightbox__prev {
		left: 1.25rem;
	}

	.xtra-lightbox__next {
		right: 1.25rem;
	}
}
