/* BT YouTube Video widget */
.bt-youtube {
	--bt-yt-ratio: 16 / 9;
	--bt-yt-play-size: 72px;
	--bt-yt-play-color: rgba(0, 0, 0, 0.7);
	--bt-yt-play-icon: #fff;
	--bt-yt-progress: #fff;
	--bt-yt-track: rgba(255, 255, 255, 0.25);
	--bt-yt-buffer: rgba(255, 255, 255, 0.45);
	--bt-yt-icon: #fff;
	position: relative;
	width: 100%;
	aspect-ratio: var(--bt-yt-ratio);
	overflow: hidden;
	background: #000;
	-webkit-tap-highlight-color: transparent;
	/*
	 * Everything inside is absolutely positioned, so the player has no natural
	 * width and collapses to 0×0 in containers sized by their content (e.g.
	 * Elementor containers on mobile). This empty grid track gives it a
	 * preferred width of the full screen but a minimum of 0, so such containers
	 * grow to the space available while tight rows can still shrink it.
	 */
	display: grid;
	grid-template-columns: minmax(0, 100vw);
}

/*
 * The player has no intrinsic width (everything inside is absolutely
 * positioned), so in Elementor flex containers it must be told to fill the
 * row — the same rule Elementor applies to its own Video widget. Without it the
 * widget collapses to 0×0 and following sections overlap it.
 */
.e-con > .elementor-widget-bt-youtube,
.e-con-inner > .elementor-widget-bt-youtube {
	width: var(--container-widget-width, 100%);
	--flex-grow: var(--container-widget-flex-grow);
}

.elementor-widget-bt-youtube {
	max-width: 100%;
}

/*
 * Neutralise global button styles (Elementor Site Settings → Buttons, theme).
 * [type="button"] lifts specificity above `.elementor-kit-N button` and its
 * :hover/:focus variants, so widget buttons never turn orange/dark.
 */
.bt-youtube button[type="button"],
.bt-youtube-lightbox button[type="button"] {
	min-width: 0;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	line-height: 1;
	letter-spacing: normal;
	text-decoration: none;
	text-shadow: none;
	text-transform: none;
}

.bt-youtube button[type="button"]:hover,
.bt-youtube button[type="button"]:focus,
.bt-youtube button[type="button"]:active,
.bt-youtube-lightbox button[type="button"]:hover,
.bt-youtube-lightbox button[type="button"]:focus,
.bt-youtube-lightbox button[type="button"]:active {
	border-color: transparent;
	background: none;
	box-shadow: none;
	color: inherit;
	text-decoration: none;
}

.bt-youtube iframe,
.bt-youtube > video,
.bt-youtube__overlay,
.bt-youtube__thumb {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
}

/* self-hosted video: letterbox by default (Style → Video fit overrides) */
.bt-youtube > video {
	display: block;
	object-fit: contain;
	background: #000;
}

/* with custom controls, clicks go to our layer, not the browser's video UI */
.bt-youtube--custom > video {
	pointer-events: none;
}

/* hide the browser's own play overlay that some mobile browsers draw on a paused <video> */
.bt-youtube--custom > video::-webkit-media-controls,
.bt-youtube--custom > video::-webkit-media-controls-start-playback-button {
	display: none !important;
	-webkit-appearance: none;
}

.bt-youtube__overlay {
	display: block;
	cursor: pointer;
}

.bt-youtube__thumb {
	object-fit: cover;
}

.bt-youtube__play {
	position: absolute;
	top: 50%;
	left: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	/* shrink on small players: never more than 20% of the player width */
	width: min(var(--bt-yt-play-size), 20%);
	height: auto;
	aspect-ratio: 1;
	border-radius: 50%;
	background: var(--bt-yt-play-color);
	transform: translate(-50%, -50%);
	transition: transform 0.2s ease;
}

.bt-youtube__play svg {
	width: 45%;
	height: 45%;
	fill: var(--bt-yt-play-icon);
}

.bt-youtube__overlay:focus-visible .bt-youtube__play,
.bt-youtube__bigplay:focus-visible .bt-youtube__play {
	transform: translate(-50%, -50%) scale(1.1);
}

/* hover effects only on devices that can hover (they stick after a tap on touch screens) */
@media (hover: hover) {
	.bt-youtube__overlay:hover .bt-youtube__play,
	.bt-youtube__bigplay:hover .bt-youtube__play {
		transform: translate(-50%, -50%) scale(1.1);
	}
}

/* Background mode: cover the box, no interaction */
.bt-youtube--background iframe {
	pointer-events: none;
	/* slight zoom hides the player chrome flashing at the edges */
	transform: scale(1.2);
}

/* a self-hosted video has no player chrome, so it can simply cover the box */
.bt-youtube--background > video {
	object-fit: cover;
	pointer-events: none;
}

