/**
 * Variation Quick Add - compact variation form inside the product loop.
 *
 * Everything is scoped to .vqa-form so the single product page stays untouched.
 * The custom properties below are the intended place to adjust the look.
 */

.vqa-form {
	--vqa-gap: 0.5rem;
	--vqa-radius: 6px;
	--vqa-border: rgba(0, 0, 0, 0.18);
	--vqa-border-focus: rgba(0, 0, 0, 0.55);
	--vqa-field-bg: #fff;
	--vqa-field-color: inherit;
	--vqa-muted: rgba(0, 0, 0, 0.55);
	--vqa-success: #1a7f37;
	--vqa-error: #b32d2e;
	--vqa-control-height: 44px;

	container-type: inline-size;
	display: flex;
	flex-direction: column;
	gap: var(--vqa-gap);
	margin: 0.75rem 0 0;
	text-align: left;
}

.vqa-form *,
.vqa-form *::before,
.vqa-form *::after {
	box-sizing: border-box;
}

/* Screen reader only labels - the loop hides them visually. */
.vqa-form .screen-reader-text {
	position: absolute !important;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0 0 0 0);
	clip-path: inset(50%);
	white-space: nowrap;
	border: 0;
}

/* --- Attribute dropdowns + quantity, on one line ------------------------- */

.vqa-form .vqa-selectors {
	display: flex;
	align-items: center;
	gap: 0.4rem;
}

.vqa-form .vqa-times {
	flex: 0 0 auto;
	font-size: 0.95rem;
	line-height: 1;
	color: var(--vqa-muted);
	-webkit-user-select: none;
	user-select: none;
}

.vqa-form .vqa-quantity {
	flex: 0 0 auto;
	margin: 0 !important;
	float: none;
	width: auto;
}

/* Set by the script when the chosen variation allows exactly one amount. */
.vqa-form.vqa-single-qty .vqa-times,
.vqa-form.vqa-single-qty .vqa-quantity {
	display: none;
}

.vqa-form select.vqa-qty {
	width: auto;
	min-width: 3.9rem;
	padding-right: 1.8rem;
	padding-left: 0.6rem;
	text-align: center;
	background-position: right 0.5rem center;
}

.vqa-form .vqa-variations {
	flex: 1 1 auto;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.35rem;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}

.vqa-form .vqa-variation-row {
	margin: 0;
}

.vqa-form select {
	width: 100%;
	max-width: 100%;
	min-height: var(--vqa-control-height);
	margin: 0;
	padding: 0.5rem 2.25rem 0.5rem 0.75rem;
	font-size: 16px; /* keeps iOS from zooming in on focus */
	line-height: 1.3;
	color: var(--vqa-field-color);
	background-color: var(--vqa-field-bg);
	border: 1px solid var(--vqa-border);
	border-radius: var(--vqa-radius);
	box-shadow: none;
	-webkit-appearance: none;
	-moz-appearance: none;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5 6 6.5l5-5' fill='none' stroke='%23555' stroke-width='1.6' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 0.75rem center;
	background-size: 12px 8px;
	cursor: pointer;
}

.vqa-form select:focus-visible,
.vqa-form input.qty:focus-visible,
.vqa-form .single_add_to_cart_button:focus-visible {
	outline: 2px solid var(--vqa-border-focus);
	outline-offset: 2px;
}

/* Reset link: a quiet text link, and it always reserves its line so the
   tile does not jump when WooCommerce reveals it. */
.vqa-form .reset_variations {
	visibility: hidden;
	align-self: flex-start;
	min-height: 1.2em;
	padding: 0;
	font-size: 0.8125em;
	line-height: 1.2;
	color: var(--vqa-muted);
	text-decoration: underline;
	background: none;
	border: 0;
}

.vqa-form .reset_variations::before,
.vqa-form .reset_variations::after {
	content: none !important;
}

/* --- Selected variation (price / availability) --------------------------- */

