/*
 * Product card, same as the app's ProductCard (agelpack-mobile/src/components/product/product-card.tsx):
 * 1px border, 16px radius, square white image area (whole photo), name in 2 lines,
 * bold price and a 36px round cart button (44px touch area).
 */

.product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	height: 100%;
	overflow: hidden;
	border: 1px solid var(--color-border);
	border-radius: var(--radius-lg);
	background: var(--color-background);
	transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.product-card:hover {
	border-color: var(--color-separator);
	box-shadow: var(--shadow-card);
}

.product-card__link {
	display: flex;
	flex: 1;
	flex-direction: column;
	color: var(--color-text-primary);
	text-decoration: none;
}

.product-card__link:hover {
	color: var(--color-text-primary);
}

/* Shop thumbnails are square (WooCommerce crops them), so "cover" cuts nothing off. */
/* Thin line where the image ends: white product photos no longer
   blend into the white text area. */
/*
 * The whole photo with breathing room: shop photos are framed
 * differently and some touched the edges and the line. White area like most photos,
 * 12px padding, "contain" so nothing is cut off.
 */
.product-card__image {
	position: relative;
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	padding: var(--space-sm);
	border-bottom: 1px solid var(--color-border);
	background: var(--color-background);
}

.product-card__image img {
	display: block;
	width: 100%;
	height: 100%;
	border-radius: var(--radius-sm);
	object-fit: contain;
	transition: transform 300ms ease-out;
}

/* Stock badge in the image corner: the grey button alone was easy to miss. */
.product-card__badge {
	position: absolute;
	top: var(--space-xs);
	left: var(--space-xs);
	z-index: 1;
}

.product-card:hover .product-card__image img {
	transform: scale(1.03);
}

/* Always two lines, so cards in a row have the same height. */
.product-card__name {
	display: -webkit-box;
	min-height: calc(2 * 1.35em);
	margin: var(--space-sm) var(--space-sm) 0;
	overflow: hidden;
	font-size: var(--text-subheadline);
	line-height: 1.35;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}

/* Packaging and measures under the name: small, grey, one line; the space
   is kept when a product has none, so the prices in a row stay level. */
.product-card__facts {
	display: block;
	min-height: 1.4em;
	margin: var(--space-xxs) var(--space-sm) 0;
	overflow: hidden;
	color: var(--color-text-secondary);
	font-size: var(--text-caption);
	line-height: 1.4;
	white-space: nowrap;
	text-overflow: ellipsis;
	font-variant-numeric: tabular-nums;
}

.product-card__footer {
	display: flex;
	align-items: center;
	gap: var(--space-xs);
	padding: var(--space-xs) var(--space-sm) var(--space-sm);
}

.product-card__price {
	flex: 1;
	min-width: 0;
	color: var(--color-text-primary);
	font-size: var(--text-headline);
	font-weight: var(--font-weight-bold);
	white-space: nowrap;
}

/* Narrow cards (phones, about 160–170px): four-digit prices like "5.850,00 KM" touched
   the cart button at 17px, so the price is 15px there. */
.product-card {
	container-type: inline-size;
}

@container (max-width: 200px) {
	.product-card__price {
		font-size: var(--text-subheadline);
		letter-spacing: -0.01em;
	}
}

/* WooCommerce wraps prices in its own elements; keep them plain. */
.product-card__price .woocommerce-Price-amount,
.product-card__price ins {
	color: inherit;
	text-decoration: none;
}

.product-card__price del {
	margin-right: var(--space-xxs);
	color: var(--color-text-tertiary);
	font-size: var(--text-footnote);
	font-weight: var(--font-weight-regular);
}

/* Round cart button (web, the app keeps "+"): brand red with a white
   symbol (non-text contrast 4.26:1). 36px so the cart symbol stays readable. */
.product-card__add {
	position: relative;
	display: inline-flex;
	flex-shrink: 0;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border-radius: var(--radius-full);
	background: var(--color-primary);
	color: var(--color-on-button-primary);
	transition: background-color var(--transition-fast), transform var(--transition-fast);
}

/* 44px touch area without a bigger circle. */
.product-card__add::after {
	content: "";
	position: absolute;
	inset: -4px;
}

.product-card__add:hover {
	background: var(--color-primary-pressed);
	color: var(--color-on-button-primary);
}

.product-card__add:active {
	transform: scale(0.94);
}

.product-card__add svg {
	display: block;
	width: 20px;
	height: 20px;
}

.product-card__add.is-disabled {
	background: var(--color-background-secondary);
	color: var(--color-text-tertiary);
}

/* States from WooCommerce's AJAX add to cart: "loading" while adding, "added" after. */
.product-card__add-icon--done {
	display: none;
}

.product-card__add.loading {
	opacity: 0.6;
	pointer-events: none;
}

/* Dark green (white check 5.4:1); the light app green would be too faint behind white. */
.product-card__add.added {
	background: var(--color-on-status-success);
}

.product-card__add.added .product-card__add-icon--add {
	display: none;
}

.product-card__add.added .product-card__add-icon--done {
	display: inline-flex;
}

/* WooCommerce adds a "Vidi korpu" link after the button; the header badge already shows it.
   WooCommerce's own rule (.woocommerce a.added_to_cart) is stronger, hence the longer selector. */
.product-card .added_to_cart,
.woocommerce .product-card a.added_to_cart {
	display: none;
}
