/* Bookshelf: cover grid with flip cards (category pages) + topic search (/footnotes/ask) + Pull a line (/footnotes).
   Made by scripts/build-footnotes.mjs pages; behaviour in bookshelf.js. */

/* ---------- category nav ---------- */
.cat-nav {
  display: flex; flex-wrap: wrap; justify-content: center; gap: 6px 18px;
  margin-top: var(--space-md); font-size: var(--fs-small); text-transform: lowercase;
}
.cat-nav a { color: var(--text-tertiary); border-bottom: 1px solid transparent; transition: color .15s, border-color .15s; }
.cat-nav a:hover { color: var(--text-soft); border-bottom-color: var(--text-soft); }
.cat-nav [aria-current] { color: var(--text-strong); font-weight: 700; }
.cat-nav-bottom { justify-content: flex-start; margin-top: var(--space-sm); }

.shelf-tools {
  display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 10px 20px;
  margin-top: var(--space-md); font-size: var(--fs-small); color: var(--text-tertiary);
}
.shelf-tools button {
  font: inherit; color: var(--text-strong); background: none; border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 14px; cursor: pointer; transition: background .15s, border-color .15s;
}
.shelf-tools button:hover { background: var(--accent-soft); border-color: var(--text-tertiary); }

/* ---------- cover grid ---------- */
.shelf {
  max-width: 1100px; margin: 0 auto; padding: var(--space-lg, 32px) var(--gutter) var(--space-2xl, 64px);
  display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 36px 24px;
}
@media (max-width: 520px) {
  .shelf { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px 16px; padding-left: 16px; padding-right: 16px; }
}
.book { display: flex; flex-direction: column; gap: 10px; min-width: 0; scroll-margin-top: 90px; }
.book-flip {
  position: relative; width: 100%; aspect-ratio: 2 / 3; perspective: 1000px;
  border: 0; padding: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.book-flip:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 4px; }
.book-inner {
  position: absolute; inset: 0; transform-style: preserve-3d;
  transition: transform .55s cubic-bezier(.2,.7,.2,1);
}
.book.is-flipped .book-inner { transform: rotateY(180deg); }
.book-face {
  position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden;
  border-radius: 3px; overflow: hidden;
  box-shadow: 0 1px 2px rgba(28,41,51,.12), 0 6px 18px rgba(28,41,51,.12);
}
.book-front img { width: 100%; height: 100%; object-fit: cover; display: block; background: var(--accent-soft); }
.no-cover {
  width: 100%; height: 100%; display: flex; flex-direction: column; justify-content: space-between;
  padding: 14px; background: var(--bg-alt); color: #F7F5F3;
}
.no-cover-title { font-weight: 700; font-size: 17px; line-height: 1.1; letter-spacing: -0.02em; overflow-wrap: anywhere; }
.no-cover-author { font-size: var(--fs-tiny); opacity: .75; }
.book-back {
  transform: rotateY(180deg); background: #fff; border: 1px solid var(--border-light);
  padding: 14px 13px; display: flex; flex-direction: column; gap: 8px;
}
.book-back .why {
  display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 9; line-clamp: 9;
  margin: 0; font-size: 13px; line-height: 1.42; color: var(--text); overflow: hidden;
}
@media (max-width: 520px) { .book-back .why { -webkit-line-clamp: 8; line-clamp: 8; font-size: 12.5px; } }
.book-back .back-label { font-size: 11px; color: var(--text-tertiary); text-transform: lowercase; letter-spacing: .02em; }
.book-back .back-more { margin-top: auto; font-size: 12px; font-weight: 700; color: var(--text-strong); }
.book-meta { display: flex; flex-direction: column; gap: 2px; }
.book-meta .t { font-weight: 700; font-size: 14px; line-height: 1.3; color: var(--text-strong); }
.book-meta .a { font-size: var(--fs-tiny); color: var(--text-tertiary); }

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

