/* wpagent/product-grid (P04) — product cards in a grid, rows or a slider,
 * plus the shared shop list and slider frame (also used by
 * wpagent/product-categories). Non-default prop values arrive as custom
 * properties from the style engine (style-rules.php); the fallbacks below are
 * the registry defaults. Card HTML is identical in every layout. */

.wpab-sr-only {
	position: absolute !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Shared list: --wpab-shop-cols columns, --wpab-shop-gap gaps. */
.wpab-product-grid,
.wpab-product-categories {
	--wpab-shop-cols: 2;
	--wpab-shop-gap: 24px;
}
.wpab-shop-list {
	display: grid;
	grid-template-columns: repeat(var(--wpab-shop-cols), minmax(0, 1fr));
	column-gap: var(--wpab-shop-gap);
	row-gap: var(--wpab-shop-row-gap, var(--wpab-shop-gap));
	margin: 0;
	padding: 0;
	list-style: none;
}

/* Slider frame: one scroll-snapping row; arrows appear once view.js runs and the row overflows. */
.wpab-shop-slider {
	position: relative;
}
.wpab-shop-list.wpab-shop-slider__track {
	grid-template-columns: none;
	grid-auto-flow: column;
	grid-auto-columns: calc((100% - (var(--wpab-shop-cols) - 1) * var(--wpab-shop-gap)) / var(--wpab-shop-cols));
	overflow-x: auto;
	overscroll-behavior-x: contain;
	scroll-snap-type: x mandatory;
	scroll-behavior: smooth;
	scrollbar-width: none;
}
.wpab-shop-slider__track::-webkit-scrollbar {
	display: none;
}
.wpab-shop-slider__track > * {
	scroll-snap-align: start;
}
.wpab-shop-slider__arrow {
	position: absolute;
	top: 38%;
	z-index: 2;
	display: none;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	padding: 0;
	border: 1px solid var(--wp--preset--color--line, rgba(17, 24, 39, 0.12));
	border-radius: 50%;
	background: var(--wp--preset--color--surface, #fff);
	color: var(--wp--preset--color--ink, #111827);
	font-size: 20px;
	cursor: pointer;
	transform: translateY(-50%);
	transition: opacity 0.2s ease;
}
.wpab-shop-slider.is-scrollable .wpab-shop-slider__arrow {
	display: inline-flex;
}
.wpab-shop-slider__arrow--prev {
	left: 8px;
}
.wpab-shop-slider__arrow--next {
	right: 8px;
}
.wpab-shop-slider__arrow--prev .wpab-shop-slider__icon {
	transform: rotate(180deg);
}
.wpab-shop-slider__arrow:disabled {
	opacity: 0.35;
	cursor: default;
}

/* Card. */
.wpab-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	min-width: 0;
	margin: 0;
	text-align: var(--wpab-pg-align, start);
}
.wpab-product-card__media {
	position: relative;
	display: block;
	overflow: hidden;
	aspect-ratio: var(--wpab-pg-ratio, 1 / 1);
	margin-bottom: 14px;
	background: var(--wpab-pg-img-bg, var(--wp--preset--color--tint, #f3f4f6));
}
/* Images fill the ratio box whatever their own shape (absolute: an
 * aspect-ratio box gives its children no definite height). Two classes beat
 * Woo's ".woocommerce img { height: auto }" on shop pages. */
.wpab-product-card .wpab-product-card__img {
	position: absolute;
	inset: 0;
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}
.wpab-product-grid--ratio-auto .wpab-product-card .wpab-product-card__img:not(.wpab-product-card__img--hover) {
	position: static;
	height: auto;
}
.wpab-product-card__img--hover {
	opacity: 0;
	transition: opacity 0.3s ease;
}
.wpab-product-card:hover .wpab-product-card__img--hover,
.wpab-product-card:focus-within .wpab-product-card__img--hover {
	opacity: 1;
}
.wpab-product-card__badge {
	position: absolute;
	top: 12px;
	left: 12px;
	z-index: 1;
	padding: 4px 10px;
	background: var(--wpab-pg-badge-bg, var(--wp--preset--color--accent, #2563eb));
	color: var(--wpab-pg-badge, var(--wp--preset--color--on-accent, #fff));
	font-size: 12px;
	font-weight: 600;
	line-height: 1.4;
}
.wpab-product-card__badge--stock {
	background: var(--wp--preset--color--ink, #111827);
	color: var(--wp--preset--color--surface, #fff);
}
.wpab-product-card__body {
	display: flex;
	flex: 1 1 auto;
	flex-direction: column;
	align-items: var(--wpab-pg-items, flex-start);
	gap: 6px;
	min-width: 0;
}
.wpab-product-card__body > .wpab-product-card__badge {
	position: static;
}
.wpab-product-card__title {
	margin: 0;
	color: var(--wpab-pg-title, inherit);
	font-size: var(--wpab-pg-title-size, 1rem);
	font-weight: 600;
	line-height: 1.35;
}
.wpab-product-card__title a {
	color: inherit;
	text-decoration: none;
}
.wpab-product-card__title a:hover,
.wpab-product-card__title a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}
.wpab-product-card__price {
	color: var(--wpab-pg-price, inherit);
	font-variant-numeric: tabular-nums;
}
.wpab-product-card__price del {
	margin-inline-end: 0.4em;
	opacity: 0.55;
}
.wpab-product-card__price ins {
	text-decoration: none;
}
.wpab-product-card__excerpt {
	margin: 0;
	color: var(--wp--preset--color--muted, inherit);
	font-size: 0.9375em;
}
.wpab-product-card__rating {
	display: inline-block;
	line-height: 1;
}
.wpab-product-card__stars {
	display: inline-block;
	background: linear-gradient(90deg, var(--wp--preset--color--accent, #f59e0b) var(--wpab-rating, 0%), var(--wp--preset--color--line, rgba(17, 24, 39, 0.18)) 0);
	-webkit-background-clip: text;
	background-clip: text;
	color: transparent;
	font-size: 14px;
	letter-spacing: 2px;
}
.wpab-product-card__stars::before {
	content: "★★★★★";
}
.wpab-product-card__swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
	margin: 4px 0 0;
	padding: 0;
	list-style: none;
}
.wpab-product-card__swatch {
	width: 14px;
	height: 14px;
	border: 1px solid var(--wp--preset--color--line, rgba(17, 24, 39, 0.12));
	border-radius: 50%;
	background: var(--wpab-swatch, var(--wp--preset--color--tint, #f3f4f6));
}
.wpab-product-card__cart {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	margin-top: 6px;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.2;
}
.wpab-product-card__cart--button {
	min-height: 40px;
	padding: 8px 16px;
	border: 0;
	background: var(--wpab-pg-btn-bg, var(--wp--preset--color--brand, #111827));
	color: var(--wpab-pg-btn, var(--wp--preset--color--surface, #fff));
	text-decoration: none;
	transition: opacity 0.2s ease;
}
.wpab-product-card__cart--button:hover,
.wpab-product-card__cart--button:focus-visible {
	opacity: 0.86;
}
.wpab-product-card__cart--link {
	color: inherit;
	text-decoration: underline;
	text-underline-offset: 3px;
}
.wpab-product-card__cart.loading {
	opacity: 0.6;
	pointer-events: none;
}
.wpab-product-card .added_to_cart {
	font-size: 0.875rem;
	color: inherit;
}

/* Rows (menus): name and price on one line, the rest under them. */
.wpab-product-grid--rows .wpab-product-card {
	flex-direction: row;
	align-items: flex-start;
	gap: 16px;
	padding: 16px 0;
	border-bottom: 1px solid var(--wpab-pg-divider, var(--wp--preset--color--line, rgba(17, 24, 39, 0.12)));
}
.wpab-product-grid--rows .wpab-product-card__media {
	flex: 0 0 88px;
	margin: 0;
}
.wpab-product-grid--rows .wpab-product-card__body {
	display: grid;
	flex: 1 1 auto;
	grid-template-columns: minmax(0, 1fr) auto;
	align-items: baseline;
	column-gap: 16px;
	row-gap: 6px;
}
.wpab-product-grid--rows .wpab-product-card__body > * {
	grid-column: 1 / -1;
	justify-self: start;
}
.wpab-product-grid--rows .wpab-product-card__title {
	grid-row: 1;
	grid-column: 1;
}
.wpab-product-grid--rows .wpab-product-card__price {
	grid-row: 1;
	grid-column: 2;
	justify-self: end;
	white-space: nowrap;
}

/* Filter bar: category chips + sort menu. */
.wpab-product-grid__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 16px;
	margin-bottom: 28px;
	padding-bottom: 22px;
	border-bottom: 1px solid var(--wpab-pg-divider, var(--wp--preset--color--line, rgba(17, 24, 39, 0.12)));
}
.wpab-product-grid__chips {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.wpab-product-grid__chip {
	display: inline-flex;
	align-items: center;
	min-height: 40px;
	padding: 0 16px;
	border: 1px solid var(--wp--preset--color--line, rgba(17, 24, 39, 0.12));
	color: inherit;
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: none;
}
/* Outranks the chip part styles (0,3,0), so hover and the current chip keep
 * their colours; the chipActive part (0,6,0) restyles the current chip. */
.wpab.wpab-product-grid .wpab-product-grid__chips > .wpab-product-grid__chip:hover,
.wpab.wpab-product-grid .wpab-product-grid__chips > .wpab-product-grid__chip.is-active {
	border-color: var(--wpab-pg-btn-bg, var(--wp--preset--color--brand, #111827));
	background: var(--wpab-pg-btn-bg, var(--wp--preset--color--brand, #111827));
	color: var(--wpab-pg-btn, var(--wp--preset--color--surface, #fff));
}
.wpab-product-grid__sort {
	margin: 0;
}
.wpab-product-grid__select {
	min-width: 200px;
	min-height: 40px;
	padding: 0 12px;
	border: 1px solid var(--wp--preset--color--line, rgba(17, 24, 39, 0.12));
	border-radius: 0;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 0.875rem;
}
@media (max-width: 767.98px) {
	.wpab-product-grid__sort,
	.wpab-product-grid__sort-label,
	.wpab-product-grid__select {
		display: block;
		width: 100%;
	}
}

/* Pagination (main product query). */
.wpab-product-grid__pagination {
	margin-top: 40px;
}
.wpab-product-grid__pagination ul {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 8px;
	margin: 0;
	padding: 0;
	list-style: none;
}
.wpab-product-grid__pagination .page-numbers {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--wp--preset--color--line, rgba(17, 24, 39, 0.12));
	color: inherit;
	text-decoration: none;
}
.wpab-product-grid__pagination .page-numbers.current {
	border-color: var(--wpab-pg-btn-bg, var(--wp--preset--color--brand, #111827));
	background: var(--wpab-pg-btn-bg, var(--wp--preset--color--brand, #111827));
	color: var(--wpab-pg-btn, var(--wp--preset--color--surface, #fff));
}
.wpab-product-grid__pagination .page-numbers.dots {
	border-color: transparent;
}

.wpab-product-grid__empty {
	margin: 0;
	color: var(--wp--preset--color--muted, inherit);
}

/* Card effects (P11): hover lift / shadow / image zoom set by the cardHover*
 * props (per-uid rules on the hovered or focused card); transitions only on
 * grids that use them. Reduced motion: shadows still change, nothing moves.
 * Card entrance runs on the shared effects engine (assets/css/effects.css). */
.wpab-product-grid.has-card-hover .wpab-product-card {
	transition: translate 0.25s ease, box-shadow 0.25s ease;
}
.wpab-product-grid.has-card-hover .wpab-product-card__img {
	transition: scale 0.35s ease, opacity 0.3s ease;
}
@media (prefers-reduced-motion: reduce) {
	.wpab-product-grid.has-card-hover .wpab-product-card,
	.wpab-product-grid.has-card-hover .wpab-product-card__img {
		transition: none;
	}
	.wpab-product-grid.has-card-hover .wpab-product-card:is(:hover, :focus-within),
	.wpab-product-grid.has-card-hover .wpab-product-card:is(:hover, :focus-within) .wpab-product-card__img {
		translate: none !important;
		scale: none !important;
	}
}

/* Card category line and horizontal cards (P12; only rendered with the
 * cardCategory / cardLayout props, styled further by the cardCategory* and
 * cardText* part props). Horizontal: image left at --wpab-pg-img-w, text
 * right from tablet width up; phones keep the stacked card. */
.wpab-product-card__category {
	margin: 0;
	color: var(--wp--preset--color--muted, inherit);
	font-size: 0.75rem;
	letter-spacing: 0.04em;
	line-height: 1.3;
	text-transform: uppercase;
}
.wpab-product-card__category a {
	color: inherit;
	text-decoration: none;
}
.wpab-product-card__category a:hover,
.wpab-product-card__category a:focus-visible {
	text-decoration: underline;
	text-underline-offset: 3px;
}
@media (min-width: 768px) {
	.wpab-product-grid--card-horizontal .wpab-product-card {
		flex-direction: row;
		align-items: center;
	}
	.wpab-product-grid--card-horizontal .wpab-product-card__media {
		flex: 0 0 var(--wpab-pg-img-w, 40%);
		margin-bottom: 0;
	}
	/* The text side fills the card height (its background too), text centred. */
	.wpab-product-grid--card-horizontal .wpab-product-card__body {
		align-self: stretch;
		justify-content: center;
		padding-inline-start: 16px;
	}
	.wpab-product-grid--card-horizontal .wpab-product-card > .wpab-quick-view-btn {
		right: calc(100% - var(--wpab-pg-img-w, 40%) + 10px);
	}
}
