/*
 * Hubka Theme
 *
 * Phase: 12D — Shop by Genre Rebuild
 * Purpose: "Shop by Genre" now renders WooCommerce's native
 * woocommerce/product-categories block (real thumbnails, live counts,
 * working links, empty categories hidden via its own hasEmpty:false)
 * instead of 4 static hardcoded text columns. This file transforms its
 * native <ul>/<li> list markup into the card-tile grid.
 *
 * Selectors below target WooCommerce's own stable classes
 * (wc-block-product-categories*), scoped under the Hubka-owned
 * `.hubka-genre-grid__list` className — the Component Class Rule
 * approach (WC-owned dynamic internals get stable WC classes scoped
 * under the Hubka parent, not redundant Hubka classes on WC markup),
 * confirmed against WooCommerce's actual render source
 * (ProductCategories.php) rather than assumed.
 *
 * Revision note (real thumbnails now uploaded, images rendering at
 * ~48px instead of filling the grid tile): root-caused with live
 * browser access, not guessed. WooCommerce's own default stylesheet
 * assumes each category renders as a small *floated* thumbnail beside
 * inline text — `.wc-block-product-categories-list-item` carries
 * `margin: 4px 0 4px 60px` (indent reserved for the float) and
 * `.wc-block-product-categories-list-item__image` carries
 * `max-width: 50px` plus a matching `-60px` negative margin and a 1px
 * border (the classic hanging-indent-plus-float pattern). None of that
 * applies to this card-grid layout, so all three are explicitly
 * neutralized below. Same investigation also found WooCommerce's count
 * markup has its own `::before { content: " (" }` (designed to read
 * "Category (5)" inline) — harmless with the old textual placeholder,
 * but rendered as a stray "(" once real content made the count visible
 * on its own line; neutralized alongside the sizing fix.
 *
 * Rules:
 * - Reuse theme.json tokens.
 * - Use logical properties.
 * - Keep selectors shallow.
 * - Do not duplicate component styling.
 */

.hubka-genre-grid {
	padding-block: var(--wp--preset--spacing--50);
}

.hubka-genre-grid__heading {
	align-items: baseline;
	margin-block-end: var(--wp--preset--spacing--40);
}

.hubka-genre-grid__title {
	margin-block-end: 0;
}

.hubka-genre-grid__view-all a {
	color: var(--wp--preset--color--text);
	text-decoration: none;
}

.hubka-genre-grid__view-all a:hover {
	text-decoration: underline;
}

/* The list itself: WooCommerce renders a plain <ul>; this is what
 * actually becomes the tile grid. Tighter, faster-scanning gap than
 * Featured Collection's spacing--50, per spec. */
.hubka-genre-grid__list .wc-block-product-categories-list {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(9rem, 1fr));
	gap: var(--wp--preset--spacing--40);
	list-style: none;
	padding-inline-start: 0;
	margin-block: 0;
}

.hubka-genre-grid__list .wc-block-product-categories-list-item {
	list-style: none;
	/* Overrides WooCommerce's default float-thumbnail hanging indent
	 * (margin: 4px 0 4px 60px) — see revision note above. */
	margin: 0;
	clear: none;
}

.hubka-genre-grid__list .wc-block-product-categories-list-item > a {
	display: block;
	text-decoration: none;
	border-radius: var(--wp--custom--book-cover--radius);
	overflow: hidden;
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.hubka-genre-grid__list .wc-block-product-categories-list-item:hover > a {
	transform: translateY(-2px);
	box-shadow: var(--wp--custom--book-cover--shadow-hover);
}

.hubka-genre-grid__list .wc-block-product-categories-list-item__image {
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	/* Overrides WooCommerce's default 50px floated-thumbnail cap
	 * (max-width: 50px), its matching -60px negative margin, and its
	 * 1px default border — see revision note above. */
	max-width: none;
	margin: 0;
	border: none;
	inline-size: 100%;
}

.hubka-genre-grid__list .wc-block-product-categories-list-item__image img {
	inline-size: 100%;
	block-size: 100%;
	object-fit: cover;
	/* Desaturated so genre tiles don't compete with Featured Collection's
	 * full-color covers above; hover restores full color. */
	filter: saturate(0.55);
	transition: filter 0.2s ease;
}

.hubka-genre-grid__list .wc-block-product-categories-list-item:hover .wc-block-product-categories-list-item__image img {
	filter: saturate(1);
}

.hubka-genre-grid__list .wc-block-product-categories-list-item__name {
	display: block;
	margin-block-start: var(--wp--preset--spacing--20);
	font-size: var(--wp--preset--font-size--medium);
	font-weight: 600;
	letter-spacing: 0.01em;
	color: var(--wp--preset--color--text);
}

.hubka-genre-grid__list .wc-block-product-categories-list-item-count {
	display: block;
	font-size: var(--wp--preset--font-size--small);
	color: var(--wp--preset--color--muted);
}

.hubka-genre-grid__list .wc-block-product-categories-list-item-count::after {
	content: " books";
}

/* WooCommerce's default count markup opens with `::before { content: " (" }`,
 * designed for an inline "Category (5)" reading — see revision note above. */
.hubka-genre-grid__list .wc-block-product-categories-list-item-count::before {
	content: none;
}

@media (max-width: 782px) {
	.hubka-genre-grid__list .wc-block-product-categories-list {
		grid-template-columns: repeat(2, 1fr);
	}
}
