/* TREJKA Tables – front end. Inherits font and text colour from the theme. */
.trtb {
	--trtb-accent: #bc0000;
	--trtb-line: rgba(127, 127, 127, .28);
	--trtb-soft: rgba(127, 127, 127, .08);
	margin: 1.5em 0;
	font-size: inherit;
}
.trtb *, .trtb *::before { box-sizing: border-box; }
.trtb [hidden] { display: none !important; }

.trtb-sr {
	position: absolute !important;
	width: 1px; height: 1px;
	margin: -1px; padding: 0; border: 0;
	overflow: hidden;
	clip: rect(0 0 0 0);
	white-space: nowrap;
}

/* Controls */
.trtb-controls {
	display: flex;
	flex-wrap: wrap;
	gap: .5em;
	padding: .75em;
	background: var(--trtb-soft);
	border: 1px solid var(--trtb-line);
	border-bottom: 0;
	border-radius: 6px 6px 0 0;
}
.trtb-field { flex: 1 1 12em; min-width: 0; margin: 0; }
.trtb-field input,
.trtb-field select {
	width: 100%;
	min-height: 2.6em;
	margin: 0;
	padding: .45em .7em;
	font: inherit;
	font-size: .95em;
	line-height: 1.3;
	color: #1d2327;
	background: #fff;
	border: 1px solid var(--trtb-line);
	border-radius: 4px;
	box-shadow: none;
}
.trtb-field input:focus,
.trtb-field select:focus,
.trtb-sort:focus-visible,
.trtb-pager button:focus-visible,
.trtb-scroll:focus-visible {
	outline: 2px solid var(--trtb-accent);
	outline-offset: 1px;
}

/* Table */
.trtb-scroll {
	overflow-x: auto;
	border: 1px solid var(--trtb-line);
	border-radius: 6px;
	-webkit-overflow-scrolling: touch;
}
.trtb-controls + .trtb-scroll { border-radius: 0 0 6px 6px; }
.trtb-table {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
	font-size: .95em;
	line-height: 1.4;
}
.trtb-table caption {
	padding: .75em;
	font-weight: 700;
	text-align: left;
	caption-side: top;
}
.trtb-table th,
.trtb-table td {
	padding: .7em .85em;
	border: 0;
	border-bottom: 1px solid var(--trtb-line);
	text-align: left;
	vertical-align: top;
	background: none;
}
.trtb-table tbody tr:last-child td { border-bottom: 0; }
.trtb-table th {
	font-weight: 700;
	white-space: nowrap;
	background: var(--trtb-soft);
}
.trtb-table .trtb-num { text-align: right; font-variant-numeric: tabular-nums; }
.trtb-table .trtb-al-left { text-align: left; }
.trtb-table .trtb-al-center { text-align: center; }
.trtb-table .trtb-al-right { text-align: right; }
.trtb-table td a { overflow-wrap: anywhere; }
.trtb-table .trtb-nowrap { white-space: nowrap; overflow-wrap: normal; }

.trtb--striped:not(.trtb--js) tbody tr:nth-child(even) td,
.trtb--striped.trtb--js tbody tr.trtb-alt td { background: var(--trtb-soft); }

/* Row under the pointer */
.trtb.trtb--hover .trtb-table tbody tr:hover > td { background: rgba(127, 127, 127, .18); }
@supports (background: color-mix(in srgb, red 10%, transparent)) {
	.trtb.trtb--hover .trtb-table tbody tr:hover > td { background: color-mix(in srgb, var(--trtb-accent) 12%, transparent); }
}

/* Sorting */
.trtb-sort {
	display: inline-flex;
	align-items: center;
	gap: .4em;
	margin: 0;
	padding: 0;
	font: inherit;
	font-weight: 700;
	color: inherit;
	text-align: inherit;
	text-transform: none;
	letter-spacing: inherit;
	background: none;
	border: 0;
	border-radius: 2px;
	box-shadow: none;
	cursor: pointer;
}
.trtb-sort:hover { color: var(--trtb-accent); background: none; }
.trtb-sort-icon {
	width: 0; height: 0;
	border: .3em solid transparent;
	border-top-color: currentColor;
	border-bottom-width: 0;
	opacity: .3;
}
[aria-sort] .trtb-sort-icon { opacity: 1; color: var(--trtb-accent); }
[aria-sort="ascending"] .trtb-sort-icon {
	border-top-width: 0;
	border-bottom: .3em solid currentColor;
}

/* Footer */
.trtb-empty {
	margin: 0;
	padding: 1.5em;
	text-align: center;
	border: 1px solid var(--trtb-line);
	border-radius: 0 0 6px 6px;
}
.trtb-footer {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: .5em 1em;
	margin-top: .6em;
	font-size: .9em;
}
.trtb-count { opacity: .8; }
.trtb-pager nav { display: flex; align-items: center; gap: .6em; }
.trtb-pager button {
	margin: 0;
	padding: .4em .9em;
	font: inherit;
	color: inherit;
	background: transparent;
	border: 1px solid var(--trtb-line);
	border-radius: 4px;
	box-shadow: none;
	cursor: pointer;
}
.trtb-pager button:hover:not(:disabled) { color: var(--trtb-accent); border-color: var(--trtb-accent); background: transparent; }
.trtb-pager button:disabled { opacity: .4; cursor: default; }

.trtb-missing { padding: .75em 1em; border: 1px dashed currentColor; }

/* Phones: every row becomes a card */
@media (max-width: 640px) {
	.trtb--cards .trtb-scroll { overflow: visible; border: 0; border-radius: 0; }
	.trtb--cards .trtb-controls { border-bottom: 1px solid var(--trtb-line); border-radius: 6px; margin-bottom: .75em; }
	.trtb--cards .trtb-table,
	.trtb--cards .trtb-table tbody,
	.trtb--cards .trtb-table tr,
	.trtb--cards .trtb-table td { display: block; width: 100%; }
	.trtb--cards .trtb-table thead {
		position: absolute;
		width: 1px; height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}
	.trtb--cards .trtb-table tr {
		margin-bottom: .75em;
		padding: .35em 0;
		border: 1px solid var(--trtb-line);
		border-radius: 6px;
	}
	.trtb--cards .trtb-table td {
		display: grid;
		grid-template-columns: minmax(6em, 36%) 1fr;
		gap: .75em;
		padding: .4em .85em;
		border: 0;
		text-align: left;
	}
	.trtb--cards .trtb-table td::before {
		content: attr(data-label);
		font-weight: 700;
	}
	.trtb--cards .trtb-table td:empty { display: none; }
	.trtb--cards .trtb-table .trtb-nowrap { white-space: normal; overflow-wrap: anywhere; }
	.trtb--cards.trtb--striped tbody tr td,
	.trtb--cards.trtb--hover .trtb-table tbody tr:hover > td { background: none !important; }
	.trtb--cards .trtb-table td[class] { text-align: left; }
}
