/* Valin Popups - frontend
 * Identità Valin: blu #1436c5, forma firma (angoli diagonali 60px), Titillium Web.
 * Titillium Web NON viene caricato dal plugin: è già servito dal tema (no richieste extra/GDPR);
 * fallback a uno stack di sistema raffinato.
 * Prefisso .vp- per non collidere col tema. Mobile-first, responsive, accessibile.
 */

.vp-popup {
	--vp-accent: #1436c5;
	--vp-accent-text: #ffffff;
	--vp-surface: #ffffff;
	--vp-surface-2: #f5f6f9;
	--vp-ink: #161519;
	--vp-ink-soft: #5b626d;
	--vp-border: rgba(20, 22, 26, 0.10);
	--vp-corner: 60px;   /* forma firma Valin */
	--vp-corner-sm: 24px;
	--vp-font: "Titillium Web", -apple-system, BlinkMacSystemFont, "Segoe UI",
		Roboto, "Helvetica Neue", Arial, sans-serif;

	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
	box-sizing: border-box;
	font-family: var(--vp-font);
	-webkit-font-smoothing: antialiased;
	text-rendering: optimizeLegibility;
}

.vp-popup[hidden] { display: none; }
.vp-popup * { box-sizing: border-box; }

/* ===== Overlay ===== */
.vp-overlay {
	position: absolute;
	inset: 0;
	background: radial-gradient( 120% 120% at 50% 0%, rgba(8, 12, 30, 0.55), rgba(4, 6, 18, 0.80) );
	-webkit-backdrop-filter: blur(6px) saturate(115%);
	backdrop-filter: blur(6px) saturate(115%);
	opacity: 0;
	transition: opacity 0.35s ease;
	cursor: pointer;
}

/* ===== Dialog ===== */
.vp-dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 440px;
	max-height: calc(100vh - 48px);
	overflow-y: auto;
	overflow-x: hidden;
	background: var(--vp-surface);
	color: var(--vp-ink);
	border-radius: var(--vp-corner) 0 var(--vp-corner) 0;   /* angoli diagonali */
	padding: 44px 40px 40px;
	box-shadow:
		0 40px 80px -24px rgba(8, 12, 40, 0.45),
		0 12px 28px -16px rgba(8, 12, 40, 0.35);

	transform: translateY(24px) scale(0.96);
	opacity: 0;
	filter: blur(2px);
	transition:
		transform 0.5s cubic-bezier(0.16, 1, 0.3, 1),
		opacity 0.4s ease,
		filter 0.4s ease;
}

.vp-popup.is-open .vp-overlay { opacity: 1; }
.vp-popup.is-open .vp-dialog {
	transform: translateY(0) scale(1);
	opacity: 1;
	filter: blur(0);
}

/* ===== Reveal scaglionato dei contenuti ===== */
.vp-icon,
.vp-eyebrow,
.vp-popup-title,
.vp-countdown,
.vp-popup-content,
.vp-popup-actions {
	opacity: 0;
	transform: translateY(10px);
	transition: opacity 0.45s ease, transform 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

.vp-popup.is-open .vp-icon { transition-delay: 0.06s; }
.vp-popup.is-open .vp-eyebrow { transition-delay: 0.12s; }
.vp-popup.is-open .vp-popup-title { transition-delay: 0.18s; }
.vp-popup.is-open .vp-countdown { transition-delay: 0.24s; }
.vp-popup.is-open .vp-popup-content { transition-delay: 0.30s; }
.vp-popup.is-open .vp-popup-actions { transition-delay: 0.36s; }

.vp-popup.is-open .vp-icon,
.vp-popup.is-open .vp-eyebrow,
.vp-popup.is-open .vp-popup-title,
.vp-popup.is-open .vp-countdown,
.vp-popup.is-open .vp-popup-content,
.vp-popup.is-open .vp-popup-actions {
	opacity: 1;
	transform: translateY(0);
}

/* ===== Logo Valin ===== */
.vp-icon {
	display: inline-flex;
	margin: 0 0 18px;
	color: var(--vp-accent);
}

.vp-icon .vp-mark {
	width: 38px;
	height: 38px;
	display: block;
}

/* ===== Close ===== */
.vp-close {
	position: absolute;
	top: 18px;
	right: 18px;
	width: 38px;
	height: 38px;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 22px;
	line-height: 1;
	color: var(--vp-ink-soft);
	background: var(--vp-surface-2);
	border: 0;
	border-radius: 50%;
	cursor: pointer;
	padding: 0;
	z-index: 2;
	transition: transform 0.25s ease, background 0.2s ease, color 0.2s ease;
}

.vp-close:hover,
.vp-close:focus-visible {
	background: var(--vp-ink);
	color: #fff;
	transform: rotate(90deg);
	outline: none;
}

/* ===== Eyebrow / occhiello ===== */
.vp-eyebrow {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	margin: 0 0 14px;
	padding: 5px 13px;
	font-size: 11px;
	font-weight: 700;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--vp-accent);
	background: rgba(20, 54, 197, 0.10);
	border-radius: 999px;
}

