/* Sortable table headers, see public/js/table-sort.js. The button keeps the
   header's own type so a table looks the same before and after sorting. */

.table-sort-button {
  display: inline;
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  color: inherit;
  font: inherit;
  letter-spacing: inherit;
  line-height: inherit;
  text-align: inherit;
  text-transform: inherit;
  white-space: inherit;
  text-decoration: none;
  cursor: pointer;
}

/* The no-break space keeps the arrow on the same line as the last word. */
.table-sort-button::after {
  content: "\00a0↕";
  opacity: 0;
  transition: opacity 120ms ease;
}

.table-sort-button:hover,
.table-sort-button:focus-visible,
th.is-sort-active .table-sort-button {
  color: var(--ink);
}

.table-sort-button:hover::after,
.table-sort-button:focus-visible::after {
  opacity: 0.5;
}

th.is-sort-active .table-sort-button::after {
  content: "\00a0↓";
  opacity: 1;
}

th.is-sort-active.is-sort-asc .table-sort-button::after {
  content: "\00a0↑";
}

/* Without a pointer to hover with, the arrow shows faintly from the start,
   so a sortable column can be seen, and the header is 44 px to tap. */
@media (pointer: coarse) {
  .table-sort-button {
    display: inline-flex;
    min-width: 44px;
    min-height: 44px;
    align-items: center;
  }

  .table-sort-button::after {
    opacity: 0.5;
  }
}

@media print {
  .table-sort-button::after {
    display: none;
  }
}
