/* ============================================================
   The Reading Room — Library styles
   Aesthetic: warm editorial / private library.
   Cream paper, ink, terracotta + gold accents.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Fraunces:ital,opsz,wght@0,9..144,400;0,9..144,600;0,9..144,900;1,9..144,500&family=Hanken+Grotesk:wght@400;500;600;700&display=swap');

:root {
  --paper: #f4efe6;
  --paper-2: #ece4d6;
  --ink: #211c17;
  --ink-soft: #5d5448;
  --line: #d9cfbe;
  --terracotta: #b4532a;
  --terracotta-deep: #8f3d1c;
  --gold: #b78b2e;
  --shadow: rgba(33, 28, 23, 0.16);
  --display: 'Fraunces', Georgia, serif;
  --body: 'Hanken Grotesk', system-ui, sans-serif;
  --radius: 4px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { -webkit-text-size-adjust: 100%; }

body {
  font-family: var(--body);
  color: var(--ink);
  background-color: var(--paper);
  background-image:
    radial-gradient(circle at 15% 0%, rgba(183,139,46,0.06), transparent 40%),
    radial-gradient(circle at 100% 100%, rgba(180,83,42,0.05), transparent 45%),
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)' opacity='0.025'/%3E%3C/svg%3E");
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; }

/* ---------- Header ---------- */
.masthead {
  max-width: 1200px;
  margin: 0 auto;
  padding: clamp(32px, 6vw, 72px) clamp(20px, 5vw, 56px) 24px;
}
.masthead .rule {
  height: 2px;
  background: var(--ink);
  margin-bottom: 18px;
}
.masthead .eyebrow {
  font-size: 12px;
  letter-spacing: 0.32em;
  text-transform: uppercase;
  color: var(--terracotta-deep);
  font-weight: 700;
  margin-bottom: 10px;
}
.masthead h1 {
  font-family: var(--display);
  font-weight: 900;
  font-size: clamp(40px, 9vw, 88px);
  line-height: 0.92;
  letter-spacing: -0.02em;
  font-optical-sizing: auto;
}
.masthead .tagline {
  font-family: var(--display);
  font-style: italic;
  font-weight: 500;
  font-size: clamp(16px, 2.4vw, 22px);
  color: var(--ink-soft);
  margin-top: 14px;
  max-width: 44ch;
}

