/* Book page (#/book/<id>): big cover, buy panel, details, table of contents, reviews, carousels.
   Only theme variables are used for colours, so it follows light / paper / dark / warm night / programmer. */

.bk .section { margin-top: 28px; }
.bk-sec { scroll-margin-top: 140px; }

/* ---------- product and purchase ---------- */
.bk-hero {
  display: grid;
  grid-template-columns: minmax(235px, .88fr) minmax(0, 1.3fr);
  gap: clamp(2rem, 6vw, 5.5rem);
  align-items: start;
  max-width: 1120px;
  margin: clamp(1rem, 4vw, 3.25rem) auto 0;
}
.bk-cover {
  position: relative;
  width: 100%;
  max-width: 460px;
  justify-self: center;
}
.bk-cover .cover {
  border-radius: 4px 8px 8px 4px;
  box-shadow: none;
}
@media (min-width: 681px) and (min-height: 540px) {
  .bk-cover {
    --bk-cover-top: 9.5rem;
    position: sticky;
    inset-block-start: var(--bk-cover-top);
    margin-block-start: -1.75rem;
    max-width: clamp(120px, calc((100svh - var(--bk-cover-top) - 1rem) * 2 / 3), 460px);
  }
}
.bk-discount {
  position: absolute;
  inset-block-start: 1rem;
  inset-inline-start: 1rem;
  padding: .28rem .65rem;
  border-radius: 4px;
  background: var(--primary-50);
  color: var(--primary);
  font-size: .78rem;
  font-weight: 700;
}
.bk-byline { margin: 0 0 .4rem; color: var(--muted); font-size: .92rem; }
.bk-byline a, .bk-summary a { color: var(--primary); }
.bk-byline a:hover, .bk-summary a:hover { text-decoration: underline; }
.bk-main { min-width: 0; padding-block-start: .35rem; }
.bk-main .title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: .75rem; }
.bk-main .title-row .heart.big { flex: none; }
.bk-main h1 {
  margin: 0;
  font-size: clamp(1.7rem, 3.4vw, 2.9rem);
  font-weight: 700;
  line-height: 1.35;
  overflow-wrap: anywhere;
}
.bk-price { margin-top: .85rem; }
.bk-price .price { flex-direction: row; flex-wrap: wrap; align-items: baseline; gap: .25rem .75rem; }
.bk-price .price .now { order: -1; font-size: clamp(1.25rem, 2.3vw, 1.7rem); color: var(--text); }
.bk-price .price .old { font-size: .95rem; }
.bk-rating { display: inline-flex; align-items: center; flex-wrap: wrap; gap: .35rem; margin-top: .45rem; font-size: .83rem; }
.bk-rating:hover { text-decoration: underline; }
.bk-rating .rating { color: var(--accent); }
.bk-summary { margin: 1rem 0 0; color: var(--muted); line-height: 1.95; overflow-wrap: anywhere; }
.bk-buy { margin-block: 1.5rem 0; }
.bk-actions { display: flex; flex-wrap: wrap; align-items: center; gap: .65rem; }
.bk-actions .btn {
  min-height: 50px;
  border-radius: 6px;
  padding: .6rem 1.05rem;
}
.bk-actions .bk-add { background: var(--btn-bg, var(--primary)); color: #fff; font-weight: 700; }
.bk-actions .bk-add:hover { background: var(--btn-hover, var(--primary-600)); color: #fff; }
.bk-actions .bk-add .store-icon { width: 18px; height: 18px; }
.bk-actions .bk-secondary { color: var(--text); background: var(--card); }
.bk-actions .bk-secondary:hover { background: var(--primary-50); }
.bk-qty {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding-inline-start: .7rem;
  min-height: 50px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
}
.bk-qty label { color: var(--muted); font-size: .84rem; }
.bk-qty .qty { border: 0; background: transparent; }
.bk-qty .qty button, .bk-qty .qty input { width: 33px; color: var(--text); background: transparent; }
.bk-qty .qty button:hover { background: var(--primary-50); }
.bk-qty .qty input:focus-visible { outline-offset: -3px; }
.bk-stock { margin: .65rem 0 0; font-size: .83rem; }
.bk-buy .sample-btn {
  width: auto;
  display: inline-flex;
  justify-content: start;
  min-height: 42px;
  margin-top: .9rem;
  padding: .45rem .8rem;
  border-radius: 6px;
  border: 1px solid var(--border);
  color: var(--primary);
  background: var(--card);
  box-shadow: none;
}
.bk-buy .sample-btn:hover { background: var(--primary-50); }
.bk-buy .sample-btn .ico-lg { width: 19px; height: 19px; }
.bk-sample-note { margin: .3rem 0 0; color: var(--muted); font-size: .76rem; }
.bk-bilingual, .bk-links { display: block; margin-top: .55rem; font-size: .84rem; color: var(--primary); }
.bk-buy .bk-perks {
  list-style: none;
  margin: .55rem 0 0;
  padding: 0;
  display: grid;
  gap: .2rem;
  color: var(--muted);
  font-size: .8rem;
}
.bk-lines {
  list-style: none;
  display: grid;
  gap: .2rem;
  margin: 1.25rem 0 0;
  padding: .85rem 0 0;
  border-top: 1px solid var(--border);
  font-size: .88rem;
}
.bk-lines li { display: flex; flex-wrap: wrap; gap: .35rem; }
.bk-lines span { color: var(--muted); }
.bk-lines b { font-weight: 500; }

/* ---------- sections ---------- */
.bk-about { position: relative; }
.bk-about .description { line-height: 2.1; margin: 0; }
.bk-about.clamped { max-height: 11.5em; overflow: hidden;
  -webkit-mask-image: linear-gradient(to bottom, #000 62%, transparent 100%); mask-image: linear-gradient(to bottom, #000 62%, transparent 100%); }
.bk-more { border: 0; background: none; color: var(--primary); font: inherit; font-weight: 700; cursor: pointer; padding: 8px 0 0; }
.bk-more:hover { text-decoration: underline; }
.bk-facts { margin: 0; max-width: 640px; }
.bk-facts td:first-child { width: 150px; }
.bk-facts a { color: var(--primary); }

.bk-author { display: flex; gap: 14px; align-items: center; margin-bottom: 8px; }
.bk-author-name { font-weight: 800; font-size: 1.1rem; color: var(--primary); }
.bk-avatar { width: 52px; height: 52px; border-radius: 50%; flex: none; display: inline-flex; align-items: center; justify-content: center;
  background: linear-gradient(140deg, var(--accent), var(--primary)); color: #fff; font-weight: 800; font-size: 1.3rem; }
.bk-avatar.sm { width: 30px; height: 30px; font-size: .9rem; }

.bk-toc { list-style: none; margin: 0; padding: 0; columns: 2 320px; column-gap: 40px; }
.bk-toc li { display: flex; align-items: baseline; gap: 8px; padding: 6px 0; break-inside: avoid; }
.bk-toc li[hidden] { display: none; }
.bk-toc li.sub { padding-right: 18px; color: var(--muted); font-size: .92em; }
.bk-toc li i { flex: 1; min-width: 12px; border-bottom: 1px dotted var(--border); transform: translateY(-4px); }
.bk-toc li b { color: var(--muted); font-weight: 500; font-variant-numeric: tabular-nums; }

/* ---------- reviews ---------- */
.bk-rate-sum { display: grid; grid-template-columns: 180px minmax(0, 1fr); gap: 28px; align-items: center; padding: 6px 0 18px; margin-bottom: 14px; border-bottom: 1px solid var(--border); }
.bk-rate-big { text-align: center; }
.bk-rate-big b { display: block; font-size: 3rem; line-height: 1.1; font-weight: 800; color: var(--primary); }
.bk-rate-big .rating { font-size: 1.15rem; }
.bk-rate-big small { display: block; color: var(--muted); margin-top: 2px; }
.bk-bars { display: grid; gap: 6px; max-width: 520px; }
.bk-bar { display: grid; grid-template-columns: 38px minmax(0, 1fr) 30px; gap: 10px; align-items: center; font-size: .85rem; color: var(--muted); }
.bk-bar i { height: 8px; border-radius: 99px; background: var(--border); overflow: hidden; }
.bk-bar em { display: block; height: 100%; border-radius: 99px; background: var(--accent); }
.bk-bar-n { text-align: left; }
.bk-review-form { margin-bottom: 14px; padding: 14px; border-radius: 12px; background: var(--primary-50); }
.bk-comment { margin: 6px 0 0; line-height: 2; }

/* ---------- carousel ---------- */
.bk-carousel { position: relative; }
.bk-row { scroll-padding-inline: 4px; padding-block: 6px 12px; scrollbar-width: thin; }
.bk-nav { display: none; }
@media (hover: hover) and (pointer: fine) {
  .bk-nav { display: flex; position: absolute; top: 38%; z-index: 3; width: 42px; height: 42px; border-radius: 50%; align-items: center; justify-content: center;
    border: 1px solid var(--border); background: var(--card); color: var(--text); box-shadow: var(--shadow); font-size: 1.6rem; line-height: 1; cursor: pointer; }
  .bk-nav:hover { background: var(--primary-50); }
  .bk-nav.prev { right: -14px; }
  .bk-nav.next { left: -14px; }
}

/* ---------- bar fixed above the phone's bottom menu ---------- */
.bk-sticky { display: none; }

/* ---------- entrance ---------- */
@media (prefers-reduced-motion: no-preference) {
  .bk-hero .bk-cover, .bk-hero .bk-main > * { animation: bk-rise .55s cubic-bezier(.2, .7, .2, 1) both; }
  .bk-hero .bk-main > :nth-child(2) { animation-delay: .05s; }
  .bk-hero .bk-main > :nth-child(3) { animation-delay: .1s; }
  .bk-hero .bk-main > :nth-child(4) { animation-delay: .15s; }
  .bk-hero .bk-main > :nth-child(5) { animation-delay: .2s; }
  .bk-hero .bk-main > :nth-child(6) { animation-delay: .25s; }
}
@keyframes bk-rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
@media (prefers-reduced-motion: reduce) { .bk-cover .cover { transition: none; } .bk-cover .cover:hover { transform: none; } }

/* ---------- tablet / phone ---------- */
@media (max-width: 900px) {
  .bk-hero { gap: 1.65rem; grid-template-columns: minmax(185px, .8fr) minmax(0, 1.2fr); }
}
@media (max-width: 680px) {
  .bk-rate-sum { grid-template-columns: minmax(0, 1fr); gap: 14px; }
  .bk-facts td:first-child { width: 110px; }
  .bk-toc { columns: 1; }
  body:has(.bk-sticky) { padding-bottom: calc(132px + env(safe-area-inset-bottom)); }
  .bk-sticky:not([hidden]) { display: flex; position: fixed; right: 0; left: 0; z-index: 55; bottom: calc(var(--bk-nav, 62px) + env(safe-area-inset-bottom));
    align-items: center; justify-content: space-between; gap: 14px; padding: 10px 16px; background: var(--card); border-top: 1px solid var(--border); box-shadow: 0 -8px 24px rgba(10, 18, 30, .14); }
  .bk-sticky .price .now { font-size: 1.15rem; font-weight: 800; color: var(--primary); }
  .bk-sticky .btn { min-width: 140px; min-height: 46px; }
  .bk-sticky-price { font-size: .9rem; }
}

/* ---------- collapsible sections (small arrow opens and closes) ---------- */
.bk-acc { padding: 0; overflow: hidden; }
.bk-acc > summary { list-style: none; display: flex; align-items: center; justify-content: space-between; gap: 12px; cursor: pointer; padding: 16px 22px; user-select: none; }
.bk-acc > summary::-webkit-details-marker { display: none; }
.bk-acc > summary h2 { margin: 0; font-size: 1.08rem; font-weight: 700; color: var(--text); }
.bk-acc > summary h2 small { font-weight: 400; font-size: .78rem; color: var(--muted); margin-right: 8px; background: var(--primary-50); border-radius: 999px; padding: 2px 10px; }
.bk-acc .chev { width: 28px; height: 28px; border-radius: 50%; background: var(--primary-50); flex: none; position: relative; transition: transform .25s ease; }
.bk-acc .chev::before { content: ""; position: absolute; inset: 0; margin: auto; width: 7px; height: 7px; border: solid var(--primary); border-width: 0 0 2px 2px; transform: translateY(-2px) rotate(-45deg); }
.bk-acc[open] > summary .chev { transform: rotate(180deg); }
.bk-acc > summary:hover .chev { background: color-mix(in srgb, var(--accent) 22%, var(--primary-50)); }
.bk-acc > summary:focus-visible { outline: 2px solid var(--accent); outline-offset: -2px; }
.bk-acc-body { padding: 0 22px 20px; border-top: 1px solid var(--border); padding-top: 16px; }
.bk-acc .bk-toc { max-height: 440px; overflow-y: auto; padding-inline-end: 6px; }
.bk-about .description + .description { margin-top: 12px; }

.bk-tabs { display: flex; gap: clamp(1rem, 3vw, 2rem); margin: 34px 0 0; border-bottom: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.bk-tabs a { padding: 12px 2px; color: var(--muted); font-size: 1rem; white-space: nowrap; border-bottom: 2px solid transparent; margin-bottom: -1px; }
.bk-tabs a:hover { color: var(--text); border-bottom-color: var(--cta, var(--accent)); }

.bk .bk-flat, .bk .bk-acc { max-width: 960px; margin-inline: auto; }
.bk #similar { max-width: 1120px; margin-inline: auto; margin-block-start: 3.25rem; }
.bk-flat { background: transparent; border: 0; box-shadow: none; padding: 0; margin-top: 40px; }
.bk-h { font-size: 1.45rem; font-weight: 700; line-height: 1.6; margin: 0 0 14px; color: var(--text); }
.bk-h small { font-size: .8rem; font-weight: 400; color: var(--muted); margin-inline-start: 8px; }
.bk-flat .bk-about .description { font-size: 1rem; line-height: 1.9; }
.bk-flat .bk-facts td { padding: 10px 0; border-bottom: 1px solid var(--border); }
.bk-flat .bk-facts td:first-child { color: var(--muted); }

@media (max-width: 680px) {
  .bk-hero { grid-template-columns: minmax(0, 1fr); gap: 1.2rem; }
  .bk-cover { max-width: 290px; }
  .bk-actions { align-items: stretch; }
  .bk-actions .bk-add { flex: 1 1 auto; }
  .bk-tabs { justify-content: flex-start; gap: 1.5rem; padding-inline: .25rem; }
  .bk-h { font-size: 1.2rem; }
  .bk-flat { margin-top: 30px; }
  .bk-sticky .btn { background: var(--btn-bg, var(--primary)); color: #fff; border-radius: 6px; }
}