.vp-eyebrow::before {
	content: "";
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: currentColor;
	animation: vp-pulse 2s infinite;
}

@keyframes vp-pulse {
	0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.45); }
	70%  { box-shadow: 0 0 0 7px rgba(255, 255, 255, 0); }
	100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0); }
}

/* ===== Titolo ===== */
.vp-popup-title {
	margin: 0 30px 14px 0;
	font-size: 30px;
	line-height: 1.1;
	font-weight: 700;
	letter-spacing: -0.01em;
	color: var(--vp-ink);
}

/* ===== Contenuto ===== */
.vp-popup-content {
	margin: 0 0 26px;
	font-size: 16px;
	line-height: 1.6;
	color: var(--vp-ink-soft);
}

.vp-popup-content p:last-child { margin-bottom: 0; }
.vp-popup-content a { color: var(--vp-accent); text-underline-offset: 2px; }

/* ===== Countdown a blocchi (markup generato via JS) ===== */
.vp-countdown {
	display: flex;
	align-items: stretch;
	gap: 8px;
	margin: 0 0 26px;
}

.vp-cd-group {
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 4px;
	padding: 12px 6px 9px;
	background: var(--vp-surface-2);
	border-radius: 14px 0 14px 0;
}

.vp-cd-num {
	font-size: 30px;
	font-weight: 700;
	line-height: 1;
	letter-spacing: -0.01em;
	color: var(--vp-ink);
	font-variant-numeric: tabular-nums;
}

.vp-cd-label {
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.12em;
	text-transform: uppercase;
	color: var(--vp-ink-soft);
}

.vp-countdown.is-expired {
	display: block;
	text-align: center;
	padding: 14px;
	font-weight: 700;
	font-size: 16px;
	color: var(--vp-accent);
	background: rgba(20, 54, 197, 0.10);
	border-radius: 14px 0 14px 0;
}

/* ===== CTA ===== */
.vp-popup-actions { margin-top: 4px; }

.vp-cta {
	position: relative;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	padding: 15px 30px;
	font-family: var(--vp-font);
	font-size: 16px;
	font-weight: 700;
	letter-spacing: -0.005em;
	text-decoration: none;
	color: var(--vp-accent-text);
	background: var(--vp-accent);
	border-radius: var(--vp-corner-sm) 0 var(--vp-corner-sm) 0;
	overflow: hidden;
	cursor: pointer;
	transition: transform 0.12s ease, box-shadow 0.25s ease, filter 0.2s ease;
}

/* Sheen all'hover */
.vp-cta::before {
	content: "";
	position: absolute;
	top: 0;
	left: -120%;
	width: 60%;
	height: 100%;
	background: linear-gradient( 100deg, transparent, rgba(255, 255, 255, 0.35), transparent );
	transition: left 0.6s ease;
}

.vp-cta:hover,
.vp-cta:focus-visible {
	color: var(--vp-accent-text);
	transform: translateY(-1px);
	outline: none;
}

.vp-cta:hover::before,
.vp-cta:focus-visible::before { left: 130%; }
.vp-cta:active { transform: translateY(0); }

.vp-arrow {
	flex: none;
	transition: transform 0.25s ease;
}

.vp-cta:hover .vp-arrow { transform: translateX(4px); }

/* ===================================================================
   FORM BROCHURE
   =================================================================== */
.vp-popup-actions--form { margin-top: 8px; }

