.dvpip {
	--dvpip-scale: 0.28;
	--dvpip-ratio: 16/9;
	--dvpip-tx: -16px;
	--dvpip-ty: -16px;
	--dvpip-origin: 100% 100%;
	--dvpip-radius: 12px;
	--dvpip-accent: #fff;

	position: relative;
	width: 100%;
	aspect-ratio: var(--dvpip-ratio);
	overflow: hidden;
	background: #000;
	border-radius: 4px;
}

/* ---------- Los dos videos ---------- */

.dvpip__item {
	position: absolute;
	inset: 0;
	transform-origin: var(--dvpip-origin);
	transition: transform 380ms cubic-bezier(.2, .7, .2, 1);
	will-change: transform;
}

.dvpip__item.is-main {
	transform: none;
	z-index: 1;
}

.dvpip__item.is-pip {
	transform: translate(var(--dvpip-tx), var(--dvpip-ty)) scale(var(--dvpip-scale));
	z-index: 2;
	/* Compensamos el escalado para que radio y borde se vean a tamaño real. */
	border-radius: calc(var(--dvpip-radius) / var(--dvpip-scale));
	box-shadow: 0 calc(6px / var(--dvpip-scale)) calc(24px / var(--dvpip-scale)) rgba(0, 0, 0, .45);
	outline: calc(2px / var(--dvpip-scale)) solid rgba(255, 255, 255, .85);
	outline-offset: calc(-2px / var(--dvpip-scale));
	overflow: hidden;
	background: #000;
}

.dvpip__player,
.dvpip__player iframe,
.dvpip__player video {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	border: 0;
	display: block;
}

/* Capa que captura el clic sobre el PiP (el iframe se lo tragaría). */
.dvpip__hit {
	position: absolute;
	inset: 0;
	z-index: 2;
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	cursor: pointer;
	pointer-events: none;
	opacity: 0;
	transition: opacity 180ms ease, background-color 180ms ease;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #fff;
}

.is-pip .dvpip__hit { pointer-events: auto; }

/* Arrastre del PiP */
.dvpip--drag .is-pip .dvpip__hit {
	cursor: grab;
	touch-action: none;
}

.dvpip--drag .is-pip.is-dragging .dvpip__hit {
	cursor: grabbing;
	opacity: 1;
	background-color: rgba(0, 0, 0, .35);
}

/* Mientras se arrastra no queremos la animación de intercambio. */
.dvpip__item.is-dragging {
	transition: none;
	box-shadow: 0 calc(10px / var(--dvpip-scale)) calc(34px / var(--dvpip-scale)) rgba(0, 0, 0, .6);
}

.is-pip .dvpip__hit:hover,
.is-pip .dvpip__hit:focus-visible {
	opacity: 1;
	background-color: rgba(0, 0, 0, .35);
	outline: none;
}

.dvpip__hit-icon {
	width: calc(28px / var(--dvpip-scale));
	height: calc(28px / var(--dvpip-scale));
	display: block;
	filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6));
}

.dvpip__hit-icon svg { width: 100%; height: 100%; }

/* ---------- Botones ---------- */

.dvpip__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	flex: 0 0 auto;
	margin: 0;
	padding: 8px;
	border: 0;
	border-radius: 999px;
	background: transparent;
	color: #fff;
	font: 600 13px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
	cursor: pointer;
	transition: background-color 160ms ease, transform 120ms ease;
}

.dvpip__btn:hover { background: rgba(255, 255, 255, .18); }
.dvpip__btn:active { transform: scale(.92); }

.dvpip__btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 2px rgba(255, 255, 255, .85);
}

.dvpip__btn .dvpip__icon {
	width: 20px;
	height: 20px;
	display: block;
}

/* Qué icono se ve en cada estado. */
.dvpip__icon--pause,
.dvpip__icon--replay,
.dvpip__icon--sound-on,
.dvpip__icon--collapse { display: none; }

.dvpip:not(.is-paused) .dvpip__icon--play { display: none; }
.dvpip:not(.is-paused) .dvpip__icon--pause { display: block; }

.dvpip.is-ended .dvpip__icon--play,
.dvpip.is-ended .dvpip__icon--pause { display: none; }
.dvpip.is-ended .dvpip__icon--replay { display: block; }

.dvpip.is-sound-on .dvpip__icon--sound-off { display: none; }
.dvpip.is-sound-on .dvpip__icon--sound-on { display: block; }

.dvpip.is-fullscreen .dvpip__icon--expand { display: none; }
.dvpip.is-fullscreen .dvpip__icon--collapse { display: block; }

/* ---------- Barra de controles ---------- */

.dvpip__bar {
	position: absolute;
	z-index: 6;
	left: 0;
	right: 0;
	bottom: 0;
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 28px 16px 14px;
	background: linear-gradient(to top, rgba(0, 0, 0, .78) 0%, rgba(0, 0, 0, .45) 55%, transparent 100%);
	opacity: 1;
	transform: translateY(0);
	transition: opacity 220ms ease, transform 220ms ease;
}

