/*
 * Toasts: WooCommerce notices shown as a fixed stack (bottom right).
 * Woo's own markup is kept (.woocommerce-notices-wrapper > .woocommerce-message / -info / -error,
 * or .wc-block-components-notice-banner); this only repositions and restyles it.
 * Checkout form errors (inside form.checkout) stay inline, next to the fields.
 * Behaviour (close button, auto-dismiss, AJAX add-to-cart toast): assets/js/toast.js.
 */

.woocommerce-notices-wrapper:not(form.checkout .woocommerce-notices-wrapper),
.hs-toasts {
	position: fixed;
	right: 24px;
	bottom: 24px;
	z-index: 1000;
	display: flex;
	flex-direction: column-reverse;
	align-items: flex-end;
	gap: 10px;
	width: min(440px, calc(100vw - 32px));
	max-width: none;
	margin: 0;
	padding: 0;
	pointer-events: none;
}

.woocommerce-notices-wrapper:not(form.checkout .woocommerce-notices-wrapper):empty {
	display: none;
}

:is(.woocommerce-notices-wrapper:not(form.checkout .woocommerce-notices-wrapper), .hs-toasts) > :is(.woocommerce-message, .woocommerce-info, .woocommerce-error, .wc-block-components-notice-banner) {
	position: relative;
	display: flex;
	flex-wrap: nowrap;
	align-items: center;
	gap: 12px;
	box-sizing: border-box;
	width: 100%;
	margin: 0;
	padding: 18px 40px 18px 20px !important; /* wc-blocks.css sets the block banner's padding to 16px !important; the right side leaves room for the close button. */
	border: 0;
	border-radius: var(--hs-radius-sm, 18px);
	background: var(--hs-navy, #0e2a5c);
	box-shadow: 0 12px 32px rgb(14 42 92 / 0.25);
	color: #fff;
	font-family: var(--hs-sans);
	font-size: 15px;
	line-height: 1.45;
	list-style: none;
	pointer-events: auto;
	animation: hs-toast-in 0.35s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Status icon: Woo's block banner svg, or a dot for classic notices. */
:is(.woocommerce-notices-wrapper, .hs-toasts) > .wc-block-components-notice-banner > svg {
	flex: none;
	width: 24px;
	height: 24px;
	padding: 2px;
	border-radius: 50%;
	background: var(--wp--preset--color--green-500, #4ad94a);
	fill: var(--hs-navy, #0e2a5c);
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .wc-block-components-notice-banner.is-error > svg {
	background: var(--wp--preset--color--lilac-500, #e97ef5);
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .wc-block-components-notice-banner.is-info > svg {
	background: var(--wp--preset--color--sky-500, #57c6fe);
}

:is(.woocommerce-notices-wrapper:not(form.checkout .woocommerce-notices-wrapper), .hs-toasts) > :is(.woocommerce-message, .woocommerce-info, .woocommerce-error)::before {
	content: "";
	flex: none;
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: var(--wp--preset--color--green-500, #4ad94a);
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .woocommerce-info::before {
	background: var(--wp--preset--color--sky-500, #57c6fe);
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .woocommerce-error::before {
	display: none;
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .wc-block-components-notice-banner .wc-block-components-notice-banner__content {
	display: flex;
	flex: 1 1 0;
	flex-wrap: nowrap;
	align-items: center;
	gap: 12px;
	min-width: 0;
}

/* The message (wrapped by toast.js so bold words and links flow as one paragraph) takes the free space. */
:is(.woocommerce-notices-wrapper, .hs-toasts) .hs-notice__text {
	flex: 1 1 auto;
	min-width: 0;
	overflow-wrap: anywhere;
}

/* "View cart" sits at the end of the row. !important beats wc-blocks-style's grey, faded, floated link. */
:is(.woocommerce-notices-wrapper, .hs-toasts) :is(.button, .wc-forward),
.hs-toasts > .wc-block-components-notice-banner > .wc-block-components-notice-banner__content .wc-forward {
	float: none !important;
	margin-left: auto !important;
	color: #fff !important;
	opacity: 1 !important;
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > :is(.woocommerce-error, .wc-block-components-notice-banner.is-error) {
	box-shadow: inset 4px 0 0 var(--wp--preset--color--lilac-500, #e97ef5), 0 12px 32px rgb(14 42 92 / 0.25);
}

/* "View cart" (Woo's .button.wc-forward) as an inline link. */
:is(.woocommerce-notices-wrapper, .hs-toasts) :is(.button, .wc-forward) {
	order: 2;
	display: inline;
	min-height: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	color: #fff;
	font: inherit;
	font-weight: 600;
	letter-spacing: 0;
	text-decoration: underline;
	text-underline-offset: 3px;
	text-transform: none;
	white-space: nowrap;
	cursor: pointer;
}

:is(.woocommerce-notices-wrapper, .hs-toasts) a:not(.button) {
	color: #fff;
}

/* Error lists: one line per item. */
:is(.woocommerce-notices-wrapper, .hs-toasts) > .woocommerce-error {
	display: block;
}

:is(.woocommerce-notices-wrapper, .hs-toasts) > .woocommerce-error li + li {
	margin-top: 4px;
}

.hs-toast__close {
	position: absolute;
	top: 8px;
	right: 8px;
	display: grid;
	place-items: center;
	width: 22px;
	height: 22px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: rgb(255 255 255 / 0.12);
	color: #fff;
	font-size: 15px;
	line-height: 1;
	cursor: pointer;
}

.hs-toast__close:hover {
	background: rgb(255 255 255 / 0.24);
}

.hs-toast__close:focus-visible {
	outline: 2px solid #fff;
	outline-offset: 2px;
}

.hs-toast-out {
	animation: hs-toast-out 0.25s ease-in forwards;
}

@keyframes hs-toast-in {
	from {
		opacity: 0;
		transform: translateY(16px) scale(0.98);
	}
}

@keyframes hs-toast-out {
	to {
		opacity: 0;
		transform: translateY(8px);
	}
}

/* The toast replaces Woo's inline "View cart" link after an AJAX add on product cards. */
.hs-product-card__actions .added_to_cart {
	display: none;
}

@media (max-width: 768px) {
	.woocommerce-notices-wrapper:not(form.checkout .woocommerce-notices-wrapper),
	.hs-toasts {
		right: 16px;
		bottom: 16px;
		left: 16px;
		width: auto;
	}
}

@media (prefers-reduced-motion: reduce) {
	:is(.woocommerce-notices-wrapper, .hs-toasts) > *,
	.hs-toast-out {
		animation: none;
	}
}
