/* Arándano Product Videos — frontend
 * Prefijo apv-, sin resets globales. Variables: --apv-accent (inyectada en línea).
 */

:root {
	--apv-radius: 14px;
	--apv-shadow: 0 18px 40px -12px rgba( 17, 12, 46, 0.35 );
}

/* ---------------------------------------------------------------------------
 * Hover en la tienda
 * ------------------------------------------------------------------------- */
.apv-hover-overlay {
	position: absolute;
	inset: 0;
	overflow: hidden;
	border-radius: inherit;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.45s ease;
	z-index: 2;
}

.apv-hover-overlay video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	transform: scale( 1.02 );
	transition: transform 0.6s ease;
}

.apv-hover-overlay.is-playing {
	opacity: 1;
}

.apv-hover-overlay.is-playing video {
	transform: scale( 1 );
}

/* Indicador de video en mobile (badge) */
.apv-has-badge {
	position: relative;
}

.apv-has-badge > a::after,
.apv-has-badge::after {
	content: "▶";
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 12px;
	color: #fff;
	background: rgba( 0, 0, 0, 0.55 );
	backdrop-filter: blur( 4px );
	border-radius: 50%;
	pointer-events: none;
}

/* ---------------------------------------------------------------------------
 * PiP flotante en el producto
 * ------------------------------------------------------------------------- */
.apv-pip {
	position: fixed;
	bottom: max( 22px, env( safe-area-inset-bottom ) );
	width: 300px;
	max-width: calc( 100vw - 32px );
	z-index: 99990;
	border-radius: var( --apv-pip-radius, 16px );
	background: #ffffff;
	box-shadow: 0 20px 50px -12px rgba( 17, 12, 46, 0.28 ), 0 0 0 1px rgba( 0, 0, 0, 0.04 );
	overflow: hidden;
	opacity: 0;
	visibility: hidden;
	transition: transform 0.55s cubic-bezier( 0.22, 1, 0.36, 1 ), opacity 0.4s ease, visibility 0s linear 0.55s;
}

/* Posición */
.apv-pip--right {
	right: max( 22px, env( safe-area-inset-right ) );
	transform: translate( 130%, 0 );
}

.apv-pip--left {
	left: max( 22px, env( safe-area-inset-left ) );
	transform: translate( -130%, 0 );
}

.apv-pip[data-state="visible"] {
	transform: translate( 0, 0 );
	opacity: 1;
	visibility: visible;
	transition: transform 0.55s cubic-bezier( 0.22, 1, 0.36, 1 ), opacity 0.4s ease;
}

/* Tamaños */
.apv-pip--small { width: 240px; }
.apv-pip--medium { width: 300px; }
.apv-pip--large { width: 360px; }

.apv-pip__inner {
	position: relative;
}

.apv-pip__media {
	position: relative;
	aspect-ratio: 4 / 5;
	background: #f4f4f6;
}

.apv-pip__video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Barra de controles agrupada arriba a la derecha */
.apv-pip__controls {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 4;
	display: flex;
	gap: 6px;
}

.apv-pip__btn {
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 17, 12, 30, 0.5 );
	-webkit-backdrop-filter: blur( 6px );
	backdrop-filter: blur( 6px );
	color: #fff;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.apv-pip__btn:hover {
	background: rgba( 17, 12, 30, 0.8 );
	transform: scale( 1.08 );
}

.apv-pip__btn svg {
	display: block;
}

.apv-pip__body {
	display: flex;
	flex-direction: column;
	gap: 10px;
	padding: 12px 14px 14px;
	background: #fff;
}

