/*
 * "Comprar ahora" button — shop loop and single product page. Loaded only on
 * shop/category/product pages (see socialhero_enqueue_buy_now_assets()), so
 * this stays a small, separate file instead of pulling in the full cart/
 * checkout panel stylesheet (socialhero.css) on pages that don't need it.
 */

/*
 * No padding/font-size/line-height/display overrides here on purpose.
 * Confirmed via DevTools (2026-09-24) that on this site "Añadir al carrito"
 * is WooCommerce's Product Collection block button, sized entirely by the
 * active block theme's global styles for .wp-element-button/
 * .wp-block-button__link (theme.json, output as
 * `:root :where(.wp-element-button, .wp-block-button__link) { ... }`) — an
 * earlier version tried to approximate that size with its own padding and
 * never matched it exactly. The markup now carries those same two classes
 * (see socialhero_add_buy_now_button_to_loop() /
 * socialhero_render_buy_now_button_single()) so the box dimensions come
 * from the exact same rule instead of a guess. Only color is overridden
 * here — `:where()` contributes zero specificity, so a plain class selector
 * would already win on specificity, but !important keeps that certain
 * regardless of which stylesheet the cascade happens to load second.
 */
.socialhero-buy-now-button {
	background-color: #443370 !important;
	color: #ffffff !important;
	border-radius: 999px !important;
}

/* 2.1.38: shape chosen in the plugin settings ("Forma del botón"). */
.socialhero-buy-now-button.socialhero-buy-now-button--square {
	border-radius: 0 !important;
}

.socialhero-buy-now-button:hover,
.socialhero-buy-now-button:focus-visible {
	background-color: #352a5c !important;
	color: #ffffff !important;
}

.socialhero-buy-now-button:focus-visible {
	outline: 2px solid #443370;
	outline-offset: 3px;
}

/*
 * Wraps the theme's own "Añadir al carrito" link plus "Comprar ahora" — see
 * socialhero_add_buy_now_button_to_loop(). display:flex (not inline-flex)
 * plus justify-content:center centers the pair reliably regardless of how
 * the theme originally centered the single button on its own (margin:auto,
 * text-align, a flex column on the <li>, ...) — wrapping it changed which
 * of those mechanisms still applied, so this takes care of it directly
 * instead of depending on one of them still working by coincidence.
 *
 * align-items:flex-start (not center) — both wrapper divs are the same
 * height (confirmed via DevTools, 2026-09-24), but "Añadir al carrito"'s
 * own extra height comes from margin-bottom under its link, not padding
 * around it, so the actual button sits at the TOP of its wrapper. Centering
 * this row vertically centered "Comprar ahora" in the row's full height
 * instead of matching that same top position — flex-start lines both
 * buttons up along the top edge instead.
 */
.socialhero-buy-now-row {
	display: flex;
	width: 100%;
	justify-content: center;
	align-items: flex-start;
	flex-wrap: wrap;
	gap: 0.5rem;
}

/*
 * 2.1.38: on the block product page (Twenty Twenty-Five) the link took the
 * whole width of the form and wrapped under "Añadir al carrito" as a wide
 * pill. Its width is now its content, like the theme's own button.
 */
.socialhero-buy-now-button--single {
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto !important;
	width: auto !important;
	max-width: 100%;
	margin-left: 0.75rem;
	white-space: nowrap;
}

/*
 * Block themes: WooCommerce lays out the add-to-cart form as a 3-column grid
 * (quantity | "Añadir al carrito" | auto) and sends every other child to a
 * full row (`grid-column: 1/-1`), stretched to the whole width right under
 * the buttons. Put "Comprar ahora" in the third column, beside "Añadir al
 * carrito" and as tall as it. On narrow screens it drops to its own row,
 * with space above.
 */
/*
 * The grid's columns are `min-content auto auto`: the two auto columns split
 * the free width, so "Comprar ahora" landed far to the right. With the
 * button present, the middle column fits "Añadir al carrito" and the last
 * one takes the rest, keeping both buttons together on the left.
 */
.wp-block-woocommerce-add-to-cart-form form.cart:has(> .socialhero-buy-now-button--single),
.wp-block-woocommerce-add-to-cart-form .variations_button:has(> .socialhero-buy-now-button--single) {
	grid-template-columns: min-content auto 1fr;
}

.wp-block-woocommerce-add-to-cart-form form.cart > .socialhero-buy-now-button--single,
.wp-block-woocommerce-add-to-cart-form .variations_button > .socialhero-buy-now-button--single {
	grid-column: 3 / 4;
	justify-self: start;
	align-self: stretch;
	height: auto;
}

@media (max-width: 600px) {
	.wp-block-woocommerce-add-to-cart-form form.cart > .socialhero-buy-now-button--single,
	.wp-block-woocommerce-add-to-cart-form .variations_button > .socialhero-buy-now-button--single {
		grid-column: 1 / -1;
		margin: 0.75rem 0 0;
	}
}
