/* Table (docs/widgets/table.md), in the design language (spec §3.7), Soft design: the table on a
   white card with a thin border and a soft shadow, the header on a quiet band, lines between rows,
   a wash of the accent on hover, and pill controls with the current page in the accent. The tokens
   (--hafe-surface, --hafe-accent…) come from design.css. It stays a table on every screen, and scrolls
   sideways in its card when it doesn't fit (owner, 2026-11-05).

   The Lines setting, when left on the design's own, takes the design's lines: --hafe-table-rows and
   --hafe-table-cols, which the other designs change. */
.hafe-table {
	--hafe-table-band: color-mix(in srgb, var(--hafe-ink) 4%, var(--hafe-surface));
	--hafe-table-wash: color-mix(in srgb, var(--hafe-accent) 6%, var(--hafe-surface));
	--hafe-table-head: var(--hafe-table-band);
	--hafe-table-head-ink: var(--hafe-ink);
	--hafe-table-col: color-mix(in srgb, var(--hafe-accent) 9%, transparent);
	--hafe-table-rows: var(--hafe-table-line-width, 1px);
	--hafe-table-pad: 0.75em 1em;
	--hafe-table-cols: 0px;
	color: var(--hafe-ink);
	overflow-wrap: break-word;
}

/* Phones: snugger cells, so more of a wide table shows before it scrolls. */
@media (max-width: 767px) {
	.hafe-table {
		--hafe-table-pad: 0.6em 0.75em;
	}
}

.hafe-scheme-dark .hafe-table {
	--hafe-table-col: color-mix(in srgb, var(--hafe-accent) 16%, transparent);
	--hafe-table-band: color-mix(in srgb, var(--hafe-ink) 6%, var(--hafe-surface));
	--hafe-table-wash: color-mix(in srgb, var(--hafe-accent) 14%, var(--hafe-surface));
	color-scheme: dark;
}

/* A mouse click leaves no outline: block themes outline anything focused. The keyboard keeps its own. */
.hafe-table :focus:not(:focus-visible) {
	outline: none;
}

/* The card. It clips (without scrolling, so a sticky header still follows the page) to its corners. */
.hafe-table__frame {
	position: relative;
	overflow: clip;
	border: 1px solid var(--hafe-table-border, var(--hafe-line));
	border-radius: var(--hafe-table-radius, var(--hafe-radius));
	background: var(--hafe-table-bg, var(--hafe-surface));
	box-shadow: var(--hafe-shadow);
	color: var(--hafe-table-color, var(--hafe-ink));
}

/* Positioned, so text kept for screen readers scrolls with its cell and can't widen the page. */
.hafe-table__scroll {
	position: relative;
	overflow-x: auto;
}

/* Inside the card's edge, which clips. */
.hafe-table .hafe-table__scroll:focus-visible {
	outline: 2px solid var(--hafe-accent);
	outline-offset: -2px;
}

/* Separate borders: collapsed ones scroll away from a sticky header. */
.hafe-table__table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: separate;
	border-spacing: 0;
	background: none;
	font-size: inherit;
	overflow-wrap: break-word;
}

.hafe-table__table > tbody > tr {
	background: var(--hafe-table-row-bg, none);
	color: inherit;
}

.hafe-table__table > tbody > tr:nth-child(even) {
	background: var(--hafe-table-even-bg, var(--hafe-table-row-bg, var(--hafe-table-stripe, none)));
}

.hafe-table__table > tbody > tr:hover {
	background: var(--hafe-table-hover-bg, var(--hafe-table-wash));
	color: var(--hafe-table-hover-color, inherit);
}

/* Column colour: the body's cells in the chosen columns. The default tint is see-through, so a
   row's own colour, stripe and hover still show under it. */
.hafe-table .hafe-table__table > tbody > tr > .hafe-table__hl {
	background: var(--hafe-table-col-bg, var(--hafe-table-col));
	color: var(--hafe-table-col-color, inherit);
}

/* Specific enough to undo the table styles of themes. A line runs under the header, above each row
   after the first, and above the footer, so none doubles the card's own edge, and a row span covers
   the lines it spans. Lines between columns start at the second column. */
.hafe-table .hafe-table__table > thead > tr > th,
.hafe-table .hafe-table__table > tbody > tr > *,
.hafe-table .hafe-table__table > tfoot > tr > * {
	padding: var(--hafe-table-padding, var(--hafe-table-pad));
	overflow-wrap: break-word;
	border: 0 solid var(--hafe-table-line-color, var(--hafe-line));
	border-inline-start-width: var(--hafe-table-side, var(--hafe-table-cols));
	background: none;
	color: inherit;
	text-align: var(--hafe-table-align, start);
	text-transform: none;
	vertical-align: middle;
}

