/*
 * WCCP Pro — built-in lightbox (front end).
 *
 * Self-contained: themes style button, figure, img and figcaption freely, so
 * every element of the viewer resets what it relies on. Scoped variables keep
 * the few values in one place.
 */
.wccp-lb {
	--wccp-lb-bg: rgba(12, 14, 18, .94);
	--wccp-lb-fg: #f4f5f7;
	--wccp-lb-muted: #c4c8cf;
	--wccp-lb-btn: rgba(255, 255, 255, .12);
	--wccp-lb-btn-hover: rgba(255, 255, 255, .24);
	--wccp-lb-btn-active: rgba(255, 255, 255, .32);
	--wccp-lb-ring: #ffffff;
	--wccp-lb-gutter: 72px;
	--wccp-lb-top: 64px;
	--wccp-lb-dur: .2s;

	position: fixed;
	inset: 0;
	z-index: 2147483000;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transition: opacity var(--wccp-lb-dur) ease;
	font: 400 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--wccp-lb-fg);
	-webkit-tap-highlight-color: transparent;
}

.wccp-lb[hidden],
.wccp-lb [hidden] {
	display: none !important;
}

.wccp-lb.is-visible {
	opacity: 1;
}

html.wccp-lb-open,
html.wccp-lb-open body {
	overflow: hidden !important;
}

.wccp-lb-backdrop {
	position: absolute;
	inset: 0;
	background: var(--wccp-lb-bg);
}

.wccp-lb .wccp-lb-stage {
	position: relative;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	width: 100%;
	height: 100%;
	margin: 0;
	padding: var(--wccp-lb-top) var(--wccp-lb-gutter) 24px;
	border: 0;
	background: none;
	touch-action: pan-y;
}

.wccp-lb .wccp-lb-frame {
	position: relative;
	display: inline-block;
	max-width: 100%;
	line-height: 0;
	margin: 0;
	padding: 0;
}

.wccp-lb .wccp-lb-img {
	display: block;
	width: auto;
	height: auto;
	max-width: calc(100vw - 2 * var(--wccp-lb-gutter));
	max-height: calc(100vh - var(--wccp-lb-top) - 96px);
	max-height: calc(100dvh - var(--wccp-lb-top) - 96px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 4px;
	box-shadow: 0 12px 48px rgba(0, 0, 0, .45);
	object-fit: contain;
	pointer-events: none;
	-webkit-user-select: none;
	user-select: none;
	-webkit-user-drag: none;
	-webkit-touch-callout: none;
	transition: opacity var(--wccp-lb-dur) ease;
}

.wccp-lb.is-loading .wccp-lb-img,
.wccp-lb.has-error .wccp-lb-img {
	opacity: 0;
}

.wccp-lb .wccp-lb-caption {
	max-width: 70ch;
	margin: 14px 0 0;
	padding: 0;
	color: var(--wccp-lb-fg);
	font-size: 14px;
	line-height: 1.5;
	text-align: center;
	background: none;
}

.wccp-lb .wccp-lb-counter {
	position: absolute;
	top: 22px;
	inset-inline-start: 24px;
	color: var(--wccp-lb-muted);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
}

/* Announced to screen readers; shown only when the image fails to load. */
.wccp-lb .wccp-lb-status {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

.wccp-lb.has-error .wccp-lb-status {
	position: absolute;
	top: 50%;
	left: 50%;
	width: auto;
	height: auto;
	margin: 0;
	padding: 12px 18px;
	overflow: visible;
	clip: auto;
	white-space: normal;
	transform: translate(-50%, -50%);
	border-radius: 8px;
	background: var(--wccp-lb-btn);
	color: var(--wccp-lb-fg);
}

/* Spinner while the picture loads. */
.wccp-lb.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid var(--wccp-lb-btn-hover);
	border-top-color: var(--wccp-lb-fg);
	border-radius: 50%;
	animation: wccp-lb-spin .8s linear infinite;
}

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

/* "Expand on click" images are buttons: show where keyboard focus is. */
[data-wccp-lightbox-src]:not(a) img {
	cursor: zoom-in;
}

[data-wccp-lightbox-key]:focus {
	outline: none;
}

[data-wccp-lightbox-key]:focus-visible {
	outline: 3px solid currentColor;
	outline-offset: 3px;
}

/* Buttons: every property themes like to set is reset first. */
.wccp-lb .wccp-lb-btn {
	all: unset;
	position: absolute;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	border-radius: 50%;
	background: var(--wccp-lb-btn);
	color: var(--wccp-lb-fg);
	cursor: pointer;
	transition: background-color var(--wccp-lb-dur) ease, transform var(--wccp-lb-dur) ease;
}

.wccp-lb .wccp-lb-btn svg {
	display: block;
	width: 24px;
	height: 24px;
	pointer-events: none;
}

.wccp-lb .wccp-lb-btn:hover {
	background: var(--wccp-lb-btn-hover);
}

.wccp-lb .wccp-lb-btn:active {
	background: var(--wccp-lb-btn-active);
	transform: scale(.94);
}

.wccp-lb .wccp-lb-btn:focus {
	outline: none;
}

.wccp-lb .wccp-lb-btn:focus-visible {
	outline: 3px solid var(--wccp-lb-ring);
	outline-offset: 2px;
}

.wccp-lb .wccp-lb-close {
	top: 12px;
	inset-inline-end: 12px;
}

.wccp-lb .wccp-lb-prev,
.wccp-lb .wccp-lb-next {
	top: 50%;
	margin-top: -24px;
}

.wccp-lb .wccp-lb-prev {
	inset-inline-start: 12px;
}

.wccp-lb .wccp-lb-next {
	inset-inline-end: 12px;
}

[dir="rtl"] .wccp-lb .wccp-lb-prev svg,
[dir="rtl"] .wccp-lb .wccp-lb-next svg {
	transform: scaleX(-1);
}

@media (max-width: 720px) {
	.wccp-lb {
		--wccp-lb-gutter: 8px;
		--wccp-lb-top: 60px;
	}

	.wccp-lb .wccp-lb-prev,
	.wccp-lb .wccp-lb-next {
		top: auto;
		bottom: 16px;
		margin-top: 0;
	}

	.wccp-lb .wccp-lb-stage {
		padding-bottom: 80px;
	}

	.wccp-lb .wccp-lb-img {
		max-height: calc(100vh - var(--wccp-lb-top) - 150px);
		max-height: calc(100dvh - var(--wccp-lb-top) - 150px);
	}
}

@media (prefers-reduced-motion: reduce) {
	.wccp-lb,
	.wccp-lb .wccp-lb-img,
	.wccp-lb .wccp-lb-btn {
		transition: none;
	}

	.wccp-lb.is-loading::after {
		animation: none;
	}
}
