/**
 * Styles for woo-sil7en/product-grid.
 *
 * Two modes:
 *  - Default: even CSS-grid of product cards (column count from --pg-columns).
 *  - Bento (.is-bento): editorial mosaic on a 12-col base — a full-width
 *    horizontal FEATURED hero card, two wide SECONDARY cards, then a 4-up row
 *    of NORMAL cover-forward cards. Airy gaps, staggered scroll-reveal.
 *
 * Responsive via container queries (the grid is the query container). Motion is
 * compositor-only and gated by prefers-reduced-motion.
 *
 * @package woo-sil7en-blocks-commerce
 * @since   0.1.0
 */

.woo-sil7en-product-grid {
	container-type: inline-size;
}

.woo-sil7en-product-grid__heading {
	font-family: var(--wp--preset--font-family--display, "Lora", Georgia, serif);
	font-size: var(--wp--preset--font-size--lg, 1.5rem);
	font-weight: 500;
	letter-spacing: 0;
	line-height: 1.2;
	margin: 0 0 var(--wp--custom--grid--gap, 1.5rem);
	color: var(--wp--preset--color--contrast, #1a1714);
}

.woo-sil7en-product-grid__list {
	list-style: none;
	margin: 0;
	padding: 0;
	display: grid;
	grid-template-columns: repeat(var(--pg-columns, 4), minmax(0, 1fr));
	gap: var(--wp--custom--grid--gap, 1.5rem);
}

@container (max-width: 900px) {
	.woo-sil7en-product-grid__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
}

@container (max-width: 540px) {
	.woo-sil7en-product-grid__list {
		grid-template-columns: 1fr;
	}
}

.woo-sil7en-product-grid__item {
	min-width: 0;
}

/* ============================================================
   BENTO MODE
   ============================================================ */

/* Specificity note: keep this at the same (0,2,0) as the @container overrides
   below so the responsive rules win by source order — using the longer
   `.woo-sil7en-product-grid.is-bento` prefix (0,3,0) would beat the queries and
   leave the grid stuck at 10 columns on mobile. */
.is-bento .woo-sil7en-product-grid__list {
	grid-template-columns: repeat(10, minmax(0, 1fr));
	grid-auto-flow: row dense;
	gap: var(--wp--custom--grid--gap, 2rem);
	align-items: stretch;
}

/* Normal cards: 5 per row (span 2 of 10). display:flex so the card fills the
   stretched cell → equal heights → price + CTA align across the row. */
.is-bento .woo-sil7en-product-grid__item {
	display: flex;
	grid-column: span 2;
}

/* Featured: a large bento tile (6 of 10 cols) sitting in the mosaic with two
   normal cards beside it — integrated, not a full-width banner. A surface
   panel, accent "Destacado" eyebrow and the one strong CTA make it stand out. */
.is-bento .woo-sil7en-product-grid__item.is-featured {
	grid-column: span 4;
	grid-row: span 2;
}

.is-bento .is-featured .woo-sil7en-product-card {
	flex-direction: column;
	gap: var(--wp--preset--spacing--xs, 0.75rem);
	height: 100%;
	padding: clamp(1rem, 0.7rem + 1vw, 1.5rem);
	background: var(--wp--preset--color--surface, #f6f5f3);
	border: 1px solid var(--wp--preset--color--border, #e6e3de);
	border-radius: var(--wp--custom--radius--xxl, 0.375rem);
}

/* Big cover, capped to ~2 normal rows so the tile aligns with the cards beside. */
.is-bento .is-featured .woo-sil7en-product-card__media {
	width: 100%;
	aspect-ratio: 3 / 4;
	margin-block-end: 0.25rem;
}

/* "Destacado" eyebrow opens the copy column. */
.is-bento .is-featured .woo-sil7en-product-card__body::before {
	content: "Destacado";
	font-family: var(--wp--preset--font-family--sans, sans-serif);
	font-size: var(--wp--preset--font-size--xs, 0.75rem);
	font-weight: 600;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary, #531099);
	margin-block-end: 0.15rem;
}

/* The one strong CTA on the page lives on the featured tile. */
.is-bento .is-featured .woo-sil7en-product-card__atc {
	margin-block-start: auto;
	padding: 0.6rem 1.3rem;
	font-size: var(--wp--preset--font-size--sm, 0.9375rem);
	color: var(--wp--preset--color--primary-ink, #fff);
	background: var(--wp--preset--color--primary, #531099);
	border-color: var(--wp--preset--color--primary, #531099);
}

.is-bento .is-featured .woo-sil7en-product-card__atc:hover,
.is-bento .is-featured .woo-sil7en-product-card__atc:focus-visible {
	color: var(--wp--preset--color--primary-ink, #fff);
	background: var(--wp--preset--color--primary-hover, #3f0b78);
	border-color: var(--wp--preset--color--primary-hover, #3f0b78);
}

.is-bento .is-featured .woo-sil7en-product-card__name {
	font-size: var(--wp--preset--font-size--lg, 1.5rem);
	line-height: 1.15;
	-webkit-line-clamp: 3;
	min-height: 0;
}

/* Featured card has room: let the author breathe (wrap, base size). */
.is-bento .is-featured .woo-sil7en-product-card__author {
	font-size: var(--wp--preset--font-size--base, 1rem);
	white-space: normal;
}

.is-bento .is-featured .woo-sil7en-product-card__price {
	font-size: var(--wp--preset--font-size--lg, 1.25rem);
}

.is-bento .is-featured .woo-sil7en-product-card__excerpt {
	-webkit-line-clamp: 4;
	max-width: 48ch;
}

/* Bibliographic meta line (editorial · año · págs) — featured only. */
.woo-sil7en-product-card__meta {
	margin: 0;
	font-size: var(--wp--preset--font-size--xs, 0.8125rem);
	color: var(--wp--preset--color--muted, #6f6b64);
	font-variant-numeric: tabular-nums;
}

/* Bento responsive collapse (container = the grid, ~936px on desktop). */
@container (max-width: 820px) {
	.is-bento .woo-sil7en-product-grid__list {
		grid-template-columns: repeat(6, minmax(0, 1fr));
	}
	.is-bento .woo-sil7en-product-grid__item {
		grid-column: span 2; /* 3 per row */
	}
}

@container (max-width: 520px) {
	.is-bento .woo-sil7en-product-grid__list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}
	.is-bento .woo-sil7en-product-grid__item {
		grid-column: span 1; /* 2 per row */
	}
	.is-bento .woo-sil7en-product-grid__item.is-featured {
		grid-column: span 2;
	}
	.is-bento .is-featured .woo-sil7en-product-card {
		flex-direction: column;
		align-items: stretch;
	}
	.is-bento .is-featured .woo-sil7en-product-card__media {
		width: 100%;
	}
}

/* ============================================================
   STAGGERED SCROLL-REVEAL (progressive enhancement)
   ============================================================ */

@media (prefers-reduced-motion: no-preference) {
	@supports (animation-timeline: view()) {
		.woo-sil7en-product-grid__item {
			animation: woo-sil7en-tile-in linear both;
			animation-timeline: view();
			animation-range: entry 0% cover 22%;
		}

		@keyframes woo-sil7en-tile-in {
			from {
				opacity: 0;
				transform: translateY(2.5rem) scale(0.98);
			}
			to {
				opacity: 1;
				transform: none;
			}
		}
	}
}

/* ============================================================
   Pagination
   ============================================================ */

.woo-sil7en-product-grid__pagination {
	margin-block-start: var(--wp--custom--spacing--l, 2rem);
	display: flex;
	justify-content: center;
}

.woo-sil7en-product-grid__pagination .page-numbers {
	list-style: none;
	padding: 0;
	margin: 0;
	display: flex;
	gap: 0.35rem;
	flex-wrap: wrap;
}

.woo-sil7en-product-grid__pagination .page-numbers li a,
.woo-sil7en-product-grid__pagination .page-numbers li span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 2.5rem;
	height: 2.5rem;
	padding-inline: 0.6rem;
	border: 1px solid var(--wp--preset--color--border, #e8dfd1);
	border-radius: var(--wp--custom--radius--pill, 999px);
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	text-decoration: none;
	color: inherit;
	transition: background-color 150ms ease, color 150ms ease;
}

.woo-sil7en-product-grid__pagination .page-numbers li a:hover {
	background: var(--wp--preset--color--surface, #f4ede3);
}

.woo-sil7en-product-grid__pagination .page-numbers li span.current {
	background-color: var(--wp--preset--color--primary, #531099);
	color: var(--wp--preset--color--primary-ink, #fff);
	border-color: transparent;
}

/* ============================================================
   Sort toolbar (showSort) — native <select> in a GET form
   ============================================================ */

.woo-sil7en-product-grid__toolbar {
	display: flex;
	justify-content: flex-end;
	margin-block-end: clamp(1.25rem, 0.9rem + 1.2vw, 2rem);
}

.woo-sil7en-product-grid__sort {
	display: flex;
	align-items: center;
	gap: var(--wp--preset--spacing--xs, 0.75rem);
	flex-wrap: wrap;
}

.woo-sil7en-product-grid__sort-label {
	font-family: var(--wp--preset--font-family--sans, sans-serif);
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	font-weight: 500;
	color: var(--wp--preset--color--muted, #6f6b64);
	white-space: nowrap;
}

/* The field wraps the native select so the chevron can overlay it. */
.woo-sil7en-product-grid__sort-field {
	position: relative;
	display: inline-flex;
	align-items: center;
}

/* A soft pill "chip" select — modern, not a hard square box. Submits on change
   (view.js), so there is no separate Ordenar button when JS runs. */
.woo-sil7en-product-grid__sort-select {
	appearance: none;
	-webkit-appearance: none;
	min-block-size: 2.75rem; /* >=44px tap target. */
	padding-block: 0.55rem;
	padding-inline: 1.15rem 2.7rem; /* room for the chevron. */
	font-family: var(--wp--preset--font-family--sans, sans-serif);
	font-size: var(--wp--preset--font-size--sm, 0.9375rem);
	font-weight: 500;
	line-height: 1.3;
	color: var(--wp--preset--color--contrast, #1a1714);
	background: var(--wp--preset--color--surface, #f5f3f9);
	border: 1px solid transparent;
	border-radius: var(--wp--custom--radius--pill, 999px);
	cursor: pointer;
	transition:
		border-color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease),
		background-color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease),
		box-shadow var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

.woo-sil7en-product-grid__sort-select:hover {
	background: color-mix(in srgb, var(--wp--preset--color--primary, #531099) 8%, var(--wp--preset--color--surface, #f5f3f9));
	border-color: color-mix(in srgb, var(--wp--preset--color--primary, #531099) 28%, transparent);
}

.woo-sil7en-product-grid__sort-select:focus {
	background: var(--wp--preset--color--base, #fff);
	border-color: var(--wp--preset--color--primary, #531099);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--primary, #531099) 18%, transparent);
	outline: none;
}

.woo-sil7en-product-grid__sort-select:focus-visible {
	outline: 2px solid transparent;
	outline-offset: 2px;
}

/* Decorative chevron; the native select handles the open affordance + keyboard. */
.woo-sil7en-product-grid__sort-chevron {
	position: absolute;
	inset-inline-end: 0.95rem;
	inset-block-start: 50%;
	transform: translateY(-50%);
	inline-size: 1.05em;
	block-size: 1.05em;
	color: var(--wp--preset--color--muted, #6f6b64);
	pointer-events: none;
	transition:
		color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease),
		rotate var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

.woo-sil7en-product-grid__sort-field:hover .woo-sil7en-product-grid__sort-chevron,
.woo-sil7en-product-grid__sort-select:focus + .woo-sil7en-product-grid__sort-chevron {
	color: var(--wp--preset--color--primary, #531099);
}

/* Lift the chevron toward "open" while the select is focused. */
.woo-sil7en-product-grid__sort-select:focus + .woo-sil7en-product-grid__sort-chevron {
	rotate: 180deg;
}

/* JS auto-submits on change, so the explicit Ordenar button is redundant. */
.woo-sil7en-product-grid__sort.is-js .woo-sil7en-product-grid__sort-submit {
	display: none;
}

.woo-sil7en-product-grid__sort-submit {
	min-block-size: 2.75rem;
	padding-block: 0.5rem;
	padding-inline: 1.1rem;
	font-family: var(--wp--preset--font-family--sans, sans-serif);
	font-size: var(--wp--preset--font-size--sm, 0.875rem);
	font-weight: 500;
	color: var(--wp--preset--color--primary-ink, #fff);
	background: var(--wp--preset--color--primary, #531099);
	border: 1px solid var(--wp--preset--color--primary, #531099);
	border-radius: var(--wp--custom--radius--pill, 999px);
	cursor: pointer;
	transition: background-color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

.woo-sil7en-product-grid__sort-submit:hover,
.woo-sil7en-product-grid__sort-submit:focus-visible {
	background: var(--wp--preset--color--primary-hover, #3f0b78);
	border-color: var(--wp--preset--color--primary-hover, #3f0b78);
}

/* Mobile: the toolbar stacks full-width above the grid. */
@media (max-width: 600px) {
	.woo-sil7en-product-grid__toolbar {
		justify-content: stretch;
	}
	.woo-sil7en-product-grid__sort {
		inline-size: 100%;
	}
	.woo-sil7en-product-grid__sort-field {
		flex: 1 1 auto;
	}
	.woo-sil7en-product-grid__sort-select {
		inline-size: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.woo-sil7en-product-grid__sort-select,
	.woo-sil7en-product-grid__sort-chevron,
	.woo-sil7en-product-grid__sort-submit {
		transition: none;
	}
}

/* ============================================================
   Live search (data-search + view.js)
   ============================================================ */

.woo-sil7en-product-grid__search {
	position: relative;
	display: flex;
	align-items: center;
	inline-size: 100%;
	max-inline-size: 30rem;
	margin-block-end: clamp(1.25rem, 0.9rem + 1.2vw, 2rem);
	margin-inline: auto;
}

.woo-sil7en-product-grid__search-icon {
	position: absolute;
	inset-block-start: 50%;
	inset-inline-start: 1.1rem;
	transform: translateY(-50%);
	inline-size: 1.15em;
	block-size: 1.15em;
	color: var(--wp--preset--color--muted, #6f6b64);
	pointer-events: none;
	transition: color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

/* Lupa brightens to primary when the field is engaged. */
.woo-sil7en-product-grid__search:focus-within .woo-sil7en-product-grid__search-icon {
	color: var(--wp--preset--color--primary, #531099);
}

.woo-sil7en-product-grid__search-input {
	inline-size: 100%;
	padding: 0.85rem 1.15rem 0.85rem 3rem;
	font-family: var(--wp--preset--font-family--sans, sans-serif);
	font-size: var(--wp--preset--font-size--base, 1rem);
	line-height: 1.4;
	color: var(--wp--preset--color--contrast, #1a1714);
	background: var(--wp--preset--color--base, #fff);
	border: 1px solid var(--wp--preset--color--border, #e6e3de);
	border-radius: var(--wp--custom--radius--lg, 0.1875rem);
	box-shadow: none;
	appearance: none;
	transition:
		border-color var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease),
		box-shadow var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

.woo-sil7en-product-grid__search-input::placeholder {
	color: var(--wp--preset--color--muted, #9a958c);
	opacity: 1;
}

/* Use :focus (not :focus-visible) so the soft ring shows on click + keyboard;
   border brightens to primary, paired with a token-based focus shadow. */
.woo-sil7en-product-grid__search-input:focus {
	border-color: var(--wp--preset--color--primary, #531099);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wp--preset--color--primary, #531099) 18%, transparent);
}

.woo-sil7en-product-grid__search-input:focus-visible {
	outline: 2px solid transparent;
	outline-offset: 2px;
}

.woo-sil7en-product-grid.is-loading .woo-sil7en-product-grid__list {
	opacity: 0.45;
	transition: opacity var(--wp--custom--motion--duration--base, 220ms) var(--wp--custom--motion--ease--soft, ease);
}

/* Soft pulse on the search field while a query is in flight. */
.woo-sil7en-product-grid.is-loading .woo-sil7en-product-grid__search-input {
	border-color: var(--wp--preset--color--primary, #531099);
}

.woo-sil7en-product-grid.is-loading .woo-sil7en-product-grid__search-icon {
	color: var(--wp--preset--color--primary, #531099);
	animation: woo-sil7en-search-pulse 1s ease-in-out infinite;
}

@keyframes woo-sil7en-search-pulse {
	0%, 100% { opacity: 1; }
	50% { opacity: 0.4; }
}

.woo-sil7en-product-grid__empty {
	grid-column: 1 / -1;
	padding-block: clamp(1.5rem, 1rem + 2vw, 3rem);
	color: var(--wp--preset--color--muted, #6f6b64);
	font-size: var(--wp--preset--font-size--md, 1.0625rem);
}

/* Hide pagination while live-searching (overrides the flex display). */
.woo-sil7en-product-grid.is-searching .woo-sil7en-product-grid__pagination {
	display: none;
}

/* Reduced-motion: no transitions or pulse on the live-search UI. */
@media (prefers-reduced-motion: reduce) {
	.woo-sil7en-product-grid__search-icon,
	.woo-sil7en-product-grid__search-input,
	.woo-sil7en-product-grid.is-loading .woo-sil7en-product-grid__list {
		transition: none;
	}
	.woo-sil7en-product-grid.is-loading .woo-sil7en-product-grid__search-icon {
		animation: none;
	}
}

/* ---- Empty / no-results state (zero-result search or over-filtered) ---- */
.woo-sil7en-product-grid.is-empty {
	display: grid;
	gap: var(--wp--preset--spacing--sm, 1rem);
	justify-items: start;
	max-inline-size: 40rem;
	padding-block: var(--wp--preset--spacing--xl, 3rem);
}

.woo-sil7en-product-grid__empty {
	margin: 0;
	font-size: var(--wp--preset--font-size--md, 1.2rem);
	line-height: 1.4;
	color: var(--wp--preset--color--contrast);
	text-wrap: balance;
}

.woo-sil7en-product-grid__suggest-eyebrow {
	margin: var(--wp--preset--spacing--xs, 0.75rem) 0 0;
	font-family: var(--wp--preset--font-family--display);
	font-size: var(--wp--preset--font-size--xs, 0.8rem);
	font-weight: 500;
	letter-spacing: 0.14em;
	text-transform: uppercase;
	color: var(--wp--preset--color--primary);
}

.woo-sil7en-product-grid__suggestions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}

.woo-sil7en-product-grid__suggestion {
	display: inline-block;
	padding: 0.4rem 0.85rem;
	border: 1px solid var(--wp--preset--color--border);
	border-radius: var(--wp--custom--radius--pill, 999px);
	color: var(--wp--preset--color--contrast);
	font-size: var(--wp--preset--font-size--sm, 0.9rem);
	text-decoration: none;
	transition:
		border-color 150ms ease,
		color 150ms ease,
		background-color 150ms ease;
}

.woo-sil7en-product-grid__suggestion:hover,
.woo-sil7en-product-grid__suggestion:focus-visible {
	border-color: var(--wp--preset--color--primary);
	background: var(--wp--preset--color--primary);
	color: var(--wp--preset--color--base);
}

.woo-sil7en-product-grid__empty-link {
	display: inline-flex;
	align-items: center;
	gap: 0.4rem;
	margin-block-start: var(--wp--preset--spacing--xs, 0.75rem);
	color: var(--wp--preset--color--primary);
	font-weight: 600;
	text-decoration: none;
}

.woo-sil7en-product-grid__empty-link:hover {
	text-decoration: underline;
	text-underline-offset: 0.18em;
}

@media (prefers-reduced-motion: reduce) {
	.woo-sil7en-product-grid__suggestion {
		transition: none;
	}
}
