/**
 * Lichtspieler Video Popup
 *
 * Adjustable from a theme, on .lsvp-dialog:
 * --lsvp-overlay        Color behind the video.
 * --lsvp-max-width      How wide a landscape video may get.
 * --lsvp-radius         Rounding of the video's corners.
 * --lsvp-close          Circle of the close button.
 * --lsvp-accent         End screen button.
 * --lsvp-accent-text    Text on the end screen button.
 */

/* The page behind an open popup doesn't scroll. */
html.lsvp-locked {
	overflow: hidden;
}

/* Triggers */

.lsvp-popup {
	display: none !important;
}

.lsvp-trigger,
.ls-video-popup,
[class*="ls-video-popup-"],
[data-ls-video-popup],
.wp-video-popup {
	cursor: pointer;
}

/* A trigger standing on its own lines up with the text column in themes that size each block individually. */
.is-layout-constrained > span.lsvp-wrap {
	display: block;
}

.lsvp-trigger--wrap {
	display: inline-block;
	max-width: 100%;
}

div.lsvp-trigger--wrap {
	display: block;
	width: fit-content;
}

.lsvp-trigger--wrap:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* Dialog */

.lsvp-dialog {
	--lsvp-space-x: 20px;
	--lsvp-space-y: 84px;

	position: fixed;
	inset: 0;
	z-index: 2147483000;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: 0;
	border: 0;
	overflow: hidden;
	overscroll-behavior: contain;
	background: var(--lsvp-overlay, rgba(0, 0, 0, 0.88));
	color: #fff;
	line-height: 1.4;
	opacity: 0;
	transition: opacity 0.2s ease;
}

.lsvp-dialog:not([open]) {
	display: none;
}

.lsvp-dialog:focus,
.lsvp-dialog:focus-visible {
	outline: none;
}

.lsvp-dialog::backdrop {
	background: transparent;
}

.lsvp-dialog.is-visible {
	opacity: 1;
}

.lsvp-dialog *,
.lsvp-dialog *::before,
.lsvp-dialog *::after {
	box-sizing: border-box;
}

/*
 * Sites with a cursor of their own hide the real one on every element. Theirs can't follow
 * into the popup, which lies on top of the whole page, so the real one comes back in here.
 */
.lsvp-dialog {
	cursor: default !important;
}

.lsvp-dialog * {
	cursor: inherit !important;
}

.lsvp-stage {
	position: absolute;
	inset: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: var(--lsvp-space-y) var(--lsvp-space-x);
	container-type: size;
}

/* Video */

.lsvp-frame {
	--lsvp-ratio: 16 / 9;
	--lsvp-limit: var(--lsvp-max-width, 1200px);

	position: relative;
	flex: none;

	/* As wide as allowed, as the screen is, and as the screen's height permits. */
	width: min(var(--lsvp-limit), 100%, calc((100vh - 2 * var(--lsvp-space-y)) * var(--lsvp-ratio)));
	aspect-ratio: var(--lsvp-ratio);
	border-radius: var(--lsvp-radius, 6px);
	background: #000;
	box-shadow: 0 24px 80px rgba(0, 0, 0, 0.5);
}

@supports (width: 1cqh) {
	.lsvp-frame {
		width: min(var(--lsvp-limit), 100cqw, calc(100cqh * var(--lsvp-ratio)));
	}
}

/* Vertical videos are limited by the screen's height alone. */
.lsvp-frame--portrait {
	--lsvp-ratio: 9 / 16;
	--lsvp-limit: 100%;
}

.lsvp-player {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	margin: 0;
	border: 0;
	border-radius: inherit;
	background: #000;
}

.lsvp-frame.is-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 36px;
	height: 36px;
	margin: -18px 0 0 -18px;
	border: 3px solid rgba(255, 255, 255, 0.2);
	border-top-color: #fff;
	border-radius: 50%;
	pointer-events: none;
	animation: lsvp-spin 0.8s linear infinite;
}

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

