/* Add to quote button on product pages: a secondary action next to Add to cart. */
.yayraq-add-to-quote {
	margin-inline-start: 0.5em;
}

/* Variable products: dimmed like WooCommerce's Add to cart until a variation is chosen. */
.yayraq-add-to-quote[aria-disabled="true"] {
	cursor: not-allowed;
	opacity: 0.5;
}

/* Before Add to cart: the gap goes on the other side. */
.yayraq-add-to-quote.yayraq-before {
	margin-inline: 0 0.5em;
}

/* Hide Add to cart: the form stays, because it carries the quantity, the variation picker and our button. */
.yayraq-hide-cart .single_add_to_cart_button {
	display: none !important;
}

@media (max-width: 599px) {
	.wp-block-woocommerce-add-to-cart-form .yayraq-add-to-quote.yayraq-before {
		margin-top: 0;
		margin-bottom: 0.5em;
		margin-inline-end: 0;
	}

	.wp-block-woocommerce-add-to-cart-form .yayraq-add-to-quote {
		margin-top: 0.5em;
		margin-inline-start: 0;
	}
}

@media (min-width: 600px) {

	/* WooCommerce's Add to Cart Form block spans every extra child across the grid; keep ours on the button row. */
	.wp-block-woocommerce-add-to-cart-form form.cart:has(> .yayraq-add-to-quote),
	.wp-block-woocommerce-add-to-cart-form .variations_button:has(> .yayraq-add-to-quote) {
		grid-template-columns: min-content auto 1fr;
	}

	.wp-block-woocommerce-add-to-cart-form form.cart > .yayraq-add-to-quote.wp-element-button,
	.wp-block-woocommerce-add-to-cart-form .variations_button > .yayraq-add-to-quote.wp-element-button {
		grid-column: 3 / 4;
		justify-self: start;
	}

	/* Before Add to cart: its own row above the quantity and button. */
	.wp-block-woocommerce-add-to-cart-form form.cart > .yayraq-add-to-quote.yayraq-before.wp-element-button,
	.wp-block-woocommerce-add-to-cart-form .variations_button > .yayraq-add-to-quote.yayraq-before.wp-element-button {
		grid-column: 1 / -1;
	}
}

/* Block themes draw every wp-element-button as primary; outline ours. Classic themes keep their own plain button. */
.woocommerce-uses-block-theme .yayraq-add-to-quote.wp-element-button {
	border-color: transparent;
	background: transparent;
	box-shadow: inset 0 0 0 1px currentColor;
	color: var(--wp--preset--color--contrast, currentColor);
}

.woocommerce-uses-block-theme .yayraq-add-to-quote.wp-element-button:hover {
	background: rgba(128, 128, 128, 0.12);
	color: var(--wp--preset--color--contrast, currentColor);
}

/* Product lists: a secondary button under Add to cart, outlined on every theme. */
.yayraq-loop-quote {
	margin: 0.5em 0 1rem;
}

/* !important: classic themes style .button with very specific selectors (e.g. .site .button:not(:hover)...). */
.yayraq-loop-quote .yayraq-loop-add-to-quote.button {
	border-color: transparent;
	background: transparent !important;
	box-shadow: inset 0 0 0 1px currentColor;
	color: inherit !important;
}

.yayraq-loop-quote .yayraq-loop-add-to-quote.button:hover {
	background: rgba(128, 128, 128, 0.12) !important;
}

.yayraq-loop-status {
	margin: 0;
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

.yayraq-loop-status:not(:empty) {
	margin-top: 0.5em;
}

.yayraq-loop-quote[aria-busy="true"] .yayraq-loop-add-to-quote {
	position: relative;
	cursor: progress;
	opacity: 0.6;
}

/* Inside the right padding (1.5em or more on the themes checked), so the button keeps its width. */
.yayraq-loop-quote[aria-busy="true"] .yayraq-loop-add-to-quote::after {
	content: "";
	position: absolute;
	top: 50%;
	inset-inline-end: 0.45em;
	box-sizing: border-box;
	width: 0.8em;
	height: 0.8em;
	margin-top: -0.4em;
	border: 2px solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	animation: yayraq-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.yayraq-loop-quote[aria-busy="true"] .yayraq-loop-add-to-quote::after {
		display: none;
	}
}

/* Block themes: line up with the Product Button block above (alignment, spacing, small text). */
.wc-block-components-product-button + .yayraq-loop-quote {
	display: flex;
	flex-direction: column;
	margin-top: 0.5em;
}

.wc-block-components-product-button.align-center + .yayraq-loop-quote {
	align-items: center;
	text-align: center;
}

.wc-block-components-product-button.align-right + .yayraq-loop-quote {
	align-items: flex-end;
	text-align: end;
}

.wc-block-components-product-button:not(.align-center, .align-right) + .yayraq-loop-quote {
	align-items: flex-start;
}

.wc-block-components-product-button + .yayraq-loop-quote .yayraq-loop-add-to-quote {
	font-size: var(--wp--preset--font-size--small, 0.875rem);
}

/* Before the Product Button block: same alignment, gap below instead of above. */
.yayraq-loop-quote.yayraq-before {
	margin: 0 0 0.5em;
}

.yayraq-loop-quote.yayraq-before:has(+ .wc-block-components-product-button) {
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}

.yayraq-loop-quote.yayraq-before:has(+ .wc-block-components-product-button.align-center) {
	align-items: center;
	text-align: center;
}

.yayraq-loop-quote.yayraq-before:has(+ .wc-block-components-product-button.align-right) {
	align-items: flex-end;
	text-align: end;
}
