/* The book page (Views/Books/Details.cshtml, book-page.js): cover, title and a buy
   panel side by side. Under the cover a small menu jumps to Details, About, Reviews
   and Seller, which follow one after the other under the title (no tabs), so the
   page has no empty space beside the tall buy panel. On phones and tablets the buy
   panel comes straight after the title, the menu becomes a row of chips that stays
   at the top, and a buy bar stays at the bottom once the panel has scrolled away.
   Night mode overrides are at the end. */

.bp {
  --bp-ink: #18211a;
  --bp-muted: #5f6a5b;
  --bp-label: #3f4a3b; /* Details labels: a little darker than muted, semi-bold */
  --bp-line: #e1e6da;
  --bp-panel: #fff;
  --bp-soft: #fafbf8;
  --bp-paper: var(--bb-sage-50, #f5f7f1);
  --bp-blue: #1d4ed8;
  --bp-blue-soft: #eaf0fd;
  --bp-blue-deep: #1e3a8a;
  --bp-sage: #718a56;
  display: grid;
  gap: 1.5rem;
  margin-bottom: 1rem;
}

.bp-crumbs { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; margin: 0.25rem 0 1rem; font-size: 0.85rem; color: #5f6a5b; }
.bp-crumbs a { color: #1d4ed8; text-decoration: none; }
.bp-crumbs a:hover { text-decoration: underline; }
.bp-crumbs [aria-current] { color: #5f6a5b; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 60vw; }

/* ---- The page grid ----
   Rows: 1 = the title, 2 = whatever is left of the cover, 3 = the rest. The cover
   spans rows 1-2 and the menu starts right under it; Details starts right under the
   title (row 2), so neither column waits for the other. The buy panel spans all. */
.bp-top {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr) minmax(300px, 340px);
  grid-template-areas:
    "cover head buy"
    "cover main buy"
    "toc   main buy";
  grid-template-rows: auto auto 1fr;
  gap: 0 1.75rem;
  align-items: start;
}

.bp-cover { grid-area: cover; --cover-width: 220px; display: grid; gap: 0.6rem; padding-bottom: 1rem; }
.bp-cover > * { margin-left: 0; margin-right: 0; }
.bp-cover .book-detail-cover img { border-radius: 4px 10px 10px 4px; box-shadow: inset 6px 0 0 rgba(0, 0, 0, 0.2), 0 22px 36px -22px rgba(10, 20, 40, 0.65); }
.bp-cover p.small { margin: 0; }

.bp-head { grid-area: head; display: grid; gap: 0.55rem; min-width: 0; padding-bottom: 1.25rem; }
.bp-chips { display: flex; flex-wrap: wrap; gap: 0.35rem; align-items: center; }
.bp-chip { display: inline-flex; align-items: center; padding: 0.15rem 0.6rem; border-radius: 999px; font-size: 0.78rem; font-weight: 600; background: #f1f3ee; color: var(--bp-muted); white-space: nowrap; }
.bp-chip.is-pdf { background: #fde8e8; color: #b42318; }
.bp-chip.is-good { background: #e6f4ec; color: #1f7a46; }
.bp-chip.is-blue { background: var(--bp-blue-soft); color: var(--bp-blue); }
.bp-chip.is-out { background: #f4f4f2; color: #6b7280; }
.bp-chip.is-sale { background: #e6f4ec; color: #1f7a46; }
.bp .bp-title { margin: 0; font-size: clamp(1.7rem, 1.2rem + 2vw, 2.6rem); font-weight: 900; line-height: 1.08; color: var(--bp-blue-deep); overflow-wrap: anywhere; }
.bp-by { font-size: 1.05rem; }
.bp-by a { color: var(--bp-blue); font-weight: 600; text-decoration: none; }
.bp-by a:hover { text-decoration: underline; }
.bp-rating { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
/* The description, shown once under the title: a few lines (once book-page.js has
   checked it's long), then Read more opens the rest in place. */
.bp-blurb { margin: 0; color: var(--bp-ink); font-size: 1rem; line-height: 1.65; white-space: pre-line; overflow-wrap: anywhere; }
.bp-blurb.is-clamped { display: -webkit-box; -webkit-line-clamp: 4; -webkit-box-orient: vertical; overflow: hidden; }
.bp-readmore { justify-self: start; padding: 0; border: 0; background: none; font-size: 0.88rem; color: var(--bp-blue); text-decoration: none; font-weight: 600; }
.bp-readmore:hover { text-decoration: underline; }

/* ---- The buy panel ---- */
.bp-buy {
  grid-area: buy;
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 0.75rem;
  padding: 1rem;
  border: 1px solid var(--bp-line);
  border-radius: 1rem;
  background: var(--bp-panel);
  box-shadow: 0 18px 36px -28px rgba(24, 33, 26, 0.65);
  min-width: 0;
}

.bp-buy > * { margin: 0 !important; }
.bp-buy .buy-box { border: 0; background: transparent; box-shadow: none; }
.bp-buy .buy-box .card-body { padding: 0; }
.bp-buy .buy-box .card-body > .d-flex { flex-direction: column; align-items: stretch !important; gap: 0.75rem !important; }
.bp-buy .buy-box .btn { width: 100%; padding-block: 0.6rem; font-weight: 700; }
.bp-buy .buy-box form { width: 100%; }
.bp-buy .buy-box form.d-flex .btn { width: auto; flex: 1; }
.bp-buy .buy-box-price { font-size: 1.9rem; font-weight: 900; }
.bp-buy .wl-bookbar { margin: 0; }
.bp-buy .wl-bookbar form { flex: 1 1 auto; }
.bp-buy .wl-bookbar .wl-btn { width: 100%; justify-content: center; }
.bp-more-link { display: none; font-size: 0.88rem; font-weight: 600; color: var(--bp-blue); text-decoration: none; text-align: center; }

/* Keep on my space, then Share: two short lines, each split left / right. */
.bp-buy .bk-actions { display: grid; gap: 0.6rem; padding: 0.75rem 0 0; border: 0; border-top: 1px solid var(--bp-line); border-radius: 0; background: none; }
.bp-buy .shore-keep { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 0.4rem 0.6rem; margin: 0; padding: 0; border: 0; background: none; }
.shore-keep-label { font-size: 0.88rem; font-weight: 700; color: var(--bp-ink); white-space: nowrap; }
.shore-keep-form { display: flex; gap: 0.3rem; align-items: center; margin: 0; }
.shore-keep-form .form-select { width: auto; min-width: 9.5rem; border-radius: 0.5rem; font-size: 0.85rem; }
.bp-buy .shore-keep .shore-keep-link,
.bp-buy .shore-keep .shore-keep-signin { margin-left: 0; font-size: 0.82rem; font-weight: 600; white-space: nowrap; }
.bp-buy .shore-keep .shore-keep-link { flex-basis: 100%; text-align: right; }
.bp-buy .bk-actions .share-bar { display: flex; flex-wrap: wrap; align-items: center; gap: 0.3rem; width: auto; margin: 0; padding: 0.6rem 0 0; border: 0; border-top: 1px dashed var(--bp-line); }
.bp-buy .bk-actions .share-bar .bk-actions-label { margin-right: auto; }
.bp-buy .bk-actions .social-icon-sm { width: 1.85rem; height: 1.85rem; }
.social-icon-wave { --brand: #e8f0fe; font-size: 0.95rem; }
.bp-buy .bk-actions [data-copy-status]:not(:empty) { flex-basis: 100%; text-align: right; font-size: 0.75rem; }

/* ---- The side menu ---- */
.bp-toc {
  grid-area: toc;
  position: sticky;
  top: 1rem;
  display: grid;
  gap: 2px;
  padding: 0.5rem;
  border: 1px solid var(--bp-line);
  border-radius: 0.9rem;
  background: var(--bp-panel);
}
.bp-toc a { display: flex; justify-content: space-between; gap: 0.5rem; padding: 0.45rem 0.65rem; border-radius: 0.55rem; color: var(--bp-ink); font-weight: 600; font-size: 0.88rem; text-decoration: none; }
.bp-toc a span { color: var(--bp-muted); font-weight: 500; font-size: 0.78rem; }
.bp-toc a:hover { background: var(--bp-soft); }
.bp-toc a.is-on { background: var(--bp-blue-soft); color: var(--bp-blue); }
.bp-toc a:focus-visible { outline: 3px solid var(--bp-blue); outline-offset: 1px; }

/* ---- Details, About, Reviews, Seller ---- */
.bp-main { grid-area: main; display: grid; gap: 2rem; min-width: 0; }
.bp-sec { display: grid; gap: 0.75rem; min-width: 0; scroll-margin-top: 1rem; }
.bp .bp-sec-title { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.5rem; margin: 0; font-size: 1.25rem; font-weight: 800; }
.bp-sec-title small { font-size: 0.82rem; font-weight: 500; color: var(--bp-muted); }

/* Details: a spec sheet, "Label ······ value" in two columns with no boxes. The
   dotted leader is the row's ::before, placed between the label and the value. */
.bp-spec2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0 2.25rem; }
.bp-spec2 > div { display: flex; align-items: baseline; gap: 0.5rem; padding: 0.45rem 0; min-width: 0; }
.bp-spec2 > div::before { content: ""; order: 1; flex: 1 1 1rem; min-width: 1rem; border-bottom: 1.5px dotted #c7cebe; transform: translateY(-0.25rem); }
.bp-spec2 > div > small { order: 0; flex: none; font-size: 0.92rem; font-weight: 600; color: var(--bp-label); white-space: nowrap; }
.bp-spec2 > div > span { order: 2; flex: 0 1 auto; min-width: 0; font-weight: 600; text-align: right; overflow-wrap: anywhere; }
.bp-spec2 > .bp-spec-wide { grid-column: 1 / -1; }
.bp-spec2 .badge-category { vertical-align: baseline; }

.bp-description { margin: 0; font-size: 1.02rem; line-height: 1.7; white-space: pre-line; }
.bp-sec .why-read { margin: 0; }

.bp-reviews-card { display: grid; grid-template-columns: minmax(0, 200px) minmax(0, 1fr); gap: 1.25rem; padding: 1rem 1.1rem; border: 1px solid var(--bp-line); border-radius: 0.9rem; background: var(--bp-panel); }
.bp-reviews-list { min-width: 0; }
.bp-reviews-list > :last-child { margin-bottom: 0; }

.bp-seller-card { border: 1px solid var(--bp-line); border-radius: 0.9rem; padding: 0.75rem 1rem; background: var(--bp-panel); }
.bp-seller-card dt { color: var(--bp-muted); }
.bp-howto { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 0.6rem; }
.bp-howto div { display: grid; gap: 0.15rem; padding: 0.75rem 0.9rem; border-radius: 0.8rem; background: var(--bp-soft); border: 1px solid var(--bp-line); }
.bp-howto span { color: var(--bp-muted); font-size: 0.9rem; }

/* ---- Phone buy bar ---- */
.bp-phonebar { display: none; }

@media (max-width: 1199.98px) {
  .bp-top { grid-template-columns: 180px minmax(0, 1fr) minmax(280px, 300px); gap: 0 1.25rem; }
  .bp-cover { --cover-width: 180px; }
}

/* Tablets and phones: one column after the cover and title, the menu as a chip row
   that stays at the top. A wrapping flex row (not a grid) so the chip row can stick
   for the whole page. */
@media (max-width: 991.98px) {
  .bp-top { display: flex; flex-wrap: wrap; align-items: flex-start; gap: 1rem 1.25rem; }
  .bp-cover { flex: 0 0 170px; --cover-width: 170px; padding-bottom: 0; }
  .bp-head { flex: 1 1 0; padding-bottom: 0; }
  .bp-buy, .bp-toc, .bp-main { flex: 0 0 100%; }
  .bp-buy { position: static; }
  .bp-toc {
    top: 0;
    z-index: 5;
    display: flex;
    gap: 0.4rem;
    overflow-x: auto;
    padding: 0.5rem 0;
    border: 0;
    border-radius: 0;
    background: var(--bp-paper);
    scrollbar-width: none;
  }
  .bp-toc::-webkit-scrollbar { display: none; }
  .bp-toc a { flex: none; padding: 0.3rem 0.8rem; border: 1px solid var(--bp-line); border-radius: 999px; background: var(--bp-panel); font-size: 0.85rem; }
  .bp-toc a.is-on { border-color: var(--bp-blue); }
  .bp-sec { scroll-margin-top: 3.5rem; }
}

@media (max-width: 767.98px) {
  .bp-top { gap: 0.9rem; }
  .bp-cover { flex-basis: 110px; --cover-width: 110px; gap: 0.4rem; }
  .bp-cover p.small { display: none; }
  .bp-cover .look-inside-btn { padding: 0.35rem 0.5rem; font-size: 0.8rem; }
  .bp-cover .look-inside-btn small { display: none; }
  .bp .bp-title { font-size: 1.5rem; }
  .bp-buy { border-color: #c9d6f7; box-shadow: 0 12px 28px -20px rgba(29, 78, 216, 0.6); }
  .bp-more-link { display: block; }
  .bp-spec2 { grid-template-columns: minmax(0, 1fr); }
  .bp-reviews-card { grid-template-columns: minmax(0, 1fr); }

  .bp-phonebar {
    position: fixed;
    z-index: 1035;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem max(0.9rem, env(safe-area-inset-right, 0px)) calc(0.6rem + env(safe-area-inset-bottom, 0px)) 4.5rem;
    background: rgba(255, 255, 255, 0.97);
    border-top: 1px solid var(--bp-line, #e1e6da);
    box-shadow: 0 -8px 24px -18px rgba(0, 0, 0, 0.4);
    transform: translateY(110%);
    transition: transform 0.2s ease;
  }
  .bp-phonebar.is-shown { transform: none; }
  .bp-phonebar-price { flex: 1; font-weight: 900; font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .bp-phonebar .btn { padding: 0.5rem 1rem; font-weight: 700; white-space: nowrap; }
  .bp-pb-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border: 1px solid #e1e6da; border-radius: 50%; background: #fff; cursor: pointer; padding: 0; }
  .bp-pb-icon svg { width: 18px; height: 18px; fill: none; stroke: #5f6a5b; stroke-width: 2; stroke-linejoin: round; }
  .bp-pb-icon.is-wish[aria-pressed="true"] svg { fill: #718a56; stroke: #718a56; }
  .bp-pb-icon.is-fav[aria-pressed="true"] svg { fill: #d6336c; stroke: #d6336c; }
  body.bp-has-bar { padding-bottom: 4.5rem; }
}

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

/* ---- Night mode ---- */
[data-blog-theme="dark"] .bp {
  --bp-ink: #e6eadf;
  --bp-muted: #adb7a4;
  --bp-label: #c6cfbd;
  --bp-line: #2f3628;
  --bp-panel: #1a1e15;
  --bp-soft: #20261a;
  --bp-paper: var(--blog-night-page, #12150f);
  --bp-blue-soft: #1c2742;
  --bp-blue-deep: #a9c1ff;
  --bp-blue: #8fb0ff;
}
[data-blog-theme="dark"] .bp-crumbs a { color: #8fb0ff; }
[data-blog-theme="dark"] .bp-chip { background: #262c20; color: #c6cfbd; }
[data-blog-theme="dark"] .bp-chip.is-blue { background: #1c2742; color: #a9c1ff; }
[data-blog-theme="dark"] .bp-chip.is-good,
[data-blog-theme="dark"] .bp-chip.is-sale { background: #173322; color: #8fd6a6; }
[data-blog-theme="dark"] .bp-chip.is-pdf { background: #3a1d1d; color: #f2a5a5; }
[data-blog-theme="dark"] .social-icon-wave { --brand: #1c2742; }
[data-blog-theme="dark"] .bp-spec2 > div::before { border-bottom-color: #4a5340; }
[data-blog-theme="dark"] .bp-phonebar { background: rgba(26, 30, 21, 0.97); border-color: #2f3628; }
[data-blog-theme="dark"] .bp-pb-icon { background: #1a1e15; border-color: #2f3628; }
