/* SudGrafica — vocabolario di stampa.
   Ogni movimento imita un processo vero del reparto e risponde a una delle tre ragioni del sistema
   (guidare, dare feedback, mostrare una transizione). Solo transform, opacity e clip-path.

   registro   offset (Rubel, 1904): le lastre ciano e magenta scivolano a registro sul nero  → guida: inizio sezione
   racla      serigrafia (Simon, 1907): una passata di racla da sinistra stende il contenuto  → guida: passi in sequenza
   passate    getto d'inchiostro grande formato: la foto esce a bande, come le passate della testina → transizione: arriva un'immagine
   laser      CTP (drupa 1995): una riga di luce incide la lastra da sinistra a destra        → guida: righe di un elenco
   impronta   caratteri mobili: al click il bottone "morde" la carta                            → feedback
   inchiostro al passaggio l'inchiostro pieno si stende sul bottone da sinistra                → feedback
   Le rivelazioni partono da motion.js ([data-sg-reveal="…"] + .is-in), una volta sola.
   Con prefers-reduced-motion motion.js non parte: tutto resta visibile e fermo. */

/* ---- Segni di stampa: retino, crocini, registro ---------------------------- */

/* Retino: punti che sfumano sulla piastra, come un fondo stampato a mezzatinta */
.sg-hero__plate,
.sg-chi-hero__plate,
.sg-evo__counter {
	isolation: isolate;
}

.sg-evo__counter {
	position: relative;
	--sg-retino-dot: rgb(0 159 227 / 0.22);
}

