/**
 * Shared lightbox (assets/lightbox.js) and the trigger links.
 *
 * Colours: V4 variables --lightbox-backdrop, --lightbox-controls,
 * --lightbox-controls-hover, --lightbox-text, with fallbacks. The dialog
 * paints the backdrop itself: ::backdrop does not inherit custom properties in
 * every browser still in use.
 */

/* (0,2,1): Elementor's link base style sets cursor: pointer at (0,2,0) and loads later. */
a.scw-lb-trigger,
.elementor a.scw-lb-trigger {
	cursor: zoom-in;
}

/* Trigger links carry Elementor's link base style (all: unset), which drops the site focus ring. */
.scw-lb-trigger:focus-visible,
.elementor .scw-lb-trigger:focus-visible {
	outline: var(--focus-outline, 2px) solid var(--focus-ring, var(--brand, currentColor));
	outline-offset: var(--focus-outline-gap, 2px);
}

html.scw-lb-open {
	overflow: hidden;
}

.scw-lb {
	--_ink: var(--lightbox-text, #ffffff);
	--_ctl: var(--lightbox-controls, #ffffffcc);
	--_ctl-hover: var(--lightbox-controls-hover, #ffffff);
	--_gutter: clamp(0.5rem, 3vw, 1.5rem);
	--_btn: 2.75rem;
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow: hidden;
	background: var(--lightbox-backdrop, #000000e6);
	color: var(--_ink);
	font-family: var(--body, inherit);
}

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

.scw-lb__stage {
	display: grid;
	place-items: center;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	padding: calc(var(--_btn) + var(--_gutter) * 2);
	touch-action: pan-y pinch-zoom;
}

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

/* Two classes to beat Elementor's `.elementor img { height: auto; max-width: 100% }`. */
.scw-lb .scw-lb__img {
	display: block;
	width: auto;
	height: auto;
	max-width: 100%;
	max-height: calc(100dvh - (var(--_btn) + var(--_gutter) * 2) * 2 - 3rem);
	object-fit: contain;
	user-select: none;
	-webkit-user-select: none;
}

.scw-lb__caption {
	max-width: 60ch;
	font-size: var(--body-s-size, 0.875rem);
	line-height: 1.4;
	text-align: center;
	color: var(--_ink);
}

.scw-lb__counter {
	position: absolute;
	top: var(--_gutter);
	left: var(--_gutter);
	margin: 0;
	font-size: var(--body-s-size, 0.875rem);
	line-height: var(--_btn);
	font-variant-numeric: tabular-nums;
	color: var(--_ink);
}

/* (0,2,0) and later in the cascade, to beat Hello reset.css button rules incl. [type=button]:hover. */
.scw-lb .scw-lb__btn {
	all: unset;
	position: absolute;
	box-sizing: border-box;
	display: grid;
	place-items: center;
	width: var(--_btn);
	height: var(--_btn);
	border-radius: 50%;
	background: color-mix(in srgb, var(--lightbox-backdrop, #000000) 70%, transparent);
	color: var(--_ctl);
	cursor: pointer;
}

.scw-lb .scw-lb__btn[hidden] {
	display: none;
}

.scw-lb .scw-lb__btn:hover,
.scw-lb .scw-lb__btn:focus-visible {
	color: var(--_ctl-hover);
}

/* Ring in the control colour so it shows on the dark backdrop. */
.scw-lb .scw-lb__btn:focus-visible {
	outline: var(--focus-outline, 2px) solid var(--_ctl-hover);
	outline-offset: var(--focus-outline-gap, 2px);
}

.scw-lb .scw-lb__close {
	top: var(--_gutter);
	right: var(--_gutter);
}

.scw-lb .scw-lb__prev,
.scw-lb .scw-lb__next {
	top: 50%;
	transform: translateY(-50%);
}

.scw-lb .scw-lb__prev {
	left: var(--_gutter);
}

.scw-lb .scw-lb__next {
	right: var(--_gutter);
}

/* Narrow screens: arrows move to the bottom corners so the photo gets the full width. */
@media (max-width: 599px) {
	.scw-lb__stage {
		padding-inline: var(--_gutter);
	}

	.scw-lb .scw-lb__prev,
	.scw-lb .scw-lb__next {
		top: auto;
		bottom: var(--_gutter);
		transform: none;
	}
}

@media (prefers-reduced-motion: no-preference) {
	.scw-lb[open] {
		animation: scw-lb-in 200ms ease;
	}

	.scw-lb .scw-lb__btn {
		transition: color 150ms ease;
	}

	@keyframes scw-lb-in {
		from {
			opacity: 0;
		}
	}
}
