.books-page {
  --books-surface: rgba(255, 255, 255, 0.28);
  --books-rule: rgba(36, 33, 29, 0.18);
  --books-control: rgba(255, 255, 255, 0.42);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.books-intro {
  max-width: 61rem;
  margin-bottom: clamp(3rem, 6vw, 5rem);
}

.books-heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 2rem;
  padding-bottom: clamp(1.25rem, 2.5vw, 2rem);
  border-bottom: 1px solid var(--ink);
}

.books-heading-row h1 {
  max-width: 12ch;
  margin: 0;
}

.books-deck {
  max-width: 48rem;
  margin: 1.4rem 0 0;
  color: #504a42;
  font-size: clamp(1.08rem, 2vw, 1.32rem);
  line-height: 1.55;
}

.books-catalog {
  position: relative;
}

.books-toolbar {
  display: grid;
  grid-template-columns: minmax(15rem, 1fr) minmax(10rem, 0.34fr) minmax(11rem, 0.34fr) auto;
  align-items: end;
  gap: 0.85rem;
  padding: 1rem;
  border: 1px solid var(--books-rule);
  background: var(--books-surface);
}

.books-toolbar label {
  display: grid;
  gap: 0.42rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

.books-toolbar input,
.books-toolbar select,
.books-reset {
  min-height: 2.85rem;
  border: 1px solid var(--books-rule);
  border-radius: 0;
  color: var(--ink);
  background: var(--books-control);
  font: 500 0.86rem/1.2 var(--sans);
}

.books-toolbar input,
.books-toolbar select {
  width: 100%;
}

.books-toolbar input {
  padding: 0.75rem 0.8rem 0.75rem 2.55rem;
  border: 0;
  background: transparent;
}

.books-toolbar select {
  padding: 0.72rem 2rem 0.72rem 0.8rem;
}

.books-search-field {
  position: relative;
  display: block;
  border: 1px solid var(--books-rule);
  background: var(--books-control);
}

.books-search-field svg {
  position: absolute;
  top: 50%;
  left: 0.85rem;
  transform: translateY(-50%);
  fill: none;
  stroke: var(--muted);
  stroke-linecap: round;
  stroke-width: 1.7;
  pointer-events: none;
}

.books-toolbar input:focus,
.books-toolbar select:focus,
.books-reset:focus-visible,
.books-search-field:focus-within {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.books-toolbar input:focus {
  outline: 0;
}

.books-reset {
  padding: 0.72rem 1rem;
  cursor: pointer;
}

.books-reset:hover {
  color: var(--accent);
  border-color: var(--accent);
}

.books-results {
  margin: 0;
  padding: 0.85rem 0;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.68rem;
  font-variant-numeric: tabular-nums;
  font-weight: 650;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.books-table-frame {
  border-top: 1px solid var(--ink);
  border-bottom: 1px solid var(--ink);
}

.books-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.books-table th {
  padding: 0.78rem 0.65rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.61rem;
  font-weight: 750;
  letter-spacing: 0.12em;
  text-align: left;
  text-transform: uppercase;
}

.books-table th:nth-child(1) { width: 34%; }
.books-table th:nth-child(2) { width: 27%; }
.books-table th:nth-child(3) { width: 10%; }
.books-table th:nth-child(4) { width: 29%; }

.books-table td {
  padding: 1.15rem 0.65rem;
  border-top: 1px solid var(--books-rule);
  vertical-align: top;
}

.books-table tbody tr {
  transition: background-color 170ms ease;
}

.books-table tbody tr:hover {
  background: rgba(255, 255, 255, 0.23);
}

.book-title-wrap {
  display: grid;
  grid-template-columns: 2rem minmax(0, 1fr);
  gap: 0.25rem;
}

.book-number {
  padding-top: 0.15rem;
  color: #9a9287;
  font-family: var(--sans);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.book-title,
a.book-title {
  display: block;
  color: var(--ink);
  font-size: 1.01rem;
  font-weight: 600;
  line-height: 1.3;
  text-decoration-color: transparent;
}

a.book-title::after {
  content: " ↗";
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.72em;
  opacity: 0;
  transition: opacity 170ms ease;
}

a.book-title:hover::after,
a.book-title:focus-visible::after {
  opacity: 1;
}

.book-author {
  display: block;
  margin-top: 0.35rem;
  color: var(--muted);
  font-family: var(--sans);
  font-size: 0.72rem;
  line-height: 1.35;
}

.book-topics {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
}

.book-topic {
  padding: 0.3rem 0.5rem;
  border: 1px solid #c9bdb0;
  border-radius: 999px;
  color: #5d554b;
  background: transparent;
  font: 600 0.59rem/1 var(--sans);
  letter-spacing: 0.025em;
  cursor: pointer;
}

.book-topic:hover,
.book-topic:focus-visible {
  color: var(--accent);
  border-color: var(--accent);
  outline: 0;
}

.book-rating {
  display: inline-flex;
  align-items: baseline;
  color: var(--accent);
  font-family: var(--sans);
  font-variant-numeric: tabular-nums;
}

.book-rating strong {
  font-size: 1.2rem;
  font-weight: 650;
  line-height: 1;
}

.book-rating-denominator {
  color: var(--muted);
  font-size: 0.62rem;
}

.book-notes summary {
  width: fit-content;
  color: var(--accent);
  font-family: var(--sans);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
}

.book-notes summary:hover {
  color: #702a20;
}

.book-notes p {
  margin: 0.75rem 0 0;
  color: #514a41;
  font-size: 0.84rem;
  line-height: 1.55;
}

.book-no-notes {
  color: var(--muted);
}

.books-empty {
  padding: 4.5rem 1rem;
  text-align: center;
}

.books-empty p {
  margin-bottom: 1rem;
  font-size: 1.25rem;
}

.books-empty button {
  border: 0;
  color: var(--accent);
  background: transparent;
  font: 700 0.72rem var(--sans);
  text-decoration: underline;
  text-underline-offset: 0.25em;
  cursor: pointer;
}

@media (max-width: 900px) {
  .books-toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .books-search {
    grid-column: 1 / -1;
  }

  .books-table th:nth-child(1) { width: 40%; }
  .books-table th:nth-child(2) { width: 30%; }
  .books-table th:nth-child(3) { width: 12%; }
  .books-table th:nth-child(4) { width: 18%; }
}

@media (max-width: 680px) {
  .books-heading-row {
    align-items: flex-end;
  }

  .books-deck {
    font-size: 1.05rem;
  }

  .books-toolbar {
    grid-template-columns: 1fr;
  }

  .books-search {
    grid-column: auto;
  }

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

  .books-table thead {
    display: none;
  }

  .books-table tbody tr {
    display: grid;
    grid-template-columns: 1fr auto;
    gap: 0.9rem 1rem;
    padding: 1.4rem 0.15rem;
    border-top: 1px solid var(--books-rule);
  }

  .books-table tbody tr:first-child {
    border-top: 0;
  }

  .books-table td {
    padding: 0;
    border: 0;
  }

  .books-table td:nth-child(1) {
    grid-column: 1;
  }

  .books-table td:nth-child(2) {
    grid-column: 1;
  }

  .books-table td:nth-child(3) {
    grid-column: 2;
    grid-row: 1;
  }

  .books-table td:nth-child(4) {
    grid-column: 1 / -1;
  }

  .book-title-wrap {
    grid-template-columns: 1.7rem minmax(0, 1fr);
  }

  .book-notes p {
    max-width: 38rem;
  }
}

@media print {
  .books-toolbar,
  .books-results,
  .book-number {
    display: none !important;
  }

  .books-table th:nth-child(4),
  .books-table td:nth-child(4) {
    width: 32%;
  }

  .book-notes summary {
    display: none;
  }

  .book-notes p {
    display: block;
    margin-top: 0;
  }
}