/* ---------- Toolbar ---------- */
.toolbar {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 clamp(20px, 5vw, 56px);
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: space-between;
}
.search {
  position: relative;
  flex: 1 1 280px;
  max-width: 420px;
}
.search input {
  width: 100%;
  font-family: var(--body);
  font-size: 15px;
  color: var(--ink);
  background: rgba(255,255,255,0.55);
  border: 1.5px solid var(--line);
  border-radius: 999px;
  padding: 12px 18px 12px 42px;
  outline: none;
  transition: border-color .2s, background .2s;
}
.search input:focus { border-color: var(--terracotta); background: #fff; }
.search svg {
  position: absolute; left: 15px; top: 50%; transform: translateY(-50%);
  width: 17px; height: 17px; color: var(--ink-soft);
}
.filters { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  font-family: var(--body);
  font-size: 13px; font-weight: 600;
  letter-spacing: 0.02em;
  padding: 8px 16px;
  border-radius: 999px;
  border: 1.5px solid var(--line);
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: all .18s;
  white-space: nowrap;
}
.chip:hover { border-color: var(--ink); color: var(--ink); }
.chip[aria-pressed="true"] {
  background: var(--ink); color: var(--paper); border-color: var(--ink);
}

/* ---------- Shelf / grid ---------- */
.shelf {
  max-width: 1200px;
  margin: 0 auto;
  padding: 36px clamp(20px, 5vw, 56px) 80px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: clamp(24px, 4vw, 44px) clamp(20px, 3vw, 34px);
}

.book {
  position: relative;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  opacity: 0;
  transform: translateY(14px);
  animation: rise .6s cubic-bezier(.2,.7,.2,1) forwards;
}
@keyframes rise { to { opacity: 1; transform: none; } }

.book .cover-wrap {
  position: relative;
  aspect-ratio: 3 / 4;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  background: var(--paper-2);
  box-shadow:
    0 1px 0 rgba(255,255,255,0.6) inset,
    8px 10px 22px -8px var(--shadow);
  transition: transform .35s cubic-bezier(.2,.7,.2,1), box-shadow .35s;
}
/* book spine */
.book .cover-wrap::before {
  content: "";
  position: absolute; left: 0; top: 0; bottom: 0; width: 9px; z-index: 3;
  background: linear-gradient(90deg, rgba(0,0,0,0.22), rgba(0,0,0,0.04) 60%, transparent);
}
.book .cover-wrap::after {
  content: "";
  position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background: linear-gradient(115deg, rgba(255,255,255,0.18), transparent 40%);
}
.book:hover .cover-wrap {
  transform: translateY(-6px) perspective(800px) rotateY(-6deg);
  box-shadow: 14px 18px 38px -10px var(--shadow);
}
.book .share-btn {
  position: absolute; top: 8px; right: 8px; z-index: 4;
  width: 34px; height: 34px; border-radius: 50%; padding: 0;
  display: inline-flex; align-items: center; justify-content: center;
  border: 1px solid rgba(255,255,255,0.28);
  background: rgba(20,16,12,0.55); color: #fff; cursor: pointer;
  -webkit-backdrop-filter: blur(4px); backdrop-filter: blur(4px);
  opacity: 0; transform: translateY(-2px);
  transition: opacity .2s, transform .2s, background .2s;
}
.book .share-btn svg { width: 16px; height: 16px; }
.book:hover .share-btn, .book .share-btn:focus-visible { opacity: 1; transform: none; }
.book .share-btn:hover { background: rgba(20,16,12,0.82); }
@media (hover: none) { .book .share-btn { opacity: 1; transform: none; } }
.book .cover-img, .book .cover-canvas {
  width: 100%; height: 100%; object-fit: cover; display: block;
}
.book .cover-fallback {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; justify-content: flex-end;
  padding: 18px;
  background:
    linear-gradient(160deg, var(--ink), #3a312a);
  color: var(--paper);
}
.book .cover-fallback .ff-kicker {
  font-size: 10px; letter-spacing: 0.28em; text-transform: uppercase;
  color: var(--gold); font-weight: 700; margin-bottom: 8px;
}
.book .cover-fallback .ff-title {
  font-family: var(--display); font-weight: 600; font-size: 19px; line-height: 1.1;
}
.cover-skeleton {
  position: absolute; inset: 0;
  background: linear-gradient(100deg, var(--paper-2) 30%, #f0e9dc 50%, var(--paper-2) 70%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite;
}
@keyframes shimmer { to { background-position: -200% 0; } }

.book .meta { padding: 14px 2px 0; }
.book .b-title {
  font-family: var(--display);
  font-weight: 600;
  font-size: 17px;
  line-height: 1.18;
  letter-spacing: -0.01em;
}
.book .b-sub {
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  margin-top: 7px;
  font-size: 12.5px; color: var(--ink-soft);
}
.book .b-sub .dot { width: 3px; height: 3px; border-radius: 50%; background: var(--line); }
.book .views {
  display: inline-flex; align-items: center; gap: 5px;
  color: var(--terracotta-deep); font-weight: 600;
}
.book .views svg { width: 14px; height: 14px; }
.book .views.loading { opacity: .35; }

/* ---------- Empty / states ---------- */
.empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: var(--ink-soft);
}
.empty .e-mark { font-family: var(--display); font-size: 56px; color: var(--line); }
.empty h2 { font-family: var(--display); font-weight: 600; margin: 12px 0 6px; color: var(--ink); }
.empty code {
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--paper-2); padding: 2px 8px; border-radius: 4px; font-size: 13px;
}

.foot {
  max-width: 1200px; margin: 0 auto;
  padding: 0 clamp(20px,5vw,56px) 56px;
  font-size: 12.5px; color: var(--ink-soft);
  display: flex; justify-content: space-between; gap: 16px; flex-wrap: wrap;
  border-top: 1px solid var(--line); padding-top: 22px;
}
.foot .count { font-weight: 600; color: var(--ink); }

@media (max-width: 540px) {
  .shelf { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 26px 18px; }
  .toolbar { gap: 12px; }
  .filters { width: 100%; overflow-x: auto; padding-bottom: 4px; }
}
