/* ============================================================
   book-reader.css — Book Reader Layout & Styles
   Variables --br-* inject ด้วย PHP inline <style> ใน single-book_chapter.php
   ============================================================ */

/* ── Layout ── */
.book-reader {
  display: flex;
  min-height: 100vh;
}

/* ════════════════════════════════════════
   SIDEBAR
════════════════════════════════════════ */
.br-sidebar {
  font-family: "Google Sans Display", sans-serif;
  width: 28rem;
  min-width: 28rem;
  color: var(--br-text-light);
  background: var(--br-sidebar-bg);
  border-top-right-radius: var(--radius-sm);
  border-bottom-right-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  min-height: 100vh;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--br-accent) transparent;
  margin-bottom: 3rem;
  z-index: 50;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.br-sidebar::-webkit-scrollbar {
  width: 4px;
}
.br-sidebar::-webkit-scrollbar-thumb {
  background: var(--br-accent);
  border-radius: 2px;
}

/* Sidebar header */
.br-sidebar__header {
  padding: 2.4rem 2rem 1.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.2rem;
}

.br-sidebar__cover {
  width: 11rem;
  height: auto;
  border-radius: 0.4rem;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  transition: transform 0.3s ease;
}
.br-sidebar__cover:hover {
  transform: translateY(-3px) scale(1.02);
}

.br-sidebar__book-info {
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}
.br-sidebar__book-label {
  font-size: 1.1rem;
  color: var(--br-accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  opacity: 0.8;
  margin: 0;
}
.br-sidebar__book-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: var(--br-text-light);
  margin: 0;
}
.br-sidebar__book-sub {
  font-size: 1.2rem;
  color: var(--br-accent-light);
  margin: 0;
  opacity: 0.85;
}
.br-sidebar__lang-badge {
  display: inline-block;
  padding: 0.2rem 0.8rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 9999px;
  font-size: 1.1rem;
  color: var(--br-accent);
  margin-top: 0.4rem;
}

/* Sidebar nav */
.br-sidebar__nav {
  padding: 1.6rem 0 2rem;
  flex: 1;
}

.br-sidebar__nav-label {
  font-size: var(--font-size-xl);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--br-accent-light);
  border-bottom: 1px solid var(--color-divider-md);
  padding: 2rem 2rem 2rem 3rem;
  margin: 0;
}

/* Chapter list */
.br-chapter-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.br-chapter-list__item {
  border-left: 3px solid transparent;
  border-bottom: 0.5px solid var(--color-divider-md);
  transition: border-color 0.2s;
}
.br-chapter-list__item.is-active {
  border-left-color: var(--br-accent);
  background: var(--br-active-bg);
}
.br-chapter-list__item:hover {
  background: rgba(255, 255, 255, 0.05);
}

.br-chapter-list__link {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 1rem 2rem;
  text-decoration: none;
  transition: color 0.2s;
}
.br-chapter-list__num {
  font-size: 1.8rem;
  font-weight: 600;
  color: var(--br-accent);
  opacity: 0.8;
}
.br-chapter-list__title {
  font-family: "Google Sans Text", sans-serif;
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--br-text-light);
  opacity: 0.85;
  line-height: 1.4;
}
.br-chapter-list__item.is-active .br-chapter-list__title {
  opacity: 1;
  color: #fff;
}
.br-chapter-list__item.is-active .br-chapter-list__num {
  opacity: 1;
}

/* Close button (mobile only) */
.br-sidebar__close {
  display: none;
  position: absolute;
  top: 1.2rem;
  right: 1.2rem;
  background: rgba(255, 255, 255, 0.1);
  border: none;
  border-radius: 50%;
  width: 3.2rem;
  height: 3.2rem;
  cursor: pointer;
  color: var(--br-text-light);
  align-items: center;
  justify-content: center;
}

/* ════════════════════════════════════════
   OVERLAY (mobile)
════════════════════════════════════════ */
.br-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  z-index: 49;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s;
}
.br-overlay.is-open {
  opacity: 1;
  pointer-events: auto;
}

/* ════════════════════════════════════════
   MAIN CONTENT
════════════════════════════════════════ */
.br-main {
  flex: 1;
  min-width: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ── Banner ── */
.br-banner {
  position: relative;
  overflow: hidden;
  min-height: 18rem;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 2rem 0 rgba(82, 156, 219, 0.16);
  margin: 0 2rem;

  display: flex;
  align-items: flex-end;
}

.br-banner__bg {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    135deg,
    var(--br-banner-from) 0%,
    var(--br-banner-to) 100%
  );
  z-index: 0;
}
.br-banner__bg::after {
  content: "";
  position: absolute;
  inset: 0;
}

