/**
 * Add to Cart + Options block (single product).
 *
 * Quantity row with a mint-tint pill stepper, a full-width add-to-cart
 * button, pill-shaped variation choices, and — on phones — the button pinned
 * to the bottom of the screen as in the design.
 */

.wp-block-woocommerce-add-to-cart-with-options {
	margin-block: 0;
}

.ma-atc {
	width: 100%;
}

.ma-atc__quantity {
	width: 100%;
}

.ma-atc__quantity > p {
	margin: 0;
}

/* Sold individually / fixed quantity: hide the label with the stepper. */
.ma-atc__quantity:has(.wc-block-add-to-cart-with-options__quantity-selector--hidden) {
	display: none;
}

/*
 * A product that cannot be bought yet (no price) gets no stepper and no
 * button: hide the lone "Quantity" label, the empty bar (pinned to the
 * bottom on phones) and then the empty form itself, so no gap is left.
 */
.ma-atc__quantity:not(:has(.wc-block-components-quantity-selector)),
.ma-atc__bar:empty {
	display: none;
}

.wp-block-woocommerce-add-to-cart-with-options:has(.ma-atc):not(:has(.wc-block-components-quantity-selector, .ma-atc__bar > *)) {
	display: none;
}

/*
 * Stepper: green-tint pill (theme.json) with 44px round buttons, 124px wide
 * as in the design, without WooCommerce's grey ring.
 */
.ma-atc .wc-block-add-to-cart-with-options__quantity-selector {
	border: 0;
}

.ma-atc .wc-block-components-quantity-selector {
	align-items: center;
	border: 0;
	display: inline-flex;
	gap: 4px;
	padding: 2px;
}

.ma-atc .wc-block-components-quantity-selector::after {
	display: none;
}

.ma-atc .wc-block-components-quantity-selector__button {
	align-items: center;
	background: transparent;
	border: 0;
	border-radius: var(--wp--preset--border-radius--pill);
	color: var(--wp--preset--color--contrast);
	cursor: pointer;
	display: inline-flex;
	font-family: inherit;
	font-size: 1.25rem;
	height: 44px;
	justify-content: center;
	min-width: 44px;
	padding: 0;
	width: 44px;
}

.ma-atc .wc-block-components-quantity-selector__button:hover:not(:disabled) {
	background-color: color-mix(in srgb, var(--wp--preset--color--accent) 10%, transparent);
}

.ma-atc .wc-block-components-quantity-selector__button:disabled {
	opacity: 0.35;
}

/*
 * The number in the body font at 16px (smaller makes iOS zoom in on focus).
 * The element selector outranks WooCommerce's ".woocommerce .quantity .qty"
 * width, which loads later.
 */
.ma-atc .wc-block-components-quantity-selector input.wc-block-components-quantity-selector__input {
	-moz-appearance: textfield;
	appearance: textfield;
	background: transparent;
	border: 0;
	box-shadow: none;
	font-family: inherit;
	font-size: 1rem;
	font-weight: 600;
	min-height: 44px;
	min-width: 0;
	padding: 0;
	text-align: center;
	width: 24px;
}

.ma-atc .wc-block-components-quantity-selector__input::-webkit-inner-spin-button,
.ma-atc .wc-block-components-quantity-selector__input::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Full-width add-to-cart button. */
.ma-atc__bar .wc-block-components-product-button {
	margin: 0;
	width: 100%;
}

.ma-atc__bar .wc-block-components-product-button__button {
	font-size: 1rem;
	min-height: 56px;
	width: 100%;
}

/* Variation choices as pills. */
.wp-block-woocommerce-add-to-cart-with-options .wc-block-product-filter-chips__items {
	gap: 8px;
}

.wp-block-woocommerce-add-to-cart-with-options .wc-block-product-filter-chips__item {
	border-width: 1.5px;
	font-weight: 500;
	min-height: 44px;
}

/* Phones: pin the add-to-cart button to the bottom edge. */
@media (max-width: 781px) {
	.ma-atc__bar {
		-webkit-backdrop-filter: blur(10px);
		backdrop-filter: blur(10px);
		background-color: color-mix(in srgb, var(--wp--preset--color--base) 94%, transparent);
		bottom: 0;
		box-shadow: 0 -6px 20px rgba(2, 58, 52, 0.08);
		left: 0;
		margin: 0 !important;
		padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
		position: fixed;
		right: 0;
		z-index: 90;
	}

	.ma-atc__bar .wc-block-components-product-button__button {
		min-height: 52px;
	}

	body:has(.ma-atc__bar:not(:empty)) {
		padding-bottom: 96px;
	}

	/* Keep it in the flow inside the editor canvas. */
	.editor-styles-wrapper .ma-atc__bar {
		-webkit-backdrop-filter: none;
		backdrop-filter: none;
		box-shadow: none;
		padding: 0;
		position: static;
	}
}
