/* ============================================
   BOOK CHROME — Page Shell Styles
   ============================================
   Site nav, book header, bottom bar, TOC overlay,
   chapter bottom nav, cover page layout.
   Shared by all book pages (chapters + cover).
   ============================================ */

/* ── Site nav ── */
.site-nav {
  position: sticky;
  top: 0;
  z-index: 200;
  background: #faf8f4;
  height: 64px;
  display: flex;
  align-items: center;
  padding: 10px 1.25rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.site-nav-inner {
  display: flex;
  align-items: center;
  width: 100%;
  position: relative;
}
.site-nav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  flex-shrink: 0;
}
.site-nav-brand:hover { opacity: 1; }
.brand-logo {
  height: 40px;
  width: auto;
  opacity: 0.85;
  transition: opacity 0.2s;
}
.site-nav-brand:hover .brand-logo { opacity: 1; }
.book-title-link {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Fraunces', serif;
  font-size: 0.8rem;
  font-weight: 400;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(44, 36, 32, 0.6);
  text-decoration: none;
  transition: color 0.2s;
}
.book-title-link:hover { color: #2c2420; }
.brand-beta {
  position: absolute;
  right: 0;
  font-family: 'Fraunces', serif;
  font-size: 0.5rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #C25335;
  border: 1px solid rgba(194, 83, 53, 0.4);
  border-radius: 3px;
  padding: 1px 5px;
  line-height: 1.4;
}

/* Centered book title with library icon */
.book-switch {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: rgba(44, 36, 32, 0.6);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  transition: color 0.2s, background 0.2s;
}
.book-switch:hover {
  color: #2c2420;
  background: rgba(0, 0, 0, 0.04);
}
.book-switch-icon {
  width: 16px; height: 16px;
  stroke: #C25335; fill: none;
  stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round;
}
.book-switch-label { color: rgba(44, 36, 32, 0.4); }
.book-switch-title { color: rgba(44, 36, 32, 0.8); }

/* ── Book header (static hero) ── */
.book-header {
  background: #ffffff;
  position: relative;
  overflow: hidden;
}
.book-header-bg { display: none; }
.book-header-overlay { display: none; }
.book-header-inner {
  position: relative;
  z-index: 2;
  max-width: 760px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
  text-align: left;
  gap: 24px;
  padding: 120px 32px 120px;
}
.book-header-inner .book-header-cover-wrap { flex: 0 0 auto; }
.book-header-inner .book-header-text-wrap { flex: 1; }
.book-header-title {
  font-family: 'Fraunces', serif;
  font-size: 0.875rem;
  letter-spacing: 0.12em;
  color: #5a4f42;
  margin-bottom: 12px;
  text-transform: uppercase;
}
.book-header-chapter {
  font-family: 'IM Fell French Canon', serif;
  font-size: 3.8rem;
  font-weight: 400;
  color: #2c2420;
  line-height: 1.05;
  margin-bottom: 12px;
  text-align: left;
}

/* ── Bottom bar — sticky to bottom ── */
.bottom-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 500;
  background: rgba(250, 248, 244, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  padding: 0 1rem;
  transition: height 0.4s ease, background 0.4s ease, border-top-color 0.4s ease;
}
.bottom-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1000px;
  gap: 8px;
}
.ch-prev, .ch-next {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px; height: 36px;
  border-radius: 50%;
  background: transparent;
  text-decoration: none;
  flex-shrink: 0;
  transition: background 0.2s;
}
.ch-prev:hover, .ch-next:hover {
  background: rgba(0, 0, 0, 0.06);
}
.ch-prev[aria-disabled="true"],
.ch-next[aria-disabled="true"] {
  opacity: 0.2;
  pointer-events: none;
}
.ch-prev-title, .ch-next-title { display: none; }
.ch-prev svg, .ch-next svg {
  width: 16px; height: 16px;
  stroke: #2c2420; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* Center of bottom bar: chapter name + TOC icon */
.bottom-bar-center {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  background: none;
  border: none;
  padding: 6px 14px;
  border-radius: 4px;
  transition: background 0.2s;
}
.bottom-bar-center:hover { background: rgba(0, 0, 0, 0.04); }
.bottom-bar-chapter {
  font-family: 'Libre Baskerville', serif;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  text-transform: uppercase;
  color: #2c2420;
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.toc-icon {
  width: 24px; height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.2s;
}
.bottom-bar-center:hover .toc-icon { transform: scale(1.15); }
.toc-icon svg {
  width: 20px; height: 20px;
  stroke: #C25335; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── Fullscreen TOC overlay ── */
.toc-overlay {
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(250, 248, 244, 0.98);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
.toc-overlay.is-open { display: flex; }
.toc-overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}
.toc-overlay-title {
  font-family: 'IM Fell French Canon', serif;
  font-size: 1.2rem;
  color: #2c2420;
}
.toc-close {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.04);
  border: none;
  color: rgba(44, 36, 32, 0.6);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}
.toc-close:hover { background: rgba(0, 0, 0, 0.08); color: #2c2420; }
.toc-close svg {
  width: 18px; height: 18px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}
.toc-overlay-list {
  list-style: none;
  padding: 12px 0;
  max-width: 600px;
  margin: 0 auto;
  width: 100%;
}
.toc-overlay-list a {
  display: block;
  padding: 12px 24px;
  font-family: 'Libre Baskerville', serif;
  font-size: 1rem;
  color: rgba(44, 36, 32, 0.5);
  text-decoration: none;
  transition: color 0.15s, background 0.15s;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
}
.toc-overlay-list a:hover {
  color: #2c2420;
  background: rgba(0, 0, 0, 0.03);
}
.toc-overlay-list a.active {
  color: #2c2420;
  background: rgba(107, 58, 42, 0.2);
  border-left: 3px solid rgba(107, 58, 42, 0.6);
}

/* Bottom padding for fixed bottom bar */
body.has-bottom-bar { padding-bottom: 56px; }

/* ── Cover page — side-by-side layout ── */
.book-header.is-cover .book-header-bg { opacity: 0.3; }
.book-header.is-cover .book-header-inner {
  flex-direction: row;
  text-align: left;
  padding: 48px 2rem 84px;
  gap: 40px;
  align-items: center;
}
.book-header-cover-wrap {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
}
.book-header.is-cover .book-header-cover {
  width: 100%;
  max-width: 300px;
  max-height: 400px;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 12px 50px rgba(0, 0, 0, 0.55), 0 4px 16px rgba(0, 0, 0, 0.35);
  transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.book-header.is-cover .book-header-cover:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 20px 70px rgba(0, 0, 0, 0.65);
}
.book-header-text-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}
.book-header.is-cover .book-header-title {
  font-size: 0.875rem;
  margin-bottom: 10px;
  color: #2c2420;
}
.book-header.is-cover .book-header-chapter {
  font-family: 'IM Fell French Canon', serif;
  font-size: clamp(2rem, 4vw, 2.8rem);
  margin-bottom: 10px;
  line-height: 1.1;
  text-align: left;
}
.book-header-author {
  font-family: 'Fraunces', serif;
  font-size: 0.875rem;
  letter-spacing: 0.1em;
  color: rgba(44, 36, 32, 0.85);
  margin-bottom: 12px;
  text-transform: uppercase;
}
.book-header.is-cover .chapter-selector { justify-content: flex-start; }
.begin-reading {
  display: inline-block;
  margin-top: 12px;
  font-family: 'Fraunces', serif;
  font-size: 1rem;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: #fff;
  background: #C25335;
  padding: 14px 32px;
  border-radius: 5px;
  text-decoration: none;
  transition: background 0.2s, transform 0.2s;
}
.begin-reading:hover {
  background: #a8472e;
  transform: translateY(-1px);
}
.book-header:not(.is-cover) .begin-reading { display: none; }
.book-header:not(.is-cover) .book-header-author { display: none; }

/* Chapter page cover slideshow */
.book-header:not(.is-cover) .book-header-cover-wrap {
  position: relative;
  width: 120px;
  height: 180px;
  flex-shrink: 0;
  overflow: hidden;
  border-radius: 3px;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
.book-header:not(.is-cover) .book-header-cover {
  position: absolute;
  top: 0; left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0;
  transition: opacity 1.5s ease;
}
.book-header:not(.is-cover) .book-header-cover.is-active { opacity: 1; }
.chapter-eyebrow {
  font-family: 'IM Fell DW Pica SC', serif;
  font-size: 1.1rem;
  letter-spacing: 0.1em;
  color: #C25335;
  margin-bottom: 8px;
}
.book-header:not(.is-cover) .book-header-chapter {
  font-size: clamp(2.2rem, 6vw, 3.8rem);
  margin-bottom: 0;
  line-height: 1.05;
}

/* ── Reading area ── */
.article-body, .toc-section {
  margin-top: 0;
  border-radius: 0;
  position: relative;
  z-index: 3;
}

/* ── Bottom chapter nav (prev/next cards) ── */
.chapter-bottom-nav {
  display: flex;
  justify-content: center;
  align-items: stretch;
  gap: 1px;
  max-width: 780px;
  margin: 3rem auto 0;
  padding: 0;
  background: rgba(107, 58, 42, 0.12);
  border-radius: 6px;
  overflow: hidden;
}
.chapter-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  font-family: 'Libre Baskerville', serif;
  font-size: 0.95rem;
  color: var(--text, #2c2420);
  text-decoration: none;
  padding: 20px 16px;
  background: var(--bg, #ffffff);
  transition: background 0.2s, color 0.2s;
  text-align: center;
  line-height: 1.3;
}
.chapter-bottom-nav a:hover {
  background: var(--surface, #f0ece4);
  color: var(--accent, #6b3a2a);
}
.chapter-bottom-nav a[aria-disabled="true"] {
  color: rgba(90, 79, 66, 0.25);
  pointer-events: none;
}
.chapter-bottom-nav .nav-direction {
  font-family: 'Libre Baskerville', serif;
  font-size: 0.875rem;
  letter-spacing: 0.02em;
  color: rgba(90, 79, 66, 0.5);
}
.chapter-bottom-nav svg {
  width: 16px; height: 16px;
  stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ── TOC page styles ── */
.toc-section {
  background: var(--bg, #ffffff);
  padding: 3rem 2rem 4rem;
  max-width: 760px;
  margin-left: auto;
  margin-right: auto;
}
.toc-inner { max-width: 680px; margin: 0 auto; }
.toc-inner h2 {
  font-family: 'IM Fell French Canon', serif;
  font-size: 1.6rem; font-weight: 400;
  color: var(--text, #2c2420);
  margin-bottom: 1.5rem;
}
.toc-list { list-style: none; padding: 0; }
.toc-list li { border-bottom: 1px solid rgba(107, 58, 42, 0.1); }
.toc-list li:last-child { border-bottom: none; }
.toc-list a {
  display: block; padding: 0.75rem 0;
  font-family: 'Libre Baskerville', serif; font-size: 0.95rem;
  color: var(--text, #2c2420); text-decoration: none; transition: color 0.2s;
}
.toc-list a:hover { color: var(--accent, #6b3a2a); }

/* ── Epigraph overrides (Libre Franklin with accent border) ── */
.epigraph {
  font-family: 'Libre Franklin', sans-serif;
  font-weight: 300;
  font-style: italic;
  font-size: 1rem;
  line-height: 1.7;
  color: #5a4f42;
  border-left: 3px solid #C25335;
  padding: 16px 0 16px 20px;
  margin-left: 0;
}
.epigraph-attribution {
  font-family: 'Libre Franklin', sans-serif;
  font-size: 0.85rem;
  font-weight: 400;
  font-style: normal;
  color: #8a7e6e;
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .site-nav { padding: 0 0.75rem; height: 44px; }
  .site-nav-inner { flex-direction: row; align-items: center; gap: 0; }
  .brand-logo { height: 28px; }
  .brand-beta { display: none; }
  .book-title-link {
    position: static;
    transform: none;
    font-size: 0.65rem;
    margin-left: 10px;
    padding-left: 10px;
    border-left: 1px solid rgba(0, 0, 0, 0.12);
  }
  .epigraph { font-size: 0.85rem; }
  .epigraph-attribution { font-size: 0.75rem; }
  .book-switch { font-size: 0.6rem; padding: 4px 8px; }
  .book-switch-label { display: none; }
  .book-header-chapter { font-size: 1.5rem; }
  .book-header-inner { padding: 40px 16px 40px; gap: 16px; }
  .book-header:not(.is-cover) .book-header-cover-wrap { width: 80px; height: 120px; }
  .article-body, .toc-section { margin-top: 0; border-radius: 0; max-width: 100%; }
  .book-header-title { font-size: 0.65rem; margin-bottom: 6px; }
  .book-header-author { font-size: 0.65rem; margin-bottom: 6px; }
  .book-header.is-cover .book-header-chapter { font-size: 1.8rem; }
  .book-header.is-cover .book-header-cover { max-width: 120px; }
  .book-header.is-cover .book-header-inner { padding: 24px 1rem 16px; }
  .book-header-overlay { display: none; }
  .ch-prev-title, .ch-next-title { display: none; }
  .bottom-bar { height: 44px; background: rgba(250, 248, 244, 0.97); border-top: 1px solid rgba(0,0,0,0.08); }
  .bottom-bar-chapter { display: inline-block; font-size: 0.65rem; max-width: 120px; }
  .ch-prev, .ch-next {
    width: auto; height: auto;
    border-radius: 0;
    background: none;
    padding: 8px;
  }
  .ch-prev svg, .ch-next svg { width: 18px; height: 18px; stroke: #2c2420; }
  .ch-prev:hover svg, .ch-next:hover svg { stroke: #C25335; }
  body.has-bottom-bar { padding-bottom: 50px; }
  .chapter-bottom-nav a { font-size: 0.85rem; padding: 16px 12px; }
}

@media (max-width: 480px) {
  .book-header.is-cover .book-header-inner {
    flex-direction: column;
    text-align: center;
    gap: 24px;
  }
  .book-header.is-cover .book-header-cover { max-width: 200px; }
  .book-header-text-wrap { align-items: flex-start; }
  .book-header.is-cover .book-header-chapter { text-align: left; }
  .book-header.is-cover .chapter-selector { justify-content: center; }
}
