/*
 * Toast (.cw-toast): "added to cart" notice. Fixed at the bottom right (top on mobile, < 900px); --static keeps it
 * in the document flow (styleguide). Behavior: assets/js/toast.js (window.cwToast), markup: footer/toast-region.php.
 */
.cw-toast {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: var(--cw-z-toast);
	display: flex;
	width: min(380px, calc(100% - 32px));
	flex-direction: column;
	gap: 14px;
	padding: 16px;
	border: 1px solid var(--cw-color-line);
	border-radius: var(--cw-radius);
	background: var(--cw-color-surface);
	box-shadow: var(--cw-shadow-lg);
}

.cw-toast--static {
	position: static;
	max-width: 380px;
	animation: none;
}

.cw-toast__row {
	display: flex;
	align-items: center;
	gap: 14px;
}

.cw-toast__thumb {
	position: relative;
	display: grid;
	width: 60px;
	height: 60px;
	flex: 0 0 auto;
	place-items: center;
	border-radius: var(--cw-radius);
	background: var(--cw-color-subtle);
}

.cw-toast .cw-toast__thumb img {
	width: 100%;
	height: 100%;
	border-radius: inherit;
	object-fit: contain;
}

.cw-toast__check {
	position: absolute;
	top: -6px;
	right: -6px;
	display: grid;
	width: 22px;
	height: 22px;
	place-items: center;
	border: 2px solid var(--cw-color-surface);
	border-radius: 50%;
	background: var(--cw-color-success);
	color: var(--cw-color-surface);
}

.cw-toast__check .cw-icon {
	width: 12px;
	height: 12px;
	stroke-width: 3;
}

.cw-toast__text {
	min-width: 0;
	flex: 1 1 auto;
}

.cw-toast__title,
.cw-toast__name,
.cw-toast__meta {
	margin: 0;
}

.cw-toast__title {
	color: var(--cw-color-success);
	font-size: 13px;
	font-weight: 700;
}

.cw-toast__name {
	overflow: hidden;
	color: var(--cw-color-ink);
	font-size: 15px;
	font-weight: 700;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.cw-toast__meta {
	color: var(--cw-color-text-2);
	font-size: 13px;
}

.cw-toast__close {
	display: grid;
	width: 32px;
	height: 32px;
	flex: 0 0 auto;
	margin: 0;
	padding: 0;
	place-items: center;
	border: 0;
	border-radius: var(--cw-radius);
	background: var(--cw-color-subtle);
	color: var(--cw-color-ink);
	cursor: pointer;
}

.cw-toast__close .cw-icon {
	width: 16px;
	height: 16px;
}

.cw-toast__progress {
	height: 3px;
	overflow: hidden;
	border-radius: var(--cw-radius);
	background: var(--cw-color-subtle);
}

.cw-toast__bar {
	display: block;
	width: 100%;
	height: 100%;
	background: var(--cw-color-button);
	transform-origin: left center;
	animation: cw-toast-progress var(--cw-toast-duration, 4500ms) linear forwards;
}

/* Paused while the pointer or the focus is on the toast (toast.js adds the class). */
.cw-toast.is-paused .cw-toast__bar {
	animation-play-state: paused;
}

.cw-toast--static .cw-toast__bar {
	width: 60%;
	animation: none;
}

.cw-toast__title-qty {
	display: none;
}

@keyframes cw-toast-progress {
	from {
		transform: scaleX(1);
	}

	to {
		transform: scaleX(0);
	}
}

@keyframes cw-toast-in {
	from {
		opacity: 0;
		transform: translateY(12px);
	}

	to {
		opacity: 1;
		transform: translateY(0);
	}
}

@media (prefers-reduced-motion: no-preference) {
	.cw-toast {
		animation: cw-toast-in .22s ease both;
	}

	.cw-toast--static {
		animation: none;
	}
}

/*
 * Mobile: compact one-row notice at the top, centered and at most 420px wide: 44px check box (success-soft) instead of
 * the thumbnail, "Agregado al carrito · N u." and the product name, close button. No total and no progress bar
 * (the 4.5 s timer still runs).
 */
@media (max-width: 899px) {
	.cw-toast:not(.cw-toast--static) {
		top: calc(var(--cw-admin-bar-offset) + 12px);
		right: 12px;
		bottom: auto;
		left: 12px;
		width: auto;
		max-width: 420px;
		margin-inline: auto;
		gap: 0;
		padding: 10px 12px;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__row {
		gap: 12px;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__name {
		font-size: 14px;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__progress {
		display: none;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__thumb {
		width: 44px;
		height: 44px;
		background: var(--cw-color-success-soft);
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__thumb img {
		display: none;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__check {
		position: static;
		width: auto;
		height: auto;
		border: 0;
		background: transparent;
		color: var(--cw-color-success);
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__check .cw-icon {
		width: 22px;
		height: 22px;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__meta {
		display: none;
	}

	.cw-toast:not(.cw-toast--static) .cw-toast__title-qty:not([hidden]) {
		display: inline;
	}
}
