/**
 * NutraTea — unified Add to Basket button states.
 *
 * Covers:
 * - homepage/shop product-loop buttons;
 * - product and quick-view forms;
 * - simple-product sticky form;
 * - Frequently Bought Together.
 *
 * Does not target:
 * - Product Bundles purchase buttons;
 * - Buy Now buttons;
 * - variable-product sticky links that only scroll to product options;
 * - external/affiliate product buttons.
 */

/* -------------------------------------------------------------------------
   Sticky template contract
   ------------------------------------------------------------------------- */

/*
 * Keep the wrapper layout-neutral in the ordinary product form.
 * Existing sticky-specific rules override this with flex/inline-flex.
 */
form.cart > .add-to-cart-container {
	display: contents;
}


/* -------------------------------------------------------------------------
   Standard product, quick-view and simple sticky buttons
   ------------------------------------------------------------------------- */

:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button) {
	position: relative !important;
	overflow: visible !important;

	background-color: #198321 !important;
	border-color: #198321 !important;
	color: #ffffff !important;

	--btn-accented-bgcolor: #198321 !important;
	--btn-accented-bgcolor-hover: #145e18 !important;
	--btn-accented-color: #ffffff !important;
	--btn-accented-color-hover: #ffffff !important;
	--btn-brd-width: 0 !important;
}

/* Existing inner green detail. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button)::before {
	content: "" !important;
	position: absolute !important;
	left: 5px !important;
	top: 5px !important;
	width: calc(100% - 5px) !important;
	height: calc(100% - 5px) !important;

	display: block !important;
	opacity: 1 !important;
	z-index: 1 !important;

	border: 1px solid #198321 !important;
	border-radius: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
}

/* Normal/completed offset black line. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button)::after {
	content: "" !important;
	position: absolute !important;
	left: 5px !important;
	top: 5px !important;
	width: 100% !important;
	height: 100% !important;

	opacity: 1 !important;
	z-index: 0 !important;

	border: 1px solid #40454b !important;
	border-radius: 0 !important;
	background: transparent !important;
	animation: none !important;
}

/* Loading text is replaced by the spinner. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button.loading:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button) {
	color: transparent !important;
	-webkit-text-fill-color: transparent !important;
	text-shadow: none !important;
	cursor: wait;
}

:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button.loading:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button)::before {
	opacity: 0 !important;
	border: 0 !important;
	background: transparent !important;
}

/* Reset the decorative ::after into a centred circular spinner. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button.loading:not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button)::after {
	content: "" !important;
	position: absolute !important;

	left: auto !important;
	right: auto !important;
	top: calc(50% - 9px) !important;
	inset-inline-start: calc(50% - 9px) !important;
	inset-inline-end: auto !important;

	width: 18px !important;
	height: 18px !important;
	margin: 0 !important;

	display: inline-block !important;
	opacity: 1 !important;
	z-index: 3 !important;

	border: 1px solid rgba(255, 255, 255, 0.3) !important;
	border-left-color: #ffffff !important;
	border-radius: 50% !important;
	background: transparent !important;

	transition: none !important;
	animation: wd-rotate 450ms infinite linear !important;
}

/* Completed must retain its black border even while hovered. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button.nt-atc-complete::after,
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
)
.single_add_to_cart_button.nt-atc-complete:hover::after {
	left: 5px !important;
	top: 5px !important;
	width: 100% !important;
	height: 100% !important;

	opacity: 1 !important;
	border: 1px solid #40454b !important;
	border-radius: 0 !important;
	background: transparent !important;
	animation: none !important;
}


/* -------------------------------------------------------------------------
   Product/quick-view/sticky hover cart icon
   ------------------------------------------------------------------------- */

