/*
 * Crazy Runners — product cards (inc/woo-cards.php).
 * Loaded after assets/css/woocommerce.css, which keeps the grid and the card box (border, padding, shadow).
 *
 * A card, in source order: photo, name (the card's only link, stretched over the card), small line, price,
 * colour swatches. The swatch row is shown right under the photo and stays clickable above the stretched link.
 */

/* ==========================================================================
   1. The card: one link target
   ========================================================================== */

.woocommerce ul.products li.product .crs-card__link::after {
	content: "";
	position: absolute;
	/* Over the border too, so the focus ring follows the card's outer edge. */
	inset: -1px;
	z-index: 1;
	border-radius: var(--crs-radius);
}

/* Keyboard focus on the name rings the whole card. */
.woocommerce ul.products li.product .crs-card__link:focus-visible {
	outline: 0;
}

.woocommerce ul.products li.product .crs-card__link:focus-visible::after {
	outline: 3px solid var(--crs-accent);
	outline-offset: 2px;
}

/* A subtle lift, only for a pointer that hovers and a visitor who has not asked for less motion. */
@media (hover: hover) and (prefers-reduced-motion: no-preference) {
	.woocommerce ul.products li.product.type-product {
		transition: border-color .15s ease, box-shadow .15s ease, transform .15s ease;
	}

	.woocommerce ul.products li.product.type-product:hover {
		transform: translateY(-2px);
	}

	/* Keeps the pointer on the card along its bottom edge while it sits 2px higher. */
	.woocommerce ul.products li.product.type-product:hover::before {
		content: "";
		position: absolute;
		top: 100%;
		right: 0;
		left: 0;
		height: 3px;
	}
}

/* ==========================================================================
   2. Photo: the whole shoe in a square light frame
   ========================================================================== */

.woocommerce ul.products li.product .crs-card__media {
	order: -2;
	margin: 0 0 12px;
	overflow: hidden;
	border-radius: var(--crs-radius-sm);
	background: var(--crs-surface);
}

.woocommerce ul.products li.product .crs-card__media img {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	margin: 0;
	border: 0;
	border-radius: 0;
	box-shadow: none;
	object-fit: contain;
}

/* The price closes the card now that it has no button. */
.woocommerce ul.products li.product .price {
	margin-bottom: 0;
}

/* The sale badge sits above the stretched link: clicks go through it. Its look: section 4. */
.woocommerce ul.products li.product .onsale {
	pointer-events: none;
}

/* ==========================================================================
   3. Colour swatches
   ========================================================================== */

.woocommerce ul.products li.product .crs-card__swatches {
	position: relative;
	z-index: 2;
	display: flex;
	order: -1;
	gap: 6px;
	margin: 0 0 10px;
	padding: 0;
	list-style: none;
	/* The row is measured, not the screen: a card is narrow on a phone and in the 3-column grid alike. */
	container-type: inline-size;
	/* The gaps between swatches belong to the card link underneath. */
	pointer-events: none;
}

/* Swatches shrink rather than overflow on the narrowest screens. */
.woocommerce ul.products li.product .crs-card__swatch-item {
	flex: 0 1 30px;
	min-width: 0;
	margin: 0;
	padding: 0;
}

.woocommerce ul.products li.product .crs-card__swatch,
.woocommerce ul.products li.product .crs-card__more {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1 / 1;
	overflow: hidden;
	border: 1px solid var(--crs-border);
	border-radius: 6px;
	background: var(--crs-surface);
	pointer-events: auto;
}

.woocommerce ul.products li.product .crs-card__swatch img {
	/* Undoes what "li.product a img" (the former card photo rule) gives every image inside a link. */
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	margin: 0;
	border-radius: 0;
	background: none;
	object-fit: contain;
}

.woocommerce ul.products li.product .crs-card__swatch:hover,
.woocommerce ul.products li.product .crs-card__more:hover {
	border-color: var(--crs-sage-600);
}

/* The colourway on the photo: a quiet ring, never a fill. */
.woocommerce ul.products li.product .crs-card__swatch.is-current,
.woocommerce ul.products li.product .crs-card__swatch.is-previewed {
	border-color: var(--crs-sage-600);
	box-shadow: 0 0 0 1px var(--crs-sage-600);
}