.apv-pip__title {
	margin: 0;
	font-size: 14px;
	font-weight: 700;
	line-height: 1.35;
	color: #1b1b20;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.apv-pip__cta {
	display: block;
	width: 100%;
	box-sizing: border-box;
	padding: 11px 16px;
	font-size: 13px;
	font-weight: 800;
	letter-spacing: 0.02em;
	text-align: center;
	text-transform: uppercase;
	text-decoration: none;
	color: #fff;
	background: linear-gradient( 135deg, var( --apv-accent, #ec4899 ), var( --apv-accent-2, #db2777 ) );
	border-radius: 999px;
	box-shadow: 0 8px 18px -6px var( --apv-accent, #ec4899 );
	transition: filter 0.2s ease, transform 0.2s ease, box-shadow 0.2s ease;
}

.apv-pip__cta:hover {
	filter: brightness( 1.07 );
	transform: translateY( -1px );
	box-shadow: 0 12px 22px -6px var( --apv-accent, #ec4899 );
	color: #fff;
}

/* Mobile.
 * Por defecto el PiP NO se muestra en mobile (lo quita el JS) para no tapar
 * las variaciones ni el botón de compra. Si el admin lo activa, hay dos modos:
 * - mini en una esquina (apv-pip--mobile-corner)
 * - barra inferior (apv-pip--mobile-bar)
 */
@media ( max-width: 600px ) {

	/* Modo mini esquina: card chico, elevado para despejar barras fijas de compra. */
	.apv-pip--mobile-corner.apv-pip--small,
	.apv-pip--mobile-corner.apv-pip--medium,
	.apv-pip--mobile-corner.apv-pip--large {
		width: 150px;
		max-width: 45vw;
		bottom: calc( 84px + env( safe-area-inset-bottom ) );
	}

	.apv-pip--mobile-corner.apv-pip--left { left: 12px; right: auto; }
	.apv-pip--mobile-corner.apv-pip--right { right: 12px; left: auto; }

	/* Modo barra inferior: ancho completo, layout horizontal. */
	.apv-pip--mobile-bar {
		right: 12px;
		left: 12px;
		width: auto;
		max-width: none;
		bottom: max( 12px, env( safe-area-inset-bottom ) );
	}

	.apv-pip--mobile-bar.apv-pip--left,
	.apv-pip--mobile-bar.apv-pip--right {
		transform: translate( 0, 130% );
	}

	.apv-pip--mobile-bar[data-state="visible"] {
		transform: translate( 0, 0 );
	}

	.apv-pip--mobile-bar .apv-pip__inner {
		display: flex;
		align-items: stretch;
	}

	.apv-pip--mobile-bar .apv-pip__media {
		flex: 0 0 96px;
		aspect-ratio: auto;
	}

	.apv-pip--mobile-bar .apv-pip__body {
		flex: 1 1 auto;
		justify-content: center;
		padding: 10px 12px;
	}

	.apv-pip--mobile-bar .apv-pip__controls {
		top: 6px;
		right: 6px;
	}
}

/* Accesibilidad: sin animaciones agresivas */
@media ( prefers-reduced-motion: reduce ) {
	.apv-hover-overlay,
	.apv-hover-overlay video,
	.apv-pip,
	.apv-pip__cta,
	.apv-pip__btn {
		transition: none !important;
	}

	.apv-pip,
	.apv-pip--left,
	.apv-pip--right {
		transform: none;
	}
}

/* ---------------------------------------------------------------------------
 * Burbuja de video sobre la imagen principal del producto
 * ------------------------------------------------------------------------- */
.apv-bubble {
	position: absolute;
	bottom: 16px;
	z-index: 20;
	width: 104px;
	aspect-ratio: 3 / 4;
	border-radius: 16px;
	overflow: hidden;
	cursor: pointer;
	background: #000;
	border: 2px solid #fff;
	box-shadow: 0 10px 26px -8px rgba( 17, 12, 46, 0.45 ), 0 0 0 2px var( --apv-accent, #ec4899 );
	transition: width 0.45s cubic-bezier( 0.22, 1, 0.36, 1 ), aspect-ratio 0.45s ease, box-shadow 0.3s ease, transform 0.3s ease;
	-webkit-tap-highlight-color: transparent;
}

.apv-bubble--left { left: 16px; }
.apv-bubble--right { right: 16px; }

.apv-bubble:hover {
	transform: translateY( -2px );
	box-shadow: 0 16px 32px -8px rgba( 17, 12, 46, 0.5 ), 0 0 0 3px var( --apv-accent, #ec4899 );
}

.apv-bubble__video {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
	pointer-events: none;
}

.apv-bubble__label {
	position: absolute;
	left: 0;
	right: 0;
	bottom: 0;
	padding: 14px 8px 7px;
	font-size: 11px;
	font-weight: 700;
	text-align: center;
	color: #fff;
	letter-spacing: 0.02em;
	background: linear-gradient( to top, rgba( 0, 0, 0, 0.7 ), transparent );
	pointer-events: none;
	transition: opacity 0.25s ease;
}

.apv-bubble__close {
	position: absolute;
	top: 7px;
	right: 7px;
	width: 26px;
	height: 26px;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgba( 17, 12, 30, 0.55 );
	-webkit-backdrop-filter: blur( 6px );
	backdrop-filter: blur( 6px );
	color: #fff;
	cursor: pointer;
	transition: background 0.2s ease, transform 0.2s ease;
}

.apv-bubble__close:hover {
	background: rgba( 17, 12, 30, 0.85 );
	transform: scale( 1.08 );
}

/* Pulso sutil para invitar al tap (solo colapsada) */
.apv-bubble::after {
	content: "";
	position: absolute;
	inset: -2px;
	border-radius: inherit;
	box-shadow: 0 0 0 0 var( --apv-accent, #ec4899 );
	animation: apv-pulse 2.6s ease-out infinite;
	pointer-events: none;
}

@keyframes apv-pulse {
	0% { box-shadow: 0 0 0 0 rgba( 236, 72, 153, 0.5 ); }
	70% { box-shadow: 0 0 0 12px rgba( 236, 72, 153, 0 ); }
	100% { box-shadow: 0 0 0 0 rgba( 236, 72, 153, 0 ); }
}

/* Estado expandido */
.apv-bubble.is-expanded {
	width: 260px;
	max-width: calc( 100% - 32px );
	aspect-ratio: 4 / 5;
}

.apv-bubble.is-expanded .apv-bubble__label,
.apv-bubble.is-expanded::after {
	opacity: 0;
	animation: none;
}

.apv-bubble.is-expanded .apv-bubble__close {
	display: flex;
}

@media ( max-width: 600px ) {
	.apv-bubble {
		width: 84px;
		bottom: 12px;
	}
	.apv-bubble--left { left: 12px; }
	.apv-bubble--right { right: 12px; }
	.apv-bubble.is-expanded {
		width: 200px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.apv-bubble,
	.apv-bubble__label,
	.apv-bubble__close {
		transition: none !important;
	}
	.apv-bubble::after {
		animation: none !important;
	}
}
