/*
 * Category product cards (moto categories only, see includes/grid.php).
 * Targets the card copies built by scripts/grid-cards.sh (class .sb-card); the original
 * cards 1463/3460 are not affected.
 */

/* ---------- Desktop / tablet card (dark) ---------- */

/* The loop grid already gives every item the same height; make the card fill it and
   push the price row to the bottom, so the extra space never lands under the button. */
.e-loop-item > .sb-card--desktop {
	height: 100%;
	display: flex !important;
	flex-direction: column;
}
.sb-card--desktop .sb-card-div {
	margin-top: auto;
}

/* Title on one line (long names get "…"; the full name is on the product page).
   min-width: 0 stops a long title from stretching its grid column. */
.e-loop-item,
.sb-card--desktop,
.sb-card--desktop .sb-card-head > .e-con:first-child {
	min-width: 0;
}
.sb-card--desktop .sb-card-head > .e-con:first-child {
	flex: 1 1 auto;
	overflow: hidden;
}
.sb-card--desktop .sb-card-head .elementor-widget-woocommerce-product-title {
	width: 100%;
	min-width: 0;
	overflow: hidden;
}
.sb-card--desktop .sb-card-head .elementor-heading-title {
	display: block;
	max-width: 100%;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

/* "Comparar" icon: the whole bordered square is clickable, not only the glyph (22 x 31 px), so it is
   easy to tap on a tablet. Nothing changes visually. */
.sb-card--desktop .cuadrado:has(a[href*="/comparar/"]) {
	position: relative;
}
.sb-card--desktop .cuadrado:has(a[href*="/comparar/"]) .elementor-element {
	position: static;
}
.sb-card--desktop .cuadrado a.elementor-icon[href*="/comparar/"]::after {
	content: "";
	position: absolute;
	inset: 0;
}

/* Same photo box on every card (photos come in several proportions). */
.sb-card--desktop .sb-card-img img {
	width: 100%;
	aspect-ratio: 3 / 2;
	height: auto;
	object-fit: cover;
}

/* Specs: always a 2 x 2 grid (Motor | Batería / Velocidad | Autonomía). */
.sb-card--desktop .sb-specs {
	display: grid !important;
	grid-template-columns: 1fr 1fr;
	grid-template-rows: auto auto !important; /* the Elementor grid container adds an empty 3rd row */
	gap: 14px 12px;
	align-items: start;
}
.sb-card--desktop .sb-specs > .sb-spec {
	width: auto !important;
	max-width: none !important;
	margin: 0 !important;
}
/* Label on top, value under it: labels and values start on the same line in every card.
   Motor / Batería get room for 3 lines (e.g. "Motor Hub 1500W sin escobillas"), so nothing is cut. */
.sb-card--desktop .sb-spec .e-con,
.sb-card--desktop .sb-spec.e-con {
	align-items: flex-start !important;
}
.sb-card--desktop .sb-spec .elementor-icon-box-content {
	display: flex;
	flex-direction: column-reverse;
	gap: 2px;
}
.sb-card--desktop .sb-spec .elementor-icon-box-title {
	margin: 0;
	font-size: 16px;
	line-height: 1.25;
}
.sb-card--desktop .sb-spec .elementor-icon-box-title > * {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
.sb-card--desktop .sb-spec:nth-child(-n+2) .elementor-icon-box-title {
	min-height: 3.75em;
}
.sb-card--desktop .sb-spec:nth-child(-n+2) .elementor-icon-box-title > * {
	-webkit-line-clamp: 3;
}

/* Labels always on one line (they wrapped at tablet width and pushed the value down). */
.sb-card--desktop .sb-spec .elementor-icon-box-description {
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
/* Tablet: columns are narrow, so the top-row labels get a two-line box (e.g. "BATERÍA DE / LITIO")
   and prices are a bit smaller so a price range still fits in two lines. */
@media (max-width: 1024px) {
	.sb-card--desktop .sb-spec:nth-child(-n+2) .elementor-icon-box-description {
		white-space: normal;
		min-height: 2.4em;
	}
	.sb-card--desktop .sb-price .price {
		font-size: 18px !important;
	}
}

/* Price block has room for a price range on two lines, so the button never moves. */
.sb-card--desktop .sb-price {
	min-height: 78px;
	justify-content: flex-start !important;
}
/* Button aligned with the top of the price block: it stays put whatever the price length. */
.sb-card--desktop .sb-card-foot {
	align-items: flex-start !important;
}
.sb-card--desktop .sb-card-foot .elementor-widget-button {
	margin-top: 12px;
}
/* A price never breaks in the middle, so a range takes at most two lines. */
.sb-price .woocommerce-Price-amount {
	white-space: nowrap;
}

/* ---------- Mobile card (white, compact) ---------- */

.sb-card--mobile {
	flex-wrap: wrap !important;
}
.sb-card--mobile > .sb-card-main {
	width: 100% !important;
}
/* Title on one line, as on desktop. */
.sb-card--mobile .elementor-widget-woocommerce-product-title {
	min-width: 0;
	max-width: 100%;
	overflow: hidden;
}
.sb-card--mobile .elementor-widget-woocommerce-product-title .elementor-heading-title {
	display: block;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}
.sb-card--mobile .sb-specs {
	gap: 6px !important;
	justify-content: flex-start !important;
}
.sb-card--mobile .sb-spec .elementor-icon-box-title {
	font-size: 14px !important;
	line-height: 1.25;
	margin: 0;
}
.sb-card--mobile .sb-spec .elementor-icon-box-title > * {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}
/* Compact card: Batería, Velocidad and Autonomía on one line ("…" if longer). */
.sb-card--mobile .sb-specs > .sb-spec:not(:first-child) .elementor-icon-box-title > * {
	-webkit-line-clamp: 1;
}

/* Motor is the only value that can take two lines: reserve them, so rows line up in every card. */
.sb-card--mobile .sb-specs > .sb-spec:first-child .elementor-icon-box-title {
	display: flex;
	align-items: center;
	min-height: 2.5em;
}

/* Same black for all four icons (the speed icon file is orange). */
.sb-card--mobile .sb-spec .elementor-icon {
	filter: brightness(0);
}
.sb-card--mobile .sb-spec .elementor-icon svg {
	width: 20px;
	height: 20px;
}

/* "Comparar" under the photo: photo centred in the column, button at its bottom (in line with the
   last spec row). Outlined, so "VER MÁS" stays the main button; 40px high for the finger. */
.sb-card--mobile .sb-card-media {
	display: flex !important;
	flex-direction: column !important;
	justify-content: space-between !important;
	gap: 8px;
	padding-right: 8px !important;
}
.sb-card--mobile .sb-card-media > .elementor-widget-image {
	flex: 1 1 auto;
	display: flex;
	align-items: center;
	justify-content: center;
}
.sb-card--mobile .sb-cmp-btn {
	width: 100%;
}
.sb-card--mobile .sb-cmp-btn .elementor-button {
	display: flex;
	justify-content: center;
	width: 100%;
	min-height: 40px;
	padding: 8px 10px;
	background: #fff !important;
	color: #000 !important;
	border: 1px solid #000;
	border-radius: 0;
	font-size: 13px;
	line-height: 1.2;
	white-space: nowrap;
}
.sb-card--mobile .sb-cmp-btn .elementor-button:hover,
.sb-card--mobile .sb-cmp-btn .elementor-button:focus-visible {
	background: #000 !important;
	color: #fff !important;
}
.sb-card--mobile .sb-cmp-btn .elementor-button-icon svg {
	width: 16px;
	height: 16px;
	fill: currentColor !important; /* the site's button style makes it white */
}

.sb-card--mobile > .sb-card-foot {
	width: 100% !important;
	--padding-top: 10px;
	--padding-right: 4px;
	--padding-bottom: 12px;
	--padding-left: 4px;
	border-top: 1px solid #e6e6e6;
}
.sb-card--mobile .sb-card-foot > .sb-price {
	flex: 1 1 auto;
	min-width: 0;
}
.sb-card--mobile .sb-card-foot > .elementor-widget-button {
	flex: 0 0 auto;
}
.sb-card--mobile .sb-price .elementor-heading-title {
	color: #666 !important;
	font-size: 12px !important;
	font-weight: 400;
	line-height: 1.2;
}
.sb-card--mobile .sb-price .elementor-widget-woocommerce-product-price {
	min-height: 36px; /* keeps the card height when a product has no price */
}
.sb-card--mobile .sb-price .price,
.sb-card--mobile .sb-price .price * {
	color: #000 !important;
	font-size: 17px !important;
	line-height: 1.25;
}
.sb-card--mobile .sb-card-foot .elementor-button {
	white-space: nowrap;
	padding: 10px 18px;
	font-size: 13px;
}
