/**
 * Custom Add to Cart Button — base styles (layout of the stepper, messages, cart page
 * + / −). Every selector is wrapped in :where(), so it has zero specificity: any rule
 * in your theme wins without !important. Colours come from CSS variables with
 * fallbacks; set them in your theme, e.g.
 *   .cacb { --cacb-stepper-border: #ddd; --cacb-height: 48px; }
 *
 * Loaded in "Plugin styles" and "Theme styles" modes.
 */

:where(.cacb) {
	box-sizing: border-box;
}

:where(.cacb) *,
:where(.cacb) *::before,
:where(.cacb) *::after {
	box-sizing: inherit;
}

:where(.cacb--loop) {
	display: block;
	width: 100%;
}

:where(.cacb--single) {
	display: inline-block;
	vertical-align: middle;
}

:where(.cacb__out-of-stock) {
	display: inline-block;
	padding: 0.4em 0.9em;
	border-radius: var(--cacb-radius, 8px);
	background: #f1f3f5;
	color: #6b7280;
	font-size: 0.9em;
}

/* ---- Stepper ---------------------------------------------------------------- */

:where(.cacb-stepper) {
	display: inline-flex;
	align-items: stretch;
	position: relative;
	height: var(--cacb-height, 44px);
	min-width: 132px;
	border: 1px solid var(--cacb-stepper-border, #d5d9e6);
	border-radius: var(--cacb-radius, 8px);
	background: var(--cacb-stepper-bg, #fff);
	color: var(--cacb-stepper-color, #253d7b);
	overflow: hidden;
}

:where(.cacb--loop .cacb-stepper) {
	width: 100%;
}

:where(.cacb-stepper__button) {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: var(--cacb-height, 44px);
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: inherit;
	line-height: 1;
	cursor: pointer;
}

:where(.cacb-stepper__button:hover, .cacb-stepper__button:focus-visible) {
	background: rgba(0, 0, 0, 0.05);
}

:where(.cacb-stepper__quantity) {
	flex: 1 1 auto;
	width: 100%;
	min-width: 2.5em;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: inherit;
	font-weight: 700;
	text-align: center;
}

:where(.cacb-stepper__icon) {
	display: block;
}

:where(.cacb-stepper__icon--remove),
:where(.cacb-stepper.is-last .cacb-stepper__icon--minus) {
	display: none;
}

:where(.cacb-stepper.is-last .cacb-stepper__icon--remove) {
	display: block;
}

:where(.cacb-stepper.is-loading) {
	pointer-events: none;
}

:where(.cacb-stepper.is-loading)::after {
	content: "";
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.55);
}

:where(.cacb-full-width .cacb--single, .cacb-full-width .cacb--single .cacb-stepper) {
	width: 100%;
}

/* ---- Product lists: show on hover (setting) ---------------------------------- */

@media (hover: hover) {
	:where(.cacb-loop-hover .products .product .cacb--loop:not(.is-in-cart)) {
		opacity: 0;
		transition: opacity 0.15s ease;
	}

	:where(.cacb-loop-hover .products .product:hover .cacb--loop, .cacb-loop-hover .products .product:focus-within .cacb--loop) {
		opacity: 1;
	}
}

/* ---- Messages ----------------------------------------------------------------- */

:where(.cacb-toasts) {
	position: fixed;
	inset-inline: 16px;
	bottom: 16px;
	z-index: 100000;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 8px;
	pointer-events: none;
}

:where(.cacb-toast) {
	display: flex;
	align-items: center;
	gap: 12px;
	width: 100%;
	max-width: 480px;
	padding: 12px 14px;
	border-radius: 10px;
	background: var(--cacb-toast-bg, #1f2937);
	color: var(--cacb-toast-color, #fff);
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
	font-size: 0.92em;
	pointer-events: auto;
	animation: cacb-toast-in 0.18s ease-out;
}

:where(.cacb-toast--error) {
	background: var(--cacb-toast-error-bg, #b42318);
}

:where(.cacb-toast__text) {
	flex: 1 1 auto;
	margin: 0;
}

:where(.cacb-toast__link) {
	flex: 0 0 auto;
	color: inherit;
	font-weight: 700;
	text-decoration: underline;
}

:where(.cacb-toast__close) {
	flex: 0 0 auto;
	padding: 0 4px;
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 1.3em;
	line-height: 1;
	cursor: pointer;
}

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

@media (prefers-reduced-motion: reduce) {
	:where(.cacb-toast) {
		animation: none;
	}
}

/* ---- Cart page + / − ------------------------------------------------------------ */

:where(.cacb-cart-quantity) {
	display: inline-flex;
	align-items: stretch;
	border: 1px solid var(--cacb-stepper-border, #d5d9e6);
	border-radius: var(--cacb-radius, 8px);
	background: var(--cacb-stepper-bg, #fff);
	overflow: hidden;
}

:where(.cacb-cart-quantity input.qty) {
	width: 3.2em;
	border: 0;
	background: transparent;
	box-shadow: none;
	text-align: center;
	-moz-appearance: textfield;
}

:where(.cacb-cart-quantity input.qty)::-webkit-outer-spin-button,
:where(.cacb-cart-quantity input.qty)::-webkit-inner-spin-button {
	margin: 0;
	-webkit-appearance: none;
}

:where(.cacb-cart-quantity__button) {
	width: 2.4em;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	color: var(--cacb-stepper-color, #253d7b);
	font-size: 1.1em;
	line-height: 1;
	cursor: pointer;
}

:where(.cacb-cart-quantity__button:hover) {
	background: rgba(0, 0, 0, 0.05);
}
