/*
 * Full register page styles (issues #94 and #111). Loaded after base.css. The table scrolls
 * inside its own box on a phone, so the page itself never scrolls sideways.
 */

.register-head {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  justify-content: space-between;
  gap: var(--space-4) var(--space-6);
}

.register-download {
  margin: 0;
}

.download-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  min-height: 3rem;
  padding: var(--space-2) var(--space-6);
  border: 2px solid rgb(255 255 255 / 60%);
  border-radius: var(--pill);
  color: var(--on-navy);
  font-weight: 700;
  text-decoration: none;
}

.download-button:hover {
  border-color: var(--on-navy);
  background: rgb(255 255 255 / 8%);
}

.register-body {
  display: grid;
  gap: var(--space-4);
  padding-top: var(--space-6);
}

/* Filter by type: pills on a phone, a side list on a wide screen. */

.type-filter {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-2);
  min-width: 0;
  margin: 0;
  padding: 0;
  border: 0;
}

.type-filter legend {
  margin-bottom: var(--space-2);
  padding: 0;
}

.type-option {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
  min-height: var(--tap);
  padding: var(--space-2) var(--space-4);
  border: 1px solid var(--rule);
  border-radius: var(--pill);
  background: var(--paper);
  color: var(--ink);
  font-weight: 500;
  cursor: pointer;
}

.type-option input {
  position: absolute;
  inset: 0;
  margin: 0;
  opacity: 0;
  cursor: pointer;
}

.type-option:hover {
  border-color: var(--sky);
}

.type-option:has(input:checked) {
  border-color: var(--navy);
  background: var(--navy);
  color: var(--on-navy);
  font-weight: 700;
}

.type-option:has(input:focus-visible) {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.type-count {
  color: inherit;
  font-variant-numeric: tabular-nums;
}

/* The table: its own scroll box on a phone. */

.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--rule);
  border-radius: var(--radius-lg);
  background: var(--paper);
}

.table-wrap:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
}

.register-table {
  width: 100%;
  min-width: 40rem;
  border-collapse: collapse;
}

.register-table thead th {
  padding: var(--space-3) var(--space-4);
  border-bottom: 1px solid var(--rule);
  background: var(--panel);
  color: var(--muted);
  font-size: 1rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-align: left;
  text-transform: uppercase;
}

.register-table tbody th,
.register-table td {
  padding: var(--space-2) var(--space-4);
  border-bottom: 1px solid var(--rule);
  text-align: left;
  vertical-align: middle;
}

.register-table tbody tr:last-child > * {
  border-bottom: 0;
}

.register-table tbody tr:hover {
  background: var(--panel);
}

.register-table tbody th a {
  display: flex;
  align-items: center;
  min-height: var(--tap);
  color: var(--ink);
  font-size: 1.0625rem;
  font-weight: 700;
  text-decoration: none;
  overflow-wrap: anywhere;
}

.register-table tbody th a:hover {
  color: var(--link);
  text-decoration: underline;
}

.register-supplier {
  color: var(--text);
  overflow-wrap: anywhere;
}

.type-tag {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--pill);
  background: var(--tile);
  color: var(--ink);
  font-weight: 600;
  white-space: nowrap;
}

@media (min-width: 64rem) {
  .register-body {
    grid-template-columns: 17rem minmax(0, 1fr);
    align-items: start;
    gap: var(--space-6);
  }

  .type-filter {
    flex-direction: column;
    flex-wrap: nowrap;
    gap: var(--space-1);
    padding: var(--space-4);
    border: 1px solid var(--rule);
    border-radius: var(--radius-lg);
    background: var(--paper);
  }

  .type-filter legend {
    float: left;
    width: 100%;
    margin: 0 0 var(--space-2);
  }

  .type-option {
    justify-content: space-between;
    border-color: transparent;
    border-radius: var(--radius-sm);
  }

  /* With no filter showing (no script, or an empty register), the table takes the whole width. */
  .register-body:not(:has(.type-filter:not([hidden]))) {
    grid-template-columns: minmax(0, 1fr);
  }
}
