/* nustreads: book page (/?b=<bib>), Goodreads' book show page (SPEC §7). Loads after app.css. */

/* PageFrame: 87.5 % wide, max 1260 (1120 at a 1280 viewport). */
.wrap.bk-frame { width: 87.5%; max-width: var(--frame-max); padding: 0; padding-top: 16px; }
.bk-frame > .crumb { margin-bottom: 8px; }

/* 12-column grid, 3 / 9, the right column padded 32 px. */
.bk-grid { display: grid; grid-template-columns: repeat(12, minmax(0, 1fr)); align-items: start; margin-bottom: 40px; }
.bk-left { grid-column: span 3; align-self: stretch; }
.bk-sticky { position: sticky; top: calc(var(--top-h, 0px) + 16px); display: flex; flex-direction: column; align-items: stretch; }
.bk-main { grid-column: span 9; padding-left: 32px; min-width: 0; }

/* cover: 70 % of the column (186 px at 1280) */
.bk-cover.cv { width: 70%; margin: 0 auto 24px; border-radius: var(--r-cover); filter: var(--sh-cover); }
.bk-cover .ph b { font-size: 16px; -webkit-line-clamp: 8; }

/* left column actions: WTR split (full width), second button 16 px below, Rate this book */
.bk-acts { display: flex; flex-direction: column; gap: 16px; }
.bk-acts .split { width: 100%; height: var(--btn-h); }
.bk-acts .split-main { border-radius: var(--r-ctl) 0 0 var(--r-ctl); font: var(--w-sans-bold) 16px var(--font-sans); }
.bk-acts .split-arrow { width: 44px; border-radius: 0 var(--r-ctl) var(--r-ctl) 0; }
.bk-acts .split-menu { left: 0; right: 0; }
/* the shelf control's children join the column so the second button can sit between the split and the stars (Goodreads order) */
.bk-acts .shelf-ctl { display: contents; }
.bk-acts .shelf-ctl > .split { order: 1; }
.bk-acts > .bk-pill { order: 2; }
.bk-acts .shelf-ctl > .rate-line { order: 3; }
.bk-acts .shelf-ctl > .hint { order: 3; }
.bk-acts > .bk-hint { order: 4; }
.bk-pill { display: inline-flex; align-items: center; justify-content: center; width: 100%; height: var(--btn-h); padding: 0 20px;
  border: 2px solid var(--green-line); border-radius: var(--r-ctl); background: var(--bg); color: rgba(39,28,20,.88);
  font: var(--w-sans-bold) 16px var(--font-sans); cursor: pointer; text-decoration: none; transition: background .2s ease-in-out; }
