/* Fascia che contiene la frase: sfondo, margini e spazio riservato (non si anima mai) */
.fdm-host {
	--fdm-c1: #1d3557;
	--fdm-c2: #e63946;
	--fdm-bg: transparent;
	--fdm-pad: 10px;
	--fdm-fs: 32px;
	--fdm-fs-m: 18px;
	box-sizing: border-box;
	background: var(--fdm-bg);
	padding: var(--fdm-pad) 16px;
	font-size: var(--fdm-fs);
	line-height: 1.35;
	min-height: calc(var(--fdm-fs) * 1.35 + var(--fdm-pad) * 2); /* niente "salto" della pagina */
	overflow: hidden; /* gli effetti con movimento non escono dalla fascia */
	transition: height .5s ease, padding .5s ease, min-height .5s ease;
}
/* Fascia chiusa (opzione "chiudi anche la fascia") */
.fdm-host.fdm-closed {
	padding-top: 0 !important;
	padding-bottom: 0 !important;
	min-height: 0 !important;
}
.fdm-host.fdm-italic { font-style: italic; }
.fdm-host.fdm-has-label { min-height: calc(var(--fdm-fs) * 1.5 + max(var(--fdm-fs) * .6, 12px) * 1.3 + var(--fdm-pad) * 2 + 2px); }

/* ---------- Texture di sfondo ----------
 * Disegnate con maschere CSS (gradienti o piccoli SVG): il colore della texture
 * è --fdm-tx-c (bianco o nero, scelto dal JS) e l'intensità è --fdm-tx-o.
 */
