/* P's Library: warm wood, lantern light, covers shown whole. */
:root {
  --ink: #fbf3e4;
  --ink-soft: #e6d6bd;
  --ink-dim: #c4ad8c;
  --amber: #f3b25b;
  --amber-deep: #c9772b;
  --night: #140c07;
  --panel: rgba(30, 19, 11, .86);
  --panel-solid: #24170e;
  --line: rgba(243, 178, 91, .28);
  --focus: #ffd98a;
  --wood-1: #8a5530;
  --wood-2: #6b3f20;
  --wood-3: #4a2a14;
  --cover-h: 190px;
  --caption-w: 150px;
  --radius: 10px;
  --shadow-book: 0 10px 18px -6px rgba(0,0,0,.65), 0 2px 4px rgba(0,0,0,.4);
  --font-display: 'Fraunces', Georgia, 'Times New Roman', serif;
  --font-ui: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
@media (max-width: 640px) { :root { --cover-h: 140px; --caption-w: 112px; } }

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-ui);
  color: var(--ink);
  background: var(--night);
  line-height: 1.5;
  overflow-x: hidden;
}
img { max-width: 100%; }
button, select, input { font: inherit; color: inherit; }
:focus-visible { outline: 3px solid var(--focus); outline-offset: 3px; border-radius: 6px; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.skip-link { position: absolute; left: 12px; top: -60px; z-index: 50; background: var(--amber); color: #2a1608; padding: 10px 14px; border-radius: 8px; font-weight: 800; text-decoration: none; }
.skip-link:focus { top: 12px; }

/* ---------- scene ---------- */
.scene { position: fixed; inset: 0; z-index: -1; overflow: hidden;
  background:
    radial-gradient(ellipse at 50% 30%, rgba(243,178,91,.22), transparent 60%),
    linear-gradient(180deg, #2b1a0e 0%, #1d120a 55%, #120b06 100%); }
.scene-photo { position: absolute; inset: 0; background-size: cover; background-position: center 30%; opacity: 0; transition: opacity .8s ease; }
body.has-photo .scene-photo { opacity: 1; background-image: url('background.jpg'); }
@media (max-width: 800px) { body.has-photo.has-mobile-photo .scene-photo { background-image: url('background-mobile.jpg'); } }
body.has-photo .scene-art { display: none; }
.scene-art { position: absolute; inset: 0; width: 100%; height: 100%; }
.scene-shade { position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(10,6,3,.25) 0%, rgba(10,6,3,.35) 30%, rgba(10,6,3,.72) 70%, rgba(10,6,3,.88) 100%); }
body.has-photo .scene-shade { backdrop-filter: blur(1.5px); }
@media (prefers-reduced-motion: no-preference) {
  .sparkles circle { animation: twinkle 4s ease-in-out infinite; }
  .sparkles circle:nth-child(2n) { animation-delay: -1.3s; }
  .sparkles circle:nth-child(3n) { animation-delay: -2.6s; }
}
@keyframes twinkle { 0%, 100% { opacity: .2; } 50% { opacity: 1; } }

/* ---------- header ---------- */
.site-header { text-align: center; padding: clamp(40px, 9vh, 96px) 16px 22px; }
.brand { font-family: var(--font-display); font-weight: 700; font-size: clamp(2.1rem, 6vw, 4rem); margin: 0; letter-spacing: .01em;
  text-shadow: 0 0 28px rgba(255,190,100,.55), 0 2px 2px rgba(0,0,0,.6); }
.brand-leaf { color: var(--amber); font-size: .8em; vertical-align: .05em; }
.tagline { margin: 6px 0 0; color: var(--ink-soft); font-size: 1.05rem; text-shadow: 0 1px 2px #000; }

/* ---------- toolbar ---------- */
.toolbar { position: sticky; top: 0; z-index: 20; background: linear-gradient(180deg, rgba(20,12,7,.94), rgba(20,12,7,.86));
  backdrop-filter: blur(8px); border-bottom: 1px solid var(--line); box-shadow: 0 8px 24px rgba(0,0,0,.35); }
.toolbar-inner { max-width: 1400px; margin: 0 auto; padding: 12px 16px; display: grid; gap: 10px;
  grid-template-columns: minmax(220px, 1fr) auto; grid-template-areas: "search views" "chips chips"; align-items: center; }
.search { grid-area: search; position: relative; display: block; }
.search svg { position: absolute; left: 14px; top: 50%; width: 18px; height: 18px; transform: translateY(-50%); fill: none; stroke: var(--ink-dim); stroke-width: 2.2; stroke-linecap: round; }
.search input { width: 100%; padding: 11px 14px 11px 42px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,240,215,.08); font-size: 1rem; }
.search input::placeholder { color: var(--ink-dim); }
.views { grid-area: views; display: flex; gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
.views button { border: 1px solid transparent; background: none; padding: 8px 12px; border-radius: 999px; cursor: pointer; font-weight: 700; color: var(--ink-soft); }
.views button:hover { background: rgba(255,240,215,.08); }
.views button[aria-pressed="true"] { background: var(--amber); color: #2a1608; }
.views .count { display: inline-block; min-width: 1.4em; padding: 0 .35em; margin-left: 2px; border-radius: 999px; background: rgba(0,0,0,.25); font-size: .8em; }
.chips { grid-area: chips; display: flex; gap: 8px; overflow-x: auto; padding-bottom: 2px; scrollbar-width: none; }
.chips::-webkit-scrollbar { display: none; }
.chip { flex: none; display: inline-flex; align-items: center; gap: 6px; padding: 5px 6px 5px 12px; border-radius: 999px; border: 1px solid var(--line);
  background: rgba(255,240,215,.06); font-size: .9rem; color: var(--ink-dim); white-space: nowrap; }
.chip span { font-weight: 700; }
.chip select { border: 0; background: rgba(0,0,0,.25); color: var(--ink); border-radius: 999px; padding: 4px 8px; max-width: 220px; cursor: pointer; }
.chip select option { background: var(--panel-solid); }
.chip.active { border-color: var(--amber); background: rgba(243,178,91,.16); color: var(--ink); }
.chip.clear { cursor: pointer; padding: 6px 14px; color: #2a1608; background: var(--ink-soft); border-color: transparent; font-weight: 800; }
@media (max-width: 860px) {
  .toolbar-inner { grid-template-columns: 1fr; grid-template-areas: "search" "views" "chips"; }
  .views { justify-content: flex-start; overflow-x: auto; flex-wrap: nowrap; }
  .views button { flex: none; }
}

/* ---------- main ---------- */
main { max-width: 1400px; margin: 0 auto; padding: 18px 16px 40px; outline: none; }
.status { min-height: 1.5em; margin: 0 0 10px; color: var(--ink-soft); font-weight: 600; }
.empty { text-align: center; padding: 48px 16px; background: var(--panel); border-radius: var(--radius); color: var(--ink-soft); }

/* ---------- the bookcase ---------- */
.bookcase { position: relative; padding: 18px 18px 8px; border-radius: 14px;
  background:
    linear-gradient(180deg, rgba(0,0,0,.35), rgba(0,0,0,.15) 20%, rgba(0,0,0,.35)),
    repeating-linear-gradient(90deg, #2c180b 0 3px, #33200f 3px 9px, #2a170a 9px 11px, #301c0d 11px 22px);
  box-shadow: inset 0 0 0 10px var(--wood-2), inset 0 0 0 12px #2a160a, inset 0 18px 30px rgba(0,0,0,.6), 0 30px 60px rgba(0,0,0,.55);
}
.bookcase::before { /* crown moulding */
  content: ""; position: absolute; left: -8px; right: -8px; top: -14px; height: 22px; border-radius: 6px;
  background: linear-gradient(180deg, #a0683c, var(--wood-2) 60%, var(--wood-3)); box-shadow: 0 6px 12px rgba(0,0,0,.5); }
@media (max-width: 640px) { .bookcase { padding: 14px 8px 4px; box-shadow: inset 0 0 0 6px var(--wood-2), inset 0 0 0 7px #2a160a, inset 0 14px 24px rgba(0,0,0,.6), 0 20px 40px rgba(0,0,0,.5); } }

.shelf { position: relative; margin: 0 0 6px; padding: 10px 6px 0; }
.shelf-head { display: flex; align-items: baseline; justify-content: space-between; gap: 12px; padding: 0 44px 6px 6px; }
.shelf-head h2, .shelf-head h3 { margin: 0; font-family: var(--font-display); font-weight: 700; font-size: 1.25rem; color: var(--ink); text-shadow: 0 1px 2px #000; }
.shelf-head .meta { color: var(--ink-dim); font-size: .9rem; white-space: nowrap; }
.shelf-head a, .shelf-head button.link { color: var(--amber); font-weight: 700; background: none; border: 0; cursor: pointer; padding: 0; text-decoration: underline; text-underline-offset: 3px; }

.shelf-body { position: relative; }
.shelf-scroller { display: flex; gap: 22px; overflow-x: auto; overscroll-behavior-x: contain; scroll-snap-type: x proximity; scroll-padding: 0 16px;
  padding: 18px 16px 0; scrollbar-width: none; position: relative; }
.shelf-scroller::-webkit-scrollbar { display: none; }
/* the plank the books stand on: sits right under the cover baseline */
.shelf-body::after { content: ""; position: absolute; left: -6px; right: -6px; top: calc(18px + var(--cover-h)); height: 20px; pointer-events: none; border-radius: 3px;
  background:
    linear-gradient(180deg, rgba(255,220,170,.35) 0 2px, transparent 2px),
    repeating-linear-gradient(92deg, rgba(0,0,0,.08) 0 2px, transparent 2px 7px),
    linear-gradient(180deg, var(--wood-1), var(--wood-2) 55%, var(--wood-3));
  box-shadow: 0 10px 14px -4px rgba(0,0,0,.7), 0 2px 0 #2a160a; z-index: 0; }
.more .shelf-body { --cover-h: 140px; --caption-w: 112px; }

.book { flex: none; scroll-snap-align: start; width: auto; min-width: var(--caption-w); display: flex; flex-direction: column; align-items: center;
  background: none; border: 0; padding: 0; cursor: pointer; color: inherit; text-align: center; position: relative; z-index: 1; }
.book .cover { height: var(--cover-h); display: flex; align-items: flex-end; justify-content: center; }
.book .cover img { height: var(--cover-h); width: auto; max-width: none; }
.book .cover img, .book .cover .card { display: block; object-fit: contain; border-radius: 2px 4px 4px 2px; box-shadow: var(--shadow-book);
  transition: transform .2s ease, box-shadow .2s ease; transform-origin: bottom center; background: #3a2616; }
.book:hover .cover img, .book:hover .cover .card, .book:focus-visible .cover img, .book:focus-visible .cover .card { transform: translateY(-8px) rotate(-.6deg); box-shadow: 0 22px 26px -8px rgba(0,0,0,.75), 0 0 0 2px var(--amber); }
.book:focus-visible { outline: none; }
.book .caption { margin-top: 26px; width: var(--caption-w); }
.book .t { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; font-weight: 800; font-size: .88rem; line-height: 1.2; color: var(--ink); }
.book .a { display: block; font-size: .78rem; color: var(--ink-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-top: 2px; }
.book .flag { position: absolute; top: 6px; right: 2px; z-index: 2; font-size: .68rem; font-weight: 800; padding: 2px 7px; border-radius: 999px; background: #ffd27a; color: #3a1d05; box-shadow: 0 2px 4px rgba(0,0,0,.4); }
.book .flag.copies { background: #b8e0b0; color: #10300a; top: auto; bottom: calc(100% - var(--cover-h) - 24px); }

/* title card for books without a cover */
.card { position: relative; width: calc(var(--cover-h) * .76) !important; height: var(--cover-h) !important; padding: 14% 10% 10% 16%; display: flex !important; flex-direction: column; justify-content: space-between;
  background: var(--c, #6b2f2f) !important; color: #fff8ec; text-align: left; overflow: hidden; }
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 9%; background: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.12) 70%, rgba(0,0,0,.2)); }
.card::after { content: ""; position: absolute; inset: 7% 7% 7% 14%; border: 1.5px solid rgba(255,240,210,.45); border-radius: 2px; pointer-events: none; }
.card .ct { font-family: var(--font-display); font-weight: 700; font-size: calc(var(--cover-h) * .085); line-height: 1.15; overflow-wrap: anywhere; }
.card .ca { font-size: calc(var(--cover-h) * .06); opacity: .9; font-weight: 600; }
.card.placeholder { --c: #4b4138; }
.card.placeholder .ct { font-family: var(--font-ui); font-size: calc(var(--cover-h) * .07); }

.shelf-btn { position: absolute; top: calc(18px + var(--cover-h) / 2 - 20px); z-index: 3; width: 40px; height: 40px; border-radius: 50%; border: 1px solid var(--line);
  background: rgba(20,12,7,.82); color: var(--ink); cursor: pointer; display: grid; place-items: center; font-size: 1.3rem; box-shadow: 0 4px 10px rgba(0,0,0,.5); }
.shelf-btn:hover { background: var(--amber); color: #2a1608; }
.shelf-btn.prev { left: -4px; } .shelf-btn.next { right: -4px; }
.shelf-btn[hidden] { display: none; }
@media (hover: none) { .shelf-btn { display: none; } }

/* letter jump */
.jump { display: flex; flex-wrap: wrap; gap: 4px; margin: 0 0 14px; }
.jump a { min-width: 32px; padding: 4px 0; text-align: center; border-radius: 6px; background: var(--panel); color: var(--ink-soft); font-weight: 800; text-decoration: none; border: 1px solid var(--line); }
.jump a:hover { background: var(--amber); color: #2a1608; }

/* ---------- missing & review ---------- */
.grid-cards { display: grid; gap: 14px; grid-template-columns: repeat(auto-fill, minmax(300px, 1fr)); }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: var(--radius); padding: 16px 18px; box-shadow: 0 10px 30px rgba(0,0,0,.35); }
.panel h2, .panel h3 { font-family: var(--font-display); margin: 0 0 4px; font-size: 1.2rem; }
.panel .sub { color: var(--ink-dim); font-size: .88rem; margin: 0 0 10px; }
.panel a { color: var(--amber); }
.progress { height: 8px; border-radius: 999px; background: rgba(255,255,255,.1); overflow: hidden; margin: 8px 0 12px; }
.progress span { display: block; height: 100%; background: linear-gradient(90deg, var(--amber-deep), var(--amber)); }
.missing-list { margin: 0; padding-left: 1.1em; columns: 1; }
.missing-list li { margin: 2px 0; break-inside: avoid; }
.missing-list .yr { color: var(--ink-dim); font-size: .85em; }
.owned-list { margin: 8px 0 0; font-size: .88rem; color: var(--ink-soft); }
details summary { cursor: pointer; color: var(--amber); font-weight: 700; margin-top: 6px; }
.complete { color: #b8e0b0; font-weight: 800; }
.intro { max-width: 800px; color: var(--ink-soft); margin: 0 0 16px; }
.intro.panel { max-width: none; }

.review-list { display: grid; gap: 12px; }
.review-item { display: grid; grid-template-columns: 96px 1fr; gap: 16px; align-items: start; }
.review-item .book { --cover-h: 120px; --caption-w: 96px; }
.review-item .book .caption { display: none; }
.review-item h3 { margin: 0; font-size: 1.05rem; font-family: var(--font-display); }
.review-item ul { margin: 6px 0 0; padding-left: 1.1em; color: var(--ink-soft); }
.review-item .spine { color: var(--ink-dim); font-size: .88rem; margin: 2px 0 0; }

/* ---------- detail dialog ---------- */
dialog { padding: 0; border: 1px solid var(--line); border-radius: 16px; background: var(--panel-solid); color: var(--ink); width: min(1100px, calc(100vw - 24px)); max-height: calc(100vh - 24px);
  box-shadow: 0 40px 80px rgba(0,0,0,.7); }
dialog::backdrop { background: rgba(8,4,2,.72); backdrop-filter: blur(3px); }
.detail-inner { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 24px; padding: 26px; position: relative; }
.close { position: absolute; top: 10px; right: 12px; width: 42px; height: 42px; border-radius: 50%; border: 1px solid var(--line); background: rgba(0,0,0,.3); font-size: 1.6rem; line-height: 1; cursor: pointer; z-index: 2; }
.close:hover { background: var(--amber); color: #2a1608; }
.detail-covers { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; align-items: end; }
.detail-covers.one { grid-template-columns: 1fr; justify-items: center; }
.detail-covers figure { margin: 0; display: flex; flex-direction: column; align-items: center; }
.detail-covers img, .detail-covers .card { width: auto; height: auto; max-width: 100%; max-height: min(62vh, 560px); object-fit: contain; border-radius: 3px 6px 6px 3px; box-shadow: 0 18px 30px -10px rgba(0,0,0,.8); background: #3a2616; }
.detail-covers .card { --cover-h: min(62vh, 420px); }
.detail-covers figcaption { margin-top: 8px; color: var(--ink-dim); font-size: .82rem; }
.detail-covers .flip { display: none; }
.eyebrow { margin: 0; color: var(--amber); font-weight: 800; text-transform: uppercase; letter-spacing: .08em; font-size: .78rem; }
.eyebrow button { all: unset; cursor: pointer; text-decoration: underline; text-underline-offset: 3px; }
.eyebrow button:focus-visible { outline: 3px solid var(--focus); }
#dTitle { font-family: var(--font-display); font-size: clamp(1.5rem, 3vw, 2.2rem); line-height: 1.15; margin: 6px 0 4px; padding-right: 40px; }
.byline { margin: 0 0 10px; color: var(--ink-soft); font-size: 1.05rem; }
.badges { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 12px; }
.badge { font-size: .78rem; font-weight: 800; padding: 3px 10px; border-radius: 999px; background: rgba(255,240,215,.1); border: 1px solid var(--line); color: var(--ink-soft); }
.badge.review { background: #ffd27a; color: #3a1d05; border-color: transparent; }
.badge.genre { cursor: pointer; }
.badge.genre:hover { background: var(--amber); color: #2a1608; }
.desc { color: var(--ink-soft); white-space: pre-line; max-height: 40vh; overflow: auto; padding-right: 6px; }
.desc .src { display: block; margin-top: 8px; font-size: .8rem; color: var(--ink-dim); white-space: normal; }
.desc .src a { color: var(--amber); }
.facts { display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; margin: 14px 0 0; font-size: .92rem; }
.facts dt { color: var(--ink-dim); font-weight: 700; }
.facts dd { margin: 0; }
.facts a { color: var(--amber); }
.more { grid-column: 1 / -1; border-top: 1px solid var(--line); padding-top: 10px; }
.more h3 { font-family: var(--font-display); margin: 0; }
@media (max-width: 760px) {
  dialog { width: 100vw; max-width: 100vw; max-height: 100dvh; height: 100dvh; border-radius: 0; margin: 0; }
  .detail-inner { grid-template-columns: 1fr; padding: 18px 16px 24px; gap: 16px; }
  .detail-covers { grid-template-columns: 1fr; justify-items: center; }
  .detail-covers img, .detail-covers .card { max-height: 56vh; }
  .detail-covers.has-back figure.back-fig { display: none; }
  .detail-covers.has-back.show-back figure.back-fig { display: flex; }
  .detail-covers.has-back.show-back figure.front-fig { display: none; }
  .detail-covers .flip { display: inline-block; justify-self: center; margin-top: 4px; padding: 8px 16px; border-radius: 999px; border: 1px solid var(--line); background: rgba(255,240,215,.08); font-weight: 800; cursor: pointer; }
  .desc { max-height: none; }
}

.site-footer { text-align: center; color: var(--ink-dim); font-size: .8rem; padding: 10px 16px 30px; }
@media (prefers-reduced-motion: reduce) { * { transition: none !important; scroll-behavior: auto !important; } }

/* phone polish */
.views { scrollbar-width: none; }
.views::-webkit-scrollbar { display: none; }
@media (max-width: 640px) {
  .toolbar-inner { padding: 8px 12px; gap: 8px; }
  .search input { padding-top: 9px; padding-bottom: 9px; }
  .views button { padding: 6px 10px; }
  .jump { flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; padding-bottom: 2px; }
  .jump::-webkit-scrollbar { display: none; }
  .jump a { flex: none; }
  .site-header { padding-top: 28px; }
  .review-item { grid-template-columns: 1fr; }
}

/* ---------- missing titles & recommendations ---------- */
.rec-case { margin-bottom: 18px; }
.book .a.why { color: var(--amber); font-weight: 700; white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.book .flag.wish { background: #cfe3ff; color: #102a4a; top: 0; right: auto; left: 50%; transform: translate(-50%, -2px); white-space: nowrap; }
.is-wish { padding-top: 6px; }
.book.is-wish .cover img { filter: saturate(.92); }
.badge.wish { background: #cfe3ff; color: #102a4a; border-color: transparent; }
.wish-grid { list-style: none; margin: 0; padding: 0; display: grid; gap: 12px 10px; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); }
.wish-tile { all: unset; box-sizing: border-box; cursor: pointer; display: flex; flex-direction: column; align-items: center; gap: 6px; width: 100%; text-align: center; border-radius: 8px; padding: 4px; }
.wish-tile:hover { background: rgba(255,240,215,.07); }
.wish-tile:focus-visible { outline: 3px solid var(--focus); }
.wish-tile img, .wish-tile .card { height: 104px; width: auto; max-width: 100%; object-fit: contain; border-radius: 2px 4px 4px 2px; box-shadow: 0 6px 10px -4px rgba(0,0,0,.7); transition: transform .15s ease; }
.wish-tile:hover img, .wish-tile:hover .card { transform: translateY(-3px); }
.wish-tile .card.mini { --cover-h: 104px; width: 79px !important; height: 104px !important; padding: 12% 8% 8% 14%; }
.wish-tile .card.mini .ct { font-size: .68rem; }
.wish-tile .wt { font-size: .78rem; line-height: 1.2; color: var(--ink-soft); display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.wish-tile .yr { color: var(--ink-dim); }
details > .wish-grid { margin-top: 10px; }
