/*
 * Data table — the one look for a table: a raised panel with a border and
 * rounded corners, a filled header row, a line between rows and every other
 * row striped.
 *
 * The look is the theme's `settings.custom.table` (background, border
 * colour, radius, head background, head colour, stripe, cell padding), so a
 * child restyles every table in theme.json.
 *
 * Two wearers, one set of rules:
 *
 *   .data-table            a table a block draws. The block puts the class
 *                          on its <table>, names this sheet in block.json
 *                          (`"style": [ "wage-block-table", "file:./style.css" ]`)
 *                          and keeps only what is its own in its stylesheet.
 *   .wp-block-table > table  core's Table block (blocks.php loads this sheet
 *                          with it). Core's own sheet stays: its fixed
 *                          layout, sideways scroll, alignment and the
 *                          Border panel's rules are untouched. Only its cell
 *                          box (a border on every side, 0.5em padding) is
 *                          replaced; its header and footer rules draw nothing
 *                          once the borders are separate.
 *
 * `is-number` on a th or td: a figure, right-aligned, digits in columns.
 * The border and row line widths are the literals here.
 */

.data-table,
.wp-block-table > table {
	background: var(--wp--custom--table--background);
	border: 1px solid var(--wp--custom--table--border-color);
	/* Separate, not collapse: a collapsed table's border ignores the radius. */
	border-collapse: separate;
	border-radius: var(--wp--custom--table--radius);
	border-spacing: 0;
	margin: 0;
	overflow: hidden;
	width: 100%;
}

.data-table th,
.wp-block-table > table th {
	background: var(--wp--custom--table--head-background);
	border: 0;
	color: var(--wp--custom--table--head-color);
	font-size: var(--wp--preset--font-size--small);
	font-weight: var(--wp--custom--font-weight--bold);
	/* Snug: a header that wraps (a narrow card, a phone) stays one tight label. */
	line-height: var(--wp--custom--line-height--snug);
	padding: var(--wp--preset--spacing--xs) var(--wp--custom--table--cell-padding);
	text-align: left;
}

.data-table td,
.wp-block-table > table td {
	border: 0;
	border-top: 1px solid var(--wp--custom--table--border-color);
	padding: var(--wp--custom--table--cell-padding);
	vertical-align: top;
}

/* A table with no header row: its first row sits against the table's own border. */
.data-table > :first-child > tr:first-child > td,
.wp-block-table > table > :first-child > tr:first-child > td {
	border-top: 0;
}

/* A footer row (a total): core's heavy line above it is gone with the collapsed borders, so its weight marks it. */
.data-table tfoot td,
.wp-block-table > table tfoot td {
	font-weight: var(--wp--custom--font-weight--bold);
}

/* On the row, not its cells, so a block can tint one row's cells over it. */
.data-table tbody tr:nth-child(even),
.wp-block-table > table tbody tr:nth-child(even) {
	background: var(--wp--custom--table--stripe);
}

.data-table .is-number {
	font-variant-numeric: tabular-nums;
	text-align: right;
	white-space: nowrap;
}
