/* library.css — the shelf wall. A dark room, one warm lamp, a real bookcase. */

body.library {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  background:
    radial-gradient(1100px 680px at 50% 18%, rgba(217, 161, 59, 0.10), rgba(217, 161, 59, 0.03) 45%, transparent 70%),
    var(--bg);
}

main.room { flex: 1; position: relative; z-index: 2; padding: 26px 0 10px; }

/* continue-reading strip */
.continue-strip {
  position: relative;
  z-index: 6; /* above the bookcase's dark room-halo */
  text-align: center;
  margin: 8px 0 26px;
  min-height: 20px;
}

.continue-strip a {
  display: inline-block;
  font-family: var(--mono);
  font-size: 12.5px;
  letter-spacing: 0.1em;
  color: #e8c67a;
  text-decoration: none;
  background: rgba(26, 18, 10, 0.9);
  border: 1px solid #55432a;
  border-radius: 999px;
  padding: 10px 20px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
  transition: color 0.25s, border-color 0.25s;
}

.continue-strip a:hover { color: #f4d896; border-color: #8a6c3c; }
.continue-strip em { font-style: italic; font-family: var(--serif-display); font-size: 14.5px; letter-spacing: 0.04em; }

/* ============================================================ 3D shelf */
.stage {
  perspective: 1500px;
  perspective-origin: 50% 26%;
  padding: 16px 14px 30px;
}

.bookcase {
  width: fit-content;
  min-width: min(740px, 92vw);
  max-width: 95vw;
  margin: 0 auto;
  background: var(--wood-url), linear-gradient(180deg, #2b1b12, #1d120a);
  background-color: var(--wood);
  border-radius: 4px;
  padding: 26px 62px 12px;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.8),
    0 2px 0 rgba(255, 205, 150, 0.05) inset,
    0 0 90px rgba(0, 0, 0, 0.55) inset,
    0 44px 90px -18px rgba(0, 0, 0, 0.85);
  transform-style: preserve-3d;
  transform: rotateX(1.6deg);
  position: relative;
}

/* dark room falls away around the case (kept clear of the header above) */
.bookcase::after {
  content: "";
  position: absolute;
  inset: -26px -90px -60px;
  pointer-events: none;
  background: radial-gradient(closest-side, transparent 62%, rgba(8, 6, 6, 0.85) 96%);
}

.shelf-row { position: relative; transform-style: preserve-3d; }

.shelf-books {
  display: flex;
  align-items: flex-end;
  justify-content: center;
  gap: 6px;
  padding: 32px 22px 0;
  min-height: 384px;
  transform-style: preserve-3d;
  /* back of the shelf falls into darkness */
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.62), rgba(0, 0, 0, 0.22) 55%, rgba(0, 0, 0, 0.05));
  border-radius: 2px;
}