/* first-frame thumbnail of a self-hosted video */
video.bt-youtube__thumb {
	object-fit: cover;
	background: #000;
	pointer-events: none;
}

/* Lightbox (the video box inside is a regular .bt-youtube) */
.bt-youtube-lightbox {
	color: #fff;
	width: min(90vw, 1200px);
	max-width: none;
	padding: 0;
	border: 0;
	background: transparent;
	overflow: visible;
}

.bt-youtube-lightbox::backdrop {
	background: rgba(0, 0, 0, 0.85);
}

.bt-youtube-lightbox button.bt-youtube-lightbox__close {
	position: absolute;
	top: -44px;
	right: 0;
	width: 40px;
	height: 40px;
	font-size: 32px;
	cursor: pointer;
}

/* ─── Custom controls ───────────────────────────────────────────────────── */
.bt-youtube--custom {
	outline: none;
}

.bt-youtube--custom:focus-visible {
	box-shadow: 0 0 0 3px var(--bt-yt-progress);
}

.bt-youtube--custom:fullscreen {
	aspect-ratio: auto;
	width: 100%;
	height: 100%;
	border-radius: 0;
}

/*
 * Fullscreen on screens wider than 16:9 (most phones in landscape): limit the
 * player width so the video fits the height instead of being cut off.
 */
.bt-youtube--custom:fullscreen iframe {
	left: 50%;
	width: min(100%, 100vh * 16 / 9);
	transform: translateX(-50%);
}

.bt-youtube--custom.is-idle {
	cursor: none;
}

/*
 * Crop YouTube's own interface. YouTube pins its UI (title, channel avatar,
 * logo, "More videos", pause panel) to the edges of the player, while the
 * video is centred and fitted to the width. A player 3× taller than the box
 * keeps the video exactly in place and pushes all of that UI outside the
 * visible area, where overflow: hidden cuts it off.
 */
.bt-youtube--custom iframe {
	top: -100%;
	bottom: auto;
	height: 300%;
	pointer-events: none;
}

/* captures clicks so YouTube's own overlays (title, "more videos") can't be used */
.bt-youtube__click {
	position: absolute;
	inset: 0;
	cursor: pointer;
}

.bt-youtube__poster {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

/* covers YouTube's own title and end screens before the first play and after the end */
.bt-youtube--custom.is-unstarted .bt-youtube__poster,
.bt-youtube--custom.is-ended .bt-youtube__poster {
	opacity: 1;
}

/* transparent hit area; the visible circle is the shared .bt-youtube__play badge */
.bt-youtube button.bt-youtube__bigplay {
	position: absolute;
	top: 50%;
	left: 50%;
	width: min(var(--bt-yt-play-size), 20%);
	height: auto;
	aspect-ratio: 1;
	border-radius: 50%;
	transform: translate(-50%, -50%);
	cursor: pointer;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.2s ease, visibility 0.2s ease;
}

/* the badge fills the button (its 20% cap is already applied to the button) */
.bt-youtube__bigplay .bt-youtube__play {
	width: 100%;
}

.bt-youtube--custom.is-paused:not(.is-loading) .bt-youtube__bigplay {
	opacity: 1;
	visibility: visible;
}

/* loading: the play button's circle with a spinning ring instead of the icon */
.bt-youtube__spinner {
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
}

.bt-youtube--custom.is-loading .bt-youtube__spinner {
	opacity: 1;
	visibility: visible;
}

.bt-youtube__spinner::after {
	content: "";
	width: 45%;
	height: 45%;
	border: 3px solid var(--bt-yt-play-icon);
	border-right-color: transparent;
	border-radius: 50%;
	animation: bt-youtube-spin 0.8s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.bt-youtube__spinner::after {
		animation-duration: 2.4s;
	}
}

/*
 * The controls are the size container for the @container rules below. They
 * are absolutely positioned edge to edge, so their width never depends on
 * their content (containment on the outer player would collapse it in flex
 * layouts).
 */
.bt-youtube__controls {
	position: absolute;
	right: 0;
	bottom: 0;
	left: 0;
	container-type: inline-size;
	background: linear-gradient(to top, rgba(0, 0, 0, 0.75), rgba(0, 0, 0, 0));
	color: var(--bt-yt-icon);
	font-size: 13px;
	line-height: 1;
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.bt-youtube__bar {
	display: flex;
	align-items: center;
	gap: 12px;
	height: 56px;
	padding: 0 14px;
}

.bt-youtube--custom .bt-youtube__controls {
	opacity: 1;
	visibility: visible;
}

.bt-youtube--custom.is-idle .bt-youtube__controls {
	opacity: 0;
	visibility: hidden;
}

.bt-youtube button.bt-youtube__btn {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 4px;
	border-radius: 4px;
	cursor: pointer;
}

.bt-youtube__btn svg {
	width: 100%;
	height: 100%;
	fill: currentColor;
	/* keeps icons readable over bright video */
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.5));
}

