/* ═══ shelf.css — the bookshelf ══════════════════════════════════════
   Only /bookshelf/ loads this. Global styling stays in /styles.css.

   The view is head-on: you're looking straight at the spines, so a book
   is a single rectangle var(--t) wide by var(--h) tall. No perspective,
   no rotation, nothing overlapping the frame. What makes a spine read as
   a solid object is the shading down its two long edges, not geometry.
   ═══════════════════════════════════════════════════════════════════ */

/* muted browns — these sit better against the site's #f2f1ef than the
   paler cream does. */
.shelf-page {
  --wood: #a8926f;
  --wood-dark: #877154;
  --wood-edge: #665441;
  --shelf-back: #c4b69e;
}

/* ---------- layout ----------
   this page runs wider than the rest of the site — it has to fit a shelf and
   a sidebar, where every other page is a single column of text. */

.shelf-page .content {
  max-width: 60rem;
}

.shelf-layout {
  display: flex;
  align-items: flex-start;
  gap: 4.5rem;
}

/* the shelf takes whatever the sidebar doesn't. min-width:0 lets it actually
   shrink instead of overflowing the row. */
.stage {
  flex: 1 1 auto;
  min-width: 0;
  padding: 1rem 0 0;
}

.carcass {
  position: relative;
  max-width: 100%;
  padding: 0 18px;
  background: linear-gradient(
    180deg,
    var(--shelf-back) 0%,
    #c0a67c 60%,
    #b59a70 100%
  );
  border: 1px solid var(--wood-edge);
  border-radius: 3px;
  box-shadow:
    inset 0 3px 20px rgba(0, 0, 0, 0.32),
    0 18px 34px -18px rgba(0, 0, 0, 0.5);
}

/* the two side panels */
.upright {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 18px;
  z-index: 3;
  background: linear-gradient(90deg, var(--wood-dark), var(--wood));
}
.upright.l { left: 0; }
.upright.r {
  right: 0;
  background: linear-gradient(90deg, var(--wood), var(--wood-dark));
}

/* ---------- a bay (one row of books) ---------- */

/* the recessed shadow that separates the inside of the shelf from the frame */
.bay {
  position: relative;
  padding: 0;
  box-shadow:
    inset 0 8px 18px -7px rgba(0, 0, 0, 0.42),
    inset 9px 0 16px -10px rgba(0, 0, 0, 0.45),
    inset -9px 0 16px -10px rgba(0, 0, 0, 0.45);
}

/* no padding at all: books hug the left wall and each other, and standing
   ON the plank means no bottom gap either. gap:0 keeps them tightly packed —
   the shadow each spine throws to its right is what separates them. */
.row {
  display: flex;
  align-items: flex-end;
  gap: 0;
  min-height: 148px;
  padding: 14px 0 0;
}

/* the plank the books stand on */
.board {
  height: 13px;
  margin: 0 -18px;
  position: relative;
  z-index: 4;
  background: linear-gradient(
    180deg,
    var(--wood) 0%,
    var(--wood-dark) 62%,
    var(--wood-edge) 100%
  );
  border-top: 1px solid rgba(255, 255, 255, 0.28);
  box-shadow: 0 5px 11px -4px rgba(0, 0, 0, 0.5);
}

/* ---------- a book ---------- */

.book {
  position: relative;
  flex: 0 0 auto;
  width: var(--t);
  height: var(--h);
  margin: 0;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  transition: transform 0.22s ease;
}

/* straight up — nothing that would push a book over the frame */
.book:hover,
.book:focus-visible {
  transform: translateY(-12px);
  outline: none;
}

.book:focus-visible .spine {
  box-shadow: inset 0 0 0 2px var(--green);
}

/* the whole book, seen head-on. the dark-light-dark gradient across the
   width is doing all the work: it reads as a rounded spine catching light
   down the middle, which is why this still looks like a book and not a
   coloured rectangle. */
