/* Grid table: a table out of divs, one table of the theme's cells where every part is opened by a title of the theme's
   blocks, and the rows of all parts on one grid (subgrid), so a column runs straight through it. --cols columns, as
   wide as their content and sharing the space left, or equal with .grid-table-even; a cell spans with col-span-*.
   Only the titles come from .infos: no block surface, border, gap or own scrolling (the whole grid scrolls), so
   between the cells the page shows like between a table's. A row or part collapsed by its toggle (.hidden) stays out
   of the grid. --cell-spacing is the space between the cells and the parts like a table's border-spacing; below zero
   the cells overlap their borders like border-collapse, and the table keeps room for the last ones sticking out so
   it doesn't scroll for that.
   The titles align like the theme's table heads (--heading-align). A centred one with controls at the right gets an
   empty twin of them on the left, so the toggle stays in the middle of the title, not of the space the controls
   leave; where style queries are missing it just sits a bit to the left. A title the theme leaves see-through, its
   block being the surface, gets that surface and frame here, since these blocks have none, and a padding of its own
   for the same reason: a theme may keep that space in its block, not its title. The theme's cell blur is on the
   table as a whole: on each of its cells it makes a long page stutter while scrolling.
   A file of its own, also for the account, the admin and the public pages, loaded before main.css, so that
   main.css can still shape a single table, like the empire, with a class of its own. */
.grid-table:not(.hidden) {
	display: grid;
}

.grid-table {
	grid-template-columns: repeat(var(--cols), auto);
	row-gap: max(var(--cell-spacing), 0px);
	margin-bottom: calc(2 * max(var(--cell-spacing), 0px));
	padding: 0 calc(-1 * min(var(--cell-spacing), 0px)) calc(-1 * min(var(--cell-spacing), 0px)) 0;
	overflow-x: auto;
	-webkit-backdrop-filter: var(--cell-blur);
	backdrop-filter: var(--cell-blur);
}

.grid-table-even {
	grid-template-columns: repeat(var(--cols), minmax(0, 1fr));
}

.grid-table.table519,
.grid-table.table569 {
	margin-inline: auto;
}

.grid-table > .grid-table-part:not(.hidden) {
	display: grid;
}

.grid-table > .grid-table-part {
	grid-column: 1 / -1;
	grid-template-columns: subgrid;
	gap: max(var(--cell-spacing), 0px);
	isolation: isolate;
	margin: 0;
	padding: 0;
	overflow: visible;
	background: none;
	border: 0;
	box-shadow: none;
}

.grid-table .grid-table-title {
	position: relative;
	grid-column: 1 / -1;
	margin: 0 min(var(--cell-spacing), 0px) 0 0;
	padding: 5px;
	text-align: var(--heading-align);
}

.grid-table .grid-table-title::before {
	content: "";
	position: absolute;
	inset: 0;
	z-index: -1;
	background: var(--surface-block);
	border: var(--block-border);
	border-radius: inherit;
}

.grid-table-title > .flex {
	justify-content: var(--heading-align);
}

@container style(--heading-align: center) {
	.grid-table-title > .flex::before {
		content: "";
		flex: 1 1 0;
	}

	.grid-table-title > .flex > .collapse-toggle {
		flex: none;
		width: auto;
	}

	.grid-table-title > .flex > :last-child {
		flex: 1 1 0;
		text-align: end;
	}
}

.grid-table-row:not(.hidden) {
	display: contents;
}

.head-cell[aria-sort="ascending"] .link-button {
	color: var(--success);
}

.head-cell[aria-sort="descending"] .link-button {
	color: var(--danger);
}

/* A field keeps its own width while it fits its cell and shrinks with a narrower one. In a layer below the utilities,
   so a max-w-* on the field still counts. */
@layer base {
	.grid-table input:not([type="checkbox"], [type="radio"]),
	.grid-table select,
	.grid-table textarea {
		max-width: calc(100% - 4px);
	}
}

/* Cells stacked in one column of a row, the first taking whatever height the row has to spare. */
.grid-table-stack {
	display: grid;
	grid-template-columns: minmax(0, 1fr);
	grid-template-rows: 1fr;
	gap: max(var(--cell-spacing), 0px);
	min-width: 0;
}

.grid-table .cell,
.grid-table .head-cell {
	align-content: center;
	overflow-wrap: break-word;
	-webkit-backdrop-filter: none;
	backdrop-filter: none;
	margin: 0 min(var(--cell-spacing), 0px) min(var(--cell-spacing), 0px) 0;
}