.bt-youtube__time {
	text-shadow: 0 1px 2px rgba(0, 0, 0, 0.5);
}

@media (hover: hover) {
	.bt-youtube button.bt-youtube__btn:hover {
		background: rgba(255, 255, 255, 0.15);
	}
}

.bt-youtube__btn:focus-visible,
.bt-youtube__progress:focus-visible,
.bt-youtube__volume-range:focus-visible {
	outline: 2px solid var(--bt-yt-progress);
	outline-offset: 2px;
}

/* progress bar */
.bt-youtube__progress {
	position: relative;
	flex: 1;
	display: flex;
	align-items: center;
	height: 24px;
	cursor: pointer;
	touch-action: none;
}

.bt-youtube__track {
	position: relative;
	width: 100%;
	height: 4px;
	border-radius: 2px;
	background: var(--bt-yt-track);
	overflow: hidden;
	transition: height 0.15s ease;
}

.bt-youtube--custom.is-scrubbing .bt-youtube__track {
	height: 6px;
}

@media (hover: hover) {
	.bt-youtube__progress:hover .bt-youtube__track {
		height: 6px;
	}

	.bt-youtube__progress:hover .bt-youtube__handle {
		transform: translate(-50%, -50%) scale(1);
	}
}

.bt-youtube__buffer,
.bt-youtube__played {
	position: absolute;
	top: 0;
	bottom: 0;
	left: 0;
	width: 0;
}

.bt-youtube__buffer {
	background: var(--bt-yt-buffer);
}

.bt-youtube__played {
	background: var(--bt-yt-progress);
}

.bt-youtube__handle {
	position: absolute;
	top: 50%;
	left: 0;
	width: 14px;
	height: 14px;
	border-radius: 50%;
	background: var(--bt-yt-progress);
	transform: translate(-50%, -50%) scale(0);
	transition: transform 0.15s ease;
	pointer-events: none;
}

.bt-youtube__progress:focus-visible .bt-youtube__handle,
.bt-youtube--custom.is-scrubbing .bt-youtube__handle {
	transform: translate(-50%, -50%) scale(1);
}

.bt-youtube__time {
	flex: none;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}

/* volume */
.bt-youtube__volume {
	display: flex;
	flex: none;
	align-items: center;
	gap: 6px;
}

.bt-youtube__volume-range {
	--bt-yt-volume: 100%;
	width: 70px;
	height: 4px;
	margin: 0;
	border-radius: 2px;
	background: linear-gradient(to right, var(--bt-yt-icon) var(--bt-yt-volume), var(--bt-yt-track) var(--bt-yt-volume));
	cursor: pointer;
	appearance: none;
	-webkit-appearance: none;
}

.bt-youtube__volume-range::-webkit-slider-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 50%;
	background: var(--bt-yt-icon);
	-webkit-appearance: none;
}

.bt-youtube__volume-range::-moz-range-thumb {
	width: 12px;
	height: 12px;
	border: 0;
	border-radius: 50%;
	background: var(--bt-yt-icon);
}

/* ─── Touch devices ─────────────────────────────────────────────────────── */
@media (pointer: coarse) {
	/* phones/tablets have hardware volume buttons; keep just the mute toggle */
	.bt-youtube__volume-range {
		display: none;
	}

	/* bigger touch targets */
	.bt-youtube button.bt-youtube__btn {
		width: 40px;
		height: 40px;
		padding: 8px;
	}

	.bt-youtube__progress {
		height: 40px;
	}

	/* no hover on touch: always show the handle so the bar reads as draggable */
	.bt-youtube__handle {
		width: 12px;
		height: 12px;
		transform: translate(-50%, -50%) scale(1);
	}

	.bt-youtube--custom.is-scrubbing .bt-youtube__handle {
		transform: translate(-50%, -50%) scale(1.4);
	}
}

/* ─── Small players (phones, narrow columns) ────────────────────────────── */
@container (max-width: 600px) {
	.bt-youtube__bar {
		gap: 4px;
		height: 48px;
		padding: 0 6px;
		font-size: 12px;
	}

	.bt-youtube__progress {
		margin: 0 4px;
	}

	.bt-youtube__volume-range {
		display: none;
	}
}

@container (max-width: 420px) {
	.bt-youtube__bar {
		height: 44px;
	}

	.bt-youtube button.bt-youtube__btn {
		width: 36px;
		height: 36px;
		padding: 7px;
	}

	/* keep the current time, drop the total */
	.bt-youtube__duration {
		display: none;
	}
}

@container (max-width: 280px) {
	.bt-youtube__time {
		display: none;
	}
}
