/**
 * Casa Noce product card.
 *
 * One component for every grid and rail (see inc/cards.php). The plate keeps a fixed square
 * ratio so rows never stagger; the hover image sits on top of the primary and swaps in on a
 * straight cut.
 */

.cn-card {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 12px;
	min-width: 0;
}

.cn-card__media {
	position: relative;
	background: var(--wp--preset--color--oat-shade);
	overflow: hidden;
}

/* Square, matching the catalogue photography. On a 4:5 plate the 1:1 files left a band of
   the plate colour under every shot, which read as an empty cream box rather than as a crop. */
.cn-card__plate {
	display: block;
	aspect-ratio: 1 / 1;
	position: relative;
}

/* Two class names, not one: WooCommerce ships `.woocommerce img { height: auto }`, which
   outranks a single-class selector and collapses the fill back to the file's own ratio. */
.cn-card .cn-card__img,
.cn-card__plate .cn-slot {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

/* A straight cut, not a dissolve: mid-fade the two shots overlay each other and the piece
   reads as a double exposure. */
.cn-card__img--hover {
	opacity: 0;
	transition: none;
}

@media (hover: hover) {
	.cn-card--has-hover:hover .cn-card__img--hover,
	.cn-card--has-hover:focus-within .cn-card__img--hover {
		opacity: 1;
	}
}

/* Flags stack top-left; the wishlist heart owns the top-right corner. */
.cn-card__flags {
	position: absolute;
	top: 12px;
	left: 12px;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 6px;
	z-index: 2;
}

.cn-flag {
	display: inline-block;
	padding: 5px 9px;
	background: var(--wp--preset--color--ivory);
	color: var(--wp--preset--color--warm-ink);
	font-size: 10.5px;
	letter-spacing: 0.12em;
	line-height: 1;
	text-transform: uppercase;
}

.cn-flag--sale {
	background: var(--wp--preset--color--honey-brass);
	color: var(--wp--preset--color--ivory);
}

.cn-flag--code {
	background: var(--wp--preset--color--warm-ink);
	color: var(--wp--preset--color--oat);
}

.cn-card__media .cn-tag {
	position: absolute;
	top: auto;
	left: 12px;
	bottom: 12px;
	z-index: 2;
}

.cn-tag--pre {
	background: var(--wp--preset--color--walnut);
	color: var(--wp--preset--color--cream);
}

.cn-card__media .cn-wish {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 2;
}

.cn-card__body {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
}

.cn-card__name {
	margin: 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: 16.5px;
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1.25;
	text-wrap: balance;
}

.cn-card__name a {
	color: inherit;
	text-decoration: none;
}

.cn-card__name a::after {
	/* The whole card is the link target for the name; the plate has its own anchor for hover. */
	content: "";
	position: absolute;
	inset: 0;
	z-index: 1;
}

.cn-card__name a:hover {
	color: var(--wp--preset--color--walnut);
}

.cn-card__meta {
	margin: 0;
	color: var(--wp--preset--color--ink-muted);
	font-size: 12.5px;
	letter-spacing: 0.02em;
}

.cn-card__price {
	font-size: 14.5px;
}

.cn-card__price del {
	margin-right: 6px;
	color: var(--wp--preset--color--ink-muted);
	font-size: 13px;
}

.cn-card__price ins {
	text-decoration: none;
	color: var(--wp--preset--color--walnut);
}

.cn-card__rating {
	position: relative;
	z-index: 2;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	color: var(--wp--preset--color--ink-muted);
	font-size: 12.5px;
	text-decoration: none;
}

.cn-card__rating-count::before {
	content: "(";
}

.cn-card__rating-count::after {
	content: ")";
}

/* Five stars, filled to --cn-rating percent. Shared by cards, the PDP and the reviews. */
.cn-stars {
	position: relative;
	display: inline-block;
	color: var(--wp--preset--color--greige);
	font-size: 13px;
	letter-spacing: 2px;
	line-height: 1;
	white-space: nowrap;
}

.cn-stars::before,
.cn-stars > span::before {
	content: "★★★★★";
}

.cn-stars > span {
	position: absolute;
	top: 0;
	left: 0;
	width: var(--cn-rating, 0%);
	overflow: hidden;
	color: var(--wp--preset--color--honey-brass);
	white-space: nowrap;
}

.cn-card__swatches {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 2px;
}

.cn-card__swatches .cn-swatch {
	display: inline-block;
	width: 14px;
	height: 14px;
	border: 1px solid var(--cn-hairline);
	border-radius: 50%;
	background: var(--cn-swatch, var(--wp--preset--color--greige));
}

.cn-card__more {
	color: var(--wp--preset--color--ink-muted);
	font-size: 11.5px;
	letter-spacing: 0.04em;
}

@media (max-width: 767px) {
	.cn-card {
		gap: 9px;
	}

	.cn-card__name {
		font-size: 14.5px;
	}

	.cn-card__meta {
		font-size: 11.5px;
	}

	.cn-card__price {
		font-size: 13.5px;
	}

	.cn-card__flags {
		top: 8px;
		left: 8px;
	}

	.cn-flag {
		padding: 4px 7px;
		font-size: 9.5px;
	}
}
