/*
 * Click-to-play consent gate laid over Impreza's [vc_video] boxes.
 *
 * Geometry note: video-consent.js wraps each .w-video in .alr-vgate-wrap and adds the
 * gate as a SIBLING of the video, never a child. Impreza puts a full-box <button
 * class="w-video-play"> inside .w-video and binds its own delegated click handler to
 * the video's direct children, so a gate nested inside would hand that handler the
 * click and create the YouTube iframe before consent had been stored.
 *
 * .w-video is width:100% with aspect-ratio:16/9 and no max-width, so the wrapper's
 * content box is exactly the video box and inset:0 lines the gate up with it without
 * any measuring. The script asserts that at runtime.
 *
 * Specificity note: Impreza's and WPBakery's stylesheets load after this file, and a
 * bare .alr-vgate would tie with (and lose to) selectors like [role="region"]
 * {position:relative}, which would quietly turn position:absolute into relative and
 * drop the gate below the video. Everything below is therefore written as a child
 * combinator from .alr-vgate-wrap, and the <button> resets every property the theme's
 * button styles would otherwise leak in.
 *
 * Accent #003888 is the Impreza content-primary colour, the same one map-consent.css
 * uses and the same one the client set on the shortcode's own play icon.
 */

.alr-vgate-wrap {
	position: relative;
	display: block;
}

.alr-vgate-wrap > .alr-vgate {
	position: absolute;
	z-index: 3;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	overflow: hidden;
	box-sizing: border-box;
	cursor: pointer;
	background: #111;
	opacity: 1;
	transition: opacity 0.45s ease;

	/* Sizing is driven by the video box, not the viewport: these players sit in
	   half-width columns, so a phone-width media query would not catch them. */
	container-type: size;
	container-name: alrvgate;
}

.alr-vgate-wrap > .alr-vgate.is-leaving {
	opacity: 0;
	pointer-events: none;
}

/* The still, blurred. Inset negatively so the blur's soft edge is cropped away
   instead of showing as a pale halo around the frame. */
.alr-vgate-wrap > .alr-vgate > .alr-vgate__bg {
	position: absolute;
	top: -24px;
	right: -24px;
	bottom: -24px;
	left: -24px;
	background-position: center;
	background-size: cover;
	filter: blur(7px);
	transform: scale(1.03);
	transition: filter 0.3s ease;
}

/* Darkening gradient: keeps white text readable over any still. */
.alr-vgate-wrap > .alr-vgate > .alr-vgate__scrim {
	position: absolute;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background:
		radial-gradient(ellipse at 50% 42%, rgba(0, 0, 0, 0.12) 0%, rgba(0, 0, 0, 0.52) 100%),
		linear-gradient(to bottom, rgba(0, 0, 0, 0.28) 0%, rgba(0, 0, 0, 0.58) 100%);
}

.alr-vgate-wrap > .alr-vgate:hover > .alr-vgate__bg {
	filter: blur(5px);
}

.alr-vgate-wrap > .alr-vgate > .alr-vgate__content {
	position: relative;
	z-index: 1;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	align-items: center;
	width: 100%;
	max-width: 30rem;
	padding: 1rem;
	text-align: center;
	color: #fff;
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.55);
}

/* Hidden until the script knows there is no stored consent, so a returning visitor
   never sees the copy flash before the gate removes itself. */
.alr-vgate-wrap > .alr-vgate:not(.is-ready) > .alr-vgate__content {
	visibility: hidden;
}

/* Play button above its label by default; the short-box container query below turns
   this into a row. */
.alr-vgate-wrap > .alr-vgate .alr-vgate__cta {
	display: flex;
	flex-direction: column;
	align-items: center;
}

/* The play control. Every property the theme's .w-btn / button rules would inherit
   into is reset explicitly. */
