/* The library page. Builds on site.css: same tokens, type and row layout. */

.cat-head { padding: 40px 0 6px; }
.cat-head h1 { margin: 0 0 14px; font-size: clamp(40px, 4.4vw, 58px); line-height: 1.04; letter-spacing: -.012em; }
.cat-head .lede { max-width: 760px; font-size: 23px; line-height: 1.5; text-wrap: pretty; }

/* Spines: one per book, drawn to its page count */
.spines-wrap { position: relative; margin: 44px 0 4px; }
.spines-scroll { overflow-x: auto; scrollbar-width: none; }
.spines-scroll::-webkit-scrollbar { display: none; }
.spines { display: flex; align-items: flex-end; gap: 2px; height: 104px; padding: 8px 2px 0; border-bottom: 2px solid var(--ink); }
.spine { flex: var(--w) 1 0; min-width: 2px; height: var(--h); border-radius: 1px 1px 0 0; background: var(--ink); opacity: var(--o); cursor: pointer; transition: opacity .2s ease, transform .2s ease; }
.spine.reading { background: var(--link); opacity: .95; }
.spine:hover { opacity: 1; transform: translateY(-5px); }
.spines.filtered .spine:not(.on) { opacity: .07; }
.spine-tip {
  position: absolute; top: 0; left: 0; z-index: 5;
  display: flex; flex-direction: column; gap: 1px;
  max-width: min(360px, 90vw); padding: 7px 11px; border-radius: 6px;
  background: var(--ink); color: var(--bg);
  font-family: 'Hedvig Letters Sans', Arial, sans-serif; font-size: 13px; line-height: 1.35;
  transform: translate(-50%, calc(-100% - 4px)); pointer-events: none;
}
.spine-tip[hidden] { display: none; }
.spine-tip .tt { font-family: 'Hedvig Letters Serif', Georgia, serif; font-size: 15px; }
.spine-tip .tm { opacity: .72; }

/* Search and shelf filters */
.cat-tools { display: flex; flex-direction: column; gap: 14px; padding: 22px 0 18px; }
.cat-tools[hidden] { display: none; }
.cat-search { width: 100%; max-width: 420px; padding: 10px 2px; border: 0; border-bottom: 1px solid var(--hair); border-radius: 0; background: transparent; color: var(--ink); font-size: 16px; }
.cat-search::placeholder { color: var(--muted); }
.cat-search:focus { outline: none; border-bottom-color: var(--ink); }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip { cursor: pointer; min-height: 34px; padding: 0 13px; border: 1px solid var(--hair); border-radius: 999px; background: transparent; color: var(--ink); font: inherit; font-size: 13px; letter-spacing: .02em; transition: border-color .2s ease, background-color .2s ease, color .2s ease; }
.chip:hover { border-color: var(--ink); }
.chip .n { margin-left: 3px; font-size: 12px; color: var(--muted); }
.chip[aria-pressed="true"] { border-color: var(--ink); background: var(--ink); color: var(--bg); }
.chip[aria-pressed="true"] .n { color: inherit; opacity: .7; }

/* Shelves */
.cat-shelf { grid-template-columns: 160px minmax(0, 1fr); padding: 34px 0; }
.cat-shelf[hidden] { display: none; }
.books { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); column-gap: 36px; margin: 0; padding: 0; list-style: none; }
.books li {
  display: grid; grid-template-columns: minmax(0, 1fr) auto; column-gap: 14px;
  padding: 9px 6px 10px; margin: 0 -6px; border-bottom: 1px solid var(--hair); border-radius: 3px;
  scroll-margin-top: 140px; transition: background-color .8s ease;
}
.books li[hidden] { display: none; }
.books li.flash { background: var(--soft); transition: none; }
.bk-title { grid-column: 1; font-size: 18px; line-height: 1.3; text-wrap: pretty; }
.bk-author { grid-column: 1; margin-top: 2px; font-size: 13px; }
.bk-pages { grid-column: 2; grid-row: 1 / span 2; align-self: center; font-size: 12px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tag { display: inline-block; margin-left: 8px; padding: 0 7px; border: 1px solid var(--hair); border-radius: 999px; font-family: 'Hedvig Letters Sans', Arial, sans-serif; font-size: 11px; letter-spacing: .06em; line-height: 18px; text-transform: uppercase; color: var(--muted); vertical-align: 3px; white-space: nowrap; }
.books li[data-reading] .tag { border-color: currentColor; color: var(--link); }
.cat-empty { padding: 28px 0 40px; }
.cat-empty[hidden] { display: none; }

@media (max-width: 900px) {
  .books { grid-template-columns: 1fr; }
  .cat-shelf { grid-template-columns: 1fr; gap: 10px; }
}
@media (max-width: 760px) {
  .cat-head .lede { font-size: 21px; }
  .spines-scroll { -webkit-mask-image: linear-gradient(to right, #000 86%, transparent); mask-image: linear-gradient(to right, #000 86%, transparent); }
  .spines { min-width: 760px; height: 84px; }
}
