/**
 * Product loop: card layout, quantity stepper and add to cart control.
 *
 * Loaded after the child theme stylesheet, so plain specificity is enough to win
 * except where the theme uses !important (those cases are annotated).
 */

:root {
	/* #EF5222 only reaches 3.55:1 against white, so the CTA uses a darker tint
	   (4.74:1) and the brand orange is kept for focus rings and accents. */
	--sf-cta: #ce4319;
	--sf-cta-hover: #b03713;
	--sf-cta-active: #97300f;
	--sf-brand: #ef5222;

	--sf-ink: #2b2b2b;
	--sf-ink-soft: #6b6b6b;
	--sf-muted: #8a8a8a;
	--sf-line: #e4e4e4;
	--sf-line-strong: #d2d2d2;
	--sf-surface: #ffffff;
	--sf-surface-soft: #f6f6f6;
	--sf-success: #1e7a48;
	--sf-danger: #b3261e;

	--sf-radius: 12px;
	--sf-radius-pill: 999px;
	--sf-cols: 2;
}

@media only screen and (min-width: 600px) {
	:root {
		--sf-cols: 3;
	}
}

@media only screen and (min-width: 1025px) {
	:root {
		--sf-cols: 4;
	}
}

/* ------------------------------------------------------------------------- *
 * Grid
 *
 * The theme lays the loop out with floats, percentage widths and nth-child
 * clearing, which needs min-height hacks to keep rows from collapsing into each
 * other. Grid replaces all of it and lets every card share the same row height,
 * which is what keeps the add to cart buttons aligned across a row.
 * ------------------------------------------------------------------------- */

.eltdf-pl-main-holder > ul.products,
.related.products > ul.products,
.upsells.products > ul.products,
.cross-sells > ul.products {
	display: grid;
	grid-template-columns: repeat(var(--sf-cols), minmax(0, 1fr));
	gap: 28px 22px;
	margin: 0;
	padding: 0;
	list-style: none;
}

.eltdf-pl-main-holder > ul.products::before,
.eltdf-pl-main-holder > ul.products::after,
.related.products > ul.products::before,
.related.products > ul.products::after {
	content: none;
}

.eltdf-pl-main-holder > ul.products > li.product,
.related.products > ul.products > li.product,
.upsells.products > ul.products > li.product,
.cross-sells > ul.products > li.product {
	/* Overrides the theme's width: 20% / float rules, some of them !important. */
	width: auto !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: none !important;

	/* Only the grid cards get a query container: their width comes from the grid
	   track. The standalone shortcode cards sit inside shrink to fit lists, where
	   inline-size containment would collapse the layout. */
	container-type: inline-size;
}

/* Standalone [product] shortcodes sit one per WPBakery column with no gutter
   between them, so the card borders would touch; the padding opens the gap
   without touching the page layout. */
.wpb_wrapper > div.woocommerce > ul.products {
	box-sizing: border-box;
	padding-left: 8px;
	padding-right: 8px;
}

/* When the product behind a [product] shortcode goes out of stock, WooCommerce
   hides it and the shortcode renders an empty list. The column keeps its width,
   leaving a hole in the middle of the row, so it is collapsed instead. */
.wpb_column:has(ul.products):not(:has(li.product)) {
	display: none;
}

/* ------------------------------------------------------------------------- *
 * Card
 *
 * Applies to every product loop card, whether it comes from an archive or from
 * a [product] shortcode dropped into a WPBakery column.
 * ------------------------------------------------------------------------- */

/* The parent theme pads every loop item 15px on the sides. The card provides its
   own inner spacing now, so that padding only shows up as a white gutter inside
   the border. The attribute selector covers every eltdf-woo-*-space variant and
   outweighs the theme's .eltdf-woo-normal-space rule. */
ul.products > li.product,
[class*="eltdf-woo-"] ul.products > li.product {
	padding: 0;
}

ul.products > li.product {
	display: flex;
	flex-direction: column;
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: var(--sf-radius);
	overflow: hidden;
	transition: border-color 0.2s ease-out, box-shadow 0.2s ease-out, transform 0.2s ease-out;
}

ul.products > li.product:hover {
	border-color: var(--sf-line-strong);
	box-shadow: 0 10px 26px rgba(0, 0, 0, 0.08);
	transform: translateY(-2px);
}

/* Source images are not all square, and a missing one would otherwise stretch the
   card to the image's declared height; the ratio lives on the wrapper so the card
   keeps its shape either way. */