.br-banner__cover {
  position: absolute;
  right: 0;
  bottom: 0;
  height: 100%;
  width: auto;
  object-fit: cover;
  object-position: top;
  z-index: 1;
  /*opacity: 0.35;*/
  filter: drop-shadow(0 8px 24px rgba(0, 0, 0, 0.4));
}

.br-banner__content {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
  padding: 2.4rem 3rem;
  width: 100%;
}

/* Mobile hamburger */
.br-menu-btn {
  display: none;
  align-items: center;
  gap: 0.8rem;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 0.6rem;
  padding: 0.6rem 1.2rem;
  color: #fff;
  cursor: pointer;
  font-size: 1.3rem;
  font-weight: 500;
  flex-shrink: 0;
  transition: background 0.2s;
  position: relative;
  z-index: 10;
}
.br-menu-btn:hover {
  background: rgba(255, 255, 255, 0.18);
}
.br-menu-btn__icon {
  display: flex;
  flex-direction: column;
  gap: 4px;
  width: 18px;
}
.br-menu-btn__icon span {
  display: block;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transition: all 0.3s;
}
.br-menu-btn__label {
  font-family: "Google Sans Display", sans-serif;
  font-size: 1.8rem;
  font-weight: 500;
  white-space: nowrap;
}

.br-banner__text {
  flex: 1;
  min-width: 0;
}
.br-banner__series {
  font-family: "Google Sans Display", sans-serif;
  font-size: clamp(2.4rem, 3vw + 1rem, 4rem);
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--br-accent);
  text-transform: uppercase;
}
.br-banner__title {
  font-family: "Google Sans Display", sans-serif;
  font-size: var(--font-size-xl);
  font-weight: 500;
  letter-spacing: 1px;
  color: var(--color-text-inverse);
  margin: 0 0 0.6rem;
  line-height: 1.2;
}
.br-banner__subtitle {
  display: block;
  font-family: "Google Sans Display", sans-serif;
  font-weight: 500;
  color: var(--br-accent-light);
  letterspac
}
.br-banner__book-number {
  font-family: "Google Sans Display", sans-serif;
  background: var(--br-accent);
  color: #1a1200;
  padding: 0.5rem 1.6rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 1.7rem;
  display: inline-block;
  margin: 2rem 0;
}

.br-banner__meta {
  font-family: "Google Sans Display", sans-serif;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  flex-wrap: wrap;
  font-size: 1.5rem;
  color: rgba(255, 255, 255, 0.7);
  margin: 0;
}
.br-banner__chapter {
  background: var(--br-accent);
  color: #1a1200;
  padding: 0.2rem 0.9rem;
  border-radius: 9999px;
  font-weight: 600;
  font-size: 1.2rem;
}
.br-banner__sep {
  opacity: 0.4;
}

/* ── Chapter Article ── */
.br-chapter {
  flex: 1;
  padding: 4rem 5vw;
  background-color: #f6f1e8;
  border-radius: var(--radius-sm);
  box-shadow: 0 0 2rem 0 var(--color-shadow-sm);
  margin: 2.6rem;
}