/*
 * Controls: close and gallery arrows. Written to hold against a theme's button styles,
 * also against themes that force a corner radius or font size on every button.
 */

.lsvp-dialog button.lsvp-control {
	all: unset;
	position: absolute;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 44px;
	height: 44px;
	border-radius: 50% !important;
	background: rgba(255, 255, 255, 0.1);
	color: #fff;
	cursor: pointer !important;
	transition: background-color 0.15s ease, opacity 0.15s ease;
}

.lsvp-dialog button.lsvp-control:hover {
	background: rgba(255, 255, 255, 0.22);
	color: #fff;
}

.lsvp-dialog button.lsvp-control:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.lsvp-dialog button.lsvp-control[hidden] {
	display: none;
}

.lsvp-dialog button.lsvp-control:disabled {
	background: rgba(255, 255, 255, 0.06);
	opacity: 0.35;
	cursor: default !important;
}

.lsvp-control svg {
	display: block;
	width: 22px;
	height: 22px;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.lsvp-dialog button.lsvp-close {
	top: 24px;
	right: 24px;
	background: var(--lsvp-close, #e0302f);
	transition: filter 0.15s ease;
}

.lsvp-dialog button.lsvp-close:hover {
	background: var(--lsvp-close, #e0302f);
	filter: brightness(0.88);
}

.lsvp-dialog button.lsvp-nav {
	top: 50%;
	transform: translateY(-50%);
}

.lsvp-dialog button.lsvp-previous {
	left: 24px;
}

.lsvp-dialog button.lsvp-next {
	right: 24px;
}

/* Keeps the video clear of the arrows. */
.lsvp-dialog.has-navigation {
	--lsvp-space-x: 84px;
}

.lsvp-counter {
	position: absolute;
	bottom: 24px;
	left: 50%;
	margin: 0;
	padding: 0;
	transform: translateX(-50%);
	color: rgba(255, 255, 255, 0.72);
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.06em;
	line-height: 1;
}

.lsvp-counter[hidden] {
	display: none;
}

/* End screen */

.lsvp-end {
	position: absolute;
	top: 50%;
	right: 0;
	left: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 100%;
	max-height: 100%;
	padding: 24px;
	transform: translateY(-50%);
	overflow-y: auto;
	border-radius: inherit;
	background: rgba(8, 8, 10, 0.84);
	-webkit-backdrop-filter: blur(10px);
	backdrop-filter: blur(10px);
	color: #fff;
	text-align: center;
	opacity: 0;
	transition: opacity 0.3s ease;
}

.lsvp-end.is-visible {
	opacity: 1;
}

/* Covers the video. On a phone, where the video is small, it may grow past it as far as the popup has room. */
@supports (width: 1cqh) {
	.lsvp-end {
		max-height: 100cqh;
	}
}

.lsvp-end__inner {
	max-width: 34em;
	margin: auto;
}

.lsvp-end .lsvp-end__title {
	margin: 0 0 0.4em;
	padding: 0;
	color: #fff;
	font-size: 24px;
	font-size: clamp(20px, 3.2cqw, 34px);
	font-weight: 700;
	line-height: 1.2;
	text-wrap: balance;
}

.lsvp-end .lsvp-end__text {
	margin: 0 0 1.4em;
	padding: 0;
	color: rgba(255, 255, 255, 0.82);
	font-size: 16px;
	font-size: clamp(15px, 1.7cqw, 18px);
	line-height: 1.5;
	text-wrap: pretty;
}

.lsvp-end__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: center;
	gap: 12px;
}

.lsvp-end a.lsvp-end__button,
.lsvp-end button.lsvp-end__replay {
	all: unset;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	box-sizing: border-box;
	min-height: 44px;
	padding: 10px 22px;
	border: 2px solid transparent;
	border-radius: 999px !important;
	font-size: 16px !important;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer !important;
	transition: background-color 0.15s ease, color 0.15s ease, opacity 0.15s ease;
}

.lsvp-end a.lsvp-end__button {
	background: var(--lsvp-accent, #fff);
	color: var(--lsvp-accent-text, #111);
}

.lsvp-end a.lsvp-end__button:hover {
	color: var(--lsvp-accent-text, #111);
	opacity: 0.86;
}

.lsvp-end a.lsvp-end__button--secondary {
	border-color: rgba(255, 255, 255, 0.55);
	background: transparent;
	color: #fff;
}

.lsvp-end a.lsvp-end__button--secondary:hover {
	background: rgba(255, 255, 255, 0.14);
	color: #fff;
	opacity: 1;
}

/* Watching again is the quiet option. */
.lsvp-end button.lsvp-end__replay {
	flex-basis: 100%;
	min-height: 36px;
	padding: 6px 12px;
	color: rgba(255, 255, 255, 0.78);
	font-size: 14px !important;
	font-weight: 500;
}

.lsvp-end button.lsvp-end__replay:hover {
	color: #fff;
}

/* Without a button of its own, watching again is the only thing to do. */
.lsvp-end button.lsvp-end__replay:only-child {
	flex-basis: auto;
	border-color: rgba(255, 255, 255, 0.55);
	color: #fff;
	font-size: 16px !important;
	font-weight: 600;
	min-height: 44px;
	padding: 10px 22px;
}

.lsvp-end button.lsvp-end__replay:only-child:hover {
	background: rgba(255, 255, 255, 0.14);
}

.lsvp-end__replay svg {
	width: 16px;
	height: 16px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.lsvp-end a.lsvp-end__button:focus-visible,
.lsvp-end button.lsvp-end__replay:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

/* Narrow screens: the arrows move below the video. */

@media (max-width: 700px) {
	.lsvp-dialog,
	.lsvp-dialog.has-navigation {
		--lsvp-space-x: 12px;
		--lsvp-space-y: 76px;
	}

	.lsvp-dialog button.lsvp-close {
		top: 16px;
		right: 16px;
	}

	.lsvp-dialog button.lsvp-previous {
		left: 16px;
	}

	.lsvp-dialog button.lsvp-next {
		right: 16px;
	}

	.lsvp-dialog button.lsvp-nav {
		top: auto;
		bottom: 14px;
		transform: none;
	}

	.lsvp-counter {
		bottom: 30px;
	}

	.lsvp-end {
		padding: 14px;
	}

	.lsvp-end .lsvp-end__text {
		margin-bottom: 1em;
	}

	.lsvp-end a.lsvp-end__button,
	.lsvp-end button.lsvp-end__replay:only-child {
		min-height: 40px;
		padding: 8px 18px;
		font-size: 15px !important;
	}
}

/* Low screens (phones held sideways): the controls move next to the video. */

@media (max-height: 480px) {
	.lsvp-dialog,
	.lsvp-dialog.has-navigation {
		--lsvp-space-x: 68px;
		--lsvp-space-y: 10px;
	}

	.lsvp-dialog button.lsvp-close {
		top: 12px;
		right: 12px;
	}

	.lsvp-dialog button.lsvp-nav {
		top: 50%;
		bottom: auto;
		transform: translateY(-50%);
	}

	.lsvp-dialog button.lsvp-previous {
		left: 12px;
	}

	.lsvp-dialog button.lsvp-next {
		right: 12px;
	}

	.lsvp-counter {
		right: 12px;
		bottom: 12px;
		left: auto;
		width: 44px;
		transform: none;
		text-align: center;
	}
}

@media (prefers-reduced-motion: reduce) {
	.lsvp-dialog,
	.lsvp-end,
	.lsvp-dialog button.lsvp-control,
	.lsvp-end a.lsvp-end__button,
	.lsvp-end button.lsvp-end__replay {
		transition: none;
	}

	.lsvp-frame.is-loading::after {
		animation-duration: 2.4s;
	}
}
