/*
 * Product card (.cw-product-card), connected to the cart by assets/js/product-card.js (the "Agregar" button and the
 * stepper are both in the markup; the script toggles their [hidden]). Sizes: --sm (grids of 4-5 columns) and --lg. State modifiers:
 * --add, --in-cart, --options, --out-of-stock, --restricted, and --sale. Also styles the cw-store-core
 * restricted price block (.cw-price-restricted, theme override cw-store-core/price-restricted.php)
 * when it lives inside a card.
 */
.cw-product-card {
	display: flex;
	height: 100%;
	flex-direction: column;
	gap: 8px;
	padding: 12px;
	border: 1px solid var(--cw-color-line);
	border-radius: var(--cw-radius);
	background: var(--cw-color-surface);
	transition: box-shadow .2s ease, border-color .2s ease;
}

.cw-product-card:hover {
	border-color: var(--cw-color-line-strong);
	box-shadow: var(--cw-shadow-md);
}

.cw-product-card--lg {
	gap: 10px;
	padding: 16px;
}

.cw-product-card__media {
	position: relative;
	margin-bottom: 4px;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: var(--cw-radius);
	background: var(--cw-color-subtle);
}

.cw-product-card__image-link {
	display: grid;
	width: 100%;
	height: 100%;
	place-items: center;
}

.cw-product-card .cw-product-card__image-link img {
	width: 80%;
	height: 80%;
	object-fit: contain;
}

.cw-product-card__placeholder {
	display: grid;
	place-items: center;
	color: var(--cw-color-muted);
}

.cw-product-card__placeholder .cw-icon {
	width: 44px;
	height: 44px;
}

.cw-product-card__badges {
	position: absolute;
	top: 10px;
	left: 10px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 4px;
}

.cw-product-card__sku {
	margin: 0;
	color: var(--cw-color-muted);
	font-size: 12px;
	letter-spacing: .02em;
}

.cw-product-card__title {
	min-height: calc(2 * 1.35em);
	margin: 0;
	display: -webkit-box;
	overflow: hidden;
	font-size: 15px;
	font-weight: 600;
	letter-spacing: normal;
	line-height: 1.35;
	-webkit-box-orient: vertical;
	-webkit-line-clamp: 2;
	line-clamp: 2;
}

.cw-product-card__title a {
	padding-block: 2px;
	color: var(--cw-color-ink);
	text-decoration: none;
}

.cw-product-card__title a:hover {
	text-decoration: underline;
}

.cw-product-card--lg .cw-product-card__title {
	font-size: 17px;
}

.cw-product-card__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0 8px;
	color: var(--cw-color-ink);
	font-size: 21px;
	font-weight: 800;
	letter-spacing: -.01em;
	line-height: 1.2;
}

.cw-product-card--lg .cw-product-card__price {
	font-size: 26px;
}

.cw-product-card__price ins {
	order: 1;
	color: var(--cw-color-accent);
	text-decoration: none;
}

.cw-product-card__price del {
	order: 2;
	color: var(--cw-color-muted);
	font-size: 13px;
	font-weight: 400;
}

.cw-product-card__tax {
	color: var(--cw-color-muted);
	font-size: 12px;
	font-weight: 500;
	letter-spacing: 0;
}

.cw-product-card--sale .cw-product-card__price {
	color: var(--cw-color-accent);
}

.cw-product-card__saving {
	display: inline-flex;
	height: 22px;
	align-items: center;
	align-self: flex-start;
	margin: 0;
	padding: 0 8px;
	border-radius: var(--cw-radius);
	background: var(--cw-color-accent-soft);
	color: var(--cw-color-accent-strong);
	font-size: 12px;
	font-weight: 800;
	line-height: 1;
}

.cw-product-card__tier {
	min-height: 18px;
	margin: 0;
	color: var(--cw-color-success);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.4;
}

.cw-product-card__tierbox {
	display: flex;
	min-height: 38px;
	align-items: center;
	gap: 8px;
	margin: 0;
	padding: 8px 12px;
	border: 1px dashed color-mix(in srgb, var(--cw-color-success) 35%, transparent);
	border-radius: var(--cw-radius);
	background: var(--cw-color-success-soft);
	color: var(--cw-color-success);
	font-size: 13px;
	font-weight: 600;
	line-height: 1.3;
}

.cw-product-card__tierbox .cw-icon {
	width: 16px;
	height: 16px;
}

.cw-product-card__tierbox.is-empty {
	visibility: hidden;
}

.cw-product-card__action {
	margin-top: auto;
}

/* Restricted visitor: the action container holds the restricted block (message + "Ingresar"), pinned to the bottom. */
.cw-product-card--restricted .cw-product-card__action {
	font-size: inherit;
	font-weight: inherit;
}

.cw-product-card .cw-price-restricted {
	display: flex;
	max-width: none;
	flex-direction: column;
	align-items: stretch;
	gap: 10px;
	margin: 0;
	padding: 12px;
	border: 1px dashed var(--cw-color-line-strong);
	border-radius: var(--cw-radius);
	background: var(--cw-color-subtle);
	color: var(--cw-color-text-2);
	font-size: 13px;
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1.4;
	text-align: left;
}

.cw-product-card .cw-price-restricted__text {
	display: flex;
	align-items: flex-start;
	gap: 8px;
}

.cw-product-card .cw-price-restricted__icon {
	width: 16px;
	height: 16px;
	margin-top: 1px;
	color: var(--cw-color-muted);
}

/* Both cart controls are in the markup; the one that is not active carries [hidden] (the component rules set display). */
.cw-product-card__action [hidden] {
	display: none;
}

.cw-product-card[aria-busy="true"] .cw-product-card__action {
	cursor: progress;
}

.cw-product-card[aria-busy="true"] .cw-product-card__action > :not(.cw-product-card__error) {
	opacity: .7;
}

/* Cart error from the Store API (role=alert, always in the markup so the announcement works; empty = no height). */
.cw-product-card__error {
	margin: 0;
	color: var(--cw-color-accent-strong);
	font-size: 12px;
	font-weight: 600;
	line-height: 1.35;
}

.cw-product-card__error:not(:empty) {
	margin-top: 6px;
}

/* Compact tier line of the large card: only replaces the tier box on narrow screens. */
.cw-product-card__tier--compact {
	display: none;
}

/* Narrow screens: compact large card (2 columns). */
@media (max-width: 599px) {
	.cw-product-card--lg {
		gap: 6px;
		padding: 10px;
	}

	.cw-product-card--lg .cw-product-card__title {
		font-size: 14px;
	}

	.cw-product-card--lg .cw-product-card__price {
		font-size: 18px;
	}

	.cw-product-card--lg .cw-product-card__tax,
	.cw-product-card--lg .cw-product-card__saving,
	.cw-product-card--lg .cw-product-card__tierbox {
		display: none;
	}

	.cw-product-card--lg .cw-product-card__tier--compact {
		display: block;
	}
}
@media (prefers-reduced-motion: reduce) {
	.cw-product-card {
		transition: none;
	}
}

/* Badge "Nuevo" (category landing, "Novedades" row): top right of the image */
.cw-product-card__new {
	position: absolute;
	top: 10px;
	right: 10px;
}
