/**
 * Stacks Video — front end.
 *
 * Background mode: the video fills the Section it sits in, behind the
 * Section's content, wherever in the Section the element was dropped.
 * Cornerstone's rows and columns are position:relative, which would trap an
 * absolutely-positioned layer inside its column — so the containers between
 * the Section and the video are made static, and the Section becomes the
 * box the video fills.
 */

.x-section:has(.stacks-video--background) {
	position: relative;
	isolation: isolate;
	overflow: hidden;
}

.x-section:has(.stacks-video--background) :is(.x-container, .x-row, .x-row-inner, .x-col, .x-column):has(.stacks-video--background) {
	position: static;
}

.stacks-video--background {
	position: static;
	margin: 0;
}

.stacks-video__layer {
	position: absolute;
	inset: 0;
	z-index: -1;
	overflow: hidden;
	pointer-events: none;
}

.stacks-video--background .stacks-video__media {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.stacks-video__overlay {
	position: absolute;
	inset: 0;
}

.stacks-video--player {
	position: relative;
	width: 100%;
	aspect-ratio: 16 / 9;
	background: #000;
}

.stacks-video--player .stacks-video__media {
	width: 100%;
	height: 100%;
	object-fit: contain;
	display: block;
}

/* Editors only: shown when no video is chosen or it's still processing. */
.stacks-video--empty {
	padding: 1.25em;
	border: 2px dashed rgba(128, 128, 128, 0.6);
	border-radius: 6px;
	font: 500 14px/1.4 system-ui, sans-serif;
	color: inherit;
	text-align: center;
}

.stacks-video--empty p {
	margin: 0;
}

@media (prefers-reduced-motion: reduce) {
	.stacks-video--background video.stacks-video__media {
		visibility: hidden;
	}

	.stacks-video__layer.has-poster {
		background-size: cover;
		background-position: center;
	}
}

/* Pause/play for background video: bottom-right of the Section, above its content. */
.stacks-video__toggle {
	position: absolute;
	right: 16px;
	bottom: 16px;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, 0.55);
	color: #fff;
	cursor: pointer;
	opacity: 0.75;
	transition: opacity 0.15s ease;
}

.stacks-video__toggle:hover,
.stacks-video__toggle:focus-visible {
	opacity: 1;
}

.stacks-video__toggle:focus-visible {
	outline: 3px solid #fff;
	outline-offset: 2px;
	box-shadow: 0 0 0 5px rgba(0, 0, 0, 0.6);
}

.stacks-video__toggle svg {
	fill: currentColor;
}

.stacks-video__toggle .stacks-video__icon-play,
.stacks-video__toggle[aria-pressed="true"] .stacks-video__icon-pause {
	display: none;
}

.stacks-video__toggle[aria-pressed="true"] .stacks-video__icon-play {
	display: inline;
}