.dvpip--autohide.is-idle .dvpip__bar {
	opacity: 0;
	transform: translateY(8px);
	pointer-events: none;
}

.dvpip__time {
	flex: 0 0 auto;
	min-width: 42px;
	color: #fff;
	font: 600 12px/1 system-ui, -apple-system, "Segoe UI", sans-serif;
	font-variant-numeric: tabular-nums;
	text-align: center;
	user-select: none;
}

/* Barra de progreso */
.dvpip__seek {
	--dvpip-progress: 0%;
	flex: 1 1 auto;
	min-width: 40px;
	height: 18px;
	margin: 0;
	padding: 0;
	background: transparent;
	cursor: pointer;
	-webkit-appearance: none;
	appearance: none;
}

.dvpip__seek:disabled { cursor: default; opacity: .5; }
.dvpip__seek:focus { outline: none; }

.dvpip__seek::-webkit-slider-runnable-track {
	height: 4px;
	border-radius: 4px;
	background: linear-gradient(to right, var(--dvpip-accent) var(--dvpip-progress), rgba(255, 255, 255, .3) var(--dvpip-progress));
}

.dvpip__seek::-moz-range-track {
	height: 4px;
	border-radius: 4px;
	background: linear-gradient(to right, var(--dvpip-accent) var(--dvpip-progress), rgba(255, 255, 255, .3) var(--dvpip-progress));
}

.dvpip__seek::-webkit-slider-thumb {
	-webkit-appearance: none;
	appearance: none;
	width: 13px;
	height: 13px;
	margin-top: -4.5px;
	border: 0;
	border-radius: 50%;
	background: var(--dvpip-accent);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
	transition: transform 120ms ease;
}

.dvpip__seek::-moz-range-thumb {
	width: 13px;
	height: 13px;
	border: 0;
	border-radius: 50%;
	background: var(--dvpip-accent);
	box-shadow: 0 1px 4px rgba(0, 0, 0, .5);
}

.dvpip__seek:hover::-webkit-slider-thumb,
.dvpip__seek:focus-visible::-webkit-slider-thumb { transform: scale(1.25); }

/* ---------- Barra suelta (cuando controls="no") ---------- */

.dvpip__ui {
	position: absolute;
	z-index: 5;
	display: flex;
	align-items: center;
	gap: 8px;
}

.dvpip__ui .dvpip__btn {
	padding: 8px 12px;
	background: rgba(0, 0, 0, .55);
	-webkit-backdrop-filter: blur(6px);
	backdrop-filter: blur(6px);
}

.dvpip__ui .dvpip__btn:hover { background: rgba(0, 0, 0, .8); }

.dvpip--corner-top-left .dvpip__ui { top: 16px; left: 16px; }
.dvpip--corner-top-right .dvpip__ui { top: 16px; right: 16px; }
.dvpip--corner-bottom-left .dvpip__ui { bottom: 16px; left: 16px; }
.dvpip--corner-bottom-right .dvpip__ui { bottom: 16px; right: 16px; }

.dvpip.is-sound-on .dvpip__btn-label { display: none; }

/* ---------- Alturas ---------- */

/* Pantalla completa al cargar: rompe el ancho del contenedor de Elementor. */
.dvpip--h-viewport {
	width: 100vw;
	max-width: 100vw;
	height: 100vh;
	height: 100dvh;
	aspect-ratio: auto;
	margin-left: calc(50% - 50vw);
	margin-right: calc(50% - 50vw);
	border-radius: 0;
}

.dvpip--h-fixed {
	height: var(--dvpip-height, 600px);
	aspect-ratio: auto;
}

/* Pantalla completa nativa (botón). */
.dvpip:fullscreen,
.dvpip:-webkit-full-screen {
	width: 100%;
	max-width: none;
	height: 100%;
	margin: 0;
	aspect-ratio: auto;
	border-radius: 0;
}

/* ---------- Cover ---------- */
/* Los iframes no obedecen object-fit, así que agrandamos el reproductor
   hasta cubrir el marco usando unidades de contenedor. */
@supports (width: 1cqw) {
	.dvpip--cover .dvpip__item { container-type: size; }

	.dvpip--cover .dvpip__player iframe {
		inset: auto;
		top: 50%;
		left: 50%;
		transform: translate(-50%, -50%);
		width: max(100cqw, calc(100cqh * var(--dvpip-ratio)));
		height: max(100cqh, calc(100cqw / (var(--dvpip-ratio))));
	}
}

.dvpip--cover .dvpip__player video { object-fit: cover; }

/* ---------- Responsive / accesibilidad ---------- */

@media (max-width: 600px) {
	.dvpip { --dvpip-scale: 0.34; }
	.dvpip__bar { gap: 6px; padding: 24px 10px 10px; }
	.dvpip__time { min-width: 36px; font-size: 11px; }
	.dvpip__btn-label { display: none; }
}

@media (prefers-reduced-motion: reduce) {
	.dvpip__item,
	.dvpip__bar { transition: none; }
}