/* While another colourway is previewed (assets/js/cards.js), the ring follows it. */
.woocommerce ul.products li.crs-card--previewing .crs-card__swatch.is-current:not(.is-previewed) {
	border-color: var(--crs-border);
	box-shadow: none;
}

.woocommerce ul.products li.product .crs-card__more {
	background: var(--crs-bg);
	color: var(--crs-muted);
	font-size: .75rem;
	font-weight: 600;
	line-height: 1;
	text-decoration: none;
}

.woocommerce ul.products li.product .crs-card__more:hover {
	color: var(--crs-text);
}

/*
 * How many swatches fit. Narrow row (a phone's 2 columns, 147px at 390px): 4 slots — every swatch up to 4,
 * else 3 and "+N". Wide row: 6 slots — 5 swatches and "+N". Both "+N" counts are in the page.
 * A browser without container queries keeps the narrow layout, which fits everywhere.
 */
.woocommerce ul.products li.product .crs-card__swatch-item--wide,
.woocommerce ul.products li.product .crs-card__more-count--wide {
	display: none;
}

@container (min-width: 210px) {
	.woocommerce ul.products li.product .crs-card__swatch-item--wide {
		display: block;
	}

	.woocommerce ul.products li.product .crs-card__more-count--wide {
		display: inline;
	}

	.woocommerce ul.products li.product .crs-card__swatch-item--narrow,
	.woocommerce ul.products li.product .crs-card__more-count--narrow {
		display: none;
	}
}

/* ==========================================================================
   4. Promotions (inc/woo-promo.php writes the badge and the price, inc/woo-cards.php marks the swatches)
   ========================================================================== */

/*
 * The reduction — "−20 %", "Jusqu’à −20 %" — as a small solid tag in the top left corner of the photo, on the
 * margin the square photos keep around the shoe. Also the badge of the product page, over its gallery.
 * Replaces the look given by woocommerce.css (".woocommerce span.onsale", a soft pill); its position is kept.
 * White on the accent: 5:1.
 */
.woocommerce span.onsale.crs-promo-badge,
.woocommerce ul.products li.product .onsale.crs-promo-badge {
	max-width: calc(100% - 36px);
	padding: 3px 8px;
	overflow: hidden;
	border-radius: 6px;
	background: var(--crs-accent);
	color: #fff;
	font-size: .75rem;
	font-weight: 700;
	font-variant-numeric: tabular-nums;
	line-height: 1.5;
	letter-spacing: .01em;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* "Dès 112,00 €": the word stays quiet, the amount reads as a reduced price. */
.woocommerce ul.products li.product .price .crs-promo-from {
	color: var(--crs-muted);
	font-size: .875rem;
	font-weight: 400;
}

.woocommerce ul.products li.product .price .crs-promo-from .amount {
	color: var(--crs-accent-hover);
	font-size: 1rem;
	font-weight: 700;
}

/* "… au lieu de 140,00 €": the price the reduction is computed from, quiet but readable. */
.woocommerce ul.products li.product .price .crs-promo-from del,
.woocommerce ul.products li.product .price .crs-promo-from del .amount {
	color: var(--crs-muted);
	font-size: .875rem;
	font-weight: 400;
	opacity: 1;
}

/* A colourway on promotion: a dot in the badge's colour, in the corner of its swatch. Its name says it in words. */
.woocommerce ul.products li.product .crs-card__swatch--promo {
	position: relative;
}

.woocommerce ul.products li.product .crs-card__swatch--promo::after {
	content: "";
	position: absolute;
	top: 1px;
	right: 1px;
	width: 9px;
	height: 9px;
	border: 2px solid var(--crs-bg);
	border-radius: 50%;
	background: var(--crs-accent);
}

/* While a full-price colourway is previewed (assets/js/cards.js), the badge steps back: it is not about that one. */
.woocommerce ul.products li.crs-card--offpromo .onsale {
	opacity: .4;
}

@media (prefers-reduced-motion: no-preference) {
	.woocommerce ul.products li.product .onsale.crs-promo-badge {
		transition: opacity .15s ease;
	}
}

/* Forced colours drop backgrounds: the tag keeps an outline, the dot its ring. */
@media (forced-colors: active) {
	.woocommerce span.onsale.crs-promo-badge,
	.woocommerce ul.products li.product .onsale.crs-promo-badge {
		border: 1px solid CanvasText;
	}

	.woocommerce ul.products li.product .crs-card__swatch--promo::after {
		border-color: CanvasText;
	}
}
