/**
 * Studies:
 * - Baymard Institute (updated 2025): Product-list testing found that review counts should appear alongside average ratings.
 * - Nielsen Norman Group: Ecommerce listing research found that shoppers scan familiar star icons when comparing products.
 */

/* HOCLIN Product Card */

li.product.hx-card { list-style: none; }

.hx-card__link:focus-visible {
	outline: 2px solid var(--hx-primary);
	outline-offset: 2px;
	border-radius: var(--hx-radius-md);
}

/* WooCommerce ships `ul.products li.product a img { height: auto }`, which would
   stop the picture from filling the square media box. The long selector below
   wins over it, so the image always covers the card. */
.woocommerce ul.products li.product .hx-card__media img,
.hx-card__media img {
	display: block;
	width: 100%;
	height: 100%;
	object-fit: cover;
	object-position: center;
	margin: 0;
}

/* N7 Fix: Override WooCommerce's default negative positioning */
ul.products li.product .hx-card__media .onsale,
.woocommerce ul.products li.product .hx-card__media .onsale,
.hx-card__media .hx-card__badge {
	position: absolute;
	top: var(--hx-sp-3);
	right: auto;
	left: auto;
	inset-inline-end: var(--hx-sp-3);
	inset-inline-start: auto;
	min-height: 0;
	min-width: 0;
	margin: 0;
	line-height: 1.4;
	padding: var(--hx-sp-1) var(--hx-sp-3);
	border-radius: var(--hx-radius-full);
	background: var(--hx-badge);
	color: #fff;
	font-size: var(--hx-fs-xs);
	font-weight: 800;
	box-shadow: var(--hx-shadow);
	z-index: 2;
	display: inline-block;
}

.hx-card__stock {
	position: absolute;
	bottom: var(--hx-sp-3);
	inset-inline-start: var(--hx-sp-3);
	padding: 2px 10px;
	border-radius: var(--hx-radius-full);
	background: rgba(15, 23, 42, 0.85);
	color: #fff;
	font-size: var(--hx-fs-xs);
	font-weight: 700;
	z-index: 2;
}
.hx-card.outofstock .hx-card__media img {
	opacity: 0.6;
	filter: grayscale(0.4);
}

.hx-card__body { gap: var(--hx-sp-2); }
.hx-card__rating-slot {
	min-height: 20px;
	display: flex;
	align-items: center;
}
.hx-card__rating {
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
	min-height: 18px;
	margin: 0;
	color: var(--hx-ink-light);
	font-size: 12px;
	line-height: 1.2;
}
.hx-card__stars {
	display: inline-flex;
	flex: 0 0 auto;
	align-items: center;
	gap: 1px;
	direction: ltr;
	white-space: nowrap;
	line-height: 1;
}
.hx-card__star {
	display: inline-block;
	font-family: Arial, sans-serif;
	font-size: 15px;
	line-height: 1;
	background: linear-gradient(90deg, var(--hx-accent) var(--hx-star-fill), var(--hx-line) var(--hx-star-fill));
	-webkit-background-clip: text;
	background-clip: text;
	-webkit-text-fill-color: transparent;
	color: transparent;
}
.hx-card__rating-average {
	color: var(--hx-ink);
	font-size: 12px;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
}
.hx-card__rating-count {
	color: var(--hx-ink-light);
	font-size: 12px;
	font-weight: 400;
}
.hx-card__swatches-slot {
	min-height: 28px;
	display: flex;
	align-items: center;
}
.woocommerce ul.products li.product.hx-card .price,
.hx-card .price,
.hx-card__price {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: var(--hx-sp-2);
	margin-top: auto;
	margin-bottom: 0;
	font-size: var(--hx-fs-base);
	font-weight: 800;
	color: var(--hx-price);
	line-height: 1.3;
}
.woocommerce ul.products li.product.hx-card .price del,
.hx-card .price del {
	/* Maintain WCAG AA contrast on the white product-card background. */
	color: var(--hx-ink-light);
	font-weight: 500;
	font-size: 0.85em;
	opacity: 1;
}
.woocommerce ul.products li.product.hx-card .price ins,
.hx-card .price ins {
	text-decoration: none;
	background: none;
}
.hx-card .price .woocommerce-Price-amount { white-space: nowrap; }

.hx-card__actions {
	padding: 0 var(--hx-sp-4) var(--hx-sp-4);
	position: relative;
}
.hx-card__actions:empty { display: none; }

.hx-card a.button,
.hx-card button.button,
.woocommerce .hx-card a.button,
.woocommerce .hx-card button.button,
/* Beats the WooCommerce loop rule `ul.products li.product .button { margin-top: 1em }`. */
.woocommerce ul.products li.product.hx-card a.button,
.woocommerce ul.products li.product.hx-card button.button {
	display: inline-flex;
	width: 100%;
	align-items: center;
	justify-content: center;
	gap: var(--hx-sp-2);
	margin: 0;
	padding: var(--hx-sp-2) var(--hx-sp-4);
	background: var(--hx-primary-soft);
	color: var(--hx-brand-text);
	border: 0;
	border-radius: var(--hx-radius);
	font-size: var(--hx-fs-sm);
	font-weight: 700;
	line-height: 1.5;
	text-align: center;
	cursor: pointer;
	min-height: 44px;
	transition: background var(--hx-dur) var(--hx-ease), color var(--hx-dur) var(--hx-ease), transform var(--hx-dur) var(--hx-ease);
}
.hx-card a.button:hover,
.hx-card button.button:hover,
.woocommerce .hx-card a.button:hover,
.woocommerce .hx-card button.button:hover {
	background: var(--hx-primary-fill);
	color: #fff;
}
.hx-card .button.loading {
	opacity: 0.6;
	pointer-events: none;
}
.hx-card .button.loading::after {
	content: "";
	width: 14px;
	height: 14px;
	border: 2px solid currentColor;
	border-inline-end-color: transparent;
	border-radius: 50%;
	animation: hx-card-spin 0.7s linear infinite;
}
.hx-card .button.added::after {
	content: "\2713";
	font-weight: 800;
}
.hx-card .added_to_cart {
	display: block;
	margin-top: var(--hx-sp-2);
	text-align: center;
	font-size: var(--hx-fs-xs);
	font-weight: 700;
	color: var(--hx-brand-text);
	text-decoration: underline;
	text-underline-offset: 3px;
}

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

@media (max-width: 767px) {
	.hx-card__body { padding: var(--hx-sp-3); }
	.hx-card__actions { padding: 0 var(--hx-sp-3) var(--hx-sp-3); }
	.hx-card a.button,
	.hx-card button.button,
	.woocommerce .hx-card a.button,
	.woocommerce .hx-card button.button {
		font-size: var(--hx-fs-sm);
		padding: var(--hx-sp-2) var(--hx-sp-3);
	}
	.hx-card__title,
	.woocommerce ul.products li.product .hx-card__title.woocommerce-loop-product__title { min-height: 2.8em; }
	.hx-card .price, .hx-card__price { font-size: var(--hx-fs-sm); }
}
@media (max-width: 380px) {
	.hx-card__title,
	.woocommerce ul.products li.product .hx-card__title.woocommerce-loop-product__title { font-size: var(--hx-fs-sm); }
}
@media (prefers-reduced-motion: reduce) {
	.hx-card .button { transition: none; }
	.hx-card .button.loading::after { animation: none; }
}
