/**
 * Kreiva Popups — estilos del frente.
 *
 * Todas las clases van con prefijo kvpop- para no chocar con el tema del
 * cliente. Las propiedades se declaran de forma explícita (sin heredar del
 * tema) en los elementos que importan, para que un tema agresivo no deforme el
 * popup.
 */

html.kvpop-open {
	overflow: hidden;
}

.kvpop-overlay {
	position: fixed;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: var(--kvpop-overlay, rgba(0, 0, 0, 0.6));
	opacity: 0;
	transition: opacity 0.2s ease;
	box-sizing: border-box;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

.kvpop-overlay.is-visible {
	opacity: 1;
}

.kvpop-overlay *,
.kvpop-overlay *::before,
.kvpop-overlay *::after {
	box-sizing: border-box;
}

.kvpop-box {
	position: relative;
	width: 100%;
	/* Ancho pedido, pero sin pasar del tope en porcentaje de pantalla.
	   La primera línea es el respaldo para navegadores sin min(): se queda con
	   el ancho en píxeles, que es lo razonable si no puede comparar. */
	max-width: var(--kvpop-width, 520px);
	max-width: min( var(--kvpop-width, 520px), var(--kvpop-max-width, 92vw) );
	margin: auto;
	background: var(--kvpop-bg, #ffffff);
	color: var(--kvpop-color, #1a1a1a);
	border-radius: var(--kvpop-radius, 8px);
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
	overflow: hidden;
	transform: translateY(12px) scale(0.98);
	transition: transform 0.2s ease;
	font-family: inherit;
	line-height: 1.5;
	text-align: left;
}

.kvpop-overlay.is-visible .kvpop-box {
	transform: translateY(0) scale(1);
}

/* Botón de cerrar
   ------------------------------------------------------------------------ */

.kvpop-close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.9);
	color: #1a1a1a;
	cursor: pointer;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
	transition: background 0.15s ease, transform 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.kvpop-close:hover {
	background: #ffffff;
	transform: scale(1.05);
}

.kvpop-close:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

/* Imagen
   ------------------------------------------------------------------------ */

.kvpop-img {
	display: block;
	width: 100%;
	height: auto;
	max-width: 100%;
	margin: 0;
	border: 0;
	border-radius: 0;
}

/* Alto fijo del popup
   ------------------------------------------------------------------------ */

.kvpop-box--alto {
	height: var(--kvpop-height);
	height: min( var(--kvpop-height), 90vh );
	display: flex;
	flex-direction: column;
}

/* Con alto fijo, el cuerpo se desplaza si el contenido no entra. */
.kvpop-box--alto .kvpop-body {
	flex: 1 1 auto;
	overflow-y: auto;
	min-height: 0;
}

.kvpop-box--alto .kvpop-img {
	flex: 0 0 auto;
}

.kvpop-box--alto .kvpop-caption {
	flex: 0 0 auto;
}

/* Imagen con proporción fija
   ------------------------------------------------------------------------ */

.kvpop-img--ratio {
	aspect-ratio: var(--kvpop-ratio);
	object-fit: cover;
	object-position: center;
}

/* Imagen de fondo, con el contenido encima
   ------------------------------------------------------------------------ */

.kvpop-box--bg {
	display: grid;
	grid-template-rows: 1fr auto;
	/* El alto configurado, pero sin comerse la pantalla en un celular chico. */
	min-height: var(--kvpop-min-height, 420px);
	min-height: min( var(--kvpop-min-height, 420px), 70vh );
	background-image: var(--kvpop-image);
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
}

/* Con proporción elegida manda esa y no el alto mínimo. */
.kvpop-box--bg.kvpop-box--ratio {
	aspect-ratio: var(--kvpop-ratio);
	min-height: 0;
}

/* El alto fijo le gana a todo lo anterior. */
.kvpop-box--bg.kvpop-box--alto {
	display: grid;
	aspect-ratio: auto;
	min-height: 0;
}

/* Capa de oscurecido, para que el texto se lea sobre fotos claras. */
.kvpop-box--bg::before {
	content: "";
	position: absolute;
	inset: 0;
	top: 0;
	right: 0;
	bottom: 0;
	left: 0;
	background: var(--kvpop-scrim, rgba(0, 0, 0, 0.35));
	pointer-events: none;
}

.kvpop-box--bg .kvpop-body {
	position: relative;
	z-index: 1;
	max-width: 85%;
	/* Sombra suave: ayuda a leer si la foto tiene zonas claras y oscuras. */
	text-shadow: 0 1px 3px rgba(0, 0, 0, 0.35);
}

.kvpop-box--bg .kvpop-btn {
	text-shadow: none;
}

/* Las nueve posiciones. La primera palabra es el eje vertical y la segunda el
   horizontal; el texto se alinea para el mismo lado donde se apoya. */
.kvpop-box--bg[data-kvpop-pos^="top-"] .kvpop-body { align-self: start; }
.kvpop-box--bg[data-kvpop-pos^="middle-"] .kvpop-body { align-self: center; }
.kvpop-box--bg[data-kvpop-pos^="bottom-"] .kvpop-body { align-self: end; }

.kvpop-box--bg[data-kvpop-pos$="-left"] .kvpop-body { justify-self: start; text-align: left; }
.kvpop-box--bg[data-kvpop-pos$="-center"] .kvpop-body { justify-self: center; text-align: center; }
.kvpop-box--bg[data-kvpop-pos$="-right"] .kvpop-body { justify-self: end; text-align: right; }

.kvpop-box--bg[data-kvpop-pos$="-center"] .kvpop-countdown { justify-content: center; }
.kvpop-box--bg[data-kvpop-pos$="-left"] .kvpop-countdown { justify-content: flex-start; }
.kvpop-box--bg[data-kvpop-pos$="-right"] .kvpop-countdown { justify-content: flex-end; }

/* Sobre una foto, los recuadros del contador necesitan más cuerpo. */
.kvpop-box--bg .kvpop-cd-unit {
	backdrop-filter: blur(2px);
}

/* Deja aire para que el botón de cerrar no pise el contenido de arriba. */
.kvpop-box--bg[data-kvpop-pos="top-right"] .kvpop-body,
.kvpop-box--bg[data-kvpop-pos="top-center"] .kvpop-body {
	padding-top: 52px;
}

/* Cuerpo
   ------------------------------------------------------------------------ */

.kvpop-body {
	padding: 26px 28px 28px;
}

.kvpop-content > *:first-child {
	margin-top: 0;
}

.kvpop-content > *:last-child {
	margin-bottom: 0;
}

.kvpop-content p {
	margin: 0 0 0.8em;
	color: inherit;
}

.kvpop-content h1,
.kvpop-content h2,
.kvpop-content h3,
.kvpop-content h4 {
	margin: 0 0 0.5em;
	color: inherit;
	line-height: 1.2;
}

.kvpop-content a {
	color: inherit;
	text-decoration: underline;
}

.kvpop-content img {
	max-width: 100%;
	height: auto;
}

/* Cuenta regresiva
   ------------------------------------------------------------------------ */

.kvpop-countdown {
	display: flex;
	gap: 10px;
	justify-content: center;
	margin: 20px 0 4px;
	flex-wrap: wrap;
}

.kvpop-cd-unit {
	display: flex;
	flex-direction: column;
	align-items: center;
	min-width: 62px;
	padding: 10px 8px;
	border-radius: 6px;
	background: var(--kvpop-cd-bg, rgba(0, 0, 0, 0.06));
	color: var(--kvpop-cd-color, inherit);
}

.kvpop-cd-value {
	font-size: 26px;
	font-weight: 700;
	line-height: 1;
	color: inherit;
	font-variant-numeric: tabular-nums;
}

.kvpop-cd-label {
	margin-top: 4px;
	font-size: 11px;
	line-height: 1;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	opacity: 0.7;
	color: inherit;
}

/* Franja de color al pie
   ------------------------------------------------------------------------ */

.kvpop-caption {
	position: relative;
	z-index: 2;
	padding: 13px 20px;
	font-size: 19px;
	font-weight: 700;
	line-height: 1.25;
	text-align: center;
	letter-spacing: 0.01em;
	text-shadow: none;
}

@media (max-width: 600px) {
	.kvpop-caption {
		padding: 11px 16px;
		font-size: 16px;
	}
}

/* Botón
   ------------------------------------------------------------------------ */

.kvpop-btn {
	display: inline-block;
	margin-top: 20px;
	padding: 13px 26px;
	border: 0;
	border-radius: 6px;
	background: var(--kvpop-btn-bg, #0e5a54);
	color: var(--kvpop-btn-color, #ffffff);
	font-size: 15px;
	font-weight: 600;
	font-family: inherit;
	line-height: 1.2;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: filter 0.15s ease;
	-webkit-appearance: none;
	appearance: none;
}

.kvpop-btn:hover,
.kvpop-btn:focus {
	filter: brightness(1.12);
	color: var(--kvpop-btn-color, #ffffff);
	text-decoration: none;
}

.kvpop-btn:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 3px;
}

/* Celular
   ------------------------------------------------------------------------ */

@media (max-width: 600px) {
	.kvpop-overlay {
		padding: 12px;
	}

	.kvpop-body {
		padding: 20px 20px 22px;
	}

	.kvpop-cd-unit {
		min-width: 54px;
		padding: 8px 6px;
	}

	.kvpop-cd-value {
		font-size: 22px;
	}

	/* Con la imagen de fondo en un celular no sobra ancho: el contenido usa
	   todo el que hay y el padding hace de margen. */
	.kvpop-box--bg .kvpop-body {
		max-width: 100%;
	}

	.kvpop-box--bg[data-kvpop-pos="top-right"] .kvpop-body,
	.kvpop-box--bg[data-kvpop-pos="top-center"] .kvpop-body {
		padding-top: 46px;
	}
}

/* Respeta la preferencia de menos movimiento
   ------------------------------------------------------------------------ */

@media (prefers-reduced-motion: reduce) {
	.kvpop-overlay,
	.kvpop-box,
	.kvpop-close,
	.kvpop-btn {
		transition: none;
	}

	.kvpop-box {
		transform: none;
	}
}
