/* WPP Smart Modals */

.smart-modal {
	--smodal-width: 720px;
	--smodal-backdrop: rgba(0, 0, 0, 0.6);
	/* Minimo 20px: lascia spazio alla X che sborda dall'angolo del pannello. */
	--smodal-gutter: clamp(20px, 4vw, 40px);
	--smodal-duration: 0.3s;

	/* Il <dialog> stesso fa da overlay a tutto schermo: ::backdrop non eredita in modo
	   affidabile le custom properties dall'attributo style su tutti i browser. */
	position: fixed;
	inset: 0;
	box-sizing: border-box;
	width: 100%;
	height: 100%;
	max-width: none;
	max-height: none;
	margin: 0;
	padding: var(--smodal-gutter);
	border: 0;
	background: var(--smodal-backdrop);
	color: inherit;
	overflow: hidden;
	opacity: 0;
	transition: opacity var(--smodal-duration) ease;
}

.smart-modal[open] {
	display: flex;
	align-items: center;
	justify-content: center;
}

.smart-modal::backdrop {
	background: transparent;
}

.smart-modal.is-visible {
	opacity: 1;
}

.smart-modal__panel {
	position: relative;
	box-sizing: border-box;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-width: var(--smodal-width);
	max-height: 100%;
	padding: clamp(24px, 4vw, 48px);
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 24px 64px rgba(0, 0, 0, 0.25);
	transition: transform var(--smodal-duration) cubic-bezier(0.2, 0.8, 0.2, 1);
}

.smart-modal__panel:focus {
	outline: none;
}

/* Lo scroll sta nel body e non nel pannello, così la X resta sempre visibile. */
.smart-modal__body {
	flex: 1 1 auto;
	min-height: 0;
	overflow-y: auto;
	/* Row e colonne del tema usano margini negativi per i gutter e le animazioni
	   d'ingresso partono traslate di lato: sporgono di pochi px e farebbero
	   comparire lo scroll orizzontale. Si taglia solo spazio vuoto. */
	overflow-x: hidden;
	overscroll-behavior: contain;
	/* Nuovo stacking context: slider e immagini del tema con z-index alti restano
	   confinati qui dentro e non possono più coprire la X. */
	position: relative;
	z-index: 0;
	isolation: isolate;
}

/* I margini laterali negativi restano quelli del tema (allineano il contenuto al
   bordo del pannello); quello in fondo lascerebbe solo spazio vuoto. */
.smart-modal__body > .wpb_row,
.smart-modal-editor .smart-modal__panel > .wpb_row {
	margin-bottom: 0;
}

.smart-modal__body .wpb_column > .vc_column-inner > .wpb_wrapper > :last-child {
	margin-bottom: 0;
}

/* Copre il contenuto finché la prima immagine non è pronta. Eredita lo sfondo del
   pannello (anche quello delle Design Options) e sta sotto la X. */
.smart-modal__loader {
	position: absolute;
	inset: 0;
	z-index: 0;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: inherit;
	background: inherit;
	opacity: 0;
	visibility: hidden;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

/* Grigio semitrasparente: leggibile su pannelli chiari, scuri e colorati. */
.smart-modal__loader::after {
	content: "";
	box-sizing: border-box;
	width: 36px;
	height: 36px;
	border: 3px solid rgba(128, 128, 128, 0.25);
	border-top-color: rgba(128, 128, 128, 0.9);
	border-radius: 50%;
	animation: smart-modal-spin 0.8s linear infinite;
}

.smart-modal__panel.is-loading > .smart-modal__loader {
	opacity: 1;
	visibility: visible;
	pointer-events: auto;
	transition: opacity 0.25s ease;
}

@keyframes smart-modal-spin {
	to {
		transform: rotate(360deg);
	}
}

.smart-modal__close {
	/* A cavallo dell'angolo, fuori dal contenuto: visibile su qualsiasi sfondo
	   e senza dover riservare padding in alto. */
	position: absolute;
	top: -14px;
	right: -14px;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: #fff;
	color: #111;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.3);
	cursor: pointer;
	transition: background-color 0.2s ease, transform 0.2s ease;
}

.smart-modal__close:hover {
	background: #f1f1f1;
	transform: scale(1.06);
}

.smart-modal__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 3px;
}

@media (max-width: 600px) {
	.smart-modal__close {
		top: -12px;
		right: -12px;
		width: 36px;
		height: 36px;
	}
}

/* Larghezze */

.smart-modal--sm {
	--smodal-width: 480px;
}

.smart-modal--lg {
	--smodal-width: 1040px;
}

.smart-modal--xl {
	--smodal-width: 100%;
}

.smart-modal--fullscreen {
	padding: 0;
}

.smart-modal--fullscreen .smart-modal__panel {
	max-width: none;
	height: 100%;
	border-radius: 0;
	box-shadow: none;
}

/* A schermo intero non c'è bordo da cui sbordare: la X torna dentro. */
.smart-modal--fullscreen .smart-modal__close {
	top: 12px;
	right: 12px;
}

/* Animazioni del pannello */

.smart-modal--anim-slide-up .smart-modal__panel {
	transform: translateY(40px);
}

.smart-modal--anim-zoom .smart-modal__panel {
	transform: scale(0.94);
}

.smart-modal.is-visible .smart-modal__panel {
	transform: none;
}

.smart-modal--anim-none {
	--smodal-duration: 0s;
}

@media (prefers-reduced-motion: reduce) {
	.smart-modal {
		--smodal-duration: 0s;
	}
}

/* Blocco scroll pagina */

html.smart-modal-is-open {
	overflow: hidden;
}

html.smart-modal-is-open body {
	padding-right: var(--smodal-scrollbar, 0);
}

/* Frontend editor WPBakery */

.smart-modal-editor {
	padding: 12px;
	border: 2px dashed #7b8cde;
	border-radius: 8px;
}

.smart-modal-editor__label {
	margin-bottom: 12px;
	font: 600 12px/1.4 -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
	letter-spacing: 0.04em;
	text-transform: uppercase;
	color: #4b5bb3;
}

.smart-modal-editor .smart-modal__panel {
	max-width: none;
	box-shadow: none;
}