.alr-vgate-wrap > .alr-vgate .alr-vgate__play {
	display: flex;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	width: 4.5rem;
	height: 4.5rem;
	margin: 0;
	padding: 0;
	border: none;
	border-radius: 50%;
	background: #003888;
	box-shadow: 0 0.25rem 1.25rem rgba(0, 0, 0, 0.35);
	color: #fff;
	font: inherit;
	letter-spacing: normal;
	text-transform: none;
	cursor: pointer;
	transition: transform 0.2s ease, background-color 0.2s ease;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__play svg {
	width: 1.75rem;
	height: 1.75rem;
	/* Optical centring: a triangle's visual centre sits left of its bounding box. */
	margin-left: 0.2rem;
	fill: currentColor;
}

.alr-vgate-wrap > .alr-vgate:hover .alr-vgate__play,
.alr-vgate-wrap > .alr-vgate .alr-vgate__play:focus-visible {
	transform: scale(1.08);
	background: #002f73;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__play[disabled] {
	cursor: default;
	transform: none;
}

/* Spinner shown in place of the triangle while the iframe loads. */
.alr-vgate-wrap > .alr-vgate .alr-vgate__spinner {
	width: 1.5rem;
	height: 1.5rem;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: alr-vgate-spin 0.7s linear infinite;
}

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

.alr-vgate-wrap > .alr-vgate .alr-vgate__label {
	margin: 0.75rem 0 0;
	font-size: 1.0625rem;
	font-weight: 600;
	line-height: 1.3;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__note {
	margin: 0.5rem 0 0;
	max-width: 26rem;
	font-size: 0.8125rem;
	line-height: 1.45;
	opacity: 0.92;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__status {
	margin: 0.4rem 0 0;
	font-size: 0.8125rem;
	line-height: 1.4;
	color: #ffd4d4;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__status:empty {
	display: none;
}

/* Sits above the gate's own click handler so choosing "preferences" never starts
   the video. */
.alr-vgate-wrap > .alr-vgate .alr-vgate__prefs {
	margin: 0.6rem 0 0;
	padding: 0.2rem 0.3rem;
	border: none;
	background: none;
	box-shadow: none;
	color: #fff;
	font: inherit;
	font-size: 0.75rem;
	letter-spacing: normal;
	text-transform: none;
	text-decoration: underline;
	text-underline-offset: 0.15em;
	opacity: 0.85;
	cursor: pointer;
}

.alr-vgate-wrap > .alr-vgate .alr-vgate__prefs:hover,
.alr-vgate-wrap > .alr-vgate .alr-vgate__prefs:focus-visible {
	opacity: 1;
}

/*
 * Small players. These sit in half-width columns (~500x280 on a desktop, ~300x170 on
 * a phone), so the gate shrinks against its own box rather than the viewport.
 */
@container alrvgate (max-height: 240px) {
	.alr-vgate-wrap > .alr-vgate .alr-vgate__play {
		width: 3.5rem;
		height: 3.5rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__play svg {
		width: 1.375rem;
		height: 1.375rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__label {
		margin-top: 0.5rem;
		font-size: 0.9375rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__note {
		font-size: 0.75rem;
		line-height: 1.4;
	}
}

/* Below this the stacked layout runs out of room, so the button moves beside the
   label and the consent sentence drops under the pair. */
@container alrvgate (max-height: 185px) {
	.alr-vgate-wrap > .alr-vgate > .alr-vgate__content {
		padding: 0.625rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__cta {
		display: flex;
		flex-direction: row;
		align-items: center;
		gap: 0.625rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__play {
		width: 2.75rem;
		height: 2.75rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__play svg {
		width: 1.125rem;
		height: 1.125rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__label {
		margin: 0;
		font-size: 0.875rem;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__note {
		margin-top: 0.4rem;
		font-size: 0.6875rem;
		line-height: 1.35;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__prefs {
		margin-top: 0.3rem;
		font-size: 0.6875rem;
	}
}

/* Very short boxes: the sentence would push the button out of the frame. Keep the
   control and the link (consent stays informed via the cookie policy) and drop the
   long line. */
@container alrvgate (max-height: 130px) {
	.alr-vgate-wrap > .alr-vgate .alr-vgate__note {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.alr-vgate-wrap > .alr-vgate,
	.alr-vgate-wrap > .alr-vgate > .alr-vgate__bg,
	.alr-vgate-wrap > .alr-vgate .alr-vgate__play {
		transition: none;
	}

	.alr-vgate-wrap > .alr-vgate:hover .alr-vgate__play,
	.alr-vgate-wrap > .alr-vgate .alr-vgate__play:focus-visible {
		transform: none;
	}

	.alr-vgate-wrap > .alr-vgate .alr-vgate__spinner {
		animation-duration: 2s;
	}
}