@media (hover: hover) and (pointer: fine) {
	:is(
		.single-product-page:not(.product-type-external) form.cart,
		.product-quick-view:not(.product-type-external) form.cart,
		.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
	)
	.single_add_to_cart_button:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button):hover {
		color: transparent !important;
		-webkit-text-fill-color: transparent !important;
		text-shadow: none !important;
	}

	:is(
		.single-product-page:not(.product-type-external) form.cart,
		.product-quick-view:not(.product-type-external) form.cart,
		.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
	)
	.single_add_to_cart_button:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button):hover::before {
		content: "\f123" !important;
		position: absolute !important;
		inset: 0 !important;

		width: 100% !important;
		height: 100% !important;

		display: flex !important;
		align-items: center;
		justify-content: center;

		opacity: 1 !important;
		z-index: 3 !important;

		color: #ffffff !important;
		-webkit-text-fill-color: #ffffff !important;
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;

		font-family: "woodmart-font" !important;
		font-size: 20px !important;
		font-weight: 400 !important;

		pointer-events: none;
	}

	/* Homepage behaviour: black line disappears during hover. */
	:is(
		.single-product-page:not(.product-type-external) form.cart,
		.product-quick-view:not(.product-type-external) form.cart,
		.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
	)
	.single_add_to_cart_button:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):not(.wd-fbt-purchase-btn):not(.bundle_add_to_cart_button):hover::after {
		opacity: 0 !important;
	}
}


/* -------------------------------------------------------------------------
   Homepage, shop and category product-loop buttons
   ------------------------------------------------------------------------- */

.wd-add-btn.wd-add-btn-replace {
	position: relative;
	overflow: visible;
}

/* Wrapper owns the black line, leaving the link's ::after available to spin. */
.wd-add-btn.wd-add-btn-replace::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 5px;
	width: 100%;
	height: 100%;

	z-index: 0;
	opacity: 1;

	border: 1px solid #40454b;
	background: transparent;

	pointer-events: none;
	transition: opacity 0.15s ease;
}

@media (hover: hover) and (pointer: fine) {
	.wd-add-btn.wd-add-btn-replace:not(.nt-atc-loading):not(.nt-atc-complete):hover::after {
		opacity: 0 !important;
		border: 0 !important;
	}
}

.wd-add-btn.wd-add-btn-replace.nt-atc-loading::after {
	opacity: 0 !important;
	border: 0 !important;
}

.wd-add-btn.wd-add-btn-replace.nt-atc-complete::after,
.wd-add-btn.wd-add-btn-replace.nt-atc-complete:hover::after {
	opacity: 1 !important;
	border: 1px solid #40454b !important;
}

/*
 * Restore Woodmart's circular loader. This overrides legacy child-theme
 * declarations that set loop-button ::after to display:none or full size.
 */
.wd-add-btn.wd-add-btn-replace .add-to-cart-loop.loading::after {
	content: "" !important;
	position: absolute !important;

	left: auto !important;
	right: auto !important;
	top: calc(50% - 9px) !important;
	inset-inline-start: calc(50% - 9px) !important;
	inset-inline-end: auto !important;

	width: 18px !important;
	height: 18px !important;
	margin: 0 !important;

	display: inline-block !important;
	opacity: 1 !important;
	z-index: 3 !important;

	border: 1px solid rgba(255, 255, 255, 0.3) !important;
	border-left-color: #ffffff !important;
	border-radius: 50% !important;
	background: transparent !important;

	transition: none !important;
	animation: wd-rotate 450ms infinite linear !important;
}

/* Completed loop buttons show their text, not the hover/check icon. */
.wd-add-btn.wd-add-btn-replace.nt-atc-complete
> .add-to-cart-loop::before {
	opacity: 0 !important;
	transform: translateY(100%) !important;
}

.wd-add-btn.wd-add-btn-replace.nt-atc-complete
> .add-to-cart-loop
> .wd-action-text {
	opacity: 1 !important;
	transform: none !important;
}


/* Prevent buttons resizing between normal, loading and completed states. */
:is(
	.single-product-page:not(.product-type-external) form.cart,
	.product-quick-view:not(.product-type-external) form.cart,
	.wd-sticky-btn .wd-sticky-btn-cart:not(.wd-product-type-external) form.cart
) .single_add_to_cart_button.nt-atc-size-locked,
.wd-add-btn.wd-add-btn-replace > .add-to-cart-loop.nt-atc-size-locked {
	box-sizing: border-box !important;
	inline-size: var(--nt-atc-locked-width) !important;
	min-inline-size: var(--nt-atc-locked-width) !important;
	block-size: var(--nt-atc-locked-height) !important;
	min-block-size: var(--nt-atc-locked-height) !important;
	max-inline-size: 100% !important;
}


/* -------------------------------------------------------------------------
   Frequently Bought Together
   ------------------------------------------------------------------------- */

/*
 * Show only the portions of the offset border that sit behind the button.
 * This prevents the top and leading edges being painted over the green face.
 */
