/**
 * Toast component
 *
 * Transient notifications stacked in the top-right corner. Generic: any
 * combination of thumbnail, title, subtitle, label/value rows and actions.
 *
 * Rendered by thyme_toast() (inc/toast.php) or created at runtime with
 * window.thymeToast.show(). The region itself is printed once in the footer.
 *
 *   <div class="toast-region" aria-live="polite">
 *     <article class="toast" role="status">
 *       <button class="toast__close" data-toast-close>…</button>
 *       <div class="toast__media"> <img> </div>
 *       <div class="toast__body">
 *         <p class="toast__title">…</p>
 *         <p class="toast__subtitle">…</p>
 *         <dl class="toast__meta"> <dt>Size</dt><dd>M</dd> </dl>
 *         <div class="toast__actions"> <a class="link-mono">Go to Cart</a> </div>
 *       </div>
 *     </article>
 *   </div>
 */

.toast-region {
	position: fixed;
	/* Clears the site header rather than sitting on top of the nav. */
	top: var(--toast-offset, 5rem);
	right: var(--space-4);
	z-index: 1100;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: var(--space-3);
	width: min(100% - var(--space-8), 30rem);
	/* The region spans a column; only the toasts themselves take clicks. */
	pointer-events: none;
}

.toast-region:empty {
	display: none;
}

.toast {
	position: relative;
	display: flex;
	gap: var(--space-5);
	width: 100%;
	padding: var(--space-5);
	padding-right: var(--space-10);
	text-align: left;
	background: var(--color-surface);
	border: var(--border-width) solid var(--color-border);
	border-radius: var(--radius-none);
	pointer-events: auto;
}

/* Entry / exit — skipped entirely under reduced motion. */
@media (prefers-reduced-motion: no-preference) {
	.toast {
		animation: toast-in 220ms ease both;
	}

	.toast.is-leaving {
		animation: toast-out 160ms ease both;
	}
}

@keyframes toast-in {
	from { opacity: 0; transform: translateY(-0.5rem); }
	to   { opacity: 1; transform: none; }
}

@keyframes toast-out {
	from { opacity: 1; transform: none; }
	to   { opacity: 0; transform: translateY(-0.5rem); }
}

/* --- Close --- */

.toast__close {
	position: absolute;
	top: var(--space-3);
	right: var(--space-3);
	display: grid;
	place-content: center;
	width: 1rem;
	height: 1rem;
	padding: 0;
	color: var(--color-accent);
	background: transparent;
	border: 0;
	cursor: pointer;
	transition: color var(--transition-fast);
}

.toast__close svg {
	display: block;
	width: 100%;
	height: 100%;
}

.toast__close:hover {
	color: var(--color-accent-hover);
}

.toast__close:focus-visible {
	outline: var(--border-width-strong) solid var(--color-border-strong);
	outline-offset: 2px;
}

/* --- Media --- */

.toast__media {
	flex: none;
	width: 8rem;
	aspect-ratio: 3 / 4;
	overflow: hidden;
	background: var(--color-surface-muted);
}

.toast__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* --- Body --- */

.toast__body {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
	min-width: 0;
}

.toast__title {
	font-family: var(--font-heading);
	font-size: var(--text-sm);
	font-weight: var(--weight-semibold);
	line-height: var(--line-snug);
	letter-spacing: var(--tracking-wide);
	text-transform: uppercase;
	color: var(--color-heading);
	margin: 0;
}

.toast__title a {
	color: inherit;
	text-decoration: none;
}

.toast__title a:hover {
	text-decoration: underline;
	text-underline-offset: 0.25em;
}

.toast__subtitle {
	font-family: var(--font-mono);
	font-size: var(--text-sm);
	font-weight: var(--weight-medium);
	letter-spacing: var(--tracking-wide);
	color: var(--color-heading);
	margin: 0;
}

/* Free text, when there is no product attached. */
.toast__text {
	font-size: var(--text-sm);
	line-height: var(--line-normal);
	color: var(--color-text);
	margin: 0;
}

/* --- Label / value rows --- */

.toast__meta {
	display: grid;
	grid-template-columns: auto minmax(0, 1fr);
	gap: var(--space-1) var(--space-5);
	margin: var(--space-2) 0 0;
}

.toast__meta dt {
	font-size: var(--text-xs);
	color: var(--color-muted);
}

.toast__meta dd {
	font-size: var(--text-xs);
	color: var(--color-heading);
	margin: 0;
	min-width: 0;
	overflow-wrap: break-word;
}

/* --- Actions --- */

.toast__actions {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-4);
	margin-top: var(--space-3);
}

/* --- Tones --- */

.toast--success { border-left: var(--border-width-strong) solid var(--color-primary); }
.toast--error { border-left: var(--border-width-strong) solid var(--color-accent); }

@media (max-width: 40rem) {
	.toast-region {
		top: var(--space-16);
		right: var(--space-3);
		left: var(--space-3);
		width: auto;
	}

	.toast {
		gap: var(--space-4);
		padding: var(--space-4);
		padding-right: var(--space-8);
	}

	.toast__media {
		width: 5rem;
	}
}
