/*
 * The site's toast, for adds to cart and wishlist messages.
 *
 * A small white card in the site's style: the product's picture on its
 * pastel tile, "Added to cart ✓", the name and a "View cart" link. Bottom
 * right on desktop, across the bottom on phones. Errors swap the picture
 * for a red "!" and stay until closed.
 */
.kawaii-toast-region {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 100000;
	pointer-events: none;
}

/*
 * Toasts stack in the corner: each sits at the region's bottom edge, and
 * cart-toast.js lifts and shrinks the older ones behind the newest through
 * --kawaii-toast-y and --kawaii-toast-scale.
 */
.kawaii-toast-region > .kawaii-toast {
	position: absolute;
	right: 0;
	bottom: 0;
}

.kawaii-toast {
	--kawaii-toast-ink: var(--wp--preset--color--contrast, #302a3a);
	--kawaii-toast-muted: var(--wp--preset--color--accent-4, #746a78);
	--kawaii-toast-pink: #ec5687;

	position: relative;
	display: flex;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	width: 340px;
	max-width: calc(100vw - 32px);
	padding: 12px 12px 12px 12px;
	overflow: hidden;
	border: 1px solid var(--wp--preset--color--accent-6, #f0e5ec);
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 12px 35px rgba(80, 50, 80, 0.14);
	color: var(--kawaii-toast-ink);
	font-family: inherit;
	pointer-events: auto;
	opacity: 0;
	transform: translateY(16px);
	transform-origin: top center;
	transition: opacity 0.28s ease, transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.35s ease;
}

.kawaii-toast.is-visible {
	opacity: 1;
	transform: translateY(var(--kawaii-toast-y, 0px)) scale(var(--kawaii-toast-scale, 1));
}

/* Behind the newest: a lighter shadow, its content faded, its timer bar hidden. */
.kawaii-toast.is-behind {
	box-shadow: 0 6px 18px rgba(80, 50, 80, 0.1);
}

.kawaii-toast.is-behind > * {
	opacity: 0.35;
	transition: opacity 0.25s ease;
}

.kawaii-toast.is-behind .kawaii-toast__progress {
	visibility: hidden;
}

.kawaii-toast__media {
	display: flex;
	flex: none;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	overflow: hidden;
	border-radius: 14px;
	background: #ffe9f1;
}

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

.kawaii-toast__body {
	flex: 1;
	min-width: 0;
}

.kawaii-toast__title {
	display: flex;
	align-items: center;
	gap: 6px;
	margin: 0;
	font-size: 13px;
	font-weight: 800;
	line-height: 1.3;
}

.kawaii-toast__check {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 16px;
	height: 16px;
	border-radius: 50%;
	background: var(--wp--preset--color--accent-1, #ff79a7);
	color: #fff;
	font-size: 10px;
	line-height: 1;
}

/* Up to two lines, for the longer wishlist messages; then an ellipsis. */
.kawaii-toast__text {
	display: -webkit-box;
	margin: 2px 0 0;
	overflow: hidden;
	font-size: 12px;
	line-height: 1.4;
	color: var(--kawaii-toast-muted);
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.kawaii-toast__action {
	margin: 6px 0 0;
	padding: 0;
	border: 0;
	background: none;
	color: var(--kawaii-toast-pink);
	font: inherit;
	font-size: 11px;
	font-weight: 900;
	letter-spacing: 0.02em;
	text-transform: uppercase;
	cursor: pointer;
}

.kawaii-toast__action:hover,
.kawaii-toast__action:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}

.kawaii-toast__close {
	display: flex;
	flex: none;
	align-self: flex-start;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--kawaii-toast-muted);
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
}

.kawaii-toast__close:hover,
.kawaii-toast__close:focus-visible {
	background: #fff0f5;
	color: var(--kawaii-toast-ink);
}

.kawaii-toast__close svg {
	width: 14px;
	height: 14px;
	fill: none;
	stroke: currentColor;
	stroke-width: 2.2;
	stroke-linecap: round;
}

.kawaii-toast :focus-visible {
	outline: 2px solid var(--wp--preset--color--accent-1, #ff79a7);
	outline-offset: 2px;
}

/* Heart badge beside the title, for wishlist toasts. */
.kawaii-toast__check--heart svg {
	width: 9px;
	height: 9px;
	fill: currentColor;
}

/* Without a product picture (wishlist page actions): a pink heart. */
.kawaii-toast__heart {
	display: flex;
	color: var(--wp--preset--color--accent-1, #ff79a7);
}

.kawaii-toast__heart svg {
	width: 24px;
	height: 24px;
	fill: currentColor;
}

/* Time left before it hides, as a thin pink line along the bottom. */
.kawaii-toast__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	width: 100%;
	height: 3px;
	background: var(--wp--preset--color--accent-1, #ff79a7);
	opacity: 0.55;
	transform-origin: left center;
	animation: kawaii-toast-progress 4s linear forwards;
}

.kawaii-toast.is-paused .kawaii-toast__progress {
	animation-play-state: paused;
}

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

	to {
		transform: scaleX(0);
	}
}

/* Error */
.kawaii-toast--error {
	border-color: #fbd5da;
}

.kawaii-toast--error .kawaii-toast__media {
	background: #ffe8eb;
}

.kawaii-toast__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	border-radius: 50%;
	background: #e5484d;
	color: #fff;
	font-size: 15px;
	font-weight: 900;
	line-height: 1;
}

.kawaii-toast--error .kawaii-toast__text {
	display: block;
}

/* Phones: across the bottom, within thumb reach. */
@media (max-width: 600px) {
	.kawaii-toast-region {
		right: 16px;
		bottom: 16px;
		left: 16px;
	}

	.kawaii-toast {
		width: 100%;
		max-width: none;
	}

	.kawaii-toast-region > .kawaii-toast {
		left: 0;
	}
}

@media (prefers-reduced-motion: reduce) {
	/* The stack keeps its offsets; only the movement goes. */
	.kawaii-toast {
		transition: opacity 0.2s ease;
	}

	.kawaii-toast:not(.is-visible) {
		transform: none;
	}

	.kawaii-toast__progress {
		display: none;
	}
}

/*
 * Product cards: the toast replaces WooCommerce's "View cart" link, and the
 * button says "Added ✓" for a moment after an add.
 */
.wc-block-components-product-button .added_to_cart,
.wc-block-components-product-button + .added_to_cart,
.add_to_cart_button + .added_to_cart {
	display: none !important;
}

/* The link's wrapper too: once WooCommerce unhides it, it is an extra row in
   the button's flex column and lifts the button off the card's bottom. */
.wc-block-components-product-button > span[data-wp-bind--hidden],
.wc-block-components-product-button > span:has(> .added_to_cart) {
	display: none !important;
}

/*
 * "Added ✓" on the card's button: the label slides up and out while
 * "Added ✓" rises in from below, then the reverse. The script keeps the
 * attribute after the first add, so the text is still there on the way out.
 */
.wc-block-components-product-button__button[data-kawaii-added] > span {
	display: inline-block;
	transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
}

.wc-block-components-product-button__button.is-kawaii-added > span {
	opacity: 0;
	transform: translateY(-120%);
}

/* WooCommerce slides the label out and back in after every add, which only
   made sense for its "N in cart" text. Cut it to a blink: the label no longer
   changes, and its state machine still gets the animationend it waits for. */
.wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button span.wc-block-slide-out,
.wp-block-button.wc-block-components-product-button .wc-block-components-product-button__button span.wc-block-slide-in {
	animation-duration: 1ms !important;
}

.wc-block-components-product-button__button[data-kawaii-added]::before,
.add_to_cart_button:not(.wc-block-components-product-button__button)[data-kawaii-added]::before {
	content: attr(data-kawaii-added);
	position: absolute;
	inset: 0;
	z-index: 1;
	display: flex;
	align-items: center;
	justify-content: center;
	opacity: 0;
	transform: translateY(120%);
	transition: transform 0.35s cubic-bezier(0.2, 0.8, 0.2, 1), opacity 0.25s ease;
	pointer-events: none;
}

.wc-block-components-product-button__button.is-kawaii-added::before,
.add_to_cart_button:not(.wc-block-components-product-button__button).is-kawaii-added::before {
	opacity: 1;
	transform: none;
}

/* Classic buttons hold their label as bare text, so it fades by colour, and
   "Added ✓" names its own colour instead of inheriting the transparent one. */
.add_to_cart_button:not(.wc-block-components-product-button__button)[data-kawaii-added] {
	transition: color 0.25s ease;
}

.add_to_cart_button:not(.wc-block-components-product-button__button).is-kawaii-added {
	color: transparent !important;
}

.add_to_cart_button:not(.wc-block-components-product-button__button)[data-kawaii-added]::before {
	color: var(--wp--preset--color--contrast, #302a3a);
}

@media (prefers-reduced-motion: reduce) {
	.wc-block-components-product-button__button[data-kawaii-added] > span,
	.wc-block-components-product-button__button[data-kawaii-added]::before,
	.add_to_cart_button:not(.wc-block-components-product-button__button)[data-kawaii-added]::before {
		transform: none !important;
		transition: opacity 0.2s ease;
	}
}
