/* Product list — responsive grid, hover crossfade, overview popup.
   Astra-friendly: inherits theme fonts/colors, accent via Astra global palette. */

.cwd-pl__toolbar {
	display: flex;
	flex-wrap: wrap;
	justify-content: space-between;
	align-items: center;
	gap: 0.75rem 1rem;
	margin-bottom: 1.5rem;
}

.cwd-pl__count {
	margin: 0;
	font-size: 0.9rem;
	opacity: 0.7;
}

.cwd-pl__sort {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	font-size: 0.9rem;
}

.cwd-pl__sort select {
	padding: 0.4em 0.6em;
	border: 1px solid rgba(0, 0, 0, 0.18);
	border-radius: 4px;
	background: transparent;
	color: inherit;
	font: inherit;
}

/* Establishes the container-query context used at the bottom of this file. */
.cwd-pl {
	container-type: inline-size;
}

/* Columns auto-collapse/stretch to the container width. */
.cwd-pl__grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 230px), 1fr));
	gap: 2.25rem 1.5rem;
}

.cwd-pl-card {
	display: flex;
	flex-direction: column;
	color: inherit;
	text-decoration: none;
}

.cwd-pl-card:hover {
	color: inherit;
}

/* Batch entrance: JS appends cards with --enter, sets a per-card
   --cwd-card-delay for the stagger, then adds .is-in on the next frame. */
.cwd-pl-card--enter {
	opacity: 0;
	transform: translateY(10px);
	transition:
		opacity var(--cwd-card-fade, 400ms) cubic-bezier(0.22, 1, 0.36, 1) var(--cwd-card-delay, 0ms),
		transform var(--cwd-card-fade, 400ms) cubic-bezier(0.22, 1, 0.36, 1) var(--cwd-card-delay, 0ms);
}

.cwd-pl-card--enter.is-in {
	opacity: 1;
	transform: none;
}

@media (prefers-reduced-motion: reduce) {
	.cwd-pl-card--enter {
		opacity: 1;
		transform: none;
		transition: none;
	}
}

.cwd-pl-card__figure {
	position: relative;
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	border-radius: 4px;
	background: rgba(0, 0, 0, 0.04);
}

.cwd-pl-card__img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.cwd-pl-card__collection {
	margin-top: 0.75rem;
	font-size: 0.8rem;
	opacity: 0.6;
}

.cwd-pl-card__title {
	margin-top: 0.15rem;
	font-weight: 600;
	line-height: 1.35;
}

.cwd-pl-card__price {
	margin-top: 0.25rem;
	font-size: 0.95rem;
}

/* Infinite scroll sentinel */

.cwd-pl__sentinel {
	display: flex;
	justify-content: center;
	padding: 2rem 0;
}

/* `display:flex` above outranks the UA rule for [hidden], so restore it. */
.cwd-pl__sentinel[hidden] {
	display: none;
}

.cwd-pl__loading {
	font-size: 0.9rem;
	opacity: 0.6;
}

/* Hover overview popup (desktop, fine pointers only — JS gates it) */

/* Width is overwritten inline per card (JS sizes the popup image to a fixed
   multiple of the card image); border-box keeps that arithmetic honest.
   transform-origin must stay at the top-left: JS builds the intro transform
   relative to the popup's own box. */
.cwd-pop {
	box-sizing: border-box;
	position: fixed;
	z-index: 99999;
	width: 320px;
	max-width: calc(100vw - 32px);
	padding: 1rem;
	border: 1px solid rgba(0, 0, 0, 0.08);
	border-radius: 8px;
	background: #fff;
	color: #1e1e1e;
	box-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	pointer-events: none;
	transform-origin: 0 0;
	opacity: 0;
	/* Hidden state = the intro's start state, so leaving replays the reveal
	   backwards over --cwd-fade-out. `visibility` is deliberately not used:
	   its transition needs a hardcoded delay, which clipped the zoom whenever
	   the fade-out ran longer. pointer-events + aria-hidden already keep the
	   popup out of hit-testing and the accessibility tree. */
	transition:
		opacity var(--cwd-fade-out, 200ms ease),
		transform var(--cwd-fade-out, 200ms ease);
}

.cwd-pop.is-visible {
	opacity: 1;
	transition:
		opacity var(--cwd-fade-in, 200ms ease),
		transform var(--cwd-fade-in, 200ms ease);
}

/* Commit a start state (or a card-to-card switch) without tweening. */
.cwd-pop.is-instant {
	transition: none;
}

.cwd-pop__img {
	display: block;
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: 6px;
}

/* Stacked, matching the card's own title-then-price order: a side-by-side
   row squeezes the name into three lines on long product titles. */
.cwd-pop__head {
	margin-top: 0.75rem;
	padding-bottom: 0.5rem;
}

.cwd-pop__name {
	display: block;
	font-weight: 600;
	line-height: 1.3;
}

.cwd-pop__price {
	display: block;
	margin-top: 0.15rem;
	font-size: 0.9rem;
	opacity: 0.8;
}

.cwd-pop__row {
	display: flex;
	justify-content: space-between;
	gap: 1rem;
	padding: 0.35rem 0;
	border-bottom: 1px solid rgba(0, 0, 0, 0.06);
	font-size: 0.875rem;
}

.cwd-pop__row:last-child {
	border-bottom: 0;
}

.cwd-pop__label {
	font-weight: 600;
}

.cwd-pop__value {
	text-align: right;
	opacity: 0.8;
}

/* Narrow viewports: tighten gutters instead of device-specific overrides. */
@container (max-width: 480px) {
	.cwd-pl__grid {
		gap: 1.5rem 1rem;
	}
}
