/**
 * UF Video — Auto Scroll Sticky PiP Styles (loads after assets/css/ufl-media.css)
 */

/* Stage wrapper keeps exact geometry inside .ufl-video so layout NEVER jumps */
.ufl-video__stage {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border-radius: var(--ufl-vd-radius, var(--ufl-r-md, 12px));
	overflow: hidden;
	background: #0f172a;
	line-height: 0;
}

/* Placeholder slot revealed only while stage floats in PiP */
.ufl-video__placeholder {
	position: absolute;
	inset: 0;
	z-index: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 0.6rem;
	padding: 1.25rem;
	text-align: center;
	background:
		radial-gradient(
			420px circle at 50% 35%,
			color-mix(in srgb, var(--ufl-primary, #446084) 24%, transparent),
			transparent 70%
		),
		#0f172a;
	border: 1px dashed rgba(255, 255, 255, 0.2);
	border-radius: var(--ufl-vd-radius, var(--ufl-r-md, 12px));
	color: rgba(241, 245, 249, 0.85);
	line-height: 1.4;
	opacity: 0;
	pointer-events: none;
	transition: opacity 220ms var(--ufl-ease, ease);
}

.ufl-video__placeholder-icon {
	display: grid;
	place-items: center;
	width: 44px;
	height: 44px;
	border-radius: var(--ufl-r-pill, 9999px);
	background: rgba(255, 255, 255, 0.08);
	border: 1px solid rgba(255, 255, 255, 0.14);
	color: #f8fafc;
}

.ufl-video__placeholder-text {
	font-size: 0.86rem;
	font-weight: 500;
	color: rgba(241, 245, 249, 0.78);
}

.ufl-video__placeholder-btn {
	appearance: none;
	-webkit-appearance: none;
	margin: 0.15rem 0 0;
	padding: 0.42rem 0.92rem;
	min-height: 32px;
	border-radius: var(--ufl-r-pill, 9999px);
	border: 1px solid rgba(255, 255, 255, 0.24);
	background: rgba(255, 255, 255, 0.1);
	color: #ffffff;
	font-size: 0.76rem;
	font-weight: 600;
	line-height: 1.2;
	text-transform: none;
	cursor: pointer;
	transition:
		background-color 180ms ease,
		border-color 180ms ease,
		transform 180ms ease;
}

.ufl-video__placeholder-btn:hover,
.ufl-video__placeholder-btn:focus-visible {
	background: var(--ufl-primary, #446084);
	border-color: transparent;
	transform: translateY(-1px);
	outline: none;
}

/* PiP floating control bar (hidden in docked inline state) */
.ufl-video__pip-bar {
	position: absolute;
	top: 8px;
	left: 8px;
	right: 8px;
	z-index: 8;
	display: none;
	align-items: center;
	justify-content: space-between;
	gap: 8px;
	pointer-events: none;
	line-height: 1;
}

.ufl-video__pip-badge {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 5px 10px;
	border-radius: var(--ufl-r-pill, 9999px);
	background: rgba(15, 23, 42, 0.78);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	border: 1px solid rgba(255, 255, 255, 0.18);
	color: #f8fafc;
	font-size: 0.7rem;
	font-weight: 600;
	letter-spacing: 0.02em;
	line-height: 1.1;
	pointer-events: none;
	opacity: 0;
	transform: translateY(-3px);
	transition:
		opacity 200ms var(--ufl-ease, ease),
		transform 200ms var(--ufl-ease, ease);
}

.ufl-video__pip-dot {
	width: 6px;
	height: 6px;
	border-radius: 9999px;
	background: var(--ufl-secondary, #d26e4b);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--ufl-secondary, #d26e4b) 35%, transparent);
	flex-shrink: 0;
}

.ufl-video__pip-actions {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	margin-left: auto;
	pointer-events: auto;
}

.ufl-video__pip-btn {
	appearance: none;
	-webkit-appearance: none;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	margin: 0;
	min-height: 30px;
	height: 30px;
	padding: 0 10px;
	border-radius: var(--ufl-r-pill, 9999px);
	border: 1px solid rgba(255, 255, 255, 0.22);
	background: rgba(15, 23, 42, 0.84);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	color: #ffffff;
	font-size: 0.72rem;
	font-weight: 600;
	line-height: 1;
	letter-spacing: 0.01em;
	text-transform: none;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(2, 6, 23, 0.36);
	transition:
		background-color 160ms ease,
		border-color 160ms ease,
		transform 160ms ease;
}

.ufl-video__pip-btn--close {
	width: 30px;
	padding: 0;
	font-size: 18px;
	font-weight: 500;
}

.ufl-video__pip-btn:hover,
.ufl-video__pip-btn:focus-visible {
	background: var(--ufl-primary, #446084);
	border-color: rgba(255, 255, 255, 0.4);
	transform: scale(1.04);
	outline: none;
}

.ufl-video__pip-btn--close:hover,
.ufl-video__pip-btn--close:focus-visible {
	background: var(--ufl-danger, #dc2626);
}

.ufl-video__pip-btn-text {
	white-space: nowrap;
}

/* ==========================================================================
   Active Sticky PiP State
   ========================================================================== */
@keyframes ufl-vd-pip-in {
	from {
		opacity: 0;
		transform: translate3d(0, 14px, 0) scale(0.94);
	}
	to {
		opacity: 1;
		transform: translate3d(0, 0, 0) scale(1);
	}
}

.ufl-video.is-pip-active {
	overflow: visible;
	background: transparent;
	box-shadow: none;
}

.ufl-video.is-pip-active .ufl-video__placeholder {
	opacity: 1;
	pointer-events: auto;
}

.ufl-video.is-pip-active .ufl-video__stage {
	position: fixed;
	inset: auto;
	z-index: 99990;
	width: min(var(--ufl-vd-pip-w, 360px), calc(100vw - 32px));
	height: auto;
	aspect-ratio: 16 / 9;
	border-radius: var(--ufl-r-md, 12px);
	border: 1px solid rgba(255, 255, 255, 0.18);
	box-shadow:
		0 18px 44px -10px rgba(2, 6, 23, 0.56),
		0 4px 14px rgba(2, 6, 23, 0.28),
		0 0 0 1px rgba(15, 23, 42, 0.4);
	animation: ufl-vd-pip-in 260ms var(--ufl-ease, cubic-bezier(0.22, 1, 0.36, 1)) both;
}

.ufl-video--4x3.is-pip-active .ufl-video__stage  { aspect-ratio: 4 / 3; }
.ufl-video--1x1.is-pip-active .ufl-video__stage  { aspect-ratio: 1 / 1; width: min(var(--ufl-vd-pip-w, 360px), 280px, calc(100vw - 32px)); }
.ufl-video--9x16.is-pip-active .ufl-video__stage { aspect-ratio: 9 / 16; width: min(var(--ufl-vd-pip-w, 360px), 210px, calc(100vw - 32px)); }

/* Corner Positioning */
.ufl-video--pip-bottom-right.is-pip-active .ufl-video__stage {
	right: 20px;
	bottom: 20px;
}

.ufl-video--pip-bottom-left.is-pip-active .ufl-video__stage {
	left: 20px;
	bottom: 20px;
}

.ufl-video--pip-top-right.is-pip-active .ufl-video__stage {
	right: 20px;
	top: 24px;
}

.ufl-video--pip-top-left.is-pip-active .ufl-video__stage {
	left: 20px;
	top: 24px;
}

body.admin-bar .ufl-video--pip-top-right.is-pip-active .ufl-video__stage,
body.admin-bar .ufl-video--pip-top-left.is-pip-active .ufl-video__stage {
	top: 52px;
}

/* Reveal floating controls when PiP is active */
.ufl-video.is-pip-active .ufl-video__pip-bar {
	display: flex;
}

.ufl-video.is-pip-active .ufl-video__stage:hover .ufl-video__pip-badge,
.ufl-video.is-pip-active .ufl-video__stage:focus-within .ufl-video__pip-badge {
	opacity: 1;
	transform: translateY(0);
}

/* ==========================================================================
   Tiny Viewports (< 640px) — Compact Docked Bottom Bar (Never Covers Screen)
   ========================================================================== */
@media (max-width: 639.98px) {
	.ufl-video.is-pip-active .ufl-video__stage,
	.ufl-video--4x3.is-pip-active .ufl-video__stage,
	.ufl-video--1x1.is-pip-active .ufl-video__stage,
	.ufl-video--9x16.is-pip-active .ufl-video__stage {
		left: 10px;
		right: 10px;
		bottom: 10px;
		top: auto;
		width: auto;
		max-width: none;
		height: 76px;
		aspect-ratio: auto;
		display: flex;
		align-items: center;
		background: rgba(15, 23, 42, 0.94);
		backdrop-filter: blur(14px);
		-webkit-backdrop-filter: blur(14px);
		border-color: rgba(255, 255, 255, 0.16);
	}

	.ufl-video.is-pip-active .ufl-video__frame,
	.ufl-video.is-pip-active .ufl-video__player,
	.ufl-video.is-pip-active .ufl-video__facade {
		top: 6px;
		left: 6px;
		bottom: 6px;
		right: auto;
		width: 114px;
		height: calc(100% - 12px);
		border-radius: 7px;
	}

	.ufl-video.is-pip-active .ufl-video__play {
		width: 34px;
		height: 34px;
		padding-left: 2px;
	}

	.ufl-video.is-pip-active .ufl-video__play svg {
		width: 16px;
		height: 16px;
	}

	.ufl-video.is-pip-active .ufl-video__pip-bar {
		position: relative;
		top: auto;
		left: auto;
		right: auto;
		flex: 1 1 auto;
		padding: 0 10px 0 130px;
		pointer-events: auto;
	}

	.ufl-video.is-pip-active .ufl-video__pip-badge {
		opacity: 1;
		transform: none;
		background: transparent;
		border: 0;
		padding: 0;
		backdrop-filter: none;
		-webkit-backdrop-filter: none;
		font-size: 0.78rem;
	}

	.ufl-video.is-pip-active .ufl-video__pip-btn--back {
		width: 34px;
		height: 34px;
		padding: 0;
	}

	.ufl-video.is-pip-active .ufl-video__pip-btn--close {
		width: 34px;
		height: 34px;
	}

	.ufl-video.is-pip-active .ufl-video__pip-btn-text {
		display: none;
	}
}

/* ==========================================================================
   UX Builder Iframe Safety & Reduced Motion
   ========================================================================== */
body.ux-builder-iframe .ufl-video.is-pip-active .ufl-video__stage {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	animation: none;
}

body.ux-builder-iframe .ufl-video__pip-bar,
body.ux-builder-iframe .ufl-video__placeholder {
	display: none !important;
}

@media (prefers-reduced-motion: reduce) {
	.ufl-video.is-pip-active .ufl-video__stage,
	.ufl-video__placeholder,
	.ufl-video__pip-badge,
	.ufl-video__pip-btn {
		animation: none !important;
		transition: none !important;
	}
}
