/* ==========================================================================
   Product grid and product card (WooCommerce loop).
   Loaded on the homepage and WooCommerce pages.
   ========================================================================== */

ul.products {
	display: grid;
	grid-template-columns: repeat(2, minmax(0, 1fr));
	gap: var(--space-7) var(--space-4);
	margin: 0;
	padding: 0;
	list-style: none;
}

ul.products::before,
ul.products::after {
	display: none; /* WooCommerce clearfix */
}

@media (min-width: 768px) {
	ul.products {
		grid-template-columns: repeat(3, minmax(0, 1fr));
		gap: var(--space-7) var(--space-5);
	}
}

@media (min-width: 1024px) {
	ul.products {
		grid-template-columns: repeat(4, minmax(0, 1fr));
	}
}

ul.products li.product {
	position: relative;
	display: flex;
	flex-direction: column;
	inline-size: auto;
	margin: 0;
	padding: 0;
	float: none;
}

ul.products li.product .woocommerce-LoopProduct-link {
	display: flex;
	flex: 1;
	flex-direction: column;
	color: inherit;
	text-decoration: none;
}

/* Media */

.product-card__media {
	position: relative;
	display: block;
	aspect-ratio: 4 / 5;
	margin-block-end: var(--space-4);
	overflow: hidden;
	background: var(--color-sand);
}

.product-card__media img {
	position: absolute;
	inset: 0;
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	object-position: center top;
	transition: transform 900ms var(--ease), opacity 450ms var(--ease);
}

ul.products li.product:hover .product-card__media img {
	transform: scale(1.035);
}

.product-card__alt {
	opacity: 0;
}

@media (hover: hover) {
	ul.products li.product:hover .product-card__alt {
		opacity: 1;
	}
}

/* Badges */

/* One badge per card, top end corner: the homepage card style. */
.product-badge {
	position: absolute;
	inset-block-start: 14px;
	inset-inline-end: 14px;
	z-index: 1;
	padding: 6px 10px;
	background: var(--color-surface);
	color: var(--color-ink);
	font-size: 0.71875rem;
	font-weight: 600;
	letter-spacing: 0.06em;
	line-height: 1;
}

@media (max-width: 600px) {
	.product-badge {
		inset-block-start: 8px;
		inset-inline-end: 8px;
		font-size: 0.65625rem;
	}
}

[dir="rtl"] .product-badge {
	letter-spacing: 0;
}

.product-badge--sale {
	background: var(--color-badge-sale);
	color: #fff;
}

.product-badge--new {
	background: var(--brand-yellow);
	color: var(--color-ink);
}

.product-badge--soldout {
	background: var(--color-sand-deep);
	color: var(--color-ink);
}

/* Text */

ul.products li.product .woocommerce-loop-product__title {
	margin: 0 0 var(--space-1);
	padding: 0;
	font-family: var(--font-serif);
	font-size: clamp(1.0625rem, 1rem + 0.35vw, 1.25rem);
	font-weight: 500;
	line-height: 1.25;
	color: var(--color-ink);
	transition: color var(--dur-fast) var(--ease);
}

ul.products li.product .woocommerce-LoopProduct-link:hover .woocommerce-loop-product__title {
	color: var(--color-accent);
}

ul.products li.product .star-rating {
	display: none; /* Shown on the product page only; keeps cards calm. */
}

.price {
	display: flex;
	flex-wrap: nowrap; /* One line, always: "Dès 690 DH", or the sale price next to the struck one. */
	align-items: baseline;
	white-space: nowrap;
	gap: 0 var(--space-2);
	margin: 0;
	color: var(--color-ink);
	font-size: var(--step-0);
	font-weight: 500;
}

ul.products li.product .price {
	font-size: 0.9375rem;
}

.price del {
	order: 2;
	color: var(--color-muted); /* 5.9:1 on the page background; no extra fading, it would drop below 4.5:1 */
	font-size: 0.875em;
	font-weight: 400;
}

.price ins {
	color: var(--color-sale);
	text-decoration: none;
}

/* "Dès" before the lowest price of products whose options cost different amounts. */
.price-from {
	font-size: 0.875em;
	font-weight: 400;
}

