/* The table that sorts itself: a light table on a white page, the column sorted by washed in lilac. */
:root {
  --page: #ffffff;          /* the page */
  --ink: #1e1d22;
  --muted: #7d7b84;
  --line: #ecebe7;
  --hover: #f8f7f4;
  --sorted: #f4f2ff;        /* the column sorted by */
  --accent: #5a48d8;
  --bar: #e6e1ff;           /* the bars behind the totals */
}

* {
  box-sizing: border-box;
}

html {
  touch-action: manipulation;
}

html,
body {
  margin: 0;
}

body {
  min-height: 100svh;
  background: var(--page);
  color: var(--ink);
  font-family: 'Reddit Sans Variable', system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

.stage {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: 32px 12px;
}

.sheet {
  width: min(620px, 100%);
}

.table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  font-size: 15px;
}

.table__caption {
  padding: 0 6px 16px;
  text-align: left;
}

.table__title {
  display: block;
  font-size: 20px;
  font-weight: 700;
  letter-spacing: -0.01em;
}

.table__note {
  display: block;
  margin-top: 3px;
  font-size: 14px;
  color: var(--muted);
}

/* ---------------------------------------------------------------- the heads */
.table th {
  padding: 0;
  border-bottom: 1.5px solid var(--line);
  font-weight: 600;
  text-align: left;
}

.table th.num {
  text-align: right;
}

.head {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  padding: 10px 10px;
  border: 0;
  border-radius: 10px 10px 0 0;
  background: transparent;
  color: var(--muted);
  font: 600 13px 'Reddit Sans Variable', system-ui, sans-serif;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  cursor: pointer;
  transition: color 0.25s, background-color 0.25s;
  -webkit-tap-highlight-color: transparent;
}

.num .head {
  justify-content: flex-end;
}

@media (hover: hover) {
  .head:hover {
    color: var(--ink);
  }
}

th[aria-sort] .head {
  color: var(--accent);
  background: var(--sorted);
}

.head:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

/* the arrow: turned by the script; faint until the column is sorted */
.head svg {
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity 0.25s;
}

@media (hover: hover) {
  .head:hover svg {
    opacity: 0.4;
  }
}

th[aria-sort] .head svg {
  opacity: 1;
}

/* ---------------------------------------------------------------- the rows */
.table td {
  padding: 13px 10px;
  border-bottom: 1px solid var(--line);
  transition: background-color 0.35s;
}

.table td.num {
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.table td.is-sorted {
  background: var(--sorted);
}

@media (hover: hover) {
  .table tbody tr:hover td {
    background: var(--hover);
  }

  .table tbody tr:hover td.is-sorted {
    background: #ece9ff;
  }
}

.who {
  font-weight: 600;
}

.room {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 8px;
  background: var(--room);
  color: var(--room-ink);
  font-size: 13px;
  font-weight: 650;
}

/* the total with a bar behind it, as long as its share of the largest (its width is set by the script) */
.table td.total {
  position: relative;
}

.total__bar {
  position: absolute;
  right: 6px;
  top: 9px;
  bottom: 9px;
  border-radius: 7px;
  background: var(--bar);
  transform-origin: 100% 50%;
}

.total__value {
  position: relative;
  padding-right: 4px;
  font-weight: 650;
}

/* the rows on their way to a new place stand out a little */
.table tbody tr.is-moving td {
  background: #fbfaff;
}

@media (max-width: 480px) {
  .table {
    font-size: 14px;
  }

  .table td {
    padding: 12px 6px;
  }

  .head {
    padding: 10px 6px;
    font-size: 12px;
  }
}

.sr {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