.fdm-host { position: relative; isolation: isolate; }
.fdm-host > .fdm-box { position: relative; z-index: 1; }
.fdm-host[class*="fdm-tx-"]::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: 0;
	pointer-events: none;
	background: var(--fdm-tx-c, #fff);
	opacity: var(--fdm-tx-o, .15);
	-webkit-mask-repeat: repeat; mask-repeat: repeat;
}
.fdm-host.fdm-tx-dots::before {
	-webkit-mask-image: radial-gradient(circle, #000 1.3px, transparent 1.8px);
	mask-image: radial-gradient(circle, #000 1.3px, transparent 1.8px);
	-webkit-mask-size: 14px 14px; mask-size: 14px 14px;
}
.fdm-host.fdm-tx-grid::before {
	-webkit-mask-image: linear-gradient(#000 1px, transparent 1px), linear-gradient(90deg, #000 1px, transparent 1px);
	mask-image: linear-gradient(#000 1px, transparent 1px), linear-gradient(90deg, #000 1px, transparent 1px);
	-webkit-mask-size: 16px 16px; mask-size: 16px 16px;
}
.fdm-host.fdm-tx-lines::before {
	-webkit-mask-image: linear-gradient(transparent calc(100% - 1px), #000 calc(100% - 1px));
	mask-image: linear-gradient(transparent calc(100% - 1px), #000 calc(100% - 1px));
	-webkit-mask-size: 100% 18px; mask-size: 100% 18px;
}
.fdm-host.fdm-tx-diagonal::before {
	-webkit-mask-image: repeating-linear-gradient(45deg, #000 0 1.5px, transparent 1.5px 11px);
	mask-image: repeating-linear-gradient(45deg, #000 0 1.5px, transparent 1.5px 11px);
}
.fdm-host.fdm-tx-crosses::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M22 15v14M15 22h14' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44'%3E%3Cpath d='M22 15v14M15 22h14' stroke='black' stroke-width='1.6'/%3E%3C/svg%3E");
	-webkit-mask-size: 44px 44px; mask-size: 44px 44px;
}
.fdm-host.fdm-tx-waves::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='14'%3E%3Cpath d='M0 7 Q12 0 24 7 T48 7' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='14'%3E%3Cpath d='M0 7 Q12 0 24 7 T48 7' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
	-webkit-mask-size: 48px 14px; mask-size: 48px 14px;
}
.fdm-host.fdm-tx-zigzag::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='14'%3E%3Cpath d='M0 10 L6 4 L12 10 L18 4 L24 10' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='24' height='14'%3E%3Cpath d='M0 10 L6 4 L12 10 L18 4 L24 10' fill='none' stroke='black' stroke-width='1.4'/%3E%3C/svg%3E");
	-webkit-mask-size: 24px 14px; mask-size: 24px 14px;
}
.fdm-host.fdm-tx-stars::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='60'%3E%3Cg fill='black'%3E%3Cpath d='M12 8l1.5 4.5L18 14l-4.5 1.5L12 20l-1.5-4.5L6 14l4.5-1.5z'/%3E%3Cpath d='M58 30l1 3 3 1-3 1-1 3-1-3-3-1 3-1z'/%3E%3Cpath d='M38 44l1.2 3.3 3.3 1.2-3.3 1.2L38 53l-1.2-3.3-3.3-1.2 3.3-1.2z'/%3E%3Ccircle cx='76' cy='12' r='1.3'/%3E%3Ccircle cx='30' cy='26' r='1'/%3E%3Ccircle cx='84' cy='48' r='1'/%3E%3C/g%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='90' height='60'%3E%3Cg fill='black'%3E%3Cpath d='M12 8l1.5 4.5L18 14l-4.5 1.5L12 20l-1.5-4.5L6 14l4.5-1.5z'/%3E%3Cpath d='M58 30l1 3 3 1-3 1-1 3-1-3-3-1 3-1z'/%3E%3Cpath d='M38 44l1.2 3.3 3.3 1.2-3.3 1.2L38 53l-1.2-3.3-3.3-1.2 3.3-1.2z'/%3E%3Ccircle cx='76' cy='12' r='1.3'/%3E%3Ccircle cx='30' cy='26' r='1'/%3E%3Ccircle cx='84' cy='48' r='1'/%3E%3C/g%3E%3C/svg%3E");
	-webkit-mask-size: 90px 60px; mask-size: 90px 60px;
}
.fdm-host.fdm-tx-paper::before {
	-webkit-mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 0 0 0 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	mask-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='180' height='180'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1.4 0 0 0 -0.62'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
	-webkit-mask-size: 180px 180px; mask-size: 180px 180px;
}
.fdm-host.fdm-tx-light::before {
	opacity: calc(var(--fdm-tx-o, .15) * 2.4);
	-webkit-mask-image: radial-gradient(ellipse 60% 140% at 50% -20%, #000, transparent 75%);
	mask-image: radial-gradient(ellipse 60% 140% at 50% -20%, #000, transparent 75%);
	-webkit-mask-repeat: no-repeat; mask-repeat: no-repeat;
	-webkit-mask-size: 100% 100%; mask-size: 100% 100%;
}

/* Etichetta piccola sopra la frase ("Frase del mese:") */
.fdm-label {
	display: block;
	font-size: max(.6em, 12px);
	font-style: normal;
	font-weight: 600;
	letter-spacing: .04em;
	line-height: 1.3;
	margin-bottom: .15em;
	color: var(--fdm-c2);
}
@media (max-width: 767px) {
	.fdm-host {
		font-size: var(--fdm-fs-m);
		padding-left: 12px;
		padding-right: 12px;
		min-height: calc(var(--fdm-fs-m) * 1.35 + var(--fdm-pad) * 2);
	}
	.fdm-host.fdm-has-label { min-height: calc(var(--fdm-fs-m) * 1.5 + max(var(--fdm-fs-m) * .6, 12px) * 1.3 + var(--fdm-pad) * 2 + 2px); }
}

.fdm-box {
	font-weight: 600;
	line-height: 1.35;
	opacity: 0;
	transition: opacity .7s ease, transform .7s ease, filter .7s ease, letter-spacing .7s ease;
}
.fdm-box.fdm-in { opacity: 1; }
.fdm-box .fdm-text { display: inline-block; color: var(--fdm-c1); }
.fdm-w { display: inline-block; white-space: nowrap; }

/* 1. Slide */
.fdm-fx-slide { transform: translateY(40px); }
.fdm-fx-slide.fdm-in { transform: none; }

/* 2. Zoom */
.fdm-fx-zoom { transform: scale(.6); }
.fdm-fx-zoom.fdm-in { transform: none; }

/* 3. Blur reveal */
.fdm-fx-blur { filter: blur(14px); letter-spacing: .25em; transition: opacity 1.2s ease, filter 1.2s ease, letter-spacing 1.4s ease; }
.fdm-fx-blur.fdm-in { filter: none; letter-spacing: normal; }

/* 4. Macchina da scrivere */
.fdm-fx-typewriter .fdm-ch { opacity: 0; }
.fdm-fx-typewriter.fdm-in .fdm-ch { animation: fdm-show .01s forwards; animation-delay: calc(var(--i) * 45ms + .4s); }
.fdm-fx-typewriter .fdm-text::after {
	content: ""; display: inline-block; width: 2px; height: 1em; margin-left: 4px;
	background: var(--fdm-c2); vertical-align: -.12em; animation: fdm-blink 1s steps(1) infinite;
}
@keyframes fdm-show { to { opacity: 1; } }
@keyframes fdm-blink { 50% { opacity: 0; } }

/* 5. Onda */
.fdm-fx-wave .fdm-ch { display: inline-block; }
.fdm-fx-wave.fdm-in .fdm-ch { animation: fdm-wave 2.2s ease-in-out infinite; animation-delay: calc(var(--i) * 70ms); }
@keyframes fdm-wave {
	0%, 60%, 100% { transform: none; color: inherit; }
	30% { transform: translateY(-.35em); color: var(--fdm-c2); }
}

/* 6. Parola per parola */
.fdm-fx-words .fdm-wd { display: inline-block; opacity: 0; transform: translateY(24px); }
.fdm-fx-words.fdm-in .fdm-wd { animation: fdm-word .7s ease forwards; animation-delay: calc(var(--i) * 260ms); }
@keyframes fdm-word { to { opacity: 1; transform: none; } }

/* 7. Gradiente animato */
.fdm-fx-gradient .fdm-text {
	background: linear-gradient(90deg, var(--fdm-c1), var(--fdm-c2), var(--fdm-c1));
	background-size: 200% auto;
	-webkit-background-clip: text; background-clip: text;
	-webkit-text-fill-color: transparent; color: transparent;
	animation: fdm-grad 4s linear infinite;
}
@keyframes fdm-grad { to { background-position: 200% center; } }

/* 8. Neon */
.fdm-fx-neon .fdm-text {
	color: var(--fdm-c1);
	animation: fdm-neon 2s ease-in-out infinite alternate;
}
@keyframes fdm-neon {
	from { text-shadow: 0 0 4px var(--fdm-c2), 0 0 10px var(--fdm-c2); }
	to   { text-shadow: 0 0 8px var(--fdm-c2), 0 0 22px var(--fdm-c2), 0 0 44px var(--fdm-c2), 0 0 70px var(--fdm-c2); }
}

/* 9. Shimmer */
.fdm-fx-shimmer .fdm-text {
	background: linear-gradient(110deg, var(--fdm-c1) 38%, var(--fdm-c2) 50%, var(--fdm-c1) 62%);
	background-size: 250% 100%;
	-webkit-background-clip: text; background-clip: text;
	-webkit-text-fill-color: transparent; color: transparent;
	animation: fdm-shimmer 2.8s linear infinite;
}
@keyframes fdm-shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }

/* 10. Tendina */
.fdm-fx-reveal .fdm-text { clip-path: inset(0 100% 0 0); transition: clip-path 1.4s cubic-bezier(.65, 0, .35, 1) .15s; }
.fdm-fx-reveal.fdm-in .fdm-text { clip-path: inset(0 0 0 0); }

/* 11. Parole che salgono da una linea */
.fdm-fx-rise .fdm-w { overflow: hidden; vertical-align: top; padding-bottom: .12em; margin-bottom: -.12em; }
.fdm-fx-rise .fdm-wi { display: inline-block; transform: translateY(115%); }
.fdm-fx-rise.fdm-in .fdm-wi { animation: fdm-rise .75s cubic-bezier(.2, .7, .2, 1) forwards; animation-delay: calc(var(--i) * 70ms + .1s); }
@keyframes fdm-rise { to { transform: none; } }

/* 12. Lettere che cadono */
.fdm-fx-letters .fdm-ch { display: inline-block; opacity: 0; transform: translateY(-.9em); }
.fdm-fx-letters.fdm-in .fdm-ch { animation: fdm-drop .55s cubic-bezier(.3, 1.5, .5, 1) forwards; animation-delay: calc(var(--i) * 28ms); }
@keyframes fdm-drop { to { opacity: 1; transform: none; } }

/* 13. Ribaltamento 3D */
.fdm-fx-flip .fdm-text { transform: perspective(600px) rotateX(-95deg); transform-origin: 50% 100%; transition: transform 1s cubic-bezier(.2, .8, .2, 1); }
.fdm-fx-flip.fdm-in .fdm-text { transform: none; }

/* 14. Scritta a mano (gesso) */
.fdm-fx-chalk .fdm-ch { display: inline-block; opacity: 0; }
.fdm-fx-chalk.fdm-in .fdm-ch { animation: fdm-chalk .4s ease-out forwards; animation-delay: calc(var(--i) * 38ms + .2s); }
@keyframes fdm-chalk {
	0%   { opacity: 0; filter: blur(5px); transform: scale(1.35) rotate(-4deg); }
	100% { opacity: 1; filter: none; transform: none; }
}

/* 15. Sottolineatura che si disegna */
.fdm-fx-underline .fdm-text {
	display: inline;
	background-image: linear-gradient(var(--fdm-c2), var(--fdm-c2));
	background-repeat: no-repeat;
	background-position: 0 100%;
	background-size: 0% .09em;
	padding-bottom: .08em;
	-webkit-box-decoration-break: clone; box-decoration-break: clone;
	transition: background-size 1.1s cubic-bezier(.65, 0, .35, 1) .6s;
}
.fdm-fx-underline.fdm-in .fdm-text { background-size: 100% .09em; }

/* 16. Decodifica: le lettere sono gestite dal JS; qui solo un leggero bagliore iniziale */
.fdm-fx-scramble .fdm-ch { display: inline-block; min-width: .25em; }

/* 17. Rimbalzo */
.fdm-fx-bounce.fdm-in .fdm-text { animation: fdm-bounce .95s cubic-bezier(.3, .6, .4, 1) both; }
@keyframes fdm-bounce {
	0%   { transform: translateY(-1.6em); }
	55%  { transform: translateY(.12em); }
	75%  { transform: translateY(-.18em); }
	90%  { transform: translateY(.04em); }
	100% { transform: none; }
}

/* Copia del testo solo per lettori di schermo */
.fdm-sr {
	position: absolute !important; width: 1px; height: 1px; padding: 0; margin: -1px;
	overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* Effetti di uscita */
.fdm-box.fdm-in.fdm-out-fade { opacity: 0; }
.fdm-box.fdm-in.fdm-out-up   { opacity: 0; transform: translateY(-40px); }
.fdm-box.fdm-in.fdm-out-blur { opacity: 0; filter: blur(12px); }

/* Accessibilità: niente animazioni per chi le ha disattivate */
@media (prefers-reduced-motion: reduce) {
	.fdm-box, .fdm-box * { animation: none !important; transition: opacity .3s ease !important; }
	.fdm-box { transform: none !important; filter: none !important; letter-spacing: normal !important; }
	.fdm-box .fdm-ch, .fdm-box .fdm-wd, .fdm-box .fdm-wi { opacity: 1 !important; transform: none !important; filter: none !important; }
	.fdm-box .fdm-text { clip-path: none !important; transform: none !important; }
	.fdm-fx-underline .fdm-text { background-size: 100% .09em !important; }
}