.sg-hero__plate::after,
.sg-chi-hero__plate::after,
.sg-evo__counter::after {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	border-radius: inherit;
	pointer-events: none;
	background-image: radial-gradient(circle, var(--sg-retino-dot, rgb(255 255 255 / 0.28)) 0 1.4px, transparent 1.8px);
	background-size: 10px 10px;
	-webkit-mask-image: linear-gradient(125deg, transparent 30%, #000 95%);
	mask-image: linear-gradient(125deg, transparent 30%, #000 95%);
}

/* Crocini di taglio agli angoli di una foto (dentro il riquadro, 12px dal bordo) */
.sg-lavoro__media,
.sg-evo__media {
	position: relative;
}

.sg-lavoro__media::after,
.sg-evo__media::after {
	--c: var(--sg-crocini-color, rgb(255 255 255 / 0.9));
	--l: 22px;
	content: "";
	position: absolute;
	inset: 12px;
	z-index: 2;
	pointer-events: none;
	background:
		linear-gradient(var(--c), var(--c)) left top / var(--l) 2px,
		linear-gradient(var(--c), var(--c)) left top / 2px var(--l),
		linear-gradient(var(--c), var(--c)) right top / var(--l) 2px,
		linear-gradient(var(--c), var(--c)) right top / 2px var(--l),
		linear-gradient(var(--c), var(--c)) left bottom / var(--l) 2px,
		linear-gradient(var(--c), var(--c)) left bottom / 2px var(--l),
		linear-gradient(var(--c), var(--c)) right bottom / var(--l) 2px,
		linear-gradient(var(--c), var(--c)) right bottom / 2px var(--l);
	background-repeat: no-repeat;
	filter: drop-shadow(0 0 1px rgb(0 0 0 / 0.45));
}

/* Portfolio: i crocini compaiono al passaggio e stringono sul formato — "questo lo apri" */
.sg-lavoro__media {
	position: relative;
	border-radius: var(--sg-radius-card);
}

.sg-lavoro__media::after {
	opacity: 0;
	transform: scale(1.08);
	transition: opacity var(--sg-t2) var(--sg-ease), transform var(--sg-t2) var(--sg-ease);
}

.sg-lavoro:hover .sg-lavoro__media::after,
.sg-lavoro:focus-within .sg-lavoro__media::after {
	opacity: 1;
	transform: none;
}

/* ---- Bottoni: inchiostro al passaggio, impronta al click, laser in attesa ----- */

.wp-block-button__link,
.sg-prodotto__form .single_add_to_cart_button,
.sg-prodotto__quote-btn {
	position: relative;
	isolation: isolate;
	overflow: clip;
	--sg-inchiostro: var(--wp--preset--color--ink);
}

.wp-block-button.is-style-sg-paper .wp-block-button__link {
	--sg-inchiostro: var(--wp--preset--color--action);
}

.has-ink-background-color .wp-block-button.is-style-sg-secondary .wp-block-button__link {
	--sg-inchiostro: var(--wp--preset--color--paper);
}

/* Impronta: il bottone scende nella carta per un attimo, come un carattere che morde il foglio */
.wp-block-button__link:active,
.sg-prodotto__form .single_add_to_cart_button:active,
.sg-prodotto__quote-btn:active,
.sg-hero__path:active,
.sg-chip:active {
	transform: scale(0.97);
	box-shadow: none;
	transition-duration: 60ms;
}

@media (prefers-reduced-motion: no-preference) {
	.wp-block-button__link::before,
	.sg-prodotto__form .single_add_to_cart_button::before,
	.sg-prodotto__quote-btn::before {
		content: "";
		position: absolute;
		inset: 0;
		z-index: -1;
		background: var(--sg-inchiostro);
		transform: scaleX(0);
		transform-origin: left center;
		transition: transform var(--sg-t2) var(--sg-ease-in-out);
		pointer-events: none;
	}

	:is(.wp-block-button__link, .sg-prodotto__form .single_add_to_cart_button, .sg-prodotto__quote-btn):is(:hover, :focus-visible):not(:disabled, .disabled)::before {
		transform: scaleX(1);
	}

	/* Il fondo definitivo arriva quando la passata è finita; il testo cambia colore a metà */
	:is(.wp-block-button__link, .sg-prodotto__form .single_add_to_cart_button, .sg-prodotto__quote-btn):is(:hover, :focus-visible):not(:disabled, .disabled) {
		transition:
			background-color 0s linear var(--sg-t2),
			border-color 0s linear var(--sg-t2),
			color var(--sg-t1) linear 90ms,
			transform var(--sg-t2) var(--sg-ease),
			box-shadow var(--sg-t2) var(--sg-ease);
	}
}

/* Laser: in attesa (invio form, aggiunta al carrello) una riga di luce scorre sul fondo del bottone */
.sg-is-loading {
	position: relative;
	overflow: clip;
	pointer-events: none;
}

.sg-is-loading::after {
	content: "";
	position: absolute;
	inset: auto 0 0 0;
	height: 3px;
	background: var(--wp--preset--color--brand);
	transform-origin: left center;
	animation: sg-laser 900ms var(--sg-ease-in-out) infinite;
}

@keyframes sg-laser {
	0% { transform: translateX(-100%) scaleX(0.4); }
	100% { transform: translateX(100%) scaleX(0.4); }
}

@media (prefers-reduced-motion: reduce) {
	.sg-is-loading::after {
		animation: none;
		transform: none;
		opacity: 0.6;
	}
}

/* ---- Rivelazioni (solo con .sg-motion, impostata da motion.js) --------------- */

@media (prefers-reduced-motion: no-preference) {

	/* registro — titolo di sezione: ciano e magenta fuori registro che convergono sul nero.
	   Il testo delle lastre viene da data-sg-reg ed è escluso dagli screen reader ("/ ''"). */
	.sg-motion [data-sg-reg] {
		position: relative;
	}

	.sg-motion [data-sg-reg]::before,
	.sg-motion [data-sg-reg]::after {
		content: attr(data-sg-reg) / "";
		position: absolute;
		inset: 0;
		pointer-events: none;
		mix-blend-mode: multiply;
		opacity: 0;
	}

	.sg-motion [data-sg-reg]::before {
		color: var(--wp--preset--color--brand);
	}

	.sg-motion [data-sg-reg]::after {
		color: var(--sg-magenta, #E6007E);
	}

	/* Il testo nero resta sempre visibile (niente titolo invisibile all'apertura): si muovono solo le lastre */
	.sg-motion [data-sg-reveal="registro"].is-in::before {
		animation: sg-registro-c var(--sg-t4) var(--sg-ease) both;
	}

	.sg-motion [data-sg-reveal="registro"].is-in::after {
		animation: sg-registro-m var(--sg-t4) var(--sg-ease) 40ms both;
	}

	@keyframes sg-registro-c {
		0% { opacity: 0.9; transform: translate(-9px, 4px); }
		70% { opacity: 0.55; transform: translate(0, 0); }
		100% { opacity: 0; transform: translate(0, 0); }
	}

	@keyframes sg-registro-m {
		0% { opacity: 0.85; transform: translate(8px, -5px); }
		70% { opacity: 0.5; transform: translate(0, 0); }
		100% { opacity: 0; transform: translate(0, 0); }
	}

	/* racla — la passata scopre il blocco da sinistra, con il filo della racla davanti */
	.sg-motion [data-sg-reveal="racla"] {
		position: relative;
	}

	.sg-motion [data-sg-reveal="racla"]:not(.is-in) {
		clip-path: inset(0 100% 0 0);
	}

	.sg-motion [data-sg-reveal="racla"].is-in {
		clip-path: inset(0 0 0 0);
		transition: clip-path 640ms var(--sg-ease-in-out) var(--sg-d, 0ms);
	}

	.sg-motion [data-sg-reveal="racla"]::after {
		content: "";
		position: absolute;
		inset-block: 0;
		inset-inline-start: 0;
		width: 100%;
		border-inline-end: 4px solid var(--wp--preset--color--brand);
		pointer-events: none;
		transform: translateX(-100%);
		opacity: 0;
	}

	/* Il filo segue esattamente il bordo del ritaglio (stessa durata e curva), poi si stacca dal foglio */
	.sg-motion [data-sg-reveal="racla"].is-in::after {
		animation:
			sg-racla 640ms var(--sg-ease-in-out) var(--sg-d, 0ms) both,
			sg-racla-via 200ms linear calc(var(--sg-d, 0ms) + 640ms) forwards;
	}

	@keyframes sg-racla {
		from { transform: translateX(-100%); opacity: 1; }
		to { transform: translateX(0); opacity: 1; }
	}

	@keyframes sg-racla-via {
		to { opacity: 0; }
	}

	/* laser — una riga ciano incide il bordo della riga da sinistra, poi si spegne e resta il filetto */
	.sg-motion [data-sg-reveal="laser"] {
		position: relative;
	}

	.sg-motion [data-sg-reveal="laser"]::before {
		content: "";
		position: absolute;
		inset: -1px 0 auto 0;
		height: 2px;
		background: var(--wp--preset--color--brand);
		transform: scaleX(0);
		transform-origin: left center;
		pointer-events: none;
	}

	.sg-motion [data-sg-reveal="laser"].is-in::before {
		animation: sg-incisione 720ms var(--sg-ease-in-out) var(--sg-d, 0ms) both;
	}

	.sg-motion [data-sg-reveal="laser"] > * {
		transition: opacity var(--sg-t3) var(--sg-ease) calc(var(--sg-d, 0ms) + 160ms), transform var(--sg-t3) var(--sg-ease) calc(var(--sg-d, 0ms) + 160ms);
	}

	.sg-motion [data-sg-reveal="laser"]:not(.is-in) > * {
		opacity: 0;
		transform: translateY(10px);
	}

	@keyframes sg-incisione {
		0% { transform: scaleX(0); opacity: 1; }
		65% { transform: scaleX(1); opacity: 1; }
		100% { transform: scaleX(1); opacity: 0; }
	}

	/* passate — la foto esce a bande dall'alto, otto passate della testina */
	.sg-motion [data-sg-reveal="passate"] img {
		transition: clip-path 720ms steps(8, end) var(--sg-d, 0ms), transform var(--sg-t2) var(--sg-ease);
	}

	.sg-motion [data-sg-reveal="passate"]:not(.is-in) img {
		clip-path: inset(0 0 100% 0);
	}

	.sg-motion [data-sg-reveal="passate"] :is(.sg-lavoro__body, .sg-catalogo__body, figcaption) {
		transition: opacity var(--sg-t3) var(--sg-ease) calc(var(--sg-d, 0ms) + 360ms);
	}

	.sg-motion [data-sg-reveal="passate"]:not(.is-in) :is(.sg-lavoro__body, .sg-catalogo__body, figcaption) {
		opacity: 0;
	}

	/* riga — blocchi di testo e moduli: salgono di poco, senza effetti */
	.sg-motion [data-sg-reveal="riga"] {
		transition: opacity var(--sg-t3) var(--sg-ease) var(--sg-d, 0ms), transform var(--sg-t3) var(--sg-ease) var(--sg-d, 0ms);
	}

	.sg-motion [data-sg-reveal="riga"]:not(.is-in) {
		opacity: 0;
		transform: translateY(14px);
	}
}
