/* B2 Library website. Shares the B2 Reader's colours and fonts. */
:root {
  --bg: #eef0f3;
  --paper: #fbfbfc;
  --ink: #1d2130;
  --muted: #5d6273;
  --line: #d9dce3;
  --accent: #a8391f;
  --accent-ink: #ffffff;
  --chip: #e3e6ec;
  --font-read: "Literata", Georgia, "Times New Roman", serif;
  --font-ui: "Inter", system-ui, -apple-system, "Segoe UI", sans-serif;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #0d0f15; --paper: #151821; --ink: #e4e2dc; --muted: #9a9fb0;
    --line: #2a2e3b; --accent: #e2714f; --accent-ink: #14161d; --chip: #1f2330; color-scheme: dark;
  }
}
:root[data-theme="dark"] {
  --bg: #0d0f15; --paper: #151821; --ink: #e4e2dc; --muted: #9a9fb0;
  --line: #2a2e3b; --accent: #e2714f; --accent-ink: #14161d; --chip: #1f2330; color-scheme: dark;
}

* { box-sizing: border-box; }
html, body { margin: 0; }
body { background: var(--bg); color: var(--ink); font: 15px/1.5 var(--font-ui); }
a { color: inherit; }
img { display: block; max-width: 100%; }

.bar {
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 10px max(16px, env(safe-area-inset-left, 0px));
  background: var(--bg); border-bottom: 1px solid var(--line);
}
.brand { font-weight: 700; letter-spacing: 0.02em; text-decoration: none; flex: 1; min-width: 0; white-space: nowrap; }
.brand small { font-weight: 500; color: var(--muted); margin-left: 6px; }
@media (max-width: 420px) { .brand small { display: none; } }

.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-size: 14px; font-weight: 600; text-decoration: none;
  color: var(--ink); background: var(--paper);
  border: 1px solid var(--line); border-radius: 8px; padding: 8px 14px; cursor: pointer;
}
.btn.primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn[hidden] { display: none; }
.bar { flex-wrap: wrap; row-gap: 8px; }
.bar .back { padding: 8px 12px; }
.bar .back span[aria-hidden] { font-size: 20px; line-height: 14px; }
@media (max-width: 560px) {
  .bar { gap: 8px; }
  .bar .btn { padding: 7px 10px; font-size: 13px; }
  .bar .back-text, .bar .wide { display: none; }
}
.btn:focus-visible, .chip:focus-visible, input:focus-visible, .card:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

main { max-width: 1040px; margin: 0 auto; padding: 0 16px 64px; }

.hero { padding: 40px 0 16px; }
.hero h1 { font: 600 clamp(28px, 5vw, 40px)/1.15 var(--font-read); margin: 0 0 8px; }
.hero p { color: var(--muted); margin: 0; max-width: 560px; }

.finder { position: sticky; top: 53px; z-index: 4; background: var(--bg); padding: 16px 0 12px; }
.search { display: flex; }
.search input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; color: var(--ink);
  background: var(--paper); border: 1px solid var(--line); border-radius: 10px; padding: 11px 14px;
}
.chips { display: flex; gap: 8px; overflow-x: auto; padding: 12px 0 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; font: inherit; font-size: 14px; color: var(--ink);
  background: var(--chip); border: 1px solid transparent; border-radius: 999px; padding: 6px 12px; cursor: pointer;
}
.chip[aria-pressed="true"] { background: var(--ink); color: var(--bg); }
.chip span { opacity: 0.65; margin-left: 4px; }

.count { color: var(--muted); font-size: 14px; margin: 8px 0 16px; }
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 28px 20px; }
@media (max-width: 420px) { .grid { grid-template-columns: repeat(2, 1fr); gap: 24px 14px; } }
.card[hidden] { display: none; }
.card { display: block; text-decoration: none; border-radius: 8px; }
.cover {
  aspect-ratio: 2 / 3; width: 100%; object-fit: cover; border-radius: 6px;
  background: var(--chip); box-shadow: 0 1px 2px rgba(0,0,0,.12), 0 6px 18px rgba(0,0,0,.10);
  transition: transform .15s ease;
}
.card:hover .cover { transform: translateY(-3px); }
.card h2 { font-size: 15px; line-height: 1.3; margin: 12px 0 2px; }
.card p { font-size: 13px; color: var(--muted); margin: 0; }
.empty { color: var(--muted); padding: 32px 0; }

/* Book page */
.crumbs { padding: 20px 0 0; font-size: 14px; color: var(--muted); }
.crumbs a { color: var(--muted); }
.book { display: grid; grid-template-columns: minmax(180px, 280px) 1fr; gap: 40px; padding: 24px 0; align-items: start; }
@media (max-width: 680px) {
  .book { grid-template-columns: 1fr; gap: 24px; }
  .book .cover { max-width: 220px; margin: 0 auto; }
}
.book h1 { font: 600 clamp(28px, 5vw, 40px)/1.15 var(--font-read); margin: 0; }
.book .subtitle { font: italic 18px/1.4 var(--font-read); color: var(--muted); margin: 6px 0 0; }
.book .by { margin: 14px 0 0; }
.book .desc { font: 17px/1.6 var(--font-read); margin: 20px 0 0; max-width: 60ch; }
.actions { display: flex; flex-wrap: wrap; gap: 10px; margin: 24px 0 0; }
.actions .btn { padding: 11px 18px; font-size: 15px; }
.tags { display: flex; flex-wrap: wrap; gap: 8px; margin: 16px 0 0; }
.tags a { text-decoration: none; }
.facts { display: grid; grid-template-columns: max-content 1fr; gap: 8px 20px; margin: 28px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); font-size: 14px; }
.facts dt { color: var(--muted); }
.facts dd { margin: 0; }
.note { font-size: 13px; color: var(--muted); margin: 12px 0 0; }

footer { max-width: 1040px; margin: 0 auto; padding: 24px 16px 40px; color: var(--muted); font-size: 13px; border-top: 1px solid var(--line); }
footer a { color: var(--muted); }
.card .price-tag { margin-top: 4px; font-weight: 600; color: #2e7d32; }
.card .price-tag.paid { color: var(--accent); }
.owned { color: #2e7d32; font-weight: 600; align-self: center; }