ul.products > li.product .eltdf-pl-image {
	aspect-ratio: 1 / 1;
	overflow: hidden;
}

ul.products > li.product .eltdf-pl-image img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* ------------------------------------------------------------------------- *
 * Card text
 * ------------------------------------------------------------------------- */

ul.products > li.product .eltdf-pl-text-wrapper {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	gap: 5px;
	margin: 0 !important;
	padding: 13px 14px 15px;
	text-align: left;
	min-height: 0 !important; /* replaces the 110px min-height alignment hack */

	/* The theme sets width: 100% on this element without border-box, so the
	   padding would push its children past the edge of the card. */
	box-sizing: border-box;
}

.sf-pl-eyebrow {
	display: block;
	font-size: 10px;
	font-weight: 700;
	letter-spacing: 0.08em;
	line-height: 1.2;
	text-transform: uppercase;
	color: var(--sf-muted);
}

ul.products > li.product .eltdf-pl-text-wrapper .eltdf-product-list-title {
	margin: 0;
	min-height: 0;
	font-size: 15px;
	line-height: 1.35;
	font-weight: 600;
	color: var(--sf-ink);
}

/* The clamp lives on the link, not on the heading: the heading is a flex item and
   flex items blockify their display, which kills -webkit-box and the clamp with it. */
ul.products > li.product .eltdf-pl-text-wrapper .eltdf-product-list-title a {
	color: inherit;

	/* Product titles are stored in caps; lowercasing them here keeps two line
	   names readable. Renaming the products is the real fix. */
	text-transform: lowercase;

	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;

	/* Two lines are always reserved. In the grid it keeps the prices on a shared
	   baseline; on the standalone shortcode cards, where each list is its own
	   column and nothing equalises heights, it is what keeps the cards level. */
	min-height: 2.7em;
}

ul.products > li.product .eltdf-pl-text-wrapper .eltdf-product-list-title a::first-letter {
	text-transform: uppercase;
}

ul.products > li.product .eltdf-pl-text-wrapper .eltdf-product-list-title a:hover {
	color: var(--sf-brand);
}

ul.products > li.product .eltdf-pl-text-wrapper .price {
	margin: 2px 0 0;
	color: var(--sf-ink);
	font-weight: 700;
}

ul.products > li.product .eltdf-pl-text-wrapper .price .woocommerce-Price-amount bdi {
	/* The child theme sets 20px !important on this element. */
	font-size: 17px !important;
	color: var(--sf-ink);
}

ul.products > li.product .eltdf-pl-text-wrapper .price del {
	color: var(--sf-muted);
	font-weight: 400;
}

ul.products > li.product .eltdf-pl-text-wrapper .price ins {
	text-decoration: none;
}

/* The hover overlay no longer holds the add to cart button; it stays as a plain
   image tint so the card still reacts to the pointer. */
ul.products > li.product .eltdf-pl-text {
	background-color: rgba(43, 43, 43, 0.14);
}

/* ------------------------------------------------------------------------- *
 * Control
 * ------------------------------------------------------------------------- */

.sf-loop-cart {
	display: flex;
	flex-direction: column;
	align-items: stretch;
	flex-wrap: wrap;
	gap: 8px;
	margin-top: auto; /* pins the control to the bottom of the card */
	padding-top: 10px;
}

/* Cards wide enough fit the stepper and the button on one row. Without container
   query support the stacked layout above stands, which is a fine fallback. */
@container (min-width: 230px) {
	.sf-loop-cart {
		flex-direction: row;
		align-items: center;
	}
}

.sf-qty {
	display: inline-flex;
	align-items: center;
	align-self: center;
	flex: 0 0 auto;
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: var(--sf-radius-pill);
}

.sf-qty__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 0;
	border-radius: var(--sf-radius-pill);
	background: transparent;
	color: var(--sf-ink);
	cursor: pointer;
	transition: background-color 0.15s ease-out, color 0.15s ease-out;
}

.sf-qty__btn:hover:not(:disabled) {
	background-color: var(--sf-surface-soft);
	color: var(--sf-brand);
}

.sf-qty__btn:disabled {
	color: #c6c6c6;
	cursor: not-allowed;
}

.sf-qty__input {
	width: 34px;
	height: 40px;
	padding: 0;
	margin: 0;
	border: 0;
	background: transparent;
	color: var(--sf-ink);
	font-size: 15px;
	font-weight: 700;
	line-height: 40px;
	text-align: center;
	-moz-appearance: textfield;
	appearance: textfield;
}

