/* The shared table: a bordered box the page does not scroll around, a fixed header row, sortable and resizable
   columns. Built on the tokens in app.css. No inline styles (strict CSP); widths set by tables.js are set through the
   DOM, which the policy allows. */

:root { --field-gap: 4px; }

/* A filter block and its table sit one field-gap apart: the same distance a label sits from its input. */
.tblock { display: flex; flex-direction: column; gap: var(--field-gap); min-height: 0; }
.tblock > .filters, .tblock > .books-head { margin: 0; }

.tablebox { border: 1px solid var(--line); border-radius: var(--radius); background: var(--row); overflow: auto;
            min-height: 0; }
.tablebox table { border-collapse: separate; border-spacing: 0; }
.tablebox thead th { position: sticky; top: 0; z-index: 2; }
.tablebox tfoot td { position: sticky; bottom: 0; z-index: 1; }
.tablebox td { border-bottom: 1px solid var(--line); }
.tablebox tbody tr:last-child td { border-bottom: 0; }

/* On a laptop the page does not scroll: the box takes what is left and its rows scroll inside it. On a small screen
   the page scrolls and the box is as tall as its rows. */
@media (min-width: 761px) {
  main.fill .tblock { flex: 1 1 auto; }
  main.fill .tblock > .tablebox { flex: 1 1 auto; }
}

th.sortable { padding: 0; }
th.sortable .sortlink { display: block; padding: 7px 10px; color: inherit; text-decoration: none; white-space: nowrap; }
th.sortable .sortlink:hover { background: var(--seal); }
th.sortable .sortlink:focus-visible { outline: 3px solid var(--gold); outline-offset: -3px; }
th.sortable .ind { margin-left: 5px; font-size: .7em; opacity: .45; }
th.sortable[aria-sort="ascending"] .ind, th.sortable[aria-sort="descending"] .ind { opacity: 1; color: var(--gold-ink); }
th.fig .sortlink { text-align: right; }

/* Resizable columns (tables.js). Without the script the table lays itself out as usual. */
table.sized[data-resize] { table-layout: fixed; min-width: 100%; width: auto; }
table.sized th { position: sticky; }
table.sized td { overflow: hidden; text-overflow: ellipsis; }
table.sized th .grip { position: absolute; top: 0; right: 0; width: 8px; height: 100%; cursor: col-resize; z-index: 3; }
table.sized th .grip::after { content: ""; position: absolute; top: 20%; bottom: 20%; right: 3px;
                              border-right: 1px solid var(--head-ink); opacity: .35; }
table.sized th .grip:hover::after, table.sized th .grip:focus-visible::after, table.resizing th .grip::after { opacity: 1; }
table.resizing { user-select: none; cursor: col-resize; }
.tablebox.inflow { overflow: visible; }

/* The width controls above a resizable table: choose a column, make it narrower or wider, or reset every column. */
table.sized th .grip:focus-visible { outline: 3px solid var(--gold); outline-offset: -2px; background: var(--seal); }