.vqa-form .single_variation_wrap {
	display: flex;
	flex-direction: column;
	gap: var(--vqa-gap);
}

.vqa-form .single_variation,
.vqa-form .woocommerce-variation {
	margin: 0;
}

.vqa-form .woocommerce-variation-price {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
}

.vqa-form .woocommerce-variation-price .price {
	font-size: inherit;
}

.vqa-form .woocommerce-variation-availability p,
.vqa-form .woocommerce-variation-availability .stock {
	margin: 0.15rem 0 0;
	font-size: 0.8125rem;
	line-height: 1.3;
}

/* Descriptions are far too long for a product tile. */
.vqa-form .woocommerce-variation-description {
	display: none;
}

.vqa-form.vqa-hide-price .woocommerce-variation-price {
	display: none;
}

.vqa-form p.stock.out-of-stock {
	margin: 0;
	font-size: 0.875rem;
}

/* --- Add to cart button -------------------------------------------------- */

.vqa-form .woocommerce-variation-add-to-cart {
	display: block;
	margin: 0;
	padding: 0;
}

.vqa-form .vqa-actions {
	display: flex;
	gap: var(--vqa-gap);
	align-items: stretch;
}

.vqa-form .single_add_to_cart_button {
	position: relative;
	flex: 1 1 auto;
	min-height: var(--vqa-control-height);
	margin: 0 !important;
	padding-left: 0.75rem;
	padding-right: 0.75rem;
	line-height: 1.2;
	white-space: nowrap;
	border-radius: var(--vqa-radius);
	transition: opacity 0.15s ease;
}

.vqa-form .single_add_to_cart_button.disabled,
.vqa-form .single_add_to_cart_button:disabled {
	opacity: 0.45;
	cursor: not-allowed;
}

/* Loading state: label swaps for a spinner, button keeps its size. */
.vqa-form .vqa-add.vqa-loading .vqa-add__label {
	visibility: hidden;
}

.vqa-form .vqa-add.vqa-loading::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	width: 18px;
	height: 18px;
	margin: -9px 0 0 -9px;
	border: 2px solid currentColor;
	border-right-color: transparent;
	border-radius: 50%;
	animation: vqa-spin 0.6s linear infinite;
}

.vqa-form .vqa-add.vqa-added .vqa-add__label::before {
	content: "\2713\00a0";
}

@keyframes vqa-spin {
	to {
		transform: rotate(360deg);
	}
}

/* --- Inline feedback ----------------------------------------------------- */

/* Only errors show up here, so the line stays collapsed until there is one. */
.vqa-form .vqa-feedback {
	font-size: 0.8125rem;
	line-height: 1.3;
	color: var(--vqa-error);
}

.vqa-form .vqa-feedback:empty {
	display: none;
}

/* --- Narrow tiles and small screens -------------------------------------- */

/* Below this width the attribute dropdown would be squeezed to nothing, so
   the quantity moves to its own full width line and the x is dropped. */
@container (max-width: 210px) {
	.vqa-form .vqa-selectors {
		flex-wrap: wrap;
	}

	.vqa-form .vqa-variations {
		flex: 1 1 100%;
	}

	.vqa-form .vqa-times {
		display: none;
	}

	.vqa-form .vqa-quantity {
		flex: 1 1 100%;
	}

	.vqa-form select.vqa-qty {
		width: 100%;
	}

	.vqa-form .single_add_to_cart_button {
		white-space: normal;
	}
}

@media (max-width: 600px) {
	.vqa-form {
		--vqa-control-height: 46px;
	}

	.vqa-form .single_add_to_cart_button {
		width: 100%;
		white-space: normal;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vqa-form .vqa-add.vqa-loading::after {
		animation-duration: 2s;
	}

	.vqa-form .vqa-feedback,
	.vqa-form .single_add_to_cart_button {
		transition: none;
	}
}
