/*
 * Toast notices: WooCommerce messages re-rendered as corner pop-ups.
 */

/*
 * Hide the originals only when the flag script ran, meaning JavaScript
 * is available to re-render them. Scoped to the containers WooCommerce
 * prints transient notices into, so informational blocks that reuse the
 * same classes as UI (coupon toggles, "cart is empty") stay put.
 */
html.rua-toasts-ready .woocommerce-notices-wrapper > .woocommerce-message,
html.rua-toasts-ready .woocommerce-notices-wrapper > .woocommerce-error,
html.rua-toasts-ready .woocommerce-notices-wrapper > .woocommerce-info,
html.rua-toasts-ready .woocommerce-NoticeGroup > .woocommerce-message,
html.rua-toasts-ready .woocommerce-NoticeGroup > .woocommerce-error,
html.rua-toasts-ready .woocommerce-NoticeGroup > .woocommerce-info {
	display: none;
}

/*
 * The stack. Bottom right on wide screens, out of the way of the header
 * and any search strip under it; on phones centred at the foot of the
 * screen, above the theme's tab bar or buy bar (which report the space
 * they take through --rua-tabbar-offset; 0 without one, or under another
 * theme). Toasts size to their text rather than filling the width.
 */
.rua-toasts {
	align-items: flex-end;
	bottom: 20px;
	display: flex;
	flex-direction: column;
	gap: 8px;
	max-width: min(380px, calc(100vw - 32px));
	pointer-events: none;
	position: fixed;
	right: 20px;
	z-index: 100000;
}

/*
 * One toast: a dark chip -- ink on wide screens, cream text -- with the
 * message and, beside it when it fits, a text action such as View bag.
 * Small enough to read past; a tap anywhere on it puts it away.
 */
.rua-toast {
	--rua-toast-accent: #f2b8c6;

	align-items: center;
	background: #2b2626;
	border-radius: 12px;
	box-shadow: 0 10px 30px rgba(43, 38, 38, 0.28), 0 1px 2px rgba(0, 0, 0, 0.12);
	color: #fff6e8;
	display: flex;
	font-family: inherit;
	font-size: 13.5px;
	gap: 10px;
	line-height: 1.4;
	max-width: 100%;
	opacity: 0;
	padding: 10px 12px 10px 14px;
	pointer-events: auto;
	transform: translateY(10px) scale(0.98);
	transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.rua-toast.is-visible {
	opacity: 1;
	transform: none;
}

.rua-toast.is-leaving {
	opacity: 0;
	transform: translateY(10px) scale(0.98);
}

.rua-toast--error {
	--rua-toast-accent: #ff9b9b;
}

.rua-toast--info {
	--rua-toast-accent: #cfc4bd;
}

.rua-toast__icon {
	color: var(--rua-toast-accent);
	display: inline-flex;
	flex: none;
}

.rua-toast__icon svg {
	height: 18px;
	width: 18px;
}

/* Text and action share a line while they fit; the action wraps under otherwise. */
.rua-toast__body {
	align-items: center;
	column-gap: 14px;
	display: flex;
	flex: 1 1 auto;
	flex-wrap: wrap;
	min-width: 0;
	row-gap: 4px;
}

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

.rua-toast__body a:not(.button) {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 0.15em;
}

.rua-toast__list {
	flex: 1 1 auto;
	list-style: none;
	margin: 0;
	min-width: 0;
	padding: 0;
}

.rua-toast__list li + li {
	margin-top: 4px;
}

.rua-toast__actions {
	display: flex;
	flex: none;
	gap: 12px;
	margin-left: auto;
}

/*
 * Actions are words, not buttons: a small capitals link in the accent.
 * Written with the stack and the toast in the selector so it outranks a
 * theme's `.woocommerce :is(a.button, button.button.alt)` on shop pages.
 */
.rua-toasts .rua-toast .rua-toast__actions .button,
.rua-toasts .rua-toast .rua-toast__actions a.button {
	background: none;
	border: 0;
	border-radius: 0;
	color: var(--rua-toast-accent);
	display: inline-block;
	font-size: 12px;
	font-weight: 600;
	letter-spacing: 0.08em;
	line-height: 1;
	padding: 4px 0;
	text-decoration: none;
	text-transform: uppercase;
	white-space: nowrap;
}

.rua-toasts .rua-toast .rua-toast__actions .button:hover,
.rua-toasts .rua-toast .rua-toast__actions a.button:hover,
.rua-toasts .rua-toast .rua-toast__actions .button:focus-visible,
.rua-toasts .rua-toast .rua-toast__actions a.button:focus-visible {
	color: #fff;
	text-decoration: underline;
	text-underline-offset: 0.2em;
}

.rua-toast__close {
	background: none;
	border: 0;
	border-radius: 50%;
	color: rgba(255, 246, 232, 0.6);
	cursor: pointer;
	flex: none;
	font-size: 18px;
	height: 28px;
	line-height: 1;
	margin: -2px -4px -2px 0;
	padding: 0;
	width: 28px;
}

.rua-toast__close:hover,
.rua-toast__close:focus-visible {
	background: rgba(255, 255, 255, 0.1);
	color: #fff6e8;
}

@media (max-width: 640px) {
	.rua-toasts {
		align-items: center;
		bottom: calc(var(--rua-tabbar-offset, 0px) + 12px);
		left: 16px;
		max-width: none;
		right: 16px;
	}

	/* A chip; a message and its action often take two lines here, so no pill. */
	.rua-toast {
		border-radius: 16px;
		font-size: 13px;
		padding: 9px 14px;
	}

	/* A tap on the toast, or a swipe down, puts it away; no cross needed. */
	.rua-toast__close {
		display: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.rua-toast {
		transition: none;
	}
}
