/* ── The wide table (0.61.0, UI-Final-Review FR17, CONTRACT §8.5): the actions column, the sticky first column, the
   Columns chooser, the scroll cue and the focusable scroll region, the totals row, the export pair. ── */

/* The actions column: one group of small outline buttons that never wraps, at the row's end (P11); a destructive one
   in the destructive ink, last (Guidance::row_buttons()). */
.rooster-admin-table__td.is-actions,
.rooster-admin-table__th.is-actions {
	@apply text-end;
}

.rooster-admin-table__buttons {
	@apply inline-flex items-center gap-1.5 whitespace-nowrap;
}

.rooster-admin-table__buttons > .rooster-admin-button.is-destructive {
	@apply text-destructive-foreground hover:border-destructive;
}

/* The scroll region: focusable (a wide table's, or any that overflows: table.js), its ring inside its edge; the scroll
   cue: the columns fade out at its end while more sit beyond it (is-more, table.js), gone at the end; since 0.70.0 at
   its start too, while columns sit behind it (is-before; never over a first column that stays: its hairline says it).
   The two-edged mask is symmetric, so it needs no rtl twin; it comes after the rtl ones to win at equal weight. */
.rooster-admin-table__scroll:focus-visible {
	@apply outline-2 -outline-offset-2 outline-link;
}

.rooster-admin-table__scroll.is-more {
	mask-image: linear-gradient(to left, transparent, black 2.5rem);
}

.rooster-admin-table__scroll.is-before {
	mask-image: linear-gradient(to right, transparent, black 2.5rem);
}

.rooster-admin-table__scroll.is-more:dir(rtl) {
	mask-image: linear-gradient(to right, transparent, black 2.5rem);
}

.rooster-admin-table__scroll.is-before:dir(rtl) {
	mask-image: linear-gradient(to left, transparent, black 2.5rem);
}

.rooster-admin-table__scroll.is-before.is-more {
	mask-image: linear-gradient(to right, transparent, black 2.5rem, black calc(100% - 2.5rem), transparent);
}

/* The sticky first column (sticky_first): the row's name (and the selection before it) stays while the rest
   scrolls, on the card's surface (a row's hover and selection still tint it: the surface is at zero specificity), a
   hairline at its end. */
:where(.rooster-admin-table.is-sticky-first)
	:is(.rooster-admin-table__th, .rooster-admin-table__td):is(.is-first, .is-check) {
	@apply sticky start-0 z-2;
}

:where(.rooster-admin-table.is-sticky-first) .rooster-admin-table__td:is(.is-first, .is-check) {
	background: var(--ra-card);
}

:where(.rooster-admin-table.is-sticky-first) :is(.rooster-admin-table__th, .rooster-admin-table__td).is-first {
	@apply border-e border-e-border;
}

:where(.rooster-admin-table.is-sticky-first) :is(.rooster-admin-table__th, .rooster-admin-table__td).is-check {
	@apply box-border w-10 min-w-10;
}

:where(.rooster-admin-table.is-sticky-first:has(.rooster-admin-table__th.is-check))
	:is(.rooster-admin-table__th, .rooster-admin-table__td).is-first {
	@apply start-10;
}

/* A group heading over several columns (0.72.0, TABLES-PLAN 1c: a grid's "Difficulty" over 1 to 5): the row over the
   heads; its heading centred over its run, the line under it showing the span; its blanks (a td over every other
   column) without a line, so the heads' own line is the first seen there. With a sticky head the heads row sits under
   the group row (table.js measures it: --ra-groups-h). A hidden column never counts in that row: the server and
   table.js keep the spans right (data-ra-places), and the hiding rules leave the row alone. */
.rooster-admin-table__groups > .rooster-admin-table__th.is-grouphead {
	@apply pb-1 text-center;
}

.rooster-admin-table__groups > .rooster-admin-table__th.is-groupgap {
	@apply border-b-0;
}

:where(.rooster-admin-table.is-sticky) .rooster-admin-table__groups + tr > .rooster-admin-table__th {
	top: var(--ra-groups-h, 2.25rem);
}

