:root {
  --bg: #0b0b0a;
  --ink: #ece7dc;
  --ink-2: #a59f92;
  --ink-3: #6b665d;
  --rule: #2b2925;
  --serif: "Instrument Serif", Georgia, "Times New Roman", serif;
  --mono: "JetBrains Mono", ui-monospace, Menlo, monospace;
  --bw: 300px;  /* featured book width */
  --bh: 440px;
  --bd: 54px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0; background: var(--bg); color: var(--ink);
  font-family: var(--mono); font-size: 13px; line-height: 1.5;
  overflow-x: hidden;
}
a { color: inherit; text-decoration: none; }
a:hover { color: #fff; }
.vh { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

.label, .bar, .stage-foot, .chips, .search input, .ledger-list, .colophon {
  font-family: var(--mono); text-transform: uppercase; letter-spacing: .04em; font-size: 12px;
}

/* Top bar */
.bar {
  position: fixed; top: 0; left: 0; right: 0; z-index: 20;
  display: flex; justify-content: space-between; align-items: center;
  margin: 0 16px; padding: 14px 0 10px; border-bottom: 1px solid var(--ink);
  background: linear-gradient(var(--bg) 70%, transparent);
}
.wordmark { font-size: 17px; letter-spacing: .06em; }
.bar-right { display: flex; gap: 16px; }

.label { margin: 0; color: var(--ink); }

/* Featured: scroll-driven stage */
.featured { position: relative; }
.stage {
  position: sticky; top: 0; height: 100vh; height: 100svh;
  display: grid; grid-template-rows: auto auto 1fr auto;
  padding: 60px 16px 10px; overflow: hidden;
}
.stage .label { padding-top: 4px; }

.ticker-wrap { overflow: hidden; margin: 6px -16px 10px; }
.ticker { display: flex; gap: 48px; white-space: nowrap; will-change: transform; transition: transform .7s cubic-bezier(.2,.7,.2,1); }
.tick {
  font-family: var(--serif); font-size: clamp(34px, 5.6vw, 74px); line-height: 1.05; letter-spacing: -.02em;
  font-style: italic; color: var(--ink-2); opacity: .55; transition: opacity .5s ease, color .5s ease;
  position: relative;
}
.tick.on { font-style: normal; color: var(--ink); opacity: 1; }
.tick sup { font-family: var(--serif); font-style: normal; font-size: 13px; letter-spacing: 0; vertical-align: top; position: relative; top: 8px; margin-left: 6px; opacity: .8; }

.frame { position: relative; border-radius: 10px; overflow: visible; min-height: 0; }
.art {
  position: absolute; inset: 0; border-radius: 10px; overflow: hidden;
  background-size: cover; background-position: center;
  filter: saturate(.78) contrast(.92) brightness(.95);
  transition: opacity 1s ease;
}
.art::after { /* faint printed tint like an old plate */
  content: ""; position: absolute; inset: 0;
  background: radial-gradient(120% 90% at 50% 40%, transparent 50%, rgba(10, 10, 9, .45));
  mix-blend-mode: multiply;
}
.grain {
  position: absolute; inset: 0; border-radius: 10px; pointer-events: none; opacity: .22; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='200' height='200'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%' height='100%' filter='url(%23n)'/></svg>");
}

.book-scene {
  position: absolute; inset: -40px 0; display: grid; place-items: center;
  perspective: 1600px; pointer-events: none;
}

.stage-foot {
  display: flex; justify-content: space-between; gap: 12px; padding: 10px 0 0; color: var(--ink);
}
.stage-actions { display: flex; gap: 12px; color: var(--ink-2); white-space: nowrap; }
.stage-actions a { color: var(--ink); }
.sep { color: var(--ink-3); }
#hero-label, #shelf-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* The book */
.book {
  --w: var(--bw); --h: var(--bh); --d: var(--bd);
  position: relative; width: var(--w); height: var(--h);
  transform-style: preserve-3d;
}
.face { position: absolute; backface-visibility: hidden; }
.front, .back {
  inset: 0; border-radius: 2px 6px 6px 2px; overflow: hidden;
  background-color: var(--cloth); background-size: cover;
}
.front { transform: translateZ(calc(var(--d) / 2)); box-shadow: inset 4px 0 6px -3px rgba(0,0,0,.45), inset 0 0 0 1px rgba(255,255,255,.04); }
.back { transform: rotateY(180deg) translateZ(calc(var(--d) / 2)); }
.spine {
  width: var(--d); height: var(--h); left: calc(50% - var(--d) / 2); top: 0;
  transform: rotateY(-90deg) translateZ(calc(var(--w) / 2));
  background: var(--cloth);
  background-image: linear-gradient(90deg, rgba(0,0,0,.35), rgba(255,255,255,.07) 30%, rgba(255,255,255,.02) 60%, rgba(0,0,0,.3));
  border-radius: 3px;
  display: flex; flex-direction: column; align-items: center; justify-content: space-between; padding: 14px 0 12px;
  color: var(--foil);
}
.pages {
  width: calc(var(--d) - 6px); height: calc(var(--h) - 8px); left: calc(50% - (var(--d) - 6px) / 2); top: 4px;
  transform: rotateY(90deg) translateZ(calc(var(--w) / 2 - 4px));
  background: repeating-linear-gradient(90deg, #e9e2d0 0 1px, #d9d0bb 1px 2px);
}
.top, .bottom {
  width: calc(var(--w) - 6px); height: calc(var(--d) - 6px); left: 2px; top: calc(50% - (var(--d) - 6px) / 2);
  background: repeating-linear-gradient(0deg, #e9e2d0 0 1px, #d6cdb7 1px 2px);
}
.top { transform: rotateX(90deg) translateZ(calc(var(--h) / 2 - 4px)); }
.bottom { transform: rotateX(-90deg) translateZ(calc(var(--h) / 2 - 4px)); }

.cover-text {
  position: absolute; inset: 0; padding: 9% 10%; color: var(--foil);
  display: flex; flex-direction: column; justify-content: space-between;
  font-family: var(--serif);
}
.cover-title { font-size: calc(var(--w) * .118); line-height: .98; letter-spacing: -.01em; margin: 0; max-width: 78%; }
.cover-title .b { font-style: italic; }
.cover-title .r { display: block; font-style: italic; font-size: .52em; margin-top: .35em; opacity: .9; }
.cover-foot { display: flex; justify-content: space-between; align-items: flex-end; font-size: calc(var(--w) * .056); }
.badge {
  position: absolute; top: 7%; right: 8%; width: calc(var(--w) * .1); height: calc(var(--w) * .13);
  border: 1px solid currentColor; border-radius: 2px; display: grid; place-items: center;
  font-family: var(--serif); font-style: italic; font-size: calc(var(--w) * .05); color: var(--foil);
}
.spine-name {
  writing-mode: vertical-rl; font-family: var(--serif); font-size: calc(var(--d) * .36); line-height: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-height: 74%;
}
.spine-name .b { font-style: italic; }
.spine-est { writing-mode: vertical-rl; font-family: var(--mono); font-size: 9px; letter-spacing: .08em; opacity: .85; }
.spine-mark {
  width: calc(var(--d) * .5); height: calc(var(--d) * .62); border: 1px solid currentColor; border-radius: 2px;
  display: grid; place-items: center; font-family: var(--serif); font-style: italic; font-size: calc(var(--d) * .26);
}

/* Featured book motion */
.book.big { will-change: transform; transition: opacity .4s ease; }
.book.swap { opacity: 0; }

/* Registry shelf */
.registry { position: relative; padding: 90px 16px 20px; border-top: 1px solid var(--rule); background: var(--bg); }
.registry-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 12px; }
.filters { display: flex; flex-wrap: wrap; align-items: center; gap: 10px 16px; }
.search input {
  background: transparent; color: var(--ink); border: 0; border-bottom: 1px solid var(--ink-3); border-radius: 0;
  padding: 5px 2px; width: 190px; outline: none; font-size: 12px;
}
.search input:focus { border-bottom-color: var(--ink); }
.search input::placeholder { color: var(--ink-3); }
.chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip { background: none; border: 0; color: var(--ink-3); cursor: pointer; padding: 4px 6px; font: inherit; text-transform: inherit; letter-spacing: inherit; }
.chip:hover { color: var(--ink); }
.chip[aria-pressed="true"] { color: var(--ink); }
.chip[aria-pressed="true"]::before { content: "[ "; }
.chip[aria-pressed="true"]::after { content: " ]"; }

.shelf-title {
  font-family: var(--serif); font-weight: 400; font-size: clamp(34px, 5.6vw, 74px); line-height: 1.05; letter-spacing: -.02em;
  margin: 18px 0 10px; text-align: center; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.shelf-wrap { position: relative; margin: 0 -16px; }
.shelf {
  --sh: 400px;
  display: flex; align-items: flex-end; gap: 6px; overflow-x: auto; overflow-y: hidden;
  padding: 50px 40vw 46px; perspective: 2200px; scroll-behavior: smooth; outline: none;
  scrollbar-width: none;
}
.shelf::-webkit-scrollbar { display: none; }
.slot {
  flex: 0 0 auto; width: var(--d); height: var(--h); position: relative; cursor: pointer;
  transition: width .6s cubic-bezier(.2,.7,.2,1); background: none; border: 0; padding: 0;
}
.slot .book { position: absolute; left: 50%; top: 0; margin-left: calc(var(--w) / -2);
  transform: rotateY(90deg); transition: transform .7s cubic-bezier(.2,.7,.2,1); }
.slot:hover .book { transform: rotateY(90deg) translateZ(14px) translateY(-8px); }
.slot.on { width: calc(var(--w) + 18px); }
.slot.on .book { transform: rotateY(8deg) rotateX(2deg); }
.slot:focus-visible { outline: 1px solid var(--ink); outline-offset: 6px; }
.shelf::after { content: ""; flex: 0 0 1px; }
.shelf-wrap::before { /* the shelf plank */
  content: ""; position: absolute; left: 16px; right: 16px; bottom: 40px; height: 1px; background: var(--rule);
}
.shelf-line { text-align: center; color: var(--ink-2); font-family: var(--serif); font-size: 21px; margin: 8px auto 0; max-width: 640px; min-height: 1.5em; }

/* Ledger */
.ledger { padding: 70px 16px 40px; border-top: 1px solid var(--rule); }
.ledger-list { list-style: none; margin: 18px 0 0; padding: 0; columns: 3 300px; column-gap: 32px; }
.ledger-list li { break-inside: avoid; border-top: 1px solid var(--rule); padding: 9px 0; display: grid; grid-template-columns: 52px 1fr auto; gap: 10px; align-items: baseline; }
.ledger-list .n { color: var(--ink-3); }
.ledger-list .nm { font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 20px; line-height: 1.15; }
.ledger-list .nm i { color: var(--ink-2); }
.ledger-list .yr { color: var(--ink-3); }
.ledger-list a:hover .nm { text-decoration: underline; text-decoration-thickness: 1px; text-underline-offset: 3px; }

/* Colophon */
.colophon { text-align: center; padding: 50px 16px 70px; border-top: 1px solid var(--rule); color: var(--ink-2); }
.colophon p { margin: 8px auto; max-width: 720px; }
.colophon-main { font-family: var(--serif); text-transform: none; letter-spacing: 0; font-size: 26px; color: var(--ink); }
.colophon a { color: var(--ink); }
.seal { width: 96px; height: 96px; margin: 0 auto 18px; color: #c9a45a; }
.seal svg { width: 100%; height: 100%; animation: spin 90s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.credits { color: var(--ink-3); font-size: 11px; }

@media (max-width: 700px) {
  :root { --bw: 210px; --bh: 308px; --bd: 40px; }
  .hide-sm { display: none; }
  .tick sup { display: none; }
  .shelf { padding-left: 30vw; padding-right: 30vw; }
}

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