.hafe-table .hafe-table__table > * > tr > .hafe-table__first {
	border-inline-start-width: 0;
}

.hafe-table .hafe-table__table > thead > tr > th {
	border-block-end-width: var(--hafe-table-line, var(--hafe-table-rows));
	background: var(--hafe-table-header-bg, var(--hafe-table-head));
	color: var(--hafe-table-header-color, var(--hafe-table-head-ink));
	font-weight: 600;
	vertical-align: bottom;
}

/* Hello Elementor lines the top of a table's first header row, with a rule more specific than the
   one above. */
.hafe-table .hafe-table__table > thead:first-child > tr:first-child > th {
	border-block-start-width: 0;
}

.hafe-table .hafe-table__table > tbody > tr + tr > * {
	border-block-start-width: var(--hafe-table-line, var(--hafe-table-rows));
}

.hafe-table .hafe-table__table > tbody > tr > * {
	font-weight: inherit;
}

.hafe-table .hafe-table__table > tbody > tr > th {
	font-weight: 600;
}

/* A footer looks like the header unless it's given its own colours. */
.hafe-table .hafe-table__table > tfoot > tr > * {
	border-block-start-width: var(--hafe-table-line, var(--hafe-table-rows));
	background: var(--hafe-table-footer-bg, var(--hafe-table-header-bg, var(--hafe-table-head)));
	color: var(--hafe-table-footer-color, var(--hafe-table-header-color, var(--hafe-table-head-ink)));
	font-weight: 600;
}

/* A column's own alignment wins over the widget's. */
.hafe-table .hafe-table__table > * > tr > .hafe-table__cell--start {
	text-align: start;
}

.hafe-table .hafe-table__table > * > tr > .hafe-table__cell--center {
	text-align: center;
}

.hafe-table .hafe-table__table > * > tr > .hafe-table__cell--end {
	text-align: end;
}

.hafe-table__cell--number {
	font-variant-numeric: tabular-nums;
}

/* Columns hidden per device: the "device" control turns the matching property to `none`. */
.hafe-table .hafe-table__table > * > tr > .hafe-table__hide-desktop {
	display: var(--hafe-table-hide-desktop, table-cell);
}

.hafe-table .hafe-table__table > * > tr > .hafe-table__hide-tablet {
	display: var(--hafe-table-hide-tablet, table-cell);
}

.hafe-table .hafe-table__table > * > tr > .hafe-table__hide-mobile {
	display: var(--hafe-table-hide-mobile, table-cell);
}

/* The caption is the card's title, with a line between it and the table. */
.hafe-table__caption {
	padding: var(--hafe-table-padding, var(--hafe-table-pad));
	overflow-wrap: break-word;
	border: 0 solid var(--hafe-table-line-color, var(--hafe-line));
	border-block-end-width: var(--hafe-table-line, var(--hafe-table-rows));
	color: var(--hafe-table-caption-color, inherit);
	font-weight: 600;
	text-align: start;
}

.hafe-table__caption--below {
	caption-side: bottom;
	border-block-start-width: var(--hafe-table-line, var(--hafe-table-rows));
	border-block-end-width: 0;
}

.hafe-table__caption--hidden,
.hafe-table__sr {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	border: 0;
	overflow: hidden;
	clip-path: inset(50%);
	white-space: nowrap;
}

/* Cell content. */
/* Link cells and links in rich cells. Specific enough to beat `.elementor a`, which drops the underline. */
.hafe-table__table a:not(.hafe-table__button) {
	color: var(--hafe-table-link-color, var(--hafe-accent-ink));
	text-decoration: underline;
}

.hafe-table .hafe-table__button {
	display: inline-block;
	padding: 0.4em 0.95em;
	border: 1px solid var(--hafe-table-button-bg, transparent);
	border-radius: var(--hafe-table-button-radius, var(--hafe-pill));
	background: var(--hafe-table-button-bg, var(--hafe-tint));
	color: var(--hafe-table-button-color, var(--hafe-accent-ink));
	font-weight: 600;
	line-height: 1.25;
	text-decoration: none;
	transition: background-color 0.2s, color 0.2s;
}

.hafe-table .hafe-table__button:hover {
	background: var(--hafe-table-button-bg, var(--hafe-tint-strong));
}

.hafe-table__icon {
	display: inline-flex;
	color: var(--hafe-table-icon-color, inherit);
	font-size: var(--hafe-table-icon-size, 1.1em);
	vertical-align: middle;
}

.hafe-table__icon svg {
	width: 1em;
	height: 1em;
	fill: currentColor;
}

