:root {
  --ink: #18352c;
  --forest: #224b3d;
  --forest-light: #2e6250;
  --paper: #ffffff;
  --paper-deep: #e9dfcf;
  --cream: #ffffff;
  --rust: #c85d3f;
  --gold: #d9a441;
  --muted: #6b746d;
  --line: rgba(24, 53, 44, 0.16);
  --sans: "DM Sans", system-ui, sans-serif;
  --serif: "Newsreader", Georgia, serif;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; background: #fff; }
body { margin: 0; color: var(--ink); background: var(--paper); font-family: var(--sans); }
button, input, select { font: inherit; }
button, select { cursor: pointer; }
.wrap { width: min(1180px, calc(100% - 40px)); margin-inline: auto; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

h1, h2, h3 { font-family: var(--serif); font-weight: 600; }
h1 { margin: 0; font-size: clamp(36px, 5vw, 54px); line-height: 1; letter-spacing: -.035em; }

.catalogue { padding-block: 36px 60px; }
.section-heading { display: flex; align-items: end; justify-content: space-between; gap: 30px; margin-bottom: 36px; }
h2 { margin: 0; font-size: clamp(42px, 6vw, 68px); letter-spacing: -.035em; }
.result-summary { margin: 0 0 10px; color: var(--muted); font-size: 14px; }
.result-summary strong { color: var(--ink); }
.search-panel { padding: 20px; background: var(--cream); border: 1px solid var(--line); border-radius: 5px; box-shadow: 0 14px 35px rgba(34,50,40,.06); }
.search-box { height: 66px; display: flex; align-items: center; gap: 16px; padding: 0 20px; background: var(--paper); border: 1px solid transparent; border-radius: 3px; transition: border-color .2s, background .2s; }
.search-box:focus-within { background: white; border-color: var(--forest-light); }
.search-box input { flex: 1; min-width: 0; color: var(--ink); background: transparent; border: 0; outline: 0; font-family: var(--serif); font-size: 21px; }
.search-box input::placeholder { color: #89918c; }
.search-icon { width: 18px; height: 18px; border: 2px solid var(--forest); border-radius: 50%; position: relative; flex: 0 0 auto; }
.search-icon::after { content: ""; width: 7px; height: 2px; background: var(--forest); position: absolute; right: -5px; bottom: -2px; transform: rotate(45deg); }
kbd { padding: 3px 8px; color: var(--muted); background: var(--cream); border: 1px solid var(--line); border-radius: 3px; font: 12px var(--sans); }
.filters { display: grid; grid-template-columns: 1.4fr .8fr 1fr auto; gap: 12px; margin-top: 18px; align-items: end; }
.filters label { display: flex; flex-direction: column; gap: 7px; color: var(--muted); font-size: 10px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
select { width: 100%; height: 44px; padding: 0 36px 0 12px; color: var(--ink); background: var(--cream); border: 1px solid var(--line); border-radius: 3px; font-size: 13px; text-transform: none; }
.clear-button { height: 44px; padding: 0 15px; color: var(--rust); background: transparent; border: 0; font-size: 12px; font-weight: 700; white-space: nowrap; }
.clear-button:disabled { opacity: .35; cursor: default; }
.active-filters { display: flex; flex-wrap: wrap; gap: 8px; min-height: 39px; padding-top: 14px; }
.filter-chip { padding: 6px 10px; color: var(--forest); background: rgba(34,75,61,.08); border: 0; border-radius: 30px; font-size: 11px; }
.filter-chip span { margin-left: 5px; opacity: .55; }

.results { border-top: 1px solid var(--line); }
.book-card { min-height: 165px; display: grid; grid-template-columns: 8px minmax(0,1fr) 225px; gap: 28px; padding: 28px 20px 28px 0; border-bottom: 1px solid var(--line); transition: background .2s, transform .2s; }
.book-card:hover { background: rgba(255,253,248,.65); transform: translateX(4px); }
.spine { width: 4px; height: 100%; min-height: 100px; background: var(--gold); border-radius: 3px; }
.book-card:nth-child(3n+2) .spine { background: var(--rust); }
.book-card:nth-child(3n) .spine { background: var(--forest-light); }
.book-main { align-self: center; min-width: 0; }
.book-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 11px; }
.category-pill { display: inline-block; padding: 5px 9px; color: var(--forest); background: rgba(34,75,61,.09); border-radius: 30px; font-size: 10px; font-weight: 700; letter-spacing: .05em; text-transform: uppercase; }
.language { color: var(--muted); font-size: 11px; }
.book-card h3 { margin: 0 0 8px; font-size: clamp(22px,3vw,29px); line-height: 1.12; letter-spacing: -.018em; }
.author { margin: 0; color: var(--muted); font-size: 14px; }
.book-aside { display: grid; grid-template-columns: 1fr; align-content: center; gap: 15px; border-left: 1px solid var(--line); padding-left: 28px; }
.year { font-family: var(--serif); font-size: 20px; }
.detail-button { grid-column: 1 / -1; justify-self: start; padding: 0 0 3px; color: var(--rust); background: transparent; border: 0; border-bottom: 1px solid currentColor; font-size: 12px; font-weight: 700; }
.detail-button span { margin-left: 4px; }
.empty-state { padding: 80px 20px; text-align: center; border-top: 1px solid var(--line); }
.empty-state > span { font: 64px var(--serif); color: var(--paper-deep); }
.empty-state h3 { margin: 10px 0 5px; font-size: 30px; }
.empty-state p { color: var(--muted); }
.button { padding: 11px 17px; color: white; background: var(--forest); border: 0; border-radius: 3px; }
.pagination { display: flex; justify-content: center; align-items: center; gap: 6px; margin-top: 42px; }
.pagination button { min-width: 40px; height: 40px; padding: 0 12px; color: var(--ink); background: transparent; border: 1px solid var(--line); border-radius: 3px; }
.pagination button:hover:not(:disabled), .pagination button[aria-current="page"] { color: white; background: var(--forest); border-color: var(--forest); }
.pagination button:disabled { opacity: .35; cursor: default; }
.pagination .ellipsis { padding: 0 6px; color: var(--muted); }

dialog { width: min(680px, calc(100% - 28px)); max-height: min(80vh, 760px); padding: 0; color: var(--ink); background: var(--cream); border: 0; border-radius: 5px; box-shadow: 0 30px 90px rgba(0,0,0,.3); }
dialog::backdrop { background: rgba(11,31,25,.73); backdrop-filter: blur(3px); }
.dialog-close { position: sticky; float: right; top: 16px; right: 16px; z-index: 2; width: 38px; height: 38px; color: var(--ink); background: var(--paper); border: 0; border-radius: 50%; font-size: 24px; }
#dialog-content { padding: 52px; }
.dialog-kicker { margin: 0 0 12px; color: var(--rust); font-size: 11px; font-weight: 700; letter-spacing: .12em; text-transform: uppercase; }
#dialog-content h2 { max-width: 540px; font-size: clamp(34px,6vw,50px); line-height: 1; }
.dialog-author { margin: 14px 0 35px; color: var(--muted); font-size: 16px; }
.detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0; margin: 0; border-top: 1px solid var(--line); }
.detail-grid div { padding: 16px 10px 16px 0; border-bottom: 1px solid var(--line); }
.detail-grid div:nth-child(odd) { border-right: 1px solid var(--line); }
.detail-grid div:nth-child(even) { padding-left: 20px; }
.detail-grid dt { margin-bottom: 5px; color: var(--muted); font-size: 9px; font-weight: 700; letter-spacing: .1em; text-transform: uppercase; }
.detail-grid dd { margin: 0; overflow-wrap: anywhere; font-size: 13px; }
.error { padding: 50px; color: var(--rust); text-align: center; }

@media (max-width: 800px) {
  .filters { grid-template-columns: 1fr 1fr; }
  .clear-button { grid-column: 1 / -1; justify-self: start; }
  .book-card { grid-template-columns: 6px 1fr; gap: 18px; padding-right: 6px; }
  .book-aside { grid-column: 2; grid-template-columns: auto 1fr; padding: 0; border: 0; align-items: center; }
  .detail-button { grid-column: auto; justify-self: end; }
}

@media (max-width: 560px) {
  .wrap { width: min(100% - 28px, 1180px); }
  .catalogue { padding-block: 26px 44px; }
  .section-heading { display: block; }
  .result-summary { margin-top: 14px; }
  .search-panel { padding: 12px; }
  .search-box { height: 58px; padding: 0 14px; }
  .search-box input { font-size: 17px; }
  kbd { display: none; }
  .filters { grid-template-columns: 1fr; }
  .book-card { min-height: 0; padding-block: 23px; }
  .book-card h3 { font-size: 23px; }
  .book-aside { grid-template-columns: auto 1fr; }
  .detail-button { grid-column: 1 / -1; justify-self: start; }
  .pagination button.page-number { display: none; }
  .pagination button[aria-current="page"] { display: block; }
  .pagination .ellipsis { display: none; }
  #dialog-content { padding: 48px 24px 30px; }
  .detail-grid { grid-template-columns: 1fr; }
  .detail-grid div:nth-child(odd) { border-right: 0; }
  .detail-grid div:nth-child(even) { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition-duration: .01ms !important; }
}