/* stylelint-disable-next-line selector-max-specificity -- as the stripe it replaces: over the cell recipe, under a row's tone */
.rooster-admin-table.is-striped.is-sticky-first
	.rooster-admin-table__row:nth-child(even)
	.rooster-admin-table__td:is(.is-first, .is-check) {
	background: color-mix(in srgb, var(--ra-muted) 40%, var(--ra-card));
}

/* The totals row (	otals): under the rows, on a light wash, in the text's weight. */
.rooster-admin-table__row.is-total > .rooster-admin-table__td {
	@apply border-t border-b-0 border-border text-start font-semibold text-foreground;
	background: color-mix(in srgb, var(--ra-muted) 50%, var(--ra-card));
}

.rooster-admin-table__row.is-total > .rooster-admin-table__td.is-num {
	@apply text-end;
}

/* A total's band (0.65.7, a column's `bands`): its tone's ink over the totals row's own. */
.rooster-admin-table__row.is-total
	> .rooster-admin-table__td:is(
		.is-tone-success,
		.is-tone-destructive,
		.is-tone-warning,
		.is-tone-info,
		.is-tone-primary
	) {
	color: var(--ra-tone-fg);
}

/* The export pair (Guidance::export()): side by side; the reason it is disabled as visible text after it (FR7). */
.rooster-admin-export {
	@apply inline-flex flex-wrap items-center gap-2;
}

.rooster-admin-export__why {
	@apply text-xs text-secondary-foreground;
}

/* The Columns chooser (Guidance::columns()): its button, and its panel, a popover in the top layer placed by table.js
   under the button. */
.rooster-admin-columns__panel {
	@apply fixed m-0 w-[min(34rem,calc(100vw-16px))] max-h-[min(28rem,calc(100vh-6rem))] overflow-y-auto rounded-md border border-border bg-card p-3 text-sm text-card-foreground shadow-pop;
	inset: auto;
}

.rooster-admin-columns__head {
	@apply mb-2 flex items-center justify-between gap-2 font-semibold text-foreground;
}

.rooster-admin-columns__panel .rooster-admin-checks.is-grid {
	@apply grid-cols-[repeat(auto-fill,minmax(13rem,1fr))];
}

/* A hidden column: its cells, by their place in the row, the selection's counted (Guidance::HIDE_MAX places). */
.rooster-admin-table.is-hide-2
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(2),
.rooster-admin-table.is-hide-3
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(3),
.rooster-admin-table.is-hide-4
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(4),
.rooster-admin-table.is-hide-5
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(5),
.rooster-admin-table.is-hide-6
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(6),
.rooster-admin-table.is-hide-7
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(7),
.rooster-admin-table.is-hide-8
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(8),
.rooster-admin-table.is-hide-9
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(9),
.rooster-admin-table.is-hide-10
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(10),
.rooster-admin-table.is-hide-11
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(11),
.rooster-admin-table.is-hide-12
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(12),
.rooster-admin-table.is-hide-13
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(13),
.rooster-admin-table.is-hide-14
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(14),
.rooster-admin-table.is-hide-15
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(15),
.rooster-admin-table.is-hide-16
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(16),
.rooster-admin-table.is-hide-17
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(17),
.rooster-admin-table.is-hide-18
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(18),
.rooster-admin-table.is-hide-19
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(19),
.rooster-admin-table.is-hide-20
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(20),
.rooster-admin-table.is-hide-21
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(21),
.rooster-admin-table.is-hide-22
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(22),
.rooster-admin-table.is-hide-23
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(23),
.rooster-admin-table.is-hide-24
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(24),
.rooster-admin-table.is-hide-25
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(25),
.rooster-admin-table.is-hide-26
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(26),
.rooster-admin-table.is-hide-27
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(27),
.rooster-admin-table.is-hide-28
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(28),
.rooster-admin-table.is-hide-29
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(29),
.rooster-admin-table.is-hide-30
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(30),
.rooster-admin-table.is-hide-31
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(31),
.rooster-admin-table.is-hide-32
	:where(.rooster-admin-table__scroll > .rooster-admin-table__table > * > tr:not(.rooster-admin-table__groups))
	> :nth-child(32) {
	@apply hidden;
}
