.table {
  --table-bg: transparent;
  --table-accent-bg: transparent;
  --table-striped-color: var(--agnostic-dark);
  --table-striped-bg: rgb(0 0 0 / 2.5%);
  --table-active-color: var(--agnostic-dark);
  --table-active-bg: rgb(0 0 0 / 1.5%);
  --table-hoverable-color: var(--agnostic-dark);
  --table-hoverable-bg: var(--agnostic-table-hover-bg, #f1faff);

  width: 100%;
  margin-bottom: var(--fluid-16);
  color: var(--agnostic-dark);
  vertical-align: top;
  border-color: var(--agnostic-table-border-color, var(--agnostic-gray-light));
}

.table > :not(caption) > * > * {
  padding: var(--fluid-8) var(--fluid-8);
  background-color: var(--table-bg);
  border-bottom-width: 1px;

  /* 4th is spread --table-accent-bg will gets reset for active, hover, striped */
  box-shadow: inset 0 0 0 9999px var(--table-accent-bg);
}

.table > tbody {
  vertical-align: inherit;
}

.table > thead {
  vertical-align: bottom;
}

.table thead th {
  font-weight: 600;
}

.table-caps thead th {
  font-size: var(--fluid-12);
  text-transform: uppercase;
}

.table tbody td,
.table tbody th {
  font-weight: 400;
}

.table > :not(thead):not(caption) {
  border-top: var(--fluid-2) solid var(--agnostic-gray-light);
}

.caption-top {
  caption-side: top;
}

.caption-bottom {
  caption-side: bottom;
}

.caption-bottom,
.caption-top {
  padding-block-start: var(--fluid-12);
  padding-block-end: var(--fluid-12);

  /* Takes writing mode into account -- (mdn) same as left if direction is left-to-right
  and right if direction is right-to-left */
  text-align: start;
}

.caption-end {
  text-align: end;
}

.table-small > :not(caption) > * > * {
  padding: var(--fluid-4) var(--fluid-4);
}

.table-large > :not(caption) > * > * {
  padding: var(--fluid-12) var(--fluid-12);
}

.table-xlarge > :not(caption) > * > * {
  padding: var(--fluid-18) var(--fluid-18);
}

.table-bordered > :not(caption) > * {
  border-width: 1px 0;
}

.table-bordered > :not(caption) > * > * {
  border-width: 0 1px;
}

.table-borderless > :not(caption) > * > * {
  border-bottom-width: 0;
}

.table-borderless > :not(:first-child) {
  border-top-width: 0;
}

.table-striped > tbody > tr:nth-of-type(odd) > * {
  --table-accent-bg: var(--table-striped-bg);

  color: var(--table-striped-color);
}

.table-active {
  --table-accent-bg: var(--table-active-bg);

  color: var(--table-active-color);
}

.table-hoverable > tbody > tr:hover > * {
  --table-accent-bg: var(--table-hoverable-bg);

  color: var(--table-hoverable-color);
}

/* Stacked tables */
.table-stacked thead {
  display: none;
}

.table-stacked tr,
.table-stacked tbody th,
.table-stacked tbody td {
  display: block;
  width: 100%;
}

.table-stacked tbody th,
.table-stacked tbody td {
  border-bottom-width: 0;
}

.table-stacked td[data-label] {
  padding-bottom: var(--fluid-12);
}

.table-stacked tr {
  border-bottom: var(--fluid-2) solid var(--agnostic-gray-light);
  border-top-width: 0;
}

.table-stacked th[data-label]::before,
.table-stacked td[data-label]::before {
  content: attr(data-label);
  display: block;
  font-weight: 600;
  margin: -0.5rem -1rem 0;
  padding: var(--fluid-12) var(--fluid-16) var(--fluid-6);
}

.table-stacked tr th:first-child,
.table-stacked tr td:first-child {
  border-top-width: 0;
}

.table-stacked tr:nth-child(odd) td,
.table-stacked tr:nth-child(odd) th {
  background-color: inherit;
}

.table-stacked tr:first-child th:first-child,
.table-stacked tr:first-child td:first-child {
  border-top: var(--fluid-2) solid var(--agnostic-gray-light);
}

.table-stacked th[data-label],
.table-stacked td[data-label] {
  padding-bottom: var(--fluid-12);
}

/* As soon as there's not enough width, it will kick in horizontal scrolling */
.table-responsive {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Table is responsive only "up to" the breakpoint. Above it will not scroll */
@media (max-width: 576px) {
  .table-responsive-small {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 768px) {
  .table-responsive-medium {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 992px) {
  .table-responsive-large {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

@media (max-width: 1200px) {
  .table-responsive-xlarge {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
}

.table-header-container {
  display: flex;
  align-items: center;
}

.table-sort-label {
  flex: 1;
  padding-inline-end: 0.5rem;
  text-align: left;
}

.table-sort {
  flex: 0 1 var(--fluid-48);
  background-color: transparent;
  border-color: transparent;
  border-width: 0;
  cursor: pointer;
  display: flex;
  justify-content: center;
  padding-block-start: var(--fluid-2);
  padding-block-end: var(--fluid-2);
}

.icon-sort {
  width: 1.125rem;
  height: 1.125rem;
}

.table-sort:focus {
  box-shadow: 0 0 0 var(--agnostic-focus-ring-outline-width) var(--agnostic-focus-ring-color);

  /* Needed for High Contrast mode */
  outline:
    var(--agnostic-focus-ring-outline-width) var(--agnostic-focus-ring-outline-style)
    var(--agnostic-focus-ring-outline-color);
  transition: box-shadow var(--agnostic-timing-fast) ease-out;
}

@media (prefers-reduced-motion), (update: slow) {
  .table-sort:focus {
    transition-duration: 0.001ms !important;
  }
}
