/**
 * AES Design Kit v6 — shell dei popup Elementor
 *
 * Il guscio del popup (overlay, superficie, close, spaziatura, scroll) è un
 * default del kit per tutti i popup Elementor. Un popup che gestisce un guscio
 * proprio (drawer, full-bleed, close personalizzato) si esclude con la classe
 * `aes-e-popup--native` in Popup > Avanzate > Classi CSS.
 *
 * I controlli per-popolup restano sovrani: Elementor li emette con
 * `#elementor-popup-modal-<id>`, quindi vincono su questi default.
 */

/* --------------------------------------------------------------------------
   Overlay
   -------------------------------------------------------------------------- */
body.aes-elementor .elementor-popup-modal:not(.aes-e-popup--native) {
	padding: var(--aes-ref-space-5);
	background-color: var(--aes-sys-color-scrim);
}

/* --------------------------------------------------------------------------
   Superficie
   -------------------------------------------------------------------------- */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-widget-content {
	box-sizing: border-box;
	max-width: 100%;
	max-height: calc(100vh - 2 * var(--aes-ref-space-5));
	max-height: calc(100dvh - 2 * var(--aes-ref-space-5));
	background-color: var(--aes-sys-color-surface);
	border: var(--aes-sys-border-width) solid var(--aes-sys-color-border);
	border-radius: 0;
	box-shadow: var(--aes-sys-elevation-overlay);
}

/* L'area scrollabile è `.dialog-message`: il padding sta qui, così il bordo
   della superficie resta fermo durante lo scroll. */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-message {
	max-width: calc(100vw - 2 * var(--aes-ref-space-5));
	max-height: calc(100vh - 2 * var(--aes-ref-space-5));
	max-height: calc(100dvh - 2 * var(--aes-ref-space-5));
	padding: var(--aes-ref-space-6);
	overscroll-behavior: contain;
	scrollbar-color: var(--aes-sys-color-border) transparent;
	scrollbar-width: thin;
}

/* --------------------------------------------------------------------------
   Close
   Base valida sia dentro sia fuori. `display` non viene toccato: Elementor lo
   imposta a flex solo quando il controllo Close Button è attivo.
   -------------------------------------------------------------------------- */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-close-button {
	box-sizing: border-box;
	align-items: center;
	justify-content: center;
	width: var(--aes-ref-control-sm);
	height: var(--aes-ref-control-sm);
	margin: 0;
	padding: 0;
	color: var(--aes-sys-color-text);
	background-color: var(--aes-sys-color-surface);
	border: var(--aes-sys-border-width) solid var(--aes-sys-color-border);
	border-radius: 0;
	box-shadow: var(--aes-sys-elevation-sm);
	font-size: var(--aes-ref-icon-md);
	line-height: 1;
	text-align: center;
	text-decoration: none;
	transition:
		color var(--aes-sys-motion-fast) var(--aes-sys-ease),
		background-color var(--aes-sys-motion-fast) var(--aes-sys-ease),
		border-color var(--aes-sys-motion-fast) var(--aes-sys-ease);
	z-index: 10;
}

/* Posizione flottante solo quando Elementor lascia il close dentro la
   superficie. Con "Outside" il posizionamento è del pannello. */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-widget-content
	> .dialog-close-button {
	top: calc(-1 * var(--aes-ref-space-4));
	inset-inline-end: calc(-1 * var(--aes-ref-space-4));
}

body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-close-button
	svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-close-button:hover {
	color: var(--aes-sys-color-on-action-primary);
	background-color: var(--aes-sys-color-action-primary);
	border-color: var(--aes-sys-color-action-primary);
}

body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native)
	.dialog-close-button:focus-visible {
	color: var(--aes-sys-color-text);
	outline: var(--aes-sys-border-width-strong) solid
		var(--aes-sys-color-focus-ring);
	outline-offset: 3px;
}

/* --------------------------------------------------------------------------
   Varianti
   -------------------------------------------------------------------------- */

/* Contenuti full-bleed (immagini o gallery a filo della superficie). */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native).aes-e-popup--flush
	.dialog-message {
	padding: 0;
}

/* Popup senza oscuramento, per casi non modali. */
body.aes-elementor
	.elementor-popup-modal:not(.aes-e-popup--native).aes-e-popup--no-scrim {
	background-color: transparent;
}

/* --------------------------------------------------------------------------
   Mobile
   -------------------------------------------------------------------------- */
@media (max-width: 767px) {
	body.aes-elementor .elementor-popup-modal:not(.aes-e-popup--native) {
		padding: var(--aes-ref-space-4);
	}

	body.aes-elementor
		.elementor-popup-modal:not(.aes-e-popup--native)
		.dialog-widget-content {
		max-height: calc(100vh - 2 * var(--aes-ref-space-4));
		max-height: calc(100dvh - 2 * var(--aes-ref-space-4));
		box-shadow: var(--aes-sys-elevation-lg);
	}

	body.aes-elementor
		.elementor-popup-modal:not(.aes-e-popup--native)
		.dialog-message {
		max-width: calc(100vw - 2 * var(--aes-ref-space-4));
		max-height: calc(100vh - 2 * var(--aes-ref-space-4));
		max-height: calc(100dvh - 2 * var(--aes-ref-space-4));
		padding: var(--aes-ref-space-5);
	}

	body.aes-elementor
		.elementor-popup-modal:not(.aes-e-popup--native)
		.dialog-widget-content
		> .dialog-close-button {
		top: calc(-1 * var(--aes-ref-space-3));
		inset-inline-end: calc(-1 * var(--aes-ref-space-3));
	}
}

/* Il reset globale del kit copre già `.aes`; questo è il fallback per
   l'anteprima editor, dove il body può non avere ancora la classe `.aes`. */
@media (prefers-reduced-motion: reduce) {
	body.aes-elementor
		.elementor-popup-modal:not(.aes-e-popup--native)
		.dialog-close-button {
		transition: none;
	}
}
