/* Caramba Moreno Popups — theme-agnostic modal. Namespaced under .cm-popup. */

.cm-popup {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: clamp(12px, 4vw, 32px);
	box-sizing: border-box;
}

.cm-popup[hidden] { display: none !important; }

/* 9-point position grid (set by the Popup Wrapper block). */
.cm-popup--pos-top-left      { align-items: flex-start; justify-content: flex-start; }
.cm-popup--pos-top-center    { align-items: flex-start; justify-content: center; }
.cm-popup--pos-top-right     { align-items: flex-start; justify-content: flex-end; }
.cm-popup--pos-center-left   { align-items: center; justify-content: flex-start; }
.cm-popup--pos-center        { align-items: center; justify-content: center; }
.cm-popup--pos-center-right  { align-items: center; justify-content: flex-end; }
.cm-popup--pos-bottom-left   { align-items: flex-end; justify-content: flex-start; }
.cm-popup--pos-bottom-center { align-items: flex-end; justify-content: center; }
.cm-popup--pos-bottom-right  { align-items: flex-end; justify-content: flex-end; }

.cm-popup__overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, 0.55); /* default; the wrapper block overrides via inline style */
	cursor: pointer;
	animation: cm-popup-fade 0.18s ease-out;
}

/* Positioning wrapper that holds the close button + the dialog box. */
.cm-popup__frame {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 480px;
	display: flex;
}

/* The block-driven dialog box (Popup Wrapper) — structural only; the block
 * supplies background, radius, padding, shadow, etc. */
.cm-popup__box {
	width: 100%;
	max-height: calc(100vh - 32px);
	overflow: auto;
	box-sizing: border-box;
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
	animation: cm-popup-pop 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

/* Fallback dialog for popups without a wrapper block. */
.cm-popup__dialog {
	width: 100%;
	max-height: calc(100vh - 32px);
	overflow: auto;
	box-sizing: border-box;
	background: #fff;
	color: inherit;
	border-radius: 10px;
	padding: clamp(20px, 4vw, 36px);
	box-shadow: 0 18px 60px rgba(0, 0, 0, 0.32);
	animation: cm-popup-pop 0.2s cubic-bezier(0.2, 0.8, 0.3, 1);
}

.cm-popup__close {
	position: absolute;
	top: 8px;
	right: 10px;
	z-index: 2;
	width: 36px;
	height: 36px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	font-size: 26px;
	line-height: 1;
	color: #444;
	background: rgba(255, 255, 255, 0.85);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.cm-popup__close:hover,
.cm-popup__close:focus-visible {
	background: #fff;
	color: #000;
	outline: none;
}

.cm-popup__content > :first-child,
.cm-popup__box > :first-child { margin-top: 0; }
.cm-popup__content > :last-child,
.cm-popup__box > :last-child { margin-bottom: 0; }

body.cm-popup-open { overflow: hidden; }

/* Inline "close popup" text triggers (the Button block handles its own cursor). */
.cm-popup-close-trigger { cursor: pointer; }

@keyframes cm-popup-fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes cm-popup-pop {
	from { opacity: 0; transform: translateY(12px) scale(0.98); }
	to   { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
	.cm-popup__overlay,
	.cm-popup__box,
	.cm-popup__dialog { animation: none; }
}
