/**
 * WCPT parametric-page runtime — CSS.
 *
 * Companion stylesheet for `wcpt-parametric-page-runtime.js`.
 * Extracted from the inline <style> block that
 * `product-info-extract/tools/wc-update-parametric-page-content.php`
 * used to bake into post_content. See the module PHP file header
 * for the full migration story (tacuna-site-tweaks#153).
 *
 * Selectors that previously hardcoded `#wcpt-51221` have been
 * generalized to `[data-wcpt-table-id].parametric-no-cat-selected`
 * etc., so the rules apply to any WCPT table the runtime activates
 * for. The `.parametric-no-cat-selected` class is toggled on the
 * wcpt root by the JS when the empty state is visible.
 */

/* ---- Tile source div ---------------------------------------------
 * Source div stays in page flow but hidden; JS clones its content
 * into the empty-state container on demand. Cloning (vs moving)
 * survives plugin AJAX re-renders that wipe and rebuild the
 * empty-state container after the visitor clears filters. */
#parametric-empty-tiles {
	display: none;
}

.wcpt-required-but-missing-nav-filter-message .parametric-tiles-clone {
	display: block;
}

/* Hide the plugin's built-in empty-state message divs ("Select a
 * category!") — the cloned tile div is the only thing the visitor
 * should see when no category is selected. */
.wcpt-required-but-missing-nav-filter-message > div:not(.parametric-tiles-clone) {
	display: none !important;
}

/* ---- No-category-selected sidebar collapse -----------------------
 *
 * When the runtime detects the empty state is showing (no cat
 * selected), it toggles .parametric-no-cat-selected on the wcpt
 * root. CSS uses that to collapse the sidebar down to just the
 * Category filter so visitors aren't presented with an empty
 * attribute-filter list. */

/* The `> .wcpt-item-row >` (with explicit child combinator on the
 * navigation root) anchors to the OUTER item-row only. There are
 * nested .wcpt-item-row elements deeper inside individual filter
 * headings (e.g. inside wcpt-dropdown-label > .wcpt-item-row); a
 * bare descendant selector would also match those and hide the
 * Category label. */
[data-wcpt-table-id].parametric-no-cat-selected .wcpt-navigation > .wcpt-item-row > *:not([data-wcpt-filter="category"]) {
	display: none !important;
}

/* Category filter occupies the full sidebar width when alone
 * (default is inline-block which collapses to fit heading content). */
[data-wcpt-table-id].parametric-no-cat-selected .wcpt-navigation > .wcpt-item-row > [data-wcpt-filter="category"] {
	display: block !important;
	width: 100%;
}

/* Restore chevron icon + suppress the perpetual-spinner default
 * styling so the Category accordion looks like an accordion (not a
 * loader). */
[data-wcpt-table-id].parametric-no-cat-selected [data-wcpt-filter="category"] .wcpt-icon-chevron-down {
	display: inline-block !important;
}

[data-wcpt-table-id].parametric-no-cat-selected [data-wcpt-filter="category"] .wcpt--dynamic-filters--loading-filter__loading-icon {
	display: none !important;
}

/* ---- Empty-state appearance --------------------------------------
 * Remove the plugin's built-in light-grey wash + 10px vertical
 * margin from the empty-state container; strip default
 * padding/margin on the injected tile div; hide the table's header
 * bar ("25 per page", view options) in empty state since it has no
 * meaning without data and creates a vertical gap that pushes the
 * tile grid below the sidebar top. */

[data-wcpt-table-id].parametric-no-cat-selected .wcpt-required-but-missing-nav-filter-message {
	background: transparent !important;
	margin: 0 !important;
	padding: 0 !important;
}

[data-wcpt-table-id].parametric-no-cat-selected #parametric-empty-tiles {
	padding: 0 !important;
	margin: 0 !important;
}

[data-wcpt-table-id].parametric-no-cat-selected .wcpt-header {
	display: none !important;
}