.bk-pill:hover { background: rgba(0,0,0,.05); text-decoration: none; }
.bk-pill:focus-visible { outline: 0; box-shadow: 0 0 0 3px #fff, 0 0 0 6px var(--green-line); }
.bk-pill.on::before { content: "✓"; color: var(--wtr); margin-right: 8px; }
.bk-pill:disabled { opacity: .6; cursor: default; }
.bk-hint { margin: -4px 0 0; text-align: center; font: 400 14px/18px var(--font-sans); color: var(--ink-soft); }

/* title block */
.bk-title { font: var(--hw) 36px/46px var(--font-serif); color: var(--ink); margin: 0; letter-spacing: -.005em; }
.bk-sub { margin: 2px 0 0; font: 400 20px/28px var(--font-serif); color: var(--ink-soft); }
.bk-author { margin: 0 0 4px; font: 400 20px/28px var(--font-serif); color: var(--ink); }
.bk-head .bk-author a { color: inherit; text-decoration: none; }
.bk-head .bk-author a:hover { text-decoration: underline; }
/* availability in the RatingStatistics slot */
.bk-avail { display: flex; align-items: baseline; flex-wrap: wrap; margin: 4px 0 0; color: var(--ink); }
.bk-avail b { font: var(--hw) 22px/30px var(--font-serif); margin-right: 10px; }
.bk-avail span { font: 400 14px/19px var(--font-sans); color: var(--subdued); }
.bk-avail.in b::before { content: ""; display: inline-block; width: 10px; height: 10px; border-radius: 50%; background: var(--wtr); margin-right: 10px; vertical-align: 4px; }

/* description: clamped to 7 lines (no fade), then "Show more" */
/* Goodreads: the right column is 803 px with its rules full width; text paragraphs stop at 614 px. */
.bk-body { max-width: 803px; }
.bk-desc, .bk-genres, .bk-facts { max-width: 614px; }
.bk-desc { margin-top: 6px; font: 400 16px/22px var(--font-sans); color: var(--ink); position: relative; white-space: pre-line; }
.bk-desc p { margin: 0; }
.bk-desc.bk-clamp { display: -webkit-box; -webkit-line-clamp: 7; -webkit-box-orient: vertical; overflow: hidden; }
.bk-more { display: inline-flex; align-items: center; gap: 8px; height: 44px; padding: 10px 0; border: 0; background: none; color: var(--ink);
  font: var(--w-sans-bold) 16px var(--font-sans); cursor: pointer; }
.bk-more:hover { text-decoration: underline; }
.bk-more svg { width: 16px; height: 16px; transition: transform .2s; }
.bk-more[aria-expanded="true"] svg { transform: rotate(180deg); }

/* genres: green-underlined text tags (SPEC §8) */
.bk-genres { display: flex; flex-wrap: wrap; align-items: baseline; margin-top: 8px; }
.bk-genres-l { font: 400 14px/18px var(--font-sans); color: var(--subdued); padding: 0 16px 8px 0; }
.bk-genres ul { display: contents; list-style: none; }
.bk-genres li { display: inline; }
.bk-tag { position: relative; display: inline-block; padding: 10px 0; margin-right: 12px; border-radius: var(--r-tag);
  font: var(--w-sans-bold) 16px/23px var(--font-sans); color: var(--ink); }
.bk-tag::before, .bk-tag::after { content: ""; position: absolute; left: 0; bottom: 10px; width: 100%; height: 2px; background: var(--green-line); transition: background .3s ease-out, transform .3s ease-out; }
.bk-tag::after { transform: scaleX(0); transform-origin: left; }
.bk-tag:hover { text-decoration: none; }
.bk-tag:hover::before { background: var(--green-line-soft); }
.bk-tag:hover::after { transform: scaleX(1); }

.bk-facts { margin: 12px 0; }
.bk-facts p { margin: 0; font: 400 14px/18px var(--font-sans); color: var(--ink-soft); }
.bk-meta { margin: 0; font: 400 14px/18px var(--font-sans); color: var(--subdued); }

/* sections: 1 px rule, serif 20 heading, no boxes */
.bk-sec { border-top: 1px solid var(--divider); margin-top: 24px; padding-top: 24px; }
.bk-sec h2 { font: 400 20px/28px var(--font-serif); color: var(--ink); margin: 0 0 16px; }
.bk-body > .bk-sec:first-of-type { margin-top: 24px; }

/* where to find it */
.bk-where { width: 100%; border-collapse: collapse; font: 400 16px/22px var(--font-sans); }
.bk-where thead th { text-align: left; font: 400 14px/18px var(--font-sans); color: var(--subdued); padding: 0 16px 8px 0; border-bottom: 1px solid var(--divider); }
.bk-where tbody th, .bk-where td { text-align: left; padding: 13px 16px 13px 0; border-bottom: 1px solid var(--divider); vertical-align: top; font-weight: 400; }
.bk-where tbody th { font-weight: var(--w-sans-bold); }
.bk-where .bk-call { font: 400 14px/22px ui-monospace, "SF Mono", Menlo, Consolas, monospace; color: var(--ink-soft); white-space: nowrap; }
.bk-where .bk-n { color: var(--subdued); font-size: 14px; white-space: nowrap; padding-right: 0; }
.bk-st { display: inline-flex; align-items: baseline; gap: 6px; flex-wrap: wrap; white-space: nowrap; }
.bk-st::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: var(--star-empty); align-self: center; }
.bk-st.in { color: var(--green-text); font-weight: var(--w-sans-bold); }
.bk-st.in::before { background: var(--wtr); }
.bk-st.ref::before { background: var(--ref, #8a6a24); }
.bk-st small { font-size: 14px; color: var(--subdued); font-weight: 400; }
.bk-where-foot { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; margin-top: 16px; }
.bk-where-foot .bk-pill { width: auto; }
.bk-ext { font: 400 14px/18px var(--font-sans); color: var(--subdued); text-decoration: underline; text-underline-offset: 2px; }
.bk-ext:hover { color: var(--ink); }

/* details */
.bk-dl { display: grid; grid-template-columns: 140px minmax(0, 1fr); gap: 8px 16px; margin: 0; font: 400 14px/20px var(--font-sans); }
.bk-dl dt { color: var(--subdued); }
.bk-dl dd { margin: 0; color: var(--ink); overflow-wrap: anywhere; }

/* readers */
/* Goodreads' social proof row: round faces overlapping with a white ring, one line beside them, two items side by side */
.bk-proofs { display: flex; flex-wrap: wrap; gap: 16px 40px; }
.bk-proof { display: flex; align-items: center; gap: 16px; flex: 1 1 260px; min-width: 0; font: 400 16px/22px var(--font-sans); color: var(--ink); }
.bk-stack { display: flex; flex: none; }
.bk-stack .av { width: 42px; height: 42px; border-radius: 50%; box-shadow: 0 0 0 2px var(--bg); margin-left: -10px; font-size: 16px; }
.bk-stack .av:first-child { margin-left: 0; }
.bk-people { list-style: none; margin: 24px 0 0; padding: 0; display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px 24px; }
.bk-people li { display: flex; align-items: center; justify-content: space-between; gap: 12px; min-width: 0; }
.bk-people a { display: inline-flex; align-items: center; gap: 10px; min-width: 0; color: var(--ink); }
.bk-people a b { font: var(--hw) 14px/20px var(--font-serif); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-people .av { width: 32px; height: 32px; font-size: 13px; }
.bk-people li > span { font: 400 14px/18px var(--font-sans); color: var(--subdued); white-space: nowrap; }
.bk-pitch { margin: 0; font: 400 14px/20px var(--font-sans); color: var(--ink-soft); }
.bk-proofs + .bk-pitch { margin-top: 16px; }
.bk-link { border: 0; background: none; padding: 0; font: var(--w-sans-bold) 14px/20px var(--font-sans); color: var(--ink); cursor: pointer; }
.bk-link:hover { text-decoration: underline; }

/* more by the author: 4 cards per row, 32 px gap, scrolls sideways */
.bk-strip-wrap { position: relative; }
.bk-strip { list-style: none; margin: 0; padding: 0 0 4px; display: grid; grid-auto-flow: column; grid-auto-columns: calc((100% - 96px) / 4); gap: 32px;
  overflow-x: auto; scroll-snap-type: x mandatory; scrollbar-width: none; }
.bk-strip::-webkit-scrollbar { display: none; }
.bk-strip li { scroll-snap-align: start; display: flex; flex-direction: column; min-width: 0; }
.bk-strip .cv { width: 100%; margin-bottom: 12px; border-radius: var(--r-cover); }
.bk-strip .ph b { font-size: 14px; }
.bk-card-t { font: var(--hw) 16px/24px var(--font-serif); color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.bk-card-a { font: 400 14px/20px var(--font-sans); color: var(--ink); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bk-card-s { font: 400 14px/20px var(--font-sans); color: var(--subdued); }
.bk-card-s.in { color: var(--green-text); }
.bk-next { position: absolute; right: -22px; top: 30%; width: 44px; height: 44px; border-radius: var(--r-ctl); border: 1px solid var(--line-soft); background: var(--bg);
  display: grid; place-items: center; cursor: pointer; color: var(--ink); }
.bk-next:hover { background: var(--bg-hover); }
.bk-next svg { width: 20px; height: 20px; }
.bk-sec > .bk-more { margin-top: 8px; }

.bk-frame :focus-visible { outline: 0; box-shadow: var(--sh-focus); border-radius: 3px; }

@media (max-width: 1279px) { .wrap.bk-frame { width: 91%; } .bk-cover.cv { width: 80%; } }

/* tablet: 2 / 4 of 6 */
@media (max-width: 1023px) {
  .bk-grid { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .bk-left { grid-column: span 2; }
  .bk-main { grid-column: span 4; padding-left: 24px; }
  .bk-title { font-size: 32px; line-height: 42px; }
  .bk-strip { grid-auto-columns: calc((100% - 48px) / 3); gap: 24px; }
}

/* phone: one centred column; cover, title, actions, then the rest left-aligned (SPEC §14) */
@media (max-width: 767px) {
  .wrap.bk-frame { width: 92%; padding-top: 8px; }
  .bk-grid { display: flex; flex-direction: column; align-items: stretch; }
  .bk-left, .bk-sticky, .bk-main { display: contents; }
  .bk-cover.cv { order: 1; width: 35%; min-width: 120px; margin: 8px auto 16px; }
  .bk-head { order: 2; text-align: center; }
  .bk-acts { order: 3; margin-top: 16px; }
  .bk-body { order: 4; max-width: none; margin-top: 8px; }
  .bk-title { font-size: 22px; line-height: 30px; }
  .bk-sub { font-size: 16px; line-height: 22px; }
  .bk-avail { justify-content: center; text-align: center; }
  .bk-avail b { font-size: 18px; line-height: 26px; margin-right: 8px; }
  .bk-where thead { display: none; }
  .bk-where, .bk-where tbody { display: block; }
  .bk-where tr { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 2px 12px; padding: 12px 0; border-bottom: 1px solid var(--divider); }
  .bk-where tbody th, .bk-where td { padding: 0; border: 0; }
  .bk-where tbody th { grid-column: 1; }
  .bk-where .bk-n { grid-column: 2; grid-row: 1; text-align: right; }
  .bk-where .bk-call { grid-column: 1 / -1; white-space: normal; }
  .bk-where td:nth-child(3) { grid-column: 1 / -1; }
  .bk-where tr:first-child { border-top: 1px solid var(--divider); }
  .bk-dl { grid-template-columns: 110px minmax(0, 1fr); }
  .bk-people { grid-template-columns: 1fr; }
  .bk-proof { flex-basis: 100%; font-size: 14px; line-height: 20px; gap: 12px; }
  .bk-stack .av { width: 36px; height: 36px; font-size: 14px; }
  .bk-strip { grid-auto-columns: calc((100% - 32px) / 2.4); gap: 16px; }
  .bk-next { display: none; }
}
