/**
 * Notice toast.
 *
 * Stack fisso in alto a destra (in alto-centro su mobile stretto). Ogni
 * toast ha icona, testo, azione opzionale (es. "Visualizza carrello"),
 * pulsante chiudi e barra di progresso del timer.
 *
 * Varianti: success (default, bordo --success), info (--ink-3), error (--brand).
 * L'animazione di entrata è solo transform/opacity (no layout) e usa una
 * curva ease-out-quint coerente con il resto del tema.
 */

/* Quando JS è attivo (classe iniettata inline in <head>), nascondiamo le notice
 * WC originali prima del primo paint: il JS le promuove a toast subito dopo.
 * Senza JS la classe non esiste e le notice restano visibili nel loro flow. */
.mz-toast-ready .woocommerce-notices-wrapper,
.mz-toast-ready .woocommerce-message,
.mz-toast-ready .woocommerce-error,
.mz-toast-ready .woocommerce-info {
	position: absolute !important;
	width: 1px;
	height: 1px;
	margin: 0;
	padding: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

.mz-toast-stack {
	position: fixed;
	top: max(1rem, env(safe-area-inset-top));
	right: max(1rem, env(safe-area-inset-right));
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: 10px;
	width: min(380px, calc(100vw - 2rem));
	pointer-events: none;
}

.mz-toast {
	pointer-events: auto;
	position: relative;
	display: grid;
	grid-template-columns: auto 1fr auto;
	align-items: start;
	gap: 12px;
	padding: 14px 14px 14px 16px;
	background: var(--paper-2);
	color: var(--ink-1);
	border: 1px solid var(--stroke, color-mix(in oklch, var(--ink-1) 12%, transparent));
	border-radius: 12px;
	box-shadow:
		0 1px 0 color-mix(in oklch, var(--ink-1) 4%, transparent),
		0 8px 24px -8px color-mix(in oklch, var(--ink-1) 22%, transparent),
		0 24px 48px -24px color-mix(in oklch, var(--ink-1) 28%, transparent);
	overflow: hidden;
	opacity: 0;
	transform: translateX(16px) scale(0.985);
	transition:
		opacity 260ms cubic-bezier(0.22, 1, 0.36, 1),
		transform 360ms cubic-bezier(0.22, 1, 0.36, 1);
}

.mz-toast--in {
	opacity: 1;
	transform: translateX(0) scale(1);
}

.mz-toast--out {
	opacity: 0;
	transform: translateX(24px) scale(0.98);
	transition:
		opacity 200ms cubic-bezier(0.4, 0, 1, 1),
		transform 220ms cubic-bezier(0.4, 0, 1, 1);
}

/* Striscia colorata accent in cima (full-width, sottile). NON un side-stripe. */
.mz-toast::before {
	content: "";
	position: absolute;
	inset: 0 0 auto 0;
	height: 2px;
	background: var(--success);
}
.mz-toast--error::before { background: var(--brand); }
.mz-toast--info::before  { background: var(--ink-3); }

.mz-toast__icon {
	flex-shrink: 0;
	display: inline-flex;
	width: 22px;
	height: 22px;
	color: var(--success);
	margin-top: 1px;
}
.mz-toast--error .mz-toast__icon { color: var(--brand); }
.mz-toast--info  .mz-toast__icon { color: var(--ink-2); }

.mz-toast__icon svg {
	width: 100%;
	height: 100%;
	fill: none;
	stroke: currentColor;
	stroke-width: 1.75;
	stroke-linecap: round;
	stroke-linejoin: round;
}

.mz-toast__body {
	min-width: 0;
}

.mz-toast__text {
	margin: 0;
	font-size: 14px;
	line-height: 1.4;
	color: var(--ink-1);
	font-weight: 500;
	word-wrap: break-word;
	overflow-wrap: anywhere;
}

.mz-toast__action {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	margin-top: 8px;
	font-size: 13px;
	font-weight: 600;
	line-height: 1;
	color: var(--brand);
	text-decoration: none;
	letter-spacing: -0.005em;
	transition: color 160ms ease-out, gap 200ms cubic-bezier(0.22, 1, 0.36, 1);
}
.mz-toast__action svg {
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
	stroke-linejoin: round;
	transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}
.mz-toast__action:hover,
.mz-toast__action:focus-visible {
	color: var(--brand-ink);
	gap: 6px;
}
.mz-toast__action:hover svg,
.mz-toast__action:focus-visible svg { transform: translateX(2px); }

.mz-toast__close {
	flex-shrink: 0;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	margin: -3px -3px 0 0;
	padding: 0;
	background: transparent;
	border: 0;
	border-radius: 6px;
	color: var(--ink-3);
	cursor: pointer;
	transition: color 140ms ease-out, background-color 140ms ease-out;
}
.mz-toast__close:hover,
.mz-toast__close:focus-visible {
	color: var(--ink-1);
	background: color-mix(in oklch, var(--ink-1) 6%, transparent);
	outline: none;
}
.mz-toast__close svg {
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2;
	stroke-linecap: round;
}

.mz-toast__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 2px;
	width: 100%;
	background: color-mix(in oklch, var(--success) 70%, transparent);
	transform-origin: left center;
	transform: scaleX(1);
}
.mz-toast--error .mz-toast__progress { background: color-mix(in oklch, var(--brand) 70%, transparent); }
.mz-toast--info  .mz-toast__progress { background: color-mix(in oklch, var(--ink-3) 70%, transparent); }

.mz-toast--in .mz-toast__progress {
	animation: mz-toast-progress 5000ms linear forwards;
}
.mz-toast--paused .mz-toast__progress {
	animation-play-state: paused;
}

@keyframes mz-toast-progress {
	from { transform: scaleX(1); }
	to   { transform: scaleX(0); }
}

/* Mobile: pannello largo full-width in alto, lievemente più compatto. */
@media (max-width: 540px) {
	.mz-toast-stack {
		left: max(0.75rem, env(safe-area-inset-left));
		right: max(0.75rem, env(safe-area-inset-right));
		width: auto;
	}
	.mz-toast { padding: 12px 12px 12px 14px; }
	.mz-toast__text { font-size: 13.5px; }
}

@media (prefers-reduced-motion: reduce) {
	.mz-toast,
	.mz-toast--out,
	.mz-toast__action,
	.mz-toast__action svg,
	.mz-toast__close {
		transition: opacity 120ms linear !important;
		transform: none !important;
	}
	.mz-toast--in .mz-toast__progress { animation: none; transform: scaleX(0); }
}