.spine {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 2px;
  background: var(--cloth);
  background-image: linear-gradient(
    90deg,
    rgba(0, 0, 0, 0.38) 0%,
    rgba(0, 0, 0, 0.16) 8%,
    rgba(255, 255, 255, 0.13) 24%,
    rgba(255, 255, 255, 0.05) 62%,
    rgba(0, 0, 0, 0.16) 92%,
    rgba(0, 0, 0, 0.38) 100%
  );
  box-shadow:
    inset 0 2px 3px rgba(255, 255, 255, 0.14),
    inset 0 -3px 5px rgba(0, 0, 0, 0.28),
    2px 0 4px -2px rgba(0, 0, 0, 0.4); /* throws onto its neighbour */
}

/* ---------- spine type ---------- */

.spine-label {
  writing-mode: vertical-rl;
  transform: rotate(180deg); /* reads bottom-to-top, like a real spine */
  display: flex;
  align-items: center;
  gap: 0.85em;
  max-height: calc(var(--h) - 16px);
  color: var(--foil);
  font-size: 0.6875rem;
  line-height: 1;
  white-space: nowrap;
  overflow: hidden;
}

.book.long  .spine-label { font-size: 0.625rem; letter-spacing: -0.01em; }
.book.xlong .spine-label { font-size: 0.5625rem; letter-spacing: -0.02em; }

/* flex:0 0 auto — the title never shrinks, so it never truncates */
.spine-title {
  font-style: normal;
  font-weight: 700;
  flex: 0 0 auto;
}

/* the author absorbs every bit of the squeeze instead */
.spine-author {
  font-size: 0.9em;
  opacity: 0.58;
  flex: 0 1 auto;
  min-height: 0;
  text-overflow: ellipsis;
  overflow: hidden;
}

/* ---------- currently reading ---------- */

.nowreading {
  flex: 0 0 168px;
  padding-top: 1rem;
}

.nowreading-label {
  margin: 0 0 0.9rem;
  font-size: 0.6875rem;
  color: var(--muted);
  letter-spacing: 0.06em;
}

.nowreading-item + .nowreading-item {
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid var(--rule);
}

.nowreading-cover {
  margin-bottom: 0.85rem;
  line-height: 0;
}

.nowreading-cover img {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
  box-shadow: 0 10px 20px -12px rgba(0, 0, 0, 0.55);
}

/* no jpg yet — collapse rather than show a broken image */
.nowreading-cover.nocover { display: none; }

.nowreading-title {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.4;
}

.nowreading-author,
.nowreading-why,
.nowreading-started {
  margin: 0.35rem 0 0;
}

.nowreading-author {
  color: var(--muted);
  font-size: 0.8125rem;
}

.nowreading-started {
  color: var(--muted);
  font-size: 0.75rem;
}

/* ---------- recommend a book ---------- */

