/* CESINE Popup – estilos frontend */
.csp-overlay {
	--csp-accent: #4B7D8C;
	--csp-black: #0A0A0A;
	--csp-radius: 16px;
	position: fixed;
	inset: 0;
	z-index: 99999;
	display: flex;
	align-items: flex-end;            /* móvil: bottom sheet */
	justify-content: center;
	background: rgba(10, 10, 10, 0);
	-webkit-backdrop-filter: blur(0);
	backdrop-filter: blur(0);
	opacity: 0;
	visibility: hidden;
	transition: opacity .3s ease, visibility 0s .3s, background .3s ease, backdrop-filter .3s ease;
	padding: 0;
	padding-bottom: env(safe-area-inset-bottom);
}
.csp-overlay.is-open {
	opacity: 1;
	visibility: visible;
	background: rgba(10, 10, 10, .55);
	-webkit-backdrop-filter: blur(3px);
	backdrop-filter: blur(3px);
	transition: opacity .3s ease, visibility 0s, background .3s ease, backdrop-filter .3s ease;
}

.csp-dialog {
	position: relative;
	width: 100%;
	max-width: 100%;
	max-height: calc(100dvh - 24px);
	max-height: calc(100vh - 24px);
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: #fff;
	color: var(--csp-black);
	border-radius: var(--csp-radius) var(--csp-radius) 0 0;
	box-shadow: 0 -8px 40px rgba(0, 0, 0, .25);
	transform: translateY(24px);
	transition: transform .35s cubic-bezier(.2, .8, .2, 1);
	font-family: inherit;
	outline: none;
}
.csp-overlay.is-open .csp-dialog { transform: translateY(0); }

.csp-close {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
	width: 44px;
	height: 44px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: rgba(255, 255, 255, .92);
	color: var(--csp-black);
	cursor: pointer;
	padding: 0;
	box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
	-webkit-tap-highlight-color: transparent;
}
.csp-close:hover, .csp-close:focus-visible { background: var(--csp-accent); color: #fff; outline: none; }

/* Layout: el diálogo es una columna flex. El cuerpo (título, texto, botones) ocupa su
   altura natural y la imagen se encoge al espacio restante sin recortarse, de modo que
   todo cabe en pantalla aunque la imagen sea vertical. */
.csp-dialog { display: flex; flex-direction: column; }
.csp-media {
	flex: 0 1 auto;
	min-height: 0;
	line-height: 0;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	background: #fff;
	border-radius: var(--csp-radius) var(--csp-radius) 0 0;
	overflow: hidden;
}
.csp-media img {
	display: block;
	width: auto;
	max-width: 100%;
	height: auto;
	max-height: 60vh;                  /* el JS ajusta este tope al espacio libre real */
	object-fit: contain;
}
/* Modo recorte (opcional): limita la altura y recorta por el centro */
.csp-dialog--fit-cover .csp-media img { width: 100%; max-height: 42vh; object-fit: cover; }

.csp-body { flex: 0 0 auto; padding: 22px 20px calc(22px + env(safe-area-inset-bottom)); }
.csp-dialog--img-none .csp-body { padding-top: 56px; }

.csp-title {
	margin: 0 0 10px;
	font-size: clamp(1.25rem, 1.05rem + 1vw, 1.6rem);
	line-height: 1.2;
	font-weight: 700;
	color: var(--csp-black);
	padding-right: 36px;
}
.csp-text { font-size: 1rem; line-height: 1.5; color: #333; }
.csp-text p { margin: 0 0 .6em; }
.csp-text p:last-child { margin-bottom: 0; }
.csp-text a { color: var(--csp-accent); text-decoration: underline; }

.csp-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
	margin-top: 18px;
}
.csp-actions > * { width: 100%; box-sizing: border-box; text-align: center; }

/* Estilo propio: solo se aplica cuando no se indica clase del tema */
.csp-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 48px;
	padding: 12px 22px;
	border-radius: 999px;
	font: inherit;
	font-weight: 600;
	font-size: 1rem;
	line-height: 1.2;
	text-decoration: none;
	cursor: pointer;
	border: 2px solid var(--csp-accent);
	transition: background .2s ease, color .2s ease, border-color .2s ease, transform .15s ease;
	-webkit-tap-highlight-color: transparent;
}
.csp-btn--primary { background: var(--csp-accent); color: #fff; }
.csp-btn--primary:hover, .csp-btn--primary:focus-visible { background: var(--csp-black); border-color: var(--csp-black); color: #fff; }
.csp-btn--secondary { background: transparent; color: var(--csp-accent); }
.csp-btn--secondary:hover, .csp-btn--secondary:focus-visible { background: var(--csp-accent); color: #fff; }
.csp-btn:active { transform: translateY(1px); }
.csp-btn:focus-visible { outline: 3px solid rgba(75, 125, 140, .4); outline-offset: 2px; }

/* Bloqueo de scroll del fondo (compatible iOS) */
html.csp-lock, html.csp-lock body { overflow: hidden !important; }
html.csp-lock body { position: fixed; width: 100%; left: 0; right: 0; }

/* ---------- Tablet / escritorio ---------- */
@media (min-width: 641px) {
	.csp-overlay { align-items: center; padding: 24px; }
	.csp-dialog {
		max-width: 560px;
		max-height: calc(100vh - 48px);
		border-radius: var(--csp-radius);
		transform: translateY(16px) scale(.98);
		box-shadow: 0 24px 64px rgba(0, 0, 0, .35);
	}
	.csp-overlay.is-open .csp-dialog { transform: none; }
	.csp-dialog--fit-cover .csp-media img { max-height: 320px; }
	.csp-body { padding: 28px 32px 32px; }
	.csp-dialog--img-none .csp-body { padding-top: 48px; }
	.csp-actions { flex-direction: row; flex-wrap: wrap; }
	.csp-actions > * { width: auto; flex: 1 1 auto; }

	/* Imagen a la izquierda */
	.csp-dialog--img-left { max-width: 820px; display: grid; grid-template-columns: 42% 1fr; }
	.csp-dialog--img-left .csp-media { height: 100%; }
	.csp-dialog--img-left .csp-media img { height: 100%; max-height: none; border-radius: var(--csp-radius) 0 0 var(--csp-radius); }
	.csp-dialog--img-left.csp-dialog--fit-cover .csp-media img { object-fit: cover; min-height: 320px; }
	.csp-dialog--img-left.csp-dialog--fit-contain .csp-media { display: flex; align-items: center; background: #f2f2f2; border-radius: var(--csp-radius) 0 0 var(--csp-radius); }
	.csp-dialog--img-left.csp-dialog--fit-contain .csp-media img { height: auto; }
	.csp-dialog--img-left .csp-body { display: flex; flex-direction: column; justify-content: center; }
}

@media (prefers-reduced-motion: reduce) {
	.csp-overlay, .csp-dialog, .csp-btn { transition: none !important; }
}