.hafe-table .hafe-table__image {
	display: block;
	width: var(--hafe-table-image-width, auto);
	max-width: 100%;
	height: auto;
}

/* Scroll hint: a soft shadow inside the side with more to see. */
.hafe-table__frame::before,
.hafe-table__frame::after {
	content: "";
	position: absolute;
	z-index: 2;
	top: 0;
	bottom: 0;
	width: 1em;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.2s;
}

.hafe-table__frame::before {
	inset-inline-start: 0;
	box-shadow: inset calc(var(--hafe-table-hint-dir, 1) * 0.75em) 0 0.75em -0.75em color-mix(in srgb, var(--hafe-ink) 35%, transparent);
}

.hafe-table__frame::after {
	inset-inline-end: 0;
	box-shadow: inset calc(var(--hafe-table-hint-dir, 1) * -0.75em) 0 0.75em -0.75em color-mix(in srgb, var(--hafe-ink) 35%, transparent);
}

.hafe-table__frame:dir(rtl) {
	--hafe-table-hint-dir: -1;
}

.hafe-table__frame.has-more-start::before,
.hafe-table__frame.has-more-end::after {
	opacity: 1;
}

/* Sticky header. A box that scrolls sideways also traps the header vertically, so the script says
   when the table fits: then the header follows the page. If not, the table scrolls in its own box.
   The header's colour is opaque in every design, so rows don't show through it. */
.hafe-table--sticky {
	--hafe-table-bar: var(--wp-admin--admin-bar--height, 0px);
}

@media (max-width: 600px) {
	.hafe-table--sticky {
		--hafe-table-bar: 0px;
	}
}

.hafe-table--sticky .hafe-table__scroll {
	max-height: calc(100vh - var(--hafe-table-bar, 0px));
	overflow: auto;
}

.hafe-table--sticky .hafe-table__scroll.is-fits {
	max-height: none;
	overflow: visible;
}

.hafe-table--sticky .hafe-table__table > thead > tr > th {
	position: sticky;
	z-index: 1;
	top: 0;
}

.hafe-table--sticky .hafe-table__scroll.is-fits .hafe-table__table > thead > tr > th {
	top: calc(var(--hafe-table-sticky-top, 0px) + var(--hafe-table-bar, 0px));
}

/* Sort buttons look like the header text they replace. */
.hafe-table .hafe-table__sort.hafe-table__sort {
	display: inline-flex;
	align-items: center;
	gap: 0.35em;
	width: 100%;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: none;
	box-shadow: none;
	color: inherit;
	font: inherit;
	letter-spacing: inherit;
	text-align: inherit;
	text-transform: inherit;
	cursor: pointer;
	appearance: none;
}

/* The header text lines up with its column. In a column aligned to the end, the arrow goes before
   the text, so the text's edge meets the numbers' edge. */
.hafe-table .hafe-table__table > thead > tr > th > .hafe-table__sort {
	flex-direction: var(--hafe-table-sort-flow, row);
	justify-content: var(--hafe-table-align, start);
}

.hafe-table .hafe-table__table > thead > tr > .hafe-table__cell--start > .hafe-table__sort {
	flex-direction: row;
	justify-content: start;
}

.hafe-table .hafe-table__table > thead > tr > .hafe-table__cell--center > .hafe-table__sort {
	flex-direction: row;
	justify-content: center;
}

.hafe-table .hafe-table__table > thead > tr > .hafe-table__cell--end > .hafe-table__sort {
	flex-direction: row-reverse;
	justify-content: end;
}

.hafe-table .hafe-table__sort:focus-visible {
	outline: 2px solid currentColor;
	outline-offset: 2px;
}

.hafe-table__sort::after {
	content: "\2195";
	content: "\2195" / "";
	opacity: 0.45;
}

[aria-sort="ascending"] > .hafe-table__sort::after {
	content: "\2191";
	content: "\2191" / "";
	opacity: 1;
}

[aria-sort="descending"] > .hafe-table__sort::after {
	content: "\2193";
	content: "\2193" / "";
	opacity: 1;
}

/* Search and pages. Their labels and the row count sit on the page in the scheme's text colour,
   so Dark suits a dark section (spec §3.7); the boxes and buttons are our surfaces. */
.hafe-table__tools,
.hafe-table__footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	color: var(--hafe-table-tools-color, var(--hafe-ink));
}

.hafe-table__tools {
	justify-content: flex-end;
	gap: 0.5em;
	margin-bottom: 0.75em;
}

.hafe-table__footer {
	justify-content: space-between;
	gap: 0.5em 1em;
	margin-top: 0.75em;
}

