/**
 * Layout only (plan 1.0.0, requirement 6).
 * The container is an inline grid (R04), so the buttons stay square.
 * Colors, fonts and the outer radius stay with uk-button-default and the theme.
 */

/* One row, no gap. The buttons stretch to the height of the field. */
.quantity:has(> .wcqb-btn) {
	display: inline-grid;
	grid-auto-flow: column;
	align-items: stretch;
	gap: 0;
	max-width: 100%;
	vertical-align: middle;
}

.quantity:has(> .wcqb-btn) > .wcqb-btn,
.quantity:has(> .wcqb-btn) > input.qty {
	margin: 0;
	box-sizing: border-box;
}

/* Square: the stretched height is the field height, and aspect-ratio sets the width. */
.quantity:has(> .wcqb-btn) > .wcqb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	align-self: stretch;
	aspect-ratio: 1;
	padding: 0;
}

.quantity:has(> .wcqb-btn) > .wcqb-btn svg {
	display: block;
	width: 16px;
	height: 16px;
}

/* R12: one border on each join. The buttons keep all their borders. */
/* Inner radii stay zero; outer corners keep the theme radius. */
.quantity:has(> .wcqb-btn) > .wcqb-btn--minus {
	border-top-right-radius: 0;
	border-bottom-right-radius: 0;
}

.quantity:has(> .wcqb-btn) > .wcqb-btn--plus {
	border-top-left-radius: 0;
	border-bottom-left-radius: 0;
}

.quantity:has(> .wcqb-btn) > input.qty {
	flex: 0 0 auto;
	min-width: 0;
	border-radius: 0;
	/* R12: inside the group the field loses its side borders. The buttons keep theirs. */
	border-left-width: 0;
	border-right-width: 0;
	/* Requirement 6: native steppers go away. The buttons replace them. */
	appearance: textfield;
	-webkit-appearance: textfield;
	-moz-appearance: textfield;
}

.quantity:has(> .wcqb-btn) > input.qty::-webkit-inner-spin-button,
.quantity:has(> .wcqb-btn) > input.qty::-webkit-outer-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* Requirement 6: keyboard focus stays visible. The color is the theme's current color. */
.wcqb-btn:focus-visible {
	outline-style: solid;
	outline-width: 2px;
	outline-offset: 2px;
}

/* Plan 1.0.1, requirements 1, 3 and 4. Below 640 px the button sits under the group. */
/* display: grid keeps the buttons square, as the inline grid of 1.0.0 does (R04). */
/* Grouped products keep the theme float. From 640 px up nothing here applies. */
@media (max-width: 639px) {
	form.cart:not(.grouped_form) .quantity:has(> .wcqb-btn) {
		float: none;
		display: grid;
		width: max-content;
		margin-right: 0;
		margin-bottom: 15px;
	}

	/* YOOtheme expanded add to cart (requirement 3): the flex row wraps, the button takes the next line. */
	.tm-element-woo-add-to-cart :has(> .quantity > .wcqb-btn) {
		flex-wrap: wrap;
	}

	.tm-element-woo-add-to-cart :has(> .quantity > .wcqb-btn) > .single_add_to_cart_button {
		flex-basis: 100%;
	}
}
