/**
 * @file
 * Table component.
 *
 * A view's rows as a table, one column per field. A table wider than its
 * place scrolls sideways inside its own wrapper, which can take the
 * keyboard focus, so the page itself never scrolls sideways. A column with
 * a priority hides on smaller screens: `low` below 782 px, `medium` below
 * 600 px.
 *
 * Contents:
 * 1. Scroll wrapper
 * 2. Table
 * 3. Caption
 * 4. Headings and cells
 * 5. Sort links
 * 6. Media queries
 */

/* 1. Scroll wrapper
   ========================================================================== */

.viewspress-table__scroll {
	max-width: 100%;
	overflow-x: auto;
}

.viewspress-table__scroll:focus-visible {
	outline: 2px solid var(--viewspress-accent, var(--wp--custom--viewspress--accent, currentcolor));
	outline-offset: 2px;
}

/* End of 1. Scroll wrapper */

/* 2. Table
   ========================================================================== */

.viewspress-table {
	width: 100%;
	margin: 0;
	border-collapse: collapse;
}

/* End of 2. Table */

/* 3. Caption
   ========================================================================== */

.viewspress-table__caption {
	padding-block: 0 0.5em;
	font-weight: 600;
	text-align: start;
}

/* End of 3. Caption */

/* 4. Headings and cells
   ========================================================================== */

.viewspress-table__heading,
.viewspress-table__cell {
	padding: 0.5em 0.75em;
	border-block-end: var(--viewspress-border-width, var(--wp--custom--viewspress--border-width, 1px)) solid;
	text-align: start;
	vertical-align: top;
}

.viewspress-table__heading {
	border-block-end-color: var(--viewspress-border-color, var(--wp--custom--viewspress--border-color, currentcolor));
	font-weight: 600;
}

.viewspress-table__cell {
	border-block-end-color: var(--viewspress-border-color, var(--wp--custom--viewspress--border-color, color-mix(in srgb, currentcolor 15%, transparent)));
}

.viewspress-table .viewspress-field {
	overflow-wrap: break-word;
}

/* End of 4. Headings and cells */

/* 5. Sort links
   ========================================================================== */

.viewspress-table__sort {
	color: inherit;
	font-weight: inherit;
	text-decoration: none;
	white-space: nowrap;
}

.viewspress-table__sort:hover,
.viewspress-table__sort:focus {
	text-decoration: underline;
}

.viewspress-table__sort::after {
	margin-inline-start: 0.35em;
	opacity: 0.4;
	content: "\2195";
}

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

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

/* End of 5. Sort links */

/* 6. Media queries
   ========================================================================== */

@media (max-width: 781px) {
	.viewspress-table__heading--priority-low,
	.viewspress-table__cell--priority-low {
		display: none;
	}
}

@media (max-width: 599px) {
	.viewspress-table__heading,
	.viewspress-table__cell {
		padding: 0.5em;
	}

	.viewspress-table__heading--priority-medium,
	.viewspress-table__cell--priority-medium {
		display: none;
	}
}

/* End of 6. Media queries */