/* the plank under each row */
.plank {
  position: relative;
  height: 17px;
  margin: 0 -36px;
  background: var(--wood-url), linear-gradient(180deg, #32200f, #190f07);
  background-color: #2a1a0e;
  border-radius: 2px;
  box-shadow:
    0 -1px 0 rgba(255, 210, 160, 0.14),
    0 1px 0 rgba(0, 0, 0, 0.8),
    0 14px 22px -6px rgba(0, 0, 0, 0.75);
  transform: translateZ(14px);
}

/* books cast onto the plank */
.shelf-books::after {
  content: "";
  position: absolute;
  left: 0; right: 0; bottom: -2px;
  height: 16px;
  background: linear-gradient(180deg, rgba(0, 0, 0, 0.5), transparent);
  pointer-events: none;
}

.plate {
  position: absolute;
  left: 50%;
  bottom: -4px;
  transform: translate(-50%, 100%) translateZ(16px);
  background: linear-gradient(180deg, #d9b264, #b98f3e 55%, #8a6423);
  border: 1px solid rgba(58, 36, 6, 0.9);
  border-radius: 2px;
  padding: 5px 19px 6px;
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.28em;
  text-transform: uppercase;
  color: #2c1c06;
  text-shadow: 0 1px 0 rgba(255, 235, 190, 0.35);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6), 0 1px 0 rgba(255, 235, 190, 0.25) inset;
  white-space: nowrap;
  z-index: 3;
}

.plate-space { height: 40px; }

/* ------------------------------------------------------------- tome */
.tome {
  position: relative;
  width: var(--sw);
  height: var(--h);
  flex: 0 0 auto;
  border: 0;
  padding: 0;
  background: none;
  cursor: pointer;
  transform: rotate(var(--lean, 0deg));
  transform-origin: bottom center;
  -webkit-tap-highlight-color: transparent;
}

.tome .pull {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: translateZ(var(--jz, 0px));
  transition: transform 0.28s cubic-bezier(0.33, 0.1, 0.2, 1);
}

.tome:hover .pull, .tome:focus-visible .pull { transform: translateZ(calc(var(--jz, 0px) + 38px)); }
.tome.soon { cursor: pointer; }

/* the 3D box: spine faces the viewer (container rotated 90°) */
.box {
  position: absolute;
  left: 50%;
  top: 0;
  width: var(--cw);
  height: 100%;
  margin-left: calc(var(--cw) / -2);
  transform-style: preserve-3d;
  transform: rotateY(90deg);
}

.face {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  border-radius: 1px;
}

.f-front { transform: translateZ(calc(var(--sw) / 2)); background: var(--leather); background-size: 260px; }
.f-back  { transform: rotateY(180deg) translateZ(calc(var(--sw) / 2)); background: var(--leather); background-size: 260px; }

.f-front { box-shadow: inset 0 0 40px rgba(0,0,0,.35); }

/* pages edge (right side of the box = visible to the LEFT of the spine on screen) */
.f-pages {
  left: calc(50% - var(--sw) / 2);
  width: var(--sw);
  transform: rotateY(90deg) translateZ(calc(var(--cw) / 2 - 1px));
  background:
    repeating-linear-gradient(180deg, #eadfc9 0 2px, #d9cbaa 2px 3px);
  box-shadow: inset 0 0 8px rgba(90, 70, 40, 0.6);
}

/* spine — the face the visitor reads */
.f-spine {
  left: calc(50% - var(--sw) / 2);
  width: var(--sw);
  transform: rotateY(-90deg) translateZ(calc(var(--cw) / 2));
  background: var(--leather);
  background-size: 220px;
  display: flex;
  flex-direction: column;
  align-items: center;
  overflow: hidden;
  box-shadow:
    inset 1px 0 1px rgba(255, 230, 190, 0.16),
    inset -2px 0 4px rgba(0, 0, 0, 0.55),
    inset 0 -6px 10px rgba(0, 0, 0, 0.4);
}

/* raised hubs + gilt rules */
.f-spine::before, .f-spine::after {
  content: "";
  width: 100%;
  height: 4px;
  flex: 0 0 auto;
  background: linear-gradient(180deg, rgba(226, 180, 90, 0.85), rgba(140, 100, 40, 0.9));
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.6);
}

.f-spine::before { margin-top: 16px; }
.f-spine::after { margin-bottom: 16px; margin-top: auto; }

.spine-title {
  writing-mode: vertical-rl;
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: var(--ts, 14px);
  letter-spacing: 0.1em;
  color: #ecd9a8;
  text-shadow: 0 1px 1px rgba(0, 0, 0, 0.7);
  margin-top: 12px;
  max-height: 62%;
  overflow: hidden;
  flex: 0 1 auto;
}

.spine-num {
  writing-mode: vertical-rl;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.2em;
  color: rgba(236, 217, 168, 0.6);
  margin-top: 10px;
}

/* status: gilt band — READ FREE */
.band-free {
  width: 100%;
  flex: 0 0 auto;
  margin-top: 10px;
  padding: 8px 0;
  background: linear-gradient(180deg, #e2b45a, #c8a04b 60%, #9d7527);
  box-shadow: 0 1px 0 rgba(255, 240, 200, 0.5) inset, 0 -1px 0 rgba(60, 38, 8, 0.6) inset, 0 1px 3px rgba(0, 0, 0, 0.5);
  color: #241505;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.26em;
  writing-mode: vertical-rl;
  text-align: center;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* status: brass plaque — IN STORE */
.plaque-store {
  flex: 0 0 auto;
  margin: 10px 0 4px;
  padding: 5px 2px;
  width: calc(100% - 8px);
  background: linear-gradient(180deg, #d9b264, #b98f3e 55%, #8a6423);
  border: 1px solid rgba(58, 36, 6, 0.85);
  border-radius: 1px;
  color: #2c1c06;
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.22em;
  writing-mode: vertical-rl;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.55);
}

/* status: kraft wrap — COMING SOON */
.tome.soon .f-spine, .tome.soon .f-front, .tome.soon .f-back {
  background: var(--kraft);
  background-size: 240px;
}

.stamp-soon {
  writing-mode: vertical-rl;
  flex: 0 0 auto;
  margin-top: 12px;
  font-family: var(--mono);
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: rgba(112, 30, 18, 0.85);
  border: 1.5px solid rgba(112, 30, 18, 0.65);
  padding: 10px 4px;
  transform: rotate(0.5deg);
}

.tome.soon .f-spine::before, .tome.soon .f-spine::after {
  background: rgba(72, 52, 26, 0.75);
  height: 4px;
}

.tome.soon .spine-title { color: rgba(60, 40, 18, 0.8); text-shadow: none; }

/* lamp catches the spine on hover */
.f-spine .sheen {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(200deg, rgba(255, 226, 160, 0.22), transparent 55%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}

.tome:hover .sheen, .tome:focus-visible .sheen { opacity: 1; }

/* ------------------------------------------------------------- flyout */
.flyout {
  position: fixed;
  z-index: 60;
  pointer-events: none;
  transform-style: preserve-3d;
}

.flyout .fly-move {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transition: transform 0.72s cubic-bezier(0.34, 0.08, 0.18, 1);
}

.flyout .fly-spin {
  position: absolute;
  inset: 0;
  transform-style: preserve-3d;
  transform: rotateY(90deg);
  transition: transform 0.72s cubic-bezier(0.34, 0.08, 0.18, 1);
}

.room-dim {
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(5, 4, 3, 0);
  transition: background 0.6s;
  pointer-events: none;
}

.room-dim.on { background: rgba(5, 4, 3, 0.82); }

/* ============================================================ flat grid */
.grid-library {
  width: min(1080px, 94vw);
  margin: 0 auto;
  padding: 10px 0 30px;
}

.grid-series { margin: 34px 0 8px; }

.grid-series-head {
  display: flex;
  align-items: center;
  gap: 16px;
  margin: 0 0 6px;
}

.grid-series-head .rule { flex: 1; height: 1px; background: linear-gradient(90deg, transparent, #3a3029, transparent); }

.grid-series-head .plate { position: static; transform: none; }

.grid-series-blurb {
  text-align: center;
  color: var(--dim);
  font-size: 14px;
  font-style: italic;
  max-width: 560px;
  margin: 12px auto 22px;
}

.grid-books {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(148px, 172px));
  justify-content: center;
  gap: 30px 26px;
  padding: 6px 0 12px;
}

.grid-book {
  text-decoration: none;
  color: var(--ink);
  text-align: center;
  display: block;
}

.grid-book .cover-wrap {
  position: relative;
  aspect-ratio: 2 / 3;
  border-radius: 2px 5px 5px 2px;
  overflow: hidden;
  box-shadow:
    -6px 0 0 -3px rgba(255, 240, 210, 0.06),
    0 14px 34px -8px rgba(0, 0, 0, 0.85),
    0 3px 8px rgba(0, 0, 0, 0.6);
  transition: transform 0.3s, box-shadow 0.3s;
  background: var(--panel);
}

.grid-book:hover .cover-wrap {
  transform: translateY(-5px);
  box-shadow:
    -6px 0 0 -3px rgba(255, 240, 210, 0.08),
    0 24px 44px -10px rgba(0, 0, 0, 0.9),
    0 4px 10px rgba(0, 0, 0, 0.6);
}

.grid-book img { display: block; width: 100%; height: 100%; object-fit: cover; }

.grid-book .g-title {
  font-family: var(--serif-display);
  font-weight: 600;
  font-size: 16px;
  margin: 12px 0 3px;
  letter-spacing: 0.03em;
}

.grid-book .g-status {
  font-family: var(--mono);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--dim);
}

.grid-book .g-status.free { color: var(--gilt); }

/* narrow screens: tighten the header */
@media (max-width: 620px) {
  .grid-books { grid-template-columns: repeat(auto-fit, minmax(124px, 150px)); gap: 24px 18px; }
}
