:root {
  --bg: #0d0c0b;
  --fg: #f3efe7;
  --dim: #8f8a81;
  --line: rgba(243, 239, 231, .09);
  --tone-1: #555;
  --tone-2: #333;
  --spine: #2a2a2a;
  --serif: "Fraunces", Georgia, serif;
  --sans: "Inter Tight", "Helvetica Neue", Arial, sans-serif;
  --pad: clamp(24px, 5vw, 88px);
  --ease: cubic-bezier(.16, 1, .3, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  background: var(--bg); color: var(--fg); font-family: var(--sans);
  -webkit-font-smoothing: antialiased; text-rendering: optimizeLegibility;
  overflow-x: hidden;
}
::selection { background: var(--fg); color: var(--bg); }
img { display: block; }

/* ---------- Ambient light taken from the cover ---------- */
.ambient { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.ambient i {
  position: absolute; width: 62vmax; aspect-ratio: 1; border-radius: 50%;
  filter: blur(110px); opacity: .16;
  animation: drift 26s ease-in-out infinite alternate;
}
.ambient i:nth-child(1) { background: var(--tone-1); right: -8vmax; top: -18vmax; }
.ambient i:nth-child(2) { background: var(--tone-2); right: 14vmax; top: 18vmax; animation-duration: 32s; animation-direction: alternate-reverse; }
@keyframes drift { to { transform: translate(-6vmax, 4vmax) scale(1.08); } }
main { position: relative; z-index: 1; }

/* ---------- Hero ---------- */
.hero {
  position: relative; isolation: isolate; overflow: hidden;
  min-height: 100vh; min-height: 100svh;
  display: grid; grid-template-columns: 1.05fr 1fr; align-items: center;
  gap: 4vw; padding: 9vh var(--pad);
}
.copy { max-width: 620px; position: relative; z-index: 2; }

/* the book's world lives behind everything in the hero */
.scene { position: absolute; inset: 0; z-index: 0; pointer-events: none; }
.themed .ambient { display: none; }

.return {
  position: absolute; top: 28px; left: var(--pad); z-index: 3;
  color: inherit; text-decoration: none; font-size: 13px; font-weight: 500; opacity: .75;
}
.return:hover { opacity: 1; }
.return[hidden] { display: none; }

.eyebrow {
  display: flex; align-items: baseline; gap: 14px;
  font-family: var(--serif); font-weight: 300; font-style: italic;
  font-size: 19px; color: var(--dim);
  font-variation-settings: "opsz" 24;
}
.eyebrow .rule { width: 40px; height: 1px; background: var(--dim); opacity: .5; align-self: center; }
.eyebrow em { font-style: normal; color: var(--fg); }
.eyebrow em::before { content: "·"; margin-right: 14px; color: var(--dim); }

.title {
  font-family: var(--serif); font-weight: 300;
  font-size: clamp(96px, 13vw, 210px); line-height: .9; letter-spacing: -.045em;
  font-variation-settings: "opsz" 144;
  margin: 28px 0 22px -.04em;
}
.title.long  { font-size: clamp(64px, 8vw, 132px); }
.title.xlong { font-size: clamp(48px, 5.5vw, 92px); line-height: .95; }

.author { font-family: var(--serif); font-style: italic; font-weight: 300; font-size: clamp(24px, 2.3vw, 34px); color: var(--fg); }
.hook {
  margin-top: 26px; max-width: 30ch;
  font-size: 17px; line-height: 1.6; color: var(--dim);
}
.club {
  display: flex; gap: 14px; align-items: baseline;
  margin-top: 56px; padding-top: 20px; border-top: 1px solid var(--line);
  font-size: 13px; font-weight: 500; letter-spacing: .02em;
}

/* ---------- The 3D book ---------- */
.stage { position: relative; z-index: 2; justify-self: center; perspective: 2000px; padding: 40px 0 80px; }
.book {
  --w: clamp(220px, min(26vw, 42vh), 380px);
  --h: calc(var(--w) * 1.5);
  --t: calc(var(--w) * .13);
  position: relative; width: var(--w); height: var(--h);
  transform-style: preserve-3d;
  transform: rotateY(var(--ry, -22deg)) rotateX(var(--rx, 3deg));
}
.face { position: absolute; }

.front {
  inset: 0; transform: translateZ(calc(var(--t) / 2));
  border-radius: 1px 4px 4px 1px; overflow: hidden; background: #1a1a1a;
  box-shadow: 0 0 0 .5px rgba(0,0,0,.4);
}
.front img { width: 100%; height: 100%; object-fit: cover; }
.front::before { /* hardcover hinge groove */
  content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none;
  background:
    linear-gradient(90deg,
      rgba(0,0,0,.55) 0%, rgba(0,0,0,.15) 1.5%, rgba(255,255,255,.22) 3%,
      rgba(0,0,0,.28) 4.6%, rgba(255,255,255,.08) 6%, transparent 9%),
    linear-gradient(180deg, rgba(255,255,255,.05), transparent 35%, rgba(0,0,0,.16));
}
.front::after { /* light passing over a matte jacket */
  content: ""; position: absolute; inset: -30%; z-index: 3; pointer-events: none;
  background: linear-gradient(105deg, transparent 38%, rgba(255,255,255,.13) 50%, transparent 62%);
  transform: translateX(var(--sheen, 0%));
}
.face.back {
  inset: 0; transform: rotateY(180deg) translateZ(calc(var(--t) / 2));
  background: var(--spine); border-radius: 4px 1px 1px 4px;
}
.spine {
  width: var(--t); height: 100%; left: calc(50% - var(--t) / 2);
  transform: rotateY(-90deg) translateZ(calc(var(--w) / 2));
  background:
    linear-gradient(90deg, rgba(0,0,0,.55), rgba(255,255,255,.1) 25%, rgba(0,0,0,.1) 60%, rgba(0,0,0,.6)),
    var(--spine);
}
.pages-r {
  width: calc(var(--t) - 4px); height: calc(100% - 8px); top: 4px; left: calc(50% - (var(--t) - 4px) / 2);
  transform: rotateY(90deg) translateZ(calc(var(--w) / 2 - 4px));
  background:
    linear-gradient(90deg, rgba(0,0,0,.4), transparent 12%, transparent 88%, rgba(0,0,0,.4)),
    repeating-linear-gradient(90deg, #f1ebdf 0 1px, #d8cfbf 1px 1.6px, #f6f1e8 1.6px 2.4px);
}
.pages-t, .pages-b {
  width: calc(var(--w) - 4px); height: calc(var(--t) - 4px); left: 0; top: calc(50% - (var(--t) - 4px) / 2);
  background: repeating-linear-gradient(0deg, #eee7da 0 1px, #d4cbbb 1px 1.6px);
}
.pages-t { transform: rotateX(90deg) translateZ(calc(var(--h) / 2 - 4px)); }
.pages-b { transform: rotateX(-90deg) translateZ(calc(var(--h) / 2 - 4px)); }

.floor {
  position: absolute; left: 50%; bottom: 30px; width: 90%; height: 46px; translate: -50% 0;
  background: radial-gradient(ellipse at center, rgba(0,0,0,.75), transparent 70%);
  filter: blur(12px);
}

/* ---------- The shelf ---------- */
.library { padding: 14vh var(--pad) 18vh; }
.lib-head {
  display: flex; justify-content: space-between; align-items: baseline; gap: 24px;
  padding-bottom: 22px; border-bottom: 1px solid var(--line); margin-bottom: 72px;
}
.lib-head h2 { font-family: var(--serif); font-weight: 300; font-size: clamp(48px, 6vw, 88px); line-height: 1; letter-spacing: -.02em; }
.to-archive {
  display: inline-flex; align-items: baseline; gap: 10px; flex: none;
  color: var(--fg); font-size: 15px; font-weight: 500; text-decoration: none;
  border-bottom: 1px solid rgba(243, 239, 231, .35); padding-bottom: 4px;
  transition: border-color .3s;
}
.to-archive span { transition: transform .3s var(--ease); }
.to-archive:hover { border-color: var(--fg); }
.to-archive:hover span { transform: translateX(4px); }
.to-archive:focus-visible { outline: 1px solid var(--dim); outline-offset: 6px; }

.shelf-scroll { overflow-x: auto; padding-top: 40px; margin-top: -40px; scrollbar-width: thin; scrollbar-color: rgba(243,239,231,.18) transparent; }
.shelf-scroll:focus-visible { outline: 1px solid var(--dim); outline-offset: 8px; }
.shelf { position: relative; display: inline-block; min-width: 100%; padding-bottom: 130px; }
.books { position: relative; display: flex; align-items: flex-end; gap: clamp(22px, 2.6vw, 40px); padding: 0 12px; }

.volume { position: relative; flex: none; width: clamp(120px, 11vw, 160px); perspective: 900px; }
.vol-book {
  position: relative; aspect-ratio: 2 / 3; border-radius: 1px 3px 3px 1px; overflow: hidden;
  background: #1a1918;
  box-shadow: -1px 0 0 rgba(0,0,0,.6), 0 2px 2px rgba(0,0,0,.4), 0 18px 30px -10px rgba(0,0,0,.7);
  transform-origin: 50% 100%;
  transition: transform .7s var(--ease), box-shadow .7s var(--ease);
}
.vol-book img { width: 100%; height: 100%; object-fit: cover; }
.vol-book::before { /* spine shading */
  content: ""; position: absolute; inset: 0; pointer-events: none;
  background: linear-gradient(90deg, rgba(0,0,0,.5), rgba(255,255,255,.18) 3%, rgba(0,0,0,.2) 6%, transparent 10%),
              linear-gradient(180deg, rgba(255,255,255,.06), transparent 40%);
}
a.volume { color: inherit; text-decoration: none; }
.volume:hover .vol-book {
  transform: translateY(-22px) rotateX(4deg) rotateY(-8deg);
  box-shadow: -1px 0 0 rgba(0,0,0,.6), 0 2px 2px rgba(0,0,0,.4), 0 40px 50px -12px rgba(0,0,0,.85);
}


.plank {
  position: relative; height: 14px; margin: 0 -24px;
  background: linear-gradient(180deg, #3a342d 0, #2a2520 2px, #1d1a16 100%);
  border-radius: 1px;
  box-shadow: 0 1px 0 rgba(255,255,255,.06) inset, 0 30px 40px -8px rgba(0,0,0,.8);
}
.plank::before { /* top surface catching light */
  content: ""; position: absolute; left: 0; right: 0; top: -6px; height: 6px;
  background: linear-gradient(180deg, transparent, rgba(255,255,255,.05));
  transform: perspective(200px) rotateX(40deg); transform-origin: bottom;
}

/* captions hang below the plank, under each book */
.volume .cap { position: absolute; top: 100%; left: 0; width: 100%; padding-top: 46px; }
.volume .m { display: block; font-size: 11px; letter-spacing: .12em; text-transform: uppercase; color: var(--dim); margin-bottom: 8px; }
.volume .m em { font-style: normal; color: var(--fg); }
.volume b { display: block; font-family: var(--serif); font-weight: 300; font-size: 22px; line-height: 1.1; }
.volume .a { display: block; font-size: 13px; color: var(--dim); margin-top: 4px; }

/* ---------- Motion ---------- */
.scene { opacity: 0; transition: opacity 1.2s ease; }
.ready .scene { opacity: 1; }
.embed .scene { transition: none; }
.embed .library, .embed .return, .embed .credit { display: none; }

/* ---------- Small screens ---------- */
@media (max-width: 860px) {
  .hero { grid-template-columns: 1fr; padding-top: 6vh; gap: 0; text-align: center; }
  .stage { order: -1; padding-bottom: 60px; }
  .book { --w: min(56vw, 300px); }
  .copy { margin: 0 auto; }
  .eyebrow { justify-content: center; white-space: nowrap; font-size: 16px; gap: 10px; }
  .eyebrow .rule { display: none; }
  .eyebrow em::before { margin-right: 10px; }
  .title { margin-left: 0; }
  .hook { margin-left: auto; margin-right: auto; }
  .club { justify-content: center; margin-top: 40px; }
  .lib-head { flex-direction: column; align-items: stretch; gap: 28px; border-bottom: 0; padding-bottom: 0; margin-bottom: 64px; }
  .to-archive {
    justify-content: space-between; padding: 18px 2px; font-size: 16px;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
  }
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .scene, .vol-book, .frame { transition: none; }
  .ambient i { animation: none; }
}

/* ================= Archive page ================= */
.archive { padding: 120px var(--pad) 160px; max-width: 1500px; margin: 0 auto; position: relative; }
.archive .return { top: 36px; }
.arch-head { margin-bottom: 72px; max-width: 760px; }
.arch-head h1 {
  font-family: var(--serif); font-weight: 300; font-variation-settings: "opsz" 144;
  font-size: clamp(56px, 7.5vw, 116px); line-height: .95; letter-spacing: -.035em;
}

.editions { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 560px), 1fr)); gap: 64px 40px; }
.edition { color: inherit; text-decoration: none; display: block; }
.frame {
  position: relative; aspect-ratio: 1440 / 900; overflow: hidden; border-radius: 6px;
  background: #151311; box-shadow: 0 0 0 1px var(--line), 0 40px 80px -30px rgba(0,0,0,.8);
  transition: transform .8s var(--ease), box-shadow .8s var(--ease);
}
.frame iframe {
  position: absolute; left: 0; top: 0; width: 1440px; height: 900px; border: 0;
  transform: scale(var(--s, .4)); transform-origin: 0 0; pointer-events: none;
}
.edition:hover .frame { transform: translateY(-6px); box-shadow: 0 0 0 1px rgba(243,239,231,.2), 0 60px 90px -30px rgba(0,0,0,.9); }
.ed-cap {
  display: grid; grid-template-columns: 1fr auto; gap: 6px 18px; align-items: baseline;
  padding: 20px 2px 0;
}
.ed-title { font-family: var(--serif); font-weight: 300; font-size: 26px; letter-spacing: -.01em; }
.ed-title i { font-size: 16px; color: var(--dim); margin-left: 8px; }
.ed-month { font-size: 13px; color: var(--dim); }
.ed-month em { font-style: normal; color: var(--fg); }
.edition:only-child { grid-column: 1 / -1; }

/* cover art credit, under the 3D book */
.credit {
  position: absolute; left: 50%; bottom: 0; translate: -50% 0; white-space: nowrap;
  font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 14px;
  color: inherit; opacity: .55; text-decoration: none; transition: opacity .3s;
}
.credit:hover { opacity: .95; }
.credit[hidden] { display: none; }
.ed-credit { grid-column: 1 / -1; font-family: var(--serif); font-style: italic; font-weight: 300; font-size: 14px; color: var(--dim); }

.noscript { padding: 40px var(--pad); color: var(--dim); }
