/*
 * Site-wide toast notifications (window.linfasyToast, assets/js/toast.js).
 * Loaded unconditionally alongside dist/style.css since any page can
 * trigger one (newsletter forms today, more AJAX actions later).
 * Uses the site's existing design tokens (see :root in dist/style.css).
 */

#linfasy-toast-root {
	position: fixed;
	top: 1.25rem;
	right: 1.25rem;
	z-index: 9999;
	display: flex;
	flex-direction: column;
	gap: 0.75rem;
	width: min(22rem, calc(100vw - 2rem));
	pointer-events: none;
}
@media (max-width: 640px) {
	#linfasy-toast-root {
		top: 1rem;
		right: 1rem;
		left: 1rem;
		width: auto;
	}
}

.lm-toast {
	position: relative;
	overflow: hidden;
	display: flex;
	align-items: flex-start;
	gap: 0.75rem;
	border-radius: 1rem;
	border: 1px solid color-mix(in oklch, var(--border) 60%, transparent);
	background: color-mix(in oklch, var(--card) 92%, transparent);
	backdrop-filter: blur(10px);
	-webkit-backdrop-filter: blur(10px);
	box-shadow: var(--shadow-soft);
	padding: 0.9rem 1rem;
	pointer-events: auto;
	opacity: 0;
	transform: translateX(1.5rem) scale(0.96);
	transition: opacity 0.35s cubic-bezier(.22,1,.36,1), transform 0.35s cubic-bezier(.22,1,.36,1);
}
.lm-toast.is-visible {
	opacity: 1;
	transform: translateX(0) scale(1);
}
.lm-toast.is-leaving {
	opacity: 0;
	transform: translateX(1.5rem) scale(0.96);
}

.lm-toast-icon {
	flex-shrink: 0;
	display: grid;
	place-items: center;
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 9999px;
}
.lm-toast--success .lm-toast-icon {
	background: color-mix(in oklch, var(--primary) 15%, transparent);
	color: var(--primary);
}
.lm-toast--error .lm-toast-icon {
	background: color-mix(in oklch, var(--sale) 15%, transparent);
	color: var(--sale);
}
.lm-toast-icon svg {
	width: 1rem;
	height: 1rem;
}
.lm-toast-icon .lm-toast-check {
	stroke-dasharray: 20;
	stroke-dashoffset: 20;
	animation: lm-toast-check-draw 0.4s 0.15s cubic-bezier(.65,0,.35,1) forwards;
}
@keyframes lm-toast-check-draw {
	to { stroke-dashoffset: 0; }
}

.lm-toast-body {
	flex: 1 1 auto;
	min-width: 0;
	font-family: var(--font-sans);
	font-size: 0.8rem;
	line-height: 1.5;
	color: var(--foreground);
	padding-top: 0.15rem;
}

.lm-toast-close {
	flex-shrink: 0;
	display: grid;
	place-items: center;
	width: 1.5rem;
	height: 1.5rem;
	border-radius: 9999px;
	border: 0;
	background: none;
	color: var(--muted-foreground);
	cursor: pointer;
	transition: color 0.15s, background-color 0.15s;
}
.lm-toast-close:hover {
	color: var(--foreground);
	background: color-mix(in oklch, var(--border) 40%, transparent);
}
.lm-toast-close svg {
	width: 0.8rem;
	height: 0.8rem;
}

.lm-toast-bar {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 2px;
	width: 100%;
	transform-origin: left;
	animation: lm-toast-shrink linear forwards;
	animation-duration: var(--lm-toast-duration, 4s);
}
.lm-toast--success .lm-toast-bar {
	background: var(--primary);
}
.lm-toast--error .lm-toast-bar {
	background: var(--sale);
}
@keyframes lm-toast-shrink {
	from { transform: scaleX(1); }
	to { transform: scaleX(0); }
}

@media (prefers-reduced-motion: reduce) {
	.lm-toast {
		transition: opacity 0.2s;
		transform: none !important;
	}
	.lm-toast-bar {
		animation: none;
	}
}
