/*
 * Points wicket-bootstrap5's own custom properties at Tabler's, so none of them stays light-mode.
 *
 * wicket-bootstrap5's responsive-table.css draws the card border, surface and label color from
 * --bs-border-color, --bs-body-bg, --bs-border-radius and --bs-secondary-color. Tabler renames the
 * prefix wholesale: each of those four is declared zero times in tabler.css against 1053 --tblr-*
 * names. The base sheet therefore falls through to its literals, which are light-mode values, so a
 * card in Tabler's dark theme would draw a pale border and a white surface over a dark page.
 *
 * TablerVariableCoverageTest fails when a --bs5-* theme value is declared over there and not
 * remapped here, which is the one failure a green suite would otherwise hide until somebody looked
 * at the dark theme by hand.
 *
 * Scoped through :root purely for specificity, (0,2,0) against the base sheet's (0,1,0). The base
 * arrives lazily, contributed by the first table that opts in, while this is contributed with the
 * theme; either can land first, and the winner must not depend on which did.
 */

:root .table-responsive-cards {
	--bs5-table-card-border: var(--tblr-border-color);
	--bs5-table-card-bg: var(--tblr-bg-surface, var(--tblr-body-bg));
	--bs5-table-card-radius: var(--tblr-border-radius);
	--bs5-table-card-label: var(--tblr-secondary-color, var(--tblr-secondary));
}

/*
 * And the same again for the inbox list in list-rows.css, which reads five: --bs-border-color,
 * --bs-tertiary-bg, --bs-primary, --bs-secondary-color and --bs-border-radius. Same problem, same
 * :root for the same specificity reason.
 *
 * The one that matters most in dark mode is the hover fill. Its literal is #f8f9fa, so without this
 * a hovered row in Tabler's dark theme flashes near-white and takes the text with it.
 */
:root .table-list-rows {
	--bs5-list-row-border: var(--tblr-border-color);
	--bs5-list-row-hover: var(--tblr-bg-surface-tertiary, var(--tblr-bg-surface-secondary));
	--bs5-list-row-accent: var(--tblr-primary);
	--bs5-list-row-muted: var(--tblr-secondary-color, var(--tblr-secondary));
	--bs5-list-row-radius: var(--tblr-border-radius);
}

/*
 * And detail-list.css, which reads one: --bs-secondary-color, for the caption above each value in
 * its vertical layout. Same problem, same :root for the same specificity reason.
 *
 * Only one, because the horizontal layout deliberately styles nothing of its own - it is Bootstrap's
 * <dl class="row"> unchanged, and Tabler restyles that itself.
 */
:root .bs5-detail-list,
:root .bs5-detail-list-horizontal {
	--bs5-detail-label-color: var(--tblr-secondary-color, var(--tblr-secondary));
}

/*
 * The same again for the selected-row highlight in selection-column.css, which sets the state pair
 * .table-active uses. Tabler renames those wholesale too: --bs-table-bg-state and its three
 * neighbors are declared zero times in tabler.css.
 *
 * No :root here, unlike above. The base rule sets --bs-* names and this one sets --tblr-*, so the
 * two never compete and whichever sheet lands first is immaterial.
 */
.table-select-rows > tbody > tr:has(> .cell-select input:checked) {
	--tblr-table-color-state: var(--tblr-table-active-color);
	--tblr-table-bg-state: var(--tblr-table-active-bg);
}

/*
 * Gives Tabler back its own sort indicator, which wicket-bootstrap5's table-sort.css was dimming.
 *
 * Both sheets draw the indicator, and the assumption that Tabler's simply wins is wrong: measured on
 * the samples table page, tabler.css loads at index 1 and table-sort.css at 3, because a theme is a
 * page-level contribution while that sheet arrives with the first sortable table. See issue #42.
 *
 * Almost all of it is invisible, because the two agree exactly - both set background: currentColor,
 * margin-left: 0.25rem and a 1rem square - and the glyph itself is Tabler's, since its
 * .table-sort.asc::after at (0,2,0) outranks the base .table-sort::after at (0,1,0) where the mask
 * lives.
 *
 * One declaration does not agree. Tabler separates unsorted from sorted by color alone, and never
 * sets opacity; the base sheet dims the unsorted arrow to 0.4 because under plain Bootstrap it has
 * no color treatment to distinguish them with. Under Tabler the two compound, so the unsorted arrow
 * rendered at 40% of an already muted color - measured rgb(156, 163, 175) at 0.4, against Tabler's
 * intended rgb(156, 163, 175) at 1.
 *
 * :root for specificity rather than order, for the reason the rules above give: (0,2,0) against the
 * base sheet's (0,1,0), so this does not depend on which of the two lands first.
 */

:root .table-sort::after {
	opacity: 1;
}