/* Themes space and colour labels: these follow the tools' own colour. */
.hafe-table label.hafe-table__tool-text {
	margin: 0;
	color: inherit;
}

.hafe-table__tools[hidden],
.hafe-table__sizes[hidden],
.hafe-table__footer[hidden],
.hafe-table__pages[hidden],
.hafe-table__count[hidden] {
	display: none;
}

/* :not(#hafe-never): spec §4. */
.hafe-table .hafe-table__search:not(#hafe-never),
.hafe-table .hafe-table__size,
.hafe-table .hafe-table__page.hafe-table__page {
	min-width: 0;
	max-width: 100%;
	margin: 0;
	border: 1px solid var(--hafe-table-tools-border, var(--hafe-line));
	border-radius: var(--hafe-pill);
	background: var(--hafe-table-tools-bg, var(--hafe-surface));
	box-shadow: none;
	color: var(--hafe-table-tools-color, var(--hafe-ink));
	font: inherit;
	line-height: 1.4;
}

/* The search box keeps its label beside it, and shrinks before it leaves the line. */
.hafe-table__find {
	display: flex;
	align-items: center;
	gap: 0.5em;
	min-width: 0;
	max-width: 100%;
}

.hafe-table .hafe-table__search:not(#hafe-never) {
	flex: 0 1 auto;
	width: auto;
	padding: 0.4em 0.9em;
	appearance: none;
}

/* The menu at the start, the search box at the end. */
.hafe-table__sizes {
	display: flex;
	align-items: center;
	gap: 0.5em;
	margin-inline-end: auto;
}

/* The menu draws its own arrow, inset as far from the edge as the search box's clear button: the
   browser's own sits against the edge. */
.hafe-table__menu {
	position: relative;
	display: inline-flex;
	align-items: center;
}

.hafe-table .hafe-table__size {
	width: auto;
	padding-block: 0.4em;
	padding-inline: 0.85em 2.3em;
	appearance: none;
	cursor: pointer;
}

.hafe-table__chevron {
	position: absolute;
	inset-inline-end: 0.9em;
	width: 0.7em;
	height: auto;
	color: var(--hafe-table-tools-color, var(--hafe-ink));
	pointer-events: none;
}

/* The list opens on our surface, whatever colour the text around it is. */
.hafe-table .hafe-table__size option {
	background: var(--hafe-surface);
	color: var(--hafe-ink);
}

.hafe-table__count {
	margin: 0;
}

.hafe-table__pages {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3em;
}

.hafe-table .hafe-table__page.hafe-table__page {
	min-width: 2.4em;
	padding: 0.35em 0.75em;
	cursor: pointer;
	transition: background-color 0.2s, color 0.2s;
}

.hafe-table .hafe-table__page.hafe-table__page:not(:disabled, [aria-current="page"]):hover {
	background: var(--hafe-tint);
}

.hafe-table .hafe-table__page.hafe-table__page[aria-current="page"] {
	border-color: var(--hafe-table-page-bg, var(--hafe-accent));
	background: var(--hafe-table-page-bg, var(--hafe-accent));
	color: var(--hafe-table-page-color, var(--hafe-on-accent));
	font-weight: 600;
}

.hafe-table .hafe-table__page.hafe-table__page:disabled {
	opacity: 0.45;
	cursor: default;
}

.hafe-table .hafe-table__page:focus-visible {
	outline: 2px solid var(--hafe-accent);
	outline-offset: 2px;
}

/* Browsers show focus on these however they were reached, so it's quiet here: the line turns to the accent. */
.hafe-table .hafe-table__search:focus:not(#hafe-never),
.hafe-table .hafe-table__size:focus {
	border-color: var(--hafe-accent);
	outline: none;
}

.hafe-empty {
	margin: 0;
	padding: 1em;
	border: 1px dashed currentColor;
	opacity: 0.7;
}

@media (prefers-reduced-motion: reduce) {
	.hafe-table__frame::before,
	.hafe-table__frame::after,
	.hafe-table .hafe-table__button,
	.hafe-table .hafe-table__page {
		transition: none;
	}
}

@media print {
	.hafe-table__tools,
	.hafe-table__footer,
	.hafe-table__frame::before,
	.hafe-table__frame::after,
	.hafe-table__sort::after {
		display: none;
	}

	.hafe-table__frame {
		box-shadow: none;
	}

	.hafe-table .hafe-table__scroll {
		max-height: none;
		overflow: visible;
	}

	.hafe-table--sticky .hafe-table__table > thead > tr > th {
		position: static;
	}

	/* Totals print once, at the end, instead of on every sheet. */
	.hafe-table__table > tfoot {
		display: table-row-group;
	}
}