.rec-open {
  margin-top: 1.6rem;
  padding: 0;
  border: 0;
  border-bottom: 1px dashed var(--green-dash);
  background: none;
  color: var(--green);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.rec-open:hover { opacity: 0.7; }

.rec-form {
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  width: 100%;
}

.rec-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.rec-intro {
  margin: -0.5rem 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.55;
}

.rec-field {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.rec-label {
  font-size: 0.75rem;
  color: var(--muted);
}

.rec-field input {
  padding: 0.4rem 0;
  border: 0;
  border-bottom: 1px solid var(--rule);
  background: none;
  color: var(--text);
  font: inherit;
  font-size: 0.875rem;
}

.rec-field input:focus {
  outline: none;
  border-bottom-color: var(--green);
}

.rec-field input::placeholder {
  color: var(--muted);
  opacity: 0.7;
}

/* the honeypot — offscreen rather than display:none, which some bots skip */
.rec-trap {
  position: absolute;
  left: -9999px;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

.rec-submit {
  align-self: flex-start;
  margin-top: 0.3rem;
  padding: 0.5rem 1.1rem;
  border: 1px solid var(--green);
  border-radius: 3px;
  background: var(--green);
  color: var(--bg);
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
}

.rec-submit:hover:not(:disabled) { opacity: 0.85; }
.rec-submit:disabled { opacity: 0.55; cursor: default; }

.rec-status {
  margin: 0;
  font-size: 0.8125rem;
  min-height: 1.2em;
}

.rec-status.is-error { color: #a33; }

.rec-done {
  margin: 0;
  font-size: 0.9375rem;
}

/* ---------- rating pips ---------- */

.pips {
  display: inline-flex;
  gap: 3px;
  flex: 0 0 auto;
}

/* in the list, margin-left:auto keeps the pips right-aligned even when a
   long title pushes them onto their own line */
.booklist-head .pips { margin-left: auto; }

/* in the modal they sit in a column, so pin them to the left instead */
.bookmodal-meta .pips { align-self: flex-start; }

.pip {
  width: 7px;
  height: 7px;
  background: var(--rule);
}

.pip.on { background: var(--green); }

/* ---------- detail panel ---------- */

.bookmodal[hidden] { display: none; }

.bookmodal {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: var(--pad);
}

.bookmodal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(20, 18, 14, 0.42);
  backdrop-filter: blur(3px);
}

.bookmodal-panel {
  position: relative;
  width: 100%;
  max-width: 32rem;
  padding: 2rem;
  background: var(--bg);
  border: 1px solid var(--rule);
  border-radius: 4px;
  box-shadow: 0 24px 60px -20px rgba(0, 0, 0, 0.55);
}

.bookmodal-close {
  position: absolute;
  top: 0.6rem;
  right: 0.85rem;
  padding: 0.2rem 0.4rem;
  border: 0;
  background: none;
  color: var(--muted);
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  cursor: pointer;
}

.bookmodal-close:hover { color: var(--text); }

.bookmodal-body {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
}

/* the recommend form is the body's only child, so let it fill the panel */
.bookmodal-body > .rec-form { flex: 1 1 auto; }

.bookmodal-cover {
  flex: 0 0 auto;
  width: 108px;
}

.bookmodal-cover img {
  display: block;
  width: 100%;
  border: 1px solid var(--rule);
}

/* no jpg on disk yet — collapse rather than show a broken image */
.bookmodal-cover.nocover { display: none; }

.bookmodal-meta {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  min-width: 0;
}

.bookmodal-meta h2 {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.35;
}

.bookmodal-author {
  margin: 0;
  color: var(--muted);
  font-size: 0.875rem;
}

.bookmodal-note {
  margin: 0;
  font-size: 0.9375rem;
  line-height: 1.6;
}

body.modal-open { overflow: hidden; }

/* ---------- flat list (small screens / reduced motion) ---------- */

.booklist { display: none; }

.booklist-group + .booklist-group { margin-top: 2.4rem; }

.booklist-group h2 {
  margin: 0 0 1.1rem;
  font-size: 0.8125rem;
  font-weight: 400;
  color: var(--muted);
}

.books {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.booklist-head {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  align-items: baseline;
  gap: 0.3rem 1.5rem;
}

.booklist-title { font-weight: 700; }

.booklist-author,
.booklist-note {
  margin: 0.3rem 0 0;
}

.booklist-author {
  color: var(--muted);
  font-size: 0.875rem;
}

.booklist-note {
  font-size: 0.9375rem;
  line-height: 1.6;
}

.booklist-started {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.75rem;
}

/* ---------- small screens ----------
   a row of rotated spines is unreadable at 375px, so the shelf steps
   aside and the plain list takes over. */

/* not enough width for shelf + sidebar side by side: drop the sidebar under
   the shelf and let it run full width */
@media (max-width: 900px) {
  .shelf-layout {
    flex-direction: column;
    gap: 2rem;
  }

  .stage { width: 100%; }

  .nowreading {
    flex: 0 0 auto;
    width: 100%;
    padding-top: 0;
  }

  .nowreading-cover { max-width: 168px; }
}

@media (max-width: 640px) {
  .shelf-layout { display: none; }

  .booklist { display: block; }
}

@media (prefers-reduced-motion: reduce) {
  .book { transition: none; }

  .book:hover,
  .book:focus-visible {
    transform: rotateY(var(--ry));
  }

  .bookmodal-backdrop { backdrop-filter: none; }
}