.br-chapter__header {
  margin-bottom: 3.2rem;
}
.br-chapter__num {
  font-family: "Google Sans Display", sans-serif;
  font-size: 2.7rem;
  font-weight: 600;
  text-transform: uppercase;
  color: #424242;
  opacity: 0.6;
}
.br-chapter__title {
  font-family: "Google Sans Display", sans-serif;
  font-size: clamp(3rem, 3vw, 4rem);
  font-weight: 500;
  color: #2b2b2b;
  margin: 0 0 1.6rem;
  line-height: 1;
}
.br-chapter__divider {
  width: 4rem;
  height: 3px;
  background: var(--br-accent, #c9a84c);
  border-radius: 2px;
}

/* Chapter body typography — copy protected */
.br-chapter__body {
  font-family: "Google Sans Text", sans-serif;
  font-weight: 400;
  font-size: 1.8rem;
  line-height: 1.9;
  color: #2b2b2b;
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

.br-chapter__body p {
  margin: 0 0 1rem;
  text-indent: 2.6em;
  
  text-align: justify;
  text-justify: inter-character;

  line-height: 1.9;
  word-break: break-word;
  overflow-wrap: break-word;

  /*hyphens: auto;*/

  -webkit-text-size-adjust: 100%;
}

.br-chapter__body h2,
.br-chapter__body h3,
.br-chapter__body h4 {
  font-weight: 400;
  margin: 2.4em 0 0.8em;
  color: var(--br-primary, #0d1b3e);
}
.br-chapter__body h2 {
  font-size: 2.2rem;
}
.br-chapter__body h3 {
  font-size: 1.9rem;
}
.br-chapter__body blockquote {
  border-left: 4px solid var(--br-accent, #c9a84c);
  margin: 2em 0;
  padding: 1em 2em;
  background: rgba(201, 168, 76, 0.06);
  border-radius: 0 0.6rem 0.6rem 0;
  font-style: italic;
}

@media (max-width: 768px) {
  .br-chapter__body p {
    text-align: left;
    text-indent: 1.4em;
  }
}
/* ════════════════════════════════════════
   CHAPTER NAVIGATION
════════════════════════════════════════ */
.br-chapter-nav {
  padding: 3rem 5vw 4rem;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  display: flex;
  flex-direction: column;
  gap: 2.4rem;
  max-width: 80rem;
  margin: 0 auto;
  width: 100%;
}

/* Prev / Next arrows */
.br-chapter-nav__arrows {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.6rem;
}

.br-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  padding: var(--btn-padding-md);
  border-radius: 0.5rem;
  text-decoration: none;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--color-text-base, #1a1a2e);
  font-size: 1.3rem;
  transition: all 0.2s;
  min-width: 14rem;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.br-nav-btn:hover {
  background: var(--br-primary, #0d1b3e);
  color: #fff;
  border-color: var(--br-primary, #0d1b3e);
  transform: translateY(-1px);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}
/*.br-nav-btn--next {
  text-align: right;
  margin-left: auto;
}*/
.br-nav-btn--disabled {
  flex: 0 0 14rem;
}
.br-nav-btn span {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}
.br-nav-btn__label {
  font-family: "Google Sans Display", sans-serif;
  font-weight: 600;
  font-size: 1.7rem;
  /*opacity: 0.6;*/
}
.br-nav-btn__num {
  font-size: 1.5rem;
  font-weight: 600;
}

.br-nav-btn__toc {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1.4rem;
  border-radius: 0.6rem;
  background: rgba(0, 0, 0, 0.04);
  text-decoration: none;
  color: var(--color-text-subtle, #3f5e85);
  font-size: 1.3rem;
  transition: all 0.2s;
  white-space: nowrap;
}
.br-nav-btn__toc:hover {
  background: var(--br-accent, #c9a84c);
  color: #1a1200;
}

/* Pagination */
.br-chapter-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.br-page-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  min-width: 3.8rem;
  height: 4rem;
  padding: 0 1rem;
  border-radius: 0.6rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  color: var(--color-text-base, #1a1a2e);
  font-size: 1.5rem;
  font-weight: 500;
  text-decoration: none;
  transition: all 0.2s;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
}
.br-page-btn:hover {
  background: var(--br-primary-mid, #16285a);
  color: #fff;
  border-color: var(--br-primary-mid, #16285a);
}
.br-page-btn.is-active {
  background: var(--br-primary, #0d1b3e);
  color: var(--br-accent, #c9a84c);
  border-color: var(--br-primary, #0d1b3e);
  font-weight: 700;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.2);
}
.br-page-btn--arrow,
.br-page-btn--jump {
  min-width: 3.6rem;
  background: rgba(0, 0, 0, 0.04);
  border-color: transparent;
  color: var(--color-text-subtle, #3f5e85);
}
.br-page-btn--arrow:hover,
.br-page-btn--jump:hover {
  background: var(--br-accent, #c9a84c);
  color: #1a1200;
}
.br-page-btn__label {
  font-size: 0.9rem;
  opacity: 0.6;
  display: none; /* ซ่อนคำว่า "บทที่" บน mobile */
}
@media (min-width: 480px) {
  .br-page-btn__label {
    display: inline;
  }
}
.br-page-ellipsis {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.4rem;
  color: var(--color-text-muted, #a7acc8);
  font-size: 1.5rem;
}

/* Progress bar */
.br-progress {
  display: flex;
  align-items: center;
  gap: 1.2rem;
}
.br-progress__bar-wrap {
  flex: 1;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: hidden;
}
.br-progress {
  position: relative;
  height: 6px;
  background: rgba(0, 0, 0, 0.08);
  border-radius: 3px;
  overflow: visible;
  display: flex;
  align-items: center;
}
.br-progress__bar {
  height: 6px;
  background: linear-gradient(
    90deg,
    var(--br-primary, #0d1b3e),
    var(--br-accent, #c9a84c)
  );
  border-radius: 3px;
  transition: width 0.6s ease;
  position: absolute;
  left: 0;
  top: 0;
}
.br-progress__label {
  font-family: "Google Sans Display", sans-serif;
  position: absolute;
  right: 0;
  top: -2.4rem;
  font-size: 1.3rem;
  color: var(--color-text-muted, #a7acc8);
  white-space: nowrap;
}

/* ════════════════════════════════════════
   RESPONSIVE — Tablet & Mobile
════════════════════════════════════════ */
@media (max-width: 900px) {
  /* Sidebar ซ่อน → drawer */
  .br-sidebar {
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    width: 30rem;
    min-width: 0;
    border-right: none;
  }
  .br-sidebar.is-open {
    transform: translateX(0);
  }
  .br-sidebar__close {
    display: flex;
  }

  .br-overlay {
    display: block;
  }

  /* Mobile hamburger ปรากฏ */
  .br-menu-btn {
    display: flex;
  }

  .br-banner__cover {
    opacity: 0.35;
  }
  .br-banner__content {
    padding: 2rem 2rem 1.6rem;
  }

  .br-chapter {
    padding: 2.4rem 2rem;
  }

  .br-chapter-nav {
    padding: 2rem 2rem 3rem;
  }
  .br-nav-btn {
    min-width: 0;
    padding: 0.8rem 1.2rem;
    font-size: 1.2rem;
  }
  .br-nav-btn__label {
    display: none;
  }
  .br-nav-btn__toc span {
    display: none;
  }
}

@media (max-width: 480px) {
  .br-banner {
    min-height: 14rem;
  }

  .br-banner__content {
    gap: 0;
    2rem 1.8rem 1.6rem
  }

  .br-banner__title {
    font-size: 1.6rem;
  }
  .br-chapter {
    padding: 2rem 1.6rem;
  }

  .br-chapter-nav__arrows {
    gap: 0.8rem;
  }
  .br-page-btn {
    min-width: 3.6rem;
    height: 3.6rem;
    font-size: 1.2rem;
  }
}

/* ════════════════════════════════════════
   ACCORDION SIDEBAR
════════════════════════════════════════ */
.br-accordion {
  border-bottom: 1px solid rgba(255,255,255,0.08);
}

.br-accordion__toggle {
  font-family: "Google Sans Display", sans-serif;
  font-size: 1.8rem;
  font-weight: 500;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1.2rem 2rem;
  background: transparent;
  border: none;
  color: var(--br-text-light);
  cursor: pointer;
  text-align: left;
  transition: background 0.2s;
  letter-spacing: 0.03em;
}

.br-accordion__toggle:hover {
  background: rgba(255,255,255,0.05);
}

.br-accordion__label {
  color: var(--br-accent);
}

.br-accordion__icon {
  width: 1.6rem;
  height: 1.6rem;
  flex-shrink: 0;
  transition: transform 0.3s ease;
  opacity: 0.7;
}

.br-accordion.is-open .br-accordion__icon {
  transform: rotate(180deg);
}

.br-accordion__body {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.35s ease;
  list-style: none;
  margin: 0;
  padding: 0;
}

.br-accordion.is-open .br-accordion__body {
  max-height: 9999px;
}

/* ════════════════════════════════════════
   PAGINATION INPUT
════════════════════════════════════════ */
.br-chapter-pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 2.4rem 2.4rem;
  flex-wrap: wrap;
}

.br-pagination-input-wrap {
  font-family: "Google Sans Display", sans-serif;
  display: flex;
  align-items: center;
  gap: 0.8rem;
  background: #ffffd7;
  border: 2px solid #e0e0e0;
  border-radius: 1.2rem;
  padding: var(--btn-padding-md);
  transition: border-color 0.2s;
}

.br-pagination-input-wrap:focus-within {
  border-color: var(--br-accent, #c9a84c);
}

.br-pagination-input {
  width: 5rem;
  border: none;
  outline: none;
  font-size: 1.6rem;
  font-weight: 700;
  color: #2b2b2b;
  text-align: center;
  background: transparent;
  -moz-appearance: textfield;
}

.br-pagination-input::-webkit-outer-spin-button,
.br-pagination-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.br-pagination-of {
  font-size: 1.4rem;
  color: #888;
  white-space: nowrap;
}

/* ════════════════════════════════════════
   STANDALONE SIDEBAR LINK
   (บทที่มี chapter_label เช่น บทนำ, อ้างอิง)
════════════════════════════════════════ */
.br-standalone-link {
  font-family: "Google Sans Text", sans-serif;
  display: flex;
  flex-direction: column;
  padding: 1.2rem 2rem;
  text-decoration: none;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  transition: background 0.2s;
}

.br-standalone-link:hover {
  background: rgba(255,255,255,0.05);
}

.br-standalone-link.is-active {
  background: var(--br-active-bg);
  border-left: 3px solid var(--br-accent);
  padding-left: calc(2rem - 3px);
}

.br-standalone-link__label {
  font-size: 1.8rem;
  font-weight: 400;
  color: var(--color-text-inverse);
  letter-spacing: 0.03em;
}

.br-standalone-link__title {
  font-size: 1.2rem;
  color: var(--br-text-light);
  opacity: 0.75;
  margin-top: 0.2rem;
}