/* ---------- book dialog ---------- */
.book-dialog {
  margin: auto; border: 0; padding: 0; border-radius: 6px; width: min(640px, calc(100vw - 32px)); max-height: calc(100vh - 48px);
  background: var(--bg); color: var(--text); box-shadow: 0 20px 60px rgba(28,41,51,.35);
}
.book-dialog::backdrop { background: rgba(28,41,51,.55); }
.bd-wrap { display: grid; grid-template-columns: 150px 1fr; gap: 24px; padding: 28px; }
@media (max-width: 560px) { .bd-wrap { grid-template-columns: 1fr; padding: 22px 18px; } .bd-cover { max-width: 140px; } }
.bd-cover .no-cover { aspect-ratio: 2 / 3; height: auto; border-radius: 3px; }
.bd-cover img { width: 100%; border-radius: 3px; box-shadow: 0 6px 18px rgba(28,41,51,.18); display: block; }
.bd-title { font-size: 26px; line-height: 1.05; letter-spacing: -0.03em; color: var(--text-strong); margin: 0 0 4px; padding-right: 28px; }
.bd-author { font-size: var(--fs-small); color: var(--text-tertiary); margin: 0 0 16px; }
.bd-why { font-size: 17px; line-height: 1.5; color: var(--text-strong); margin: 0 0 16px; }
.bd-take-head { font-size: var(--fs-tiny); text-transform: lowercase; color: var(--text-tertiary); margin: 0 0 6px; letter-spacing: .03em; }
.bd-takes { margin: 0 0 16px; padding-left: 18px; }
.bd-takes li { margin-bottom: 6px; line-height: 1.45; }
.bd-line { margin: 0 0 18px; padding-left: 14px; border-left: 2px solid var(--border); color: var(--text-soft); }
.bd-label { font-size: var(--fs-tiny); color: var(--text-tertiary); margin: 0 0 18px; }
.bd-actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.bd-get {
  display: inline-block; background: var(--text-strong); color: #fff; padding: 9px 16px; border-radius: 999px;
  font-size: var(--fs-small); font-weight: 700;
}
.bd-get:hover { background: var(--text-hover); color: #fff; }
.bd-close {
  position: absolute; top: 10px; right: 12px; width: 36px; height: 36px; border: 0; background: none;
  font-size: 26px; line-height: 1; color: var(--text-tertiary); cursor: pointer;
}
.bd-close:hover { color: var(--text-strong); }
.bd-topics { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 18px; }
.bd-topics button {
  font: inherit; font-size: var(--fs-tiny); background: var(--accent-soft); border: 0; border-radius: 999px;
  padding: 4px 10px; color: var(--text-soft); cursor: pointer;
}
.bd-topics button:hover { background: var(--border-light); color: var(--text-strong); }

/* ---------- topic search (/footnotes/ask) ---------- */
.ask {
  max-width: 560px; margin: 0 auto var(--space-xl, 48px); padding: 0 var(--gutter);
}
.ask h2 { font-size: 15px; font-weight: 700; letter-spacing: 0; margin: 0 0 8px; color: var(--text-strong); }
.ask-form { display: flex; gap: 6px; }
.ask-form input {
  flex: 1; min-width: 0; font: inherit; font-size: 16px; padding: 7px 12px; border: 1px solid var(--border);
  border-radius: 999px; background: #fff; color: var(--text-strong);
}
.ask-form input:focus { outline: 2px solid var(--text-strong); outline-offset: 1px; }
.ask-form button {
  font: inherit; font-size: 13px; font-weight: 700; padding: 0 14px; border: 0; border-radius: 999px; background: var(--text-strong);
  color: #fff; cursor: pointer;
}
.ask-form button:disabled { opacity: .5; cursor: default; }
.ask-chips { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.ask-chips button {
  font: inherit; font-size: 12px; background: none; border: 1px solid var(--border); border-radius: 999px;
  padding: 3px 9px; color: var(--text-soft); cursor: pointer;
}
.ask-chips button:hover { border-color: var(--text-tertiary); color: var(--text-strong); }
.ask-result { margin-top: 28px; }
.ask-result[hidden] { display: none; }
.ask-status { color: var(--text-tertiary); font-size: var(--fs-small); }
.ask-intro-line { font-size: 19px; line-height: 1.5; color: var(--text-strong); margin: 0 0 14px; }
.ask-label { font-size: var(--fs-tiny); color: var(--text-tertiary); margin: 0 0 14px; }

/* the hand: three cards dealt in */
.hand { display: grid; grid-template-columns: repeat(3, minmax(0, 200px)); gap: 22px; justify-content: center; }
.hand-card { display: flex; flex-direction: column; gap: 10px; min-width: 0; animation: deal .5s cubic-bezier(.2,.8,.25,1) both; }
@keyframes deal {
  from { opacity: 0; transform: translate(-40px, 60px) rotate(-10deg) scale(.9); }
  to { opacity: 1; transform: none; }
}
.hand-flip {
  position: relative; width: 100%; aspect-ratio: 2 / 3; perspective: 1000px;
  border: 0; padding: 0; background: none; cursor: pointer; text-align: left; font: inherit; color: inherit;
}
.hand-flip:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 4px; }
.hand-card.is-flipped .book-inner { transform: rotateY(180deg); }
.hand-why { font-size: 15px; line-height: 1.45; color: var(--text-strong); }
.hand-card .book-back { padding: 16px; gap: 10px; }
@media (max-width: 600px) {
  /* a swipe row: one card in view, the next peeking in from the right */
  .hand {
    display: flex; justify-content: flex-start; overflow-x: auto; scroll-snap-type: x mandatory; gap: 14px;
    padding-bottom: 10px; scrollbar-width: none;
  }
  .hand::-webkit-scrollbar { display: none; }
  .hand-card { flex: 0 0 72%; scroll-snap-align: start; }
}
@media (prefers-reduced-motion: reduce) { .hand-card { animation: none; } }
.hand-tools { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 14px; margin-top: 22px; }
.hand-btn {
  font: inherit; font-size: var(--fs-small); font-weight: 700; color: var(--text-strong); background: none;
  border: 1px solid var(--text-strong); border-radius: 999px; padding: 8px 18px; cursor: pointer;
}
.hand-btn:hover { background: var(--accent-soft); }
.hand-send { background: var(--text-strong); color: #fff; }
.hand-send:hover { background: var(--text-hover); }
.hand-count { font-size: var(--fs-tiny); color: var(--text-tertiary); }
.ask-blog { margin-top: 26px; font-size: var(--fs-small); color: var(--text-tertiary); text-align: center; }
.ask-blog a { color: var(--text-strong); font-weight: 700; }

/* ---------- Pull a line (/footnotes, play.js) ---------- */
.play { max-width: 560px; margin: 0 auto var(--space-lg); padding: 0 var(--gutter); scroll-margin-top: 80px; }
.play[hidden] { display: none; }
.play-loading, .play-note { font-size: var(--fs-tiny); color: var(--text-tertiary); text-align: center; margin: 10px 0 0; }
.play-tools { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 8px 10px; margin-top: 12px; }
.play-btn {
  font: inherit; font-size: 13px; font-weight: 700; padding: 7px 16px; border-radius: 999px; cursor: pointer;
  background: none; border: 1.5px solid var(--text-strong); color: var(--text-strong); transition: background .15s, transform .1s;
}
.play-btn:hover { background: var(--accent-soft); }
.play-btn:active { transform: scale(.97); }
.play-btn-main { background: var(--red); border-color: var(--red); color: var(--on-red); }
.play-btn-main:hover { background: var(--red-hover); border-color: var(--red-hover); }
.play-btn:focus-visible { outline: 2px solid var(--text-strong); outline-offset: 3px; }

/* the line card: clean and flat, like the picture it saves (white, ink type, a red tick) */
.pull-stage { position: relative; display: grid; touch-action: pan-y; }
.pull-stage > * { grid-area: 1 / 1; }
.pull-card {
  margin: 0; background: #fff; color: var(--text-strong); border: 1px solid var(--border-light, #E6E2DC); border-radius: 4px;
  padding: 28px 30px 24px; position: relative; min-height: 180px; display: flex; flex-direction: column;
}
.pull-card::before { content: ""; display: block; width: 24px; height: 3px; background: var(--red); margin-bottom: 14px; }
.pull-label { font-size: 12px; letter-spacing: .01em; color: var(--text-tertiary); margin: 0 0 8px; }
.is-mine .pull-label { color: var(--red); }
.pull-text {
  margin: 0; padding: 0; border: 0; font-style: normal; font-weight: 700; font-size: clamp(17px, 2.2vw, 20px); line-height: 1.32; letter-spacing: -0.015em; color: #F7F5F3;
}
.pull-text { color: var(--text-strong); font-size: clamp(19px, 2.6vw, 23px); line-height: 1.28; }
.pull-from { margin-top: auto; padding-top: 18px; }
.pull-book { display: inline-flex; align-items: center; gap: 10px; color: var(--text-strong); }
.pull-book:hover strong { text-decoration: underline; }
.pull-cover { width: 28px; height: 42px; object-fit: cover; border-radius: 1px; flex: none; }
.pull-meta { display: flex; flex-direction: column; font-size: 13px; line-height: 1.3; }
.pull-meta strong { color: var(--text-strong); }
.pull-meta span { color: var(--text-tertiary); }
.play-no-cover {
  display: flex; flex-direction: column; justify-content: space-between; padding: 6px; background: #2A3A48; color: #F7F5F3;
  font-size: 9px; font-weight: 700; line-height: 1.1; overflow: hidden;
}
.play-no-cover small { font-weight: 400; opacity: .7; }
.pull-card.enter { animation: pull-in .45s cubic-bezier(.2,.8,.25,1) both; }
.pull-card.leave { animation: pull-out .4s cubic-bezier(.5,0,.75,0) both; pointer-events: none; }
@keyframes pull-in { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@keyframes pull-out { to { opacity: 0; transform: translateX(-40%); } }
@media (max-width: 600px) {
  .pull-card { padding: 22px 20px 18px; }
  .pull-card { min-height: 200px; }
}

@media (prefers-reduced-motion: reduce) {
  .pull-card.enter, .pull-card.leave { animation: none; }
}
/* "3 lines Ryan highlighted" in the book card */
.bd-hl { margin: 0 0 18px; }
.bd-hl-list:empty { display: none; }
.bd-hl-line {
  margin: 0 0 12px; padding: 0 0 0 14px; border-left: 2px solid var(--text-strong); font-style: normal;
  font-size: 16px; line-height: 1.45; color: var(--text-strong);
}
.bd-hl-btn {
  font: inherit; font-size: var(--fs-small); font-weight: 700; color: var(--text-strong); background: none;
  border: 1.5px solid var(--text-strong); border-radius: 999px; padding: 7px 16px; cursor: pointer;
}
.bd-hl-btn:hover { background: var(--accent-soft); }
.bd-hl-btn[hidden] { display: none; }
