/* Table */

table
{
  margin: 1rem 0;
  border-collapse: collapse;
}
table th,
table td
{
  padding: 0;
  text-align: left;
}
table th
{
  font-weight: bold;
  color: var(--secondary)
}
table td.number
{
  text-align: right;
}
table th > a,
table td > a
{
  display: block;
}

/* Padding is applied to the table cell, or instead to the “row link” inside it if present. An
   anchor element immediately inside a table cell in a “link row” is a “row link” when it has a
   href value with an absolute path and no class attribute value */

table th,
table tr:not(.link) td,
table tr.link td:not(:has(> a[href^="/"]:not([class]))),  /* regular link inside a link row */
table tr.link > td > a[href^="/"]:not([class])  /* row link inside a link row */
{
  padding: 0.25rem 0.5625rem;
}
table th:first-child,
table tr:not(.link) td:first-child,
table tr.link td:not(:has(> a[href^="/"]:not([class]))):first-child,
table tr.link > td:first-child > a[href^="/"]:not([class])
{
  padding-left: 0.25rem;
}
table th:last-child,
table tr:not(.link) td:last-child,
table tr.link td:not(:has(> a[href^="/"]:not([class]))):last-child,
table tr.link > td:last-child > a[href^="/"]:not([class])
{
  padding-right: 0.25rem;
}

/* Make sure an empty row link fills the full height of the table cell they’re in */

table:has(tr.link)
{
  height: fit-content;
}
table tr.link > td > a[href^="/"]:not([class])
{
  height: 100%;
}

/* Hover and active styling for a row link is applied to the link row. */

table.listing tr.link > td > a[href^="/"]:not([class]),
table.listing tr.link > td > a[href^="/"]:not([class]):active
{
  color: inherit;
  text-decoration: none;
}
table.listing tr.link:has(td > a[href^="/"]:not([class]):hover)
{
  background: var(--listing-background-hover);
}
table.listing tr.link:has(td > aa[href^="/"]:not([class]):active)
{
  color: inherit;
  background: var(--listing-background-active);
}

/* A listing table has a sticky header row with smaller bold labels */

table.listing thead th
{
  position: sticky;
  top: 0;
  background: var(--main-overlay);
  backdrop-filter: blur(0.4rem);
  font-size: var(--size-tiny);
}

/* A details table has regular weight, right-aligned labels */

table.details tbody th:first-child
{
  text-align: right;
  font-weight: normal;
}

/* Borders above and below each row in listing and details tables with a stronger borders between
   the table head and table body */

table.listing tbody > tr,
table.details tbody > tr
{
  border-top: 1px solid var(--secondary-border);
  border-bottom: 1px solid var(--secondary-border);
}
table.listing thead + tbody > tr:first-child,
table.details thead + tbody > tr:first-child
{
  border-top-color: var(--border);
}
table.listing tbody:has(+ thead) > tr:last-child,
table.details tbody:has(+ thead) > tr:last-child
{
  border-bottom-color: var(--border);
}