/* Honeypot anti-spam: fuori schermo, invisibile e non focusabile per gli umani. */
.vp-hp {
	position: absolute !important;
	left: -9999px !important;
	top: auto;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* La popup con form è più larga per non diventare lunghissima in verticale. */
.vp-has-form .vp-dialog { max-width: 640px; }

.vp-form-fields {
	display: flex;
	flex-direction: column;
	gap: 14px;
	margin-bottom: 20px;
}

/* Da tablet in su: campi su due colonne, privacy e bottone a tutta larghezza. */
@media (min-width: 560px) {
	.vp-has-form .vp-form-fields {
		display: grid;
		grid-template-columns: 1fr 1fr;
		gap: 16px 18px;
	}
	.vp-has-form .vp-field--privacy { grid-column: 1 / -1; }
}

.vp-field {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin: 0;
}

.vp-field label {
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.01em;
	color: var(--vp-ink);
}

.vp-field input[type="text"],
.vp-field input[type="email"] {
	width: 100%;
	padding: 12px 14px;
	font-family: var(--vp-font);
	font-size: 15px;
	color: var(--vp-ink);
	background: var(--vp-surface-2);
	border: 1px solid var(--vp-border);
	border-radius: 14px 0 14px 0;
	transition: border-color 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.vp-field input::placeholder { color: var(--vp-ink-soft); opacity: 0.7; }

.vp-field input:focus {
	outline: none;
	border-color: var(--vp-accent);
	box-shadow: 0 0 0 3px rgba(var(--vp-accent-rgb, 20, 54, 197), 0.18);
	background: var(--vp-surface);
}

.vp-field input:invalid:not(:placeholder-shown) {
	border-color: #d33a3a;
}

.vp-req { color: #d33a3a; }

.vp-field--privacy label {
	flex-direction: row;
	align-items: flex-start;
	gap: 10px;
	font-size: 13px;
	font-weight: 400;
	line-height: 1.45;
	color: var(--vp-ink-soft);
	cursor: pointer;
}

.vp-field--privacy input[type="checkbox"] {
	flex: none;
	width: 18px;
	height: 18px;
	margin-top: 1px;
	accent-color: var(--vp-accent);
	cursor: pointer;
}

.vp-form-actions { margin: 0; }

/* Bottone di invio: resettiamo con forza gli stili che i temi impongono ai
   <button> (padding esagerato, colore testo, altezze fisse, text-transform). */
.vp-popup .vp-form-submit {
	width: 100%;
	min-height: 0;
	height: auto;
	margin: 0;
	padding: 15px 30px !important;
	border: 0 !important;
	-webkit-appearance: none;
	appearance: none;
	font-size: 16px !important;
	line-height: 1.2 !important;
	text-transform: none !important;
	text-shadow: none;
	white-space: normal;
}
.vp-popup .vp-form-submit span { color: inherit; }
.vp-popup .vp-form-submit[disabled] { opacity: 0.6; cursor: default; pointer-events: none; }

/* Colore testo/freccia leggibile su ogni tema (vince sugli stili del tema). */
.vp-theme-brand .vp-form-submit,
.vp-theme-brand .vp-form-submit span,
.vp-theme-brand .vp-form-submit .vp-arrow { color: var(--vp-accent) !important; }
.vp-theme-light .vp-form-submit,
.vp-theme-light .vp-form-submit span,
.vp-theme-light .vp-form-submit .vp-arrow,
.vp-theme-dark .vp-form-submit,
.vp-theme-dark .vp-form-submit span,
.vp-theme-dark .vp-form-submit .vp-arrow { color: #161519 !important; }

.vp-form-status {
	margin: 14px 0 0;
	padding: 11px 14px;
	font-size: 14px;
	line-height: 1.4;
	border-radius: 14px 0 14px 0;
}

.vp-form-status.is-success {
	color: var(--vp-accent);
	background: rgba(var(--vp-accent-rgb, 20, 54, 197), 0.10);
}

.vp-form-status.is-error {
	color: #b32222;
	background: rgba(211, 58, 58, 0.10);
}

/* ===================================================================
   TEMA "BRAND" (default) - card blu Valin, testo bianco, CTA bianca
   =================================================================== */
.vp-theme-brand .vp-dialog {
	background: var(--vp-accent);
	color: #ffffff;
	box-shadow:
		0 40px 90px -24px rgba(8, 12, 60, 0.55),
		0 12px 28px -16px rgba(8, 12, 60, 0.45);
}

.vp-theme-brand .vp-popup-title { color: #ffffff; }
.vp-theme-brand .vp-popup-content { color: rgba(255, 255, 255, 0.88); }
.vp-theme-brand .vp-popup-content a { color: #ffffff; }
.vp-theme-brand .vp-icon { color: #ffffff; }

.vp-theme-brand .vp-eyebrow {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.16);
}

.vp-theme-brand .vp-close {
	background: rgba(255, 255, 255, 0.16);
	color: #ffffff;
}
.vp-theme-brand .vp-close:hover,
.vp-theme-brand .vp-close:focus-visible {
	background: #ffffff;
	color: var(--vp-accent);
}

.vp-theme-brand .vp-cd-group {
	background: rgba(255, 255, 255, 0.14);
}
.vp-theme-brand .vp-cd-num { color: #ffffff; }
.vp-theme-brand .vp-cd-label { color: rgba(255, 255, 255, 0.75); }
.vp-theme-brand .vp-countdown.is-expired {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.16);
}

/* CTA bianca, testo + freccia blu (come da richiesta) */
.vp-theme-brand .vp-cta {
	background: #ffffff;
	color: var(--vp-accent);
	box-shadow: 0 12px 26px -12px rgba(0, 0, 0, 0.5);
}
.vp-theme-brand .vp-cta:hover,
.vp-theme-brand .vp-cta:focus-visible {
	color: var(--vp-accent);
	filter: brightness(0.97);
}

/* Form sul tema brand: etichette chiare, input traslucidi, status leggibile */
.vp-theme-brand .vp-field label { color: #ffffff; }
.vp-theme-brand .vp-field--privacy label { color: rgba(255, 255, 255, 0.85); }
.vp-theme-brand .vp-field input[type="text"],
.vp-theme-brand .vp-field input[type="email"] {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.12);
	border-color: rgba(255, 255, 255, 0.22);
}
.vp-theme-brand .vp-field input::placeholder { color: rgba(255, 255, 255, 0.6); }
.vp-theme-brand .vp-field input:focus {
	border-color: #ffffff;
	background: rgba(255, 255, 255, 0.18);
	box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.22);
}
.vp-theme-brand .vp-field--privacy input[type="checkbox"] { accent-color: #ffffff; }
.vp-theme-brand .vp-req { color: #ffd5d5; }
.vp-theme-brand .vp-form-status.is-success {
	color: #ffffff;
	background: rgba(255, 255, 255, 0.16);
}
.vp-theme-brand .vp-form-status.is-error {
	color: #ffffff;
	background: rgba(211, 58, 58, 0.35);
}

/* ===================================================================
   TEMA LIGHT - card bianca, accento sul logo/CTA
   =================================================================== */
.vp-theme-light .vp-icon {
	padding: 9px;
	color: #ffffff;
	background: var(--vp-accent);
	border-radius: 12px 0 12px 0;
}

/* CTA Valin su sfondo chiaro: bottone blu, testo + chevron scuri, glow blu morbido */
.vp-theme-light .vp-cta,
.vp-theme-dark .vp-cta {
	color: #161519;
	box-shadow: 0 18px 42px -12px rgba(var(--vp-accent-rgb, 20, 54, 197), 0.55);
}
.vp-theme-light .vp-cta:hover,
.vp-theme-light .vp-cta:focus-visible,
.vp-theme-dark .vp-cta:hover,
.vp-theme-dark .vp-cta:focus-visible {
	color: #161519;
	box-shadow: 0 22px 50px -12px rgba(var(--vp-accent-rgb, 20, 54, 197), 0.65);
}

/* ===================================================================
   TEMA DARK
   =================================================================== */
.vp-theme-dark {
	--vp-surface: #181b21;
	--vp-surface-2: #11141a;
	--vp-ink: #f4f6f9;
	--vp-ink-soft: #9aa3b0;
}
.vp-theme-dark .vp-dialog {
	box-shadow: 0 40px 90px -24px rgba(0, 0, 0, 0.7);
}
.vp-theme-dark .vp-icon {
	padding: 9px;
	color: #ffffff;
	background: var(--vp-accent);
	border-radius: 12px 0 12px 0;
}
.vp-theme-dark .vp-close { background: rgba(255, 255, 255, 0.07); }
.vp-theme-dark .vp-close:hover,
.vp-theme-dark .vp-close:focus-visible { background: #fff; color: #14161a; }

/* ===== Posizioni ===== */
.vp-pos-top { align-items: flex-start; padding-top: 40px; }
.vp-pos-bottom { align-items: flex-end; padding-bottom: 40px; }
.vp-pos-bottom-right { align-items: flex-end; justify-content: flex-end; }
.vp-pos-bottom-left { align-items: flex-end; justify-content: flex-start; }

.vp-pos-bottom-right .vp-dialog,
.vp-pos-bottom-left .vp-dialog { max-width: 380px; }

.vp-pos-bottom-right .vp-overlay,
.vp-pos-bottom-left .vp-overlay {
	background: rgba(6, 8, 18, 0.32);
	-webkit-backdrop-filter: blur(2px);
	backdrop-filter: blur(2px);
}

/* ===== Mobile ===== */
@media (max-width: 600px) {
	.vp-popup { padding: 16px; }

	.vp-dialog,
	.vp-pos-bottom-right .vp-dialog,
	.vp-pos-bottom-left .vp-dialog {
		max-width: 100%;
		max-height: 90vh;
		padding: 36px 26px 30px;
		border-radius: 40px 0 40px 0;
	}

	.vp-popup-title { font-size: 25px; }
	.vp-cd-num { font-size: 26px; }

	.vp-pos-bottom-right,
	.vp-pos-bottom-left { justify-content: center; }
}

/* ===== Riduzione movimento ===== */
@media (prefers-reduced-motion: reduce) {
	.vp-overlay,
	.vp-dialog,
	.vp-icon,
	.vp-eyebrow,
	.vp-popup-title,
	.vp-countdown,
	.vp-popup-content,
	.vp-popup-actions,
	.vp-cta,
	.vp-cta::before,
	.vp-arrow,
	.vp-close,
	.vp-eyebrow::before {
		transition: none !important;
		animation: none !important;
	}
	.vp-dialog { filter: none; }
}

/* Blocca lo scroll del body quando aperta */
.vp-no-scroll { overflow: hidden; }