.sf-qty__input::-webkit-outer-spin-button,
.sf-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.sf-qty__input:focus {
	outline: 0;
}

.sf-qty:focus-within {
	border-color: var(--sf-brand);
	box-shadow: 0 0 0 3px rgba(239, 82, 34, 0.18);
}

/* Add to cart button. The theme styles a.button globally (teal, uppercase, fixed
   42px line-height) and the child theme forces a white background, so the shared
   rules are excluded from .sf-loop-cart__add in style.css rather than fought with
   !important here. */
.sf-loop-cart .sf-loop-cart__add,
.woocommerce-page .eltdf-content .sf-loop-cart a.sf-loop-cart__add,
div.woocommerce .sf-loop-cart a.sf-loop-cart__add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 7px;
	flex: 1 1 auto;
	width: auto;
	height: 40px;
	line-height: 1;
	padding: 0 14px;
	border: 0;
	border-radius: var(--sf-radius-pill);
	background-color: var(--sf-cta);
	color: #fff;
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.02em;
	text-transform: none;
	text-align: center;
	white-space: nowrap;
	cursor: pointer;
	transition: background-color 0.18s ease-out, transform 0.12s ease-out;
}

.sf-loop-cart .sf-loop-cart__add:hover,
.woocommerce-page .eltdf-content .sf-loop-cart a.sf-loop-cart__add:hover,
div.woocommerce .sf-loop-cart a.sf-loop-cart__add:hover {
	background-color: var(--sf-cta-hover);
	color: #fff;
}

.sf-loop-cart .sf-loop-cart__add:active {
	background-color: var(--sf-cta-active);
	transform: scale(0.98);
}

.sf-loop-cart .sf-loop-cart__add:focus-visible,
.sf-qty__btn:focus-visible {
	outline: 3px solid rgba(239, 82, 34, 0.45);
	outline-offset: 2px;
}

/* The home page carries its own WPBakery custom CSS (post 4906) that hides the
   loop add to cart button outright and restyles .add_to_cart_button with
   !important. Those rules predate this control and live in the database, so they
   would not travel with a deploy; they are neutralised here instead. */
.sf-loop-cart a.sf-loop-cart__add,
.semanales .sf-loop-cart a.sf-loop-cart__add,
.products.columns-5 .sf-loop-cart a.sf-loop-cart__add {
	display: inline-flex !important;
	font-size: 13px !important;
	line-height: 1 !important;
	padding: 0 14px !important;
}

/* WooCommerce adds .added after a successful request and the theme hides that
   button outright; here the button stays and reports its own success state. */
.woocommerce-page .eltdf-content a.sf-loop-cart__add.added,
div.woocommerce a.sf-loop-cart__add.added,
.sf-loop-cart a.sf-loop-cart__add.added {
	display: inline-flex;
}

/* The "view cart" link WooCommerce injects next to the button is redundant with
   the header mini cart. */
.sf-loop-cart .added_to_cart {
	display: none !important;
}

/* --- States --- */

.sf-loop-cart__spinner,
.sf-loop-cart__check {
	display: none;
	flex: 0 0 auto;
}

.sf-loop-cart__spinner {
	width: 14px;
	height: 14px;
	border: 2px solid rgba(255, 255, 255, 0.45);
	border-top-color: #fff;
	border-radius: 50%;
	animation: sf-spin 0.7s linear infinite;
}

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

@media (prefers-reduced-motion: reduce) {
	.sf-loop-cart__spinner {
		animation-duration: 2s;
	}

	ul.products > li.product,
	.sf-loop-cart .sf-loop-cart__add {
		transition: none;
	}

	ul.products > li.product:hover {
		transform: none;
	}
}

.sf-loop-cart.is-loading .sf-loop-cart__add {
	pointer-events: none; /* blocks a second tap without racing WooCommerce's handler */
}

.sf-loop-cart.is-loading .sf-loop-cart__spinner {
	display: block;
}

.sf-loop-cart.is-added .sf-loop-cart__check {
	display: block;
}

.sf-loop-cart.is-added .sf-loop-cart__add,
.woocommerce-page .eltdf-content .sf-loop-cart.is-added a.sf-loop-cart__add,
div.woocommerce .sf-loop-cart.is-added a.sf-loop-cart__add {
	background-color: var(--sf-success);
}

.sf-loop-cart__error {
	display: block;
	flex: 1 0 100%; /* drops to its own line when the control sits in a row */
	margin: 2px 0 0;
	color: var(--sf-danger);
	font-size: 12px;
	line-height: 1.35;
	text-align: left;
}

