/* Reader page — elegant chapter reading on top of the BookBlock flip.
   Relies on the palette/fonts defined in main.css (loaded first). */

.reader-body .site-footer { display: none; }

.book-container { position: relative; }

/* top bar */
.reader-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 0 8px;
}
.toc-toggle {
  font-size: 0.74rem; letter-spacing: 0.16em; text-transform: uppercase;
  font-weight: 700; color: var(--coral-deep); display: inline-flex; align-items: center; gap: 8px;
}
.toc-toggle:hover { color: var(--ink); }
.toc-toggle__icon { font-size: 1rem; }
.reader-book-title {
  font-family: var(--font-display); font-size: 0.78rem;
  letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-soft);
  text-align: center; flex: 1; padding: 0 16px;
}
.reader-close {
  font-size: 1.9rem; line-height: 1; color: var(--coral-deep); text-decoration: none;
}
.reader-close:hover { color: var(--ink); }

/* the flip stage */
.reader-stage {
  position: relative;
  height: calc(100vh - 200px);
  min-height: 460px;
  margin-top: 8px;
}
.bb-bookblock {
  width: 100% !important;
  background: transparent;
  margin: 0 auto;
}
.bb-item { background: var(--paper); }

.reader-scroll {
  position: relative;
  height: 100%;
  overflow: hidden;
  padding: 6px 7%;
}

/* chapter typography */
.chapter { max-width: 680px; margin: 0 auto; padding: 24px 0 70px; }
.chapter__title {
  font-family: var(--font-display); font-weight: 900;
  text-transform: uppercase; letter-spacing: 0.05em; text-align: center;
  font-size: clamp(1.9rem, 4vw, 3rem); margin: 0 0 42px;
}
.chapter__body {
  font-family: var(--font-sans); font-size: 1.1rem; line-height: 1.95;
  color: var(--ink-soft); text-align: justify;
}
.chapter__body p { margin: 0 0 1.3em; }
.chapter__body > p:first-of-type::first-letter {
  float: left; font-family: var(--font-display); font-weight: 900;
  font-size: 4.4em; line-height: 0.82; padding: 8px 14px 0 0; color: var(--gold);
}
.chapter__body h2, .chapter__body h3 {
  font-family: var(--font-serif); color: var(--ink); margin: 1.6em 0 0.6em;
}
.chapter__body blockquote {
  border-left: 2px solid var(--coral); margin: 1.4em 0; padding: 4px 0 4px 22px;
  font-family: var(--font-serif); font-style: italic; color: var(--ink);
}
/* Wagtail rich-text image alignment */
.chapter__body img { max-width: 100%; height: auto; border-radius: 2px; }
.chapter__body .richtext-image.left  { float: left;  max-width: 44%; margin: 6px 30px 16px 0; }
.chapter__body .richtext-image.right { float: right; max-width: 44%; margin: 6px 0 16px 30px; }
.chapter__body .richtext-image.full-width { display: block; margin: 26px auto; }

/* nav arrows */
.bb-nav {
  position: absolute; top: 50%; transform: translateY(-50%);
  font-size: 1.8rem; color: var(--coral); text-decoration: none; z-index: 1010;
  width: 52px; height: 52px; display: grid; place-items: center;
  transition: color 0.15s ease, transform 0.15s ease;
}
.bb-nav:hover { color: var(--coral-deep); }
.bb-nav--prev { left: 0; }
.bb-nav--next { right: 0; }
.bb-nav.is-hidden { display: none; }

/* table of contents drawer */
.reader-toc {
  position: fixed; top: 0; left: 0; height: 100%; width: 330px; max-width: 84vw;
  background: var(--paper); border-right: 1px solid var(--line);
  box-shadow: 18px 0 40px rgba(40, 32, 18, 0.10);
  transform: translateX(-100%); transition: transform 0.32s ease;
  z-index: 300; padding: 86px 38px; overflow-y: auto;
}
.reader-toc.is-open { transform: none; }
.reader-toc__title {
  font-family: var(--font-display); text-transform: uppercase;
  letter-spacing: 0.04em; font-size: 1.2rem; margin: 0 0 26px;
}
.menu-toc { list-style: none; margin: 0; padding: 0; }
.menu-toc li {
  cursor: pointer; color: var(--coral-deep);
  font-family: var(--font-serif); font-size: 1.3rem; line-height: 1.3;
  padding: 12px 0 12px 16px; border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}
.menu-toc li:hover { color: var(--ink); }
.menu-toc li.is-current { color: var(--ink); border-left-color: var(--coral); }

/* perfect-scrollbar styled as the thin vertical progress line + dot */
.ps__rail-y {
  width: 1px !important; background: var(--line-2) !important;
  opacity: 1 !important; right: 22px !important;
}
.ps__thumb-y {
  width: 11px !important; height: 11px !important; right: -5px !important;
  border-radius: 50%; background: var(--ink) !important;
}

@media (max-width: 680px) {
  .reader-scroll { padding: 6px 18px; }
  .bb-nav { width: 40px; height: 40px; font-size: 1.4rem; }
  .reader-stage { height: calc(100vh - 170px); }
}

/* ---- BookBlock layout (Codrops BookBlock, free license) ---- */
.bb-bookblock { position: relative; z-index: 100; }
.bb-page {
  width: 50%; height: 100%; left: 50%; position: absolute;
  transform-style: preserve-3d; transform-origin: left center;
}
.bb-page > div, .bb-outer, .bb-content { position: absolute; height: 100%; top: 0; left: 0; }
.bb-content { background: var(--paper); }
.bb-inner { position: relative; width: 100%; height: 100%; }
.bb-overlay, .bb-outer { backface-visibility: hidden; }
.bb-page > div { width: 100%; transform-style: preserve-3d; backface-visibility: hidden; }
.bb-back { transform: rotateY(-180deg); }
.bb-outer { width: 100%; overflow: hidden; z-index: 999; }
.bb-overlay, .bb-flipoverlay {
  background-color: rgba(0,0,0,0.6); position: absolute; top: 0; left: 0;
  width: 100%; height: 100%; opacity: 0; z-index: 1000;
}
.bb-flipoverlay { background-color: rgba(0,0,0,0.2); }
.bb-bookblock > div.bb-page:first-child,
.bb-bookblock > div.bb-page:first-child .bb-back { transform: rotateY(180deg); }
.js .bb-item {
  width: 100%; height: 100%; position: absolute; top: 0; left: 0;
  display: none; background: var(--paper);
}

/* ---- perfect-scrollbar base (MIT) ---- */
.ps { overflow: hidden !important; overflow-anchor: none; touch-action: auto; }
.ps__rail-y { display: none; position: absolute; width: 15px; right: 0; }
.ps--active-y > .ps__rail-y { display: block; }
.ps__thumb-y { position: absolute; right: 2px; width: 6px; border-radius: 6px; background: #aaa; }