.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn:not(.loading)::after {
	content: "" !important;
	position: absolute !important;

	top: 4px !important;
	inset-inline-start: 4px !important;

	width: 100% !important;
	height: 100% !important;

	z-index: 0 !important;
	border: 0 !important;

	background:
		linear-gradient(#40454b, #40454b) top right / 4px 1px no-repeat,
		linear-gradient(#40454b, #40454b) top right / 1px 100% no-repeat,
		linear-gradient(#40454b, #40454b) bottom left / 100% 1px no-repeat,
		linear-gradient(#40454b, #40454b) bottom left / 1px 4px no-repeat !important;

	pointer-events: none;
}

.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.nt-atc-busy {
	cursor: wait !important;
}

/* Explicit FBT loading treatment. */
.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.loading {
	color: transparent !important;
	-webkit-text-fill-color: transparent !important;
	text-shadow: none !important;
}

.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.loading::before {
	content: "" !important;
	position: absolute !important;
	inset: 0 !important;

	opacity: 1 !important;
	z-index: 2 !important;

	border: 0 !important;
	background-color: #198321 !important;
	box-shadow: none !important;

	transition: none !important;
}

.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.loading::after {
	content: "" !important;
	position: absolute !important;

	left: auto !important;
	right: auto !important;
	top: calc(50% - 9px) !important;
	inset-inline-start: calc(50% - 9px) !important;
	inset-inline-end: auto !important;

	width: 18px !important;
	height: 18px !important;
	margin: 0 !important;

	display: inline-block !important;
	opacity: 1 !important;
	z-index: 3 !important;

	border: 1px solid rgba(255, 255, 255, 0.3) !important;
	border-left-color: #ffffff !important;
	border-radius: 50% !important;
	background: transparent !important;

	transition: none !important;
	animation: wd-rotate 450ms infinite linear !important;
}

@media (hover: hover) and (pointer: fine) {
	.wd-fbt .wd-fbt-purchase
	.wd-fbt-purchase-btn:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled)::before {
		content: "\f123" !important;
		position: absolute !important;
		inset: 0 !important;

		display: flex !important;
		align-items: center;
		justify-content: center;

		opacity: 0 !important;
		z-index: 3 !important;

		color: #ffffff !important;
		-webkit-text-fill-color: #ffffff !important;
		background: transparent !important;
		border: 0 !important;
		box-shadow: none !important;

		font-family: "woodmart-font" !important;
		font-size: 20px !important;
		font-weight: 400 !important;

		transform: scale(0.85);
		transition:
			opacity 0.15s ease,
			transform 0.25s ease;

		pointer-events: none;
	}

	.wd-fbt .wd-fbt-purchase
	.wd-fbt-purchase-btn:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):hover {
		color: transparent !important;
		-webkit-text-fill-color: transparent !important;
		text-shadow: none !important;
	}

	.wd-fbt .wd-fbt-purchase
	.wd-fbt-purchase-btn:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):hover::before {
		opacity: 1 !important;
		transform: scale(1) !important;
	}

	/* Match the homepage: hide the black line on hover. */
	.wd-fbt .wd-fbt-purchase
	.wd-fbt-purchase-btn:not(.loading):not(.added):not(.nt-atc-complete):not(:disabled):hover::after {
		opacity: 0 !important;
	}
}

/* Completed FBT state always restores the black line. */
.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.nt-atc-complete::after,
.wd-fbt .wd-fbt-purchase .wd-fbt-purchase-btn.nt-atc-complete:hover::after {
	opacity: 1 !important;
}


/* -------------------------------------------------------------------------
   Checkout Smart Offers & Mini-Cart Checkout
   ------------------------------------------------------------------------- */

/* Checkout Smart Offers accept button. */
.checkout-order-review
.order_review_wrapper_amend
div.so_accept a[href*="so_action=accept"] {
	position: relative !important;
	display: flex !important;
	align-items: center;
	justify-content: center;

	width: 100% !important;
	min-height: 42px;
	padding: 10px 13px;
	overflow: visible !important;

	background: #198321 !important;
	color: #ffffff !important;
	text-decoration: none !important;
}

/* Inner green detail. */
.checkout-order-review
.order_review_wrapper_amend
div.so_accept a[href*="so_action=accept"]::before {
	content: "";
	position: absolute;
	left: 5px;
	top: 5px;
	width: calc(100% - 5px);
	height: calc(100% - 5px);

	z-index: 1;
	border: 1px solid #198321;
	pointer-events: none;
}

/* Offset black line. */
.checkout-order-review
.order_review_wrapper_amend
div.so_accept a[href*="so_action=accept"]::after {
	content: "";
	position: absolute;
	left: 5px;
	top: 5px;
	width: 100%;
	height: 100%;

	z-index: 0;
	border: 1px solid #40454b;
	background: transparent;
	pointer-events: none;
}

@media (hover: hover) and (pointer: fine) {
	.checkout-order-review
	.order_review_wrapper_amend
	div.so_accept
	a[href*="so_action=accept"]:not(.nt-so-busy):hover {
		color: transparent !important;
		-webkit-text-fill-color: transparent !important;
	}

	.checkout-order-review
	.order_review_wrapper_amend
	div.so_accept
	a[href*="so_action=accept"]:not(.nt-so-busy):hover::before {
		content: "\f123";
		inset: 0;
		width: 100%;
		height: 100%;

		display: flex;
		align-items: center;
		justify-content: center;

		z-index: 3;
		border: 0;
		color: #ffffff;
		-webkit-text-fill-color: #ffffff;

		font-family: "woodmart-font";
		font-size: 20px;
	}

	.checkout-order-review
	.order_review_wrapper_amend
	div.so_accept
	a[href*="so_action=accept"]:not(.nt-so-busy):hover::after {
		opacity: 0;
	}
}

/* Special Offer loading state. */
.checkout-order-review
.order_review_wrapper_amend
div.so_accept a.nt-so-busy {
	color: transparent !important;
	-webkit-text-fill-color: transparent !important;
	pointer-events: none;
	cursor: wait;
}

.checkout-order-review
.order_review_wrapper_amend
div.so_accept a.nt-so-busy::before {
	opacity: 0 !important;
	border: 0 !important;
}

.checkout-order-review
.order_review_wrapper_amend
div.so_accept a.nt-so-busy::after {
	content: "" !important;
	left: auto !important;
	right: auto !important;
	top: calc(50% - 9px) !important;
	inset-inline-start: calc(50% - 9px) !important;

	width: 18px !important;
	height: 18px !important;
	margin: 0 !important;

	opacity: 1 !important;
	z-index: 3 !important;
	border: 1px solid rgba(255, 255, 255, 0.3) !important;
	border-left-color: #ffffff !important;
	border-radius: 50% !important;
	background: transparent !important;
	animation: wd-rotate 450ms infinite linear !important;
}

/* Keep Smart Offers' click-blocking overlay, but do not obscure the spinner. */
.order_review_wrapper_amend
.nt-so-offer-busy
.blockUI.blockOverlay {
	background: transparent !important;
	opacity: 0 !important;
}

/* Mini-cart Checkout button spinner state. */
.cart-widget-side
.woocommerce-mini-cart__buttons
.checkout.wc-forward.nt-mini-cart-checkout-loading {
	color: transparent !important;
	-webkit-text-fill-color: transparent !important;
	text-shadow: none !important;
	pointer-events: none;
	cursor: wait;
}

.cart-widget-side
.woocommerce-mini-cart__buttons
.checkout.wc-forward.nt-mini-cart-checkout-loading::before {
	opacity: 0 !important;
	border: 0 !important;
}

.cart-widget-side
.woocommerce-mini-cart__buttons
.checkout.wc-forward.nt-mini-cart-checkout-loading::after {
	content: "" !important;
	position: absolute !important;

	left: auto !important;
	right: auto !important;
	top: calc(50% - 9px) !important;
	inset-inline-start: calc(50% - 9px) !important;

	width: 18px !important;
	height: 18px !important;
	margin: 0 !important;

	display: inline-block !important;
	opacity: 1 !important;
	z-index: 3 !important;

	border: 1px solid rgba(255, 255, 255, 0.3) !important;
	border-left-color: #ffffff !important;
	border-radius: 50% !important;
	background: transparent !important;
	animation: wd-rotate 450ms infinite linear !important;
}


/* -------------------------------------------------------------------------
   Shared busy and reduced-motion behaviour
   ------------------------------------------------------------------------- */

.nt-atc-busy {
	cursor: wait !important;
}

a.nt-atc-busy {
	pointer-events: none;
}

@media (prefers-reduced-motion: reduce) {
	.wd-add-btn.wd-add-btn-replace::after,
	.wd-fbt-purchase .wd-fbt-purchase-btn::before {
		transition: none !important;
	}
}