/* --- Not purchasable --- */

.sf-loop-cart--unavailable {
	align-items: flex-start;
	gap: 4px;
}

.sf-loop-cart__unavailable {
	display: inline-flex;
	align-items: center;
	height: 40px;
	padding: 0 14px;
	border-radius: var(--sf-radius-pill);
	background: var(--sf-surface-soft);
	color: var(--sf-ink-soft);
	font-size: 13px;
	font-weight: 700;
}

.sf-loop-cart__detail {
	color: var(--sf-cta);
	font-size: 12px;
	font-weight: 600;
	text-decoration: underline;
}

/* ------------------------------------------------------------------------- *
 * Toast
 *
 * Anchored bottom left: the WhatsApp launcher already owns the bottom right.
 * ------------------------------------------------------------------------- */

.sf-toast {
	position: fixed;
	left: 24px;
	bottom: 24px;
	z-index: 1000;
	width: 320px;
	max-width: calc(100vw - 32px);
	box-sizing: border-box;
	padding: 14px 16px 16px;
	background: var(--sf-surface);
	border: 1px solid var(--sf-line);
	border-radius: var(--sf-radius);
	box-shadow: 0 16px 40px rgba(0, 0, 0, 0.16);

	opacity: 0;
	visibility: hidden;
	transform: translateY(12px);
	transition: opacity 0.22s ease-out, transform 0.22s ease-out, visibility 0.22s;
}

.sf-toast.is-visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
}

.sf-toast__close {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	padding: 0;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--sf-muted);
	cursor: pointer;
}

.sf-toast__close:hover {
	background: var(--sf-surface-soft);
	color: var(--sf-ink);
}

.sf-toast__close:focus-visible {
	outline: 3px solid rgba(239, 82, 34, 0.45);
	outline-offset: 2px;
}

.sf-toast__title {
	margin: 0 24px 0 0;
	color: var(--sf-ink);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.35;
}

.sf-toast__check {
	color: var(--sf-success);
}

.sf-toast__progress {
	height: 6px;
	margin: 12px 0 8px;
	border-radius: var(--sf-radius-pill);
	background: #ededed;
	overflow: hidden;
}

.sf-toast__bar {
	display: block;
	height: 100%;
	width: 0;
	border-radius: inherit;
	background: var(--sf-cta);
	transition: width 0.4s ease-out;
}

.sf-toast.is-complete .sf-toast__bar {
	background: var(--sf-success);
}

.sf-toast__hint {
	margin: 0;
	color: var(--sf-ink-soft);
	font-size: 12.5px;
	line-height: 1.4;
}

.sf-toast__cta {
	display: inline-block;
	margin-top: 10px;
	color: var(--sf-cta);
	font-size: 13px;
	font-weight: 700;
	text-decoration: underline;
}

.sf-toast__cta:hover {
	color: var(--sf-cta-hover);
}

.sf-toast__cta:focus-visible {
	outline: 3px solid rgba(239, 82, 34, 0.45);
	outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
	.sf-toast,
	.sf-toast__bar {
		transition: none;
	}

	.sf-toast {
		transform: none;
	}
}

@media only screen and (max-width: 600px) {
	.sf-toast {
		left: 12px;
		right: 12px;
		width: auto;
		max-width: none;

		/* Full width here, so it clears the WhatsApp launcher (60px + 14px) by
		   sitting above it instead of beside it. */
		bottom: 86px;
	}
}

/* ------------------------------------------------------------------------- *
 * Responsive
 * ------------------------------------------------------------------------- */

@media only screen and (max-width: 767px) {
	.eltdf-pl-main-holder > ul.products,
	.related.products > ul.products,
	.upsells.products > ul.products,
	.cross-sells > ul.products {
		gap: 20px 14px;
	}

	ul.products > li.product .eltdf-pl-text-wrapper {
		padding: 11px 11px 13px;
	}

	ul.products > li.product .eltdf-pl-text-wrapper .eltdf-product-list-title {
		font-size: 14px;
	}

	/* Touch targets go to 44px on small screens. */
	.sf-qty__btn,
	.sf-qty__input {
		width: 44px;
		height: 44px;
		line-height: 44px;
	}

	.sf-qty__input {
		width: 36px;
	}

	.sf-loop-cart .sf-loop-cart__add,
	.woocommerce-page .eltdf-content .sf-loop-cart a.sf-loop-cart__add,
	div.woocommerce .sf-loop-cart a.sf-loop-cart__add {
		height: 44px;
	}
}