.price-from--sale {
	color: var(--color-sale);
}

/* Narrow phones: the longest card price ("ابتداءً من 1 090 DH 1 250 DH") still fits on one line. */
@media (max-width: 400px) {
	ul.products li.product .price {
		gap: 0 6px;
	}

	ul.products li.product .price del,
	ul.products li.product .price-from {
		font-size: 0.8em;
	}

	/* "Dès" + sale price + struck price is the longest: it scales with the card so it never wraps. */
	ul.products li.product {
		container-type: inline-size;
	}

	ul.products li.product .price:has(.price-from--sale) {
		font-size: min(0.9375rem, 7.5cqi);
	}
}

/* Add-to-cart button: quiet on cards, the product page has the big one. */

ul.products li.product .button {
	min-block-size: 2.5rem;
	margin-block-start: var(--space-4);
	padding: var(--space-2) var(--space-3);
	border-color: var(--color-line);
	background: transparent;
	color: var(--color-ink);
	font-size: 0.6875rem;
	letter-spacing: 0.1em;
}

ul.products li.product .button:hover {
	border-color: var(--color-ink);
	background: var(--color-ink);
	color: var(--color-surface);
}

ul.products li.product .button.loading {
	opacity: 0.6;
	pointer-events: none;
}

ul.products li.product .button.added::after {
	content: "✓";
	margin-inline-start: var(--space-2);
}

ul.products li.product .added_to_cart {
	margin-block-start: var(--space-2);
	font-size: var(--step--1);
	color: var(--color-accent);
	text-align: center;
}

@media (max-width: 479px) {
	[dir="ltr"] ul.products li.product .button,
	ul.products li.product .button {
		letter-spacing: 0.04em;
	}
}

/* Star rating (WooCommerce's icon font is not loaded): five glyphs, filled to the span's width. */

.star-rating {
	position: relative;
	display: inline-block;
	inline-size: 5.4em;
	block-size: 1.15em;
	overflow: hidden;
	font-size: 0.875rem;
	letter-spacing: 0.1em;
	line-height: 1.15;
}

.star-rating::before,
.star-rating span::before {
	content: "°5°5°5°5°5";
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
}

.star-rating::before {
	color: var(--color-line);
}

.star-rating span {
	position: absolute;
	inset-block-start: 0;
	inset-inline-start: 0;
	block-size: 100%;
	padding-block-start: 1.5em; /* pushes the "Noté x sur 5" text out of view */
	overflow: hidden;
}

.star-rating span::before {
	color: var(--color-gold);
}

/* Notices (WooCommerce's stylesheet is not loaded on the restyled pages) */

.woocommerce-notices-wrapper:empty {
	display: none;
}

.woocommerce-message,
.woocommerce-info,
.woocommerce-error {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: var(--space-3) var(--space-5);
	margin: 0 0 var(--space-5);
	padding: var(--space-4) var(--space-5);
	border: 1px solid var(--color-line);
	border-inline-start: 3px solid var(--color-accent);
	background: var(--color-surface);
	font-size: var(--step--1);
	list-style: none;
}

.woocommerce-error {
	border-inline-start-color: var(--color-error);
}

.woocommerce-message .button,
.woocommerce-info .button {
	order: 2;
	min-block-size: 2.5rem;
	padding: var(--space-2) var(--space-4);
	font-size: var(--step--2);
}

/* Empty state (catalog, search, empty cart) ---------------------------- */

.catalog-empty {
	display: grid;
	justify-items: center;
	gap: var(--space-6);
	max-inline-size: 520px;
	margin-inline: auto;
	padding-block: var(--space-6);
	text-align: center;
}

.catalog-empty > .art-fallback {
	position: relative;
	inline-size: 132px;
	block-size: 165px;
	border-radius: 66px 66px 0 0 / 60px 60px 0 0;
}

.catalog-empty .art-fallback__mark {
	font-size: 2.5rem;
}

.catalog-empty__title {
	font-size: var(--step-3);
}

.catalog-empty p {
	color: var(--color-muted);
}

.catalog-empty .button {
	margin-block-start: var(--space-2);
}

.catalog-empty__search {
	inline-size: 100%;
	margin-block-start: var(--space-4);
}
