/* ==========================================================================
   nav.css — Book navigation shell styles
   All selectors scoped to #book-nav, #book-progress, #book-toc,
   #book-toc-overlay, #book-prev, #book-next, #book-bottom-nav,
   #book-comments, and body.book-has-nav.
   These overlay on pages with diverse backgrounds (dark, parchment, cork)
   and must not interfere with page-specific styles.
   ========================================================================== */

/* --------------------------------------------------------------------------
   Body adjustments when nav is present
   -------------------------------------------------------------------------- */

body.book-has-nav {
  padding-top: 96px; /* 48px nav bar + 48px top prev/next bar */
}

@media (max-width: 767px) {
  body.book-has-nav {
    padding-bottom: 52px;
  }
}

/* --------------------------------------------------------------------------
   Progress bar (#book-progress)
   -------------------------------------------------------------------------- */

/* Hidden — replaced by vertical bar */
#book-progress { display: none; }
#book-progress .progress-bar { display: none; }

/* Vertical progress bar next to right arrow */
#book-progress-vertical {
  position: fixed;
  top: 50%;
  right: max(12px, calc(50% - 540px));
  transform: translateY(-50%);
  z-index: 9998;
  width: 4px;
  height: 400px;
  border-radius: 2px;
  background: rgba(128, 128, 128, 0.15);
  margin-right: 56px;
  pointer-events: none;
  overflow: hidden;
}

#book-progress-vertical .vprog-fill {
  width: 100%;
  height: 0%;
  border-radius: 2px;
  background: #c4a35a;
  box-shadow: 0 0 5px rgba(196, 163, 90, 0.35);
  transition: height 0.25s ease;
}

@media (max-width: 767px) {
  #book-progress-vertical { display: none; }
}

/* --------------------------------------------------------------------------
   Top bar (#book-nav)
   -------------------------------------------------------------------------- */

#book-nav {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 48px;
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: space-between;
  box-sizing: border-box;
  padding: 0 12px;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  transition: background 0.3s ease, color 0.3s ease;
}


#book-nav.nav-dark {
  background: rgba(26, 28, 46, 0.92);
  color: #e0d8c8;
  border-bottom: 1px solid rgba(100, 120, 180, 0.15);
}

#book-nav.nav-light {
  background: rgba(242, 234, 212, 0.92);
  color: #1a1a1a;
  border-bottom: 1px solid rgba(180, 160, 130, 0.3);
}

#book-nav .nav-hamburger {
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 8px 12px;
  color: inherit;
  line-height: 1;
  flex-shrink: 0;
}

#book-nav .nav-title {
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 0.95rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  text-align: center;
  text-decoration: none;
  color: inherit;
  flex: 1;
  min-width: 0;
  padding: 0 8px;
}

#book-nav .nav-position {
  font-family: 'Special Elite', monospace;
  font-size: 0.8rem;
  white-space: nowrap;
  flex-shrink: 0;
  opacity: 0.75;
}

/* --------------------------------------------------------------------------
   TOC overlay
   -------------------------------------------------------------------------- */

#book-toc-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 10001;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.book-toc-open #book-toc-overlay {
  opacity: 1;
  pointer-events: auto;
}

/* --------------------------------------------------------------------------
   TOC sidebar (#book-toc)
   -------------------------------------------------------------------------- */

#book-toc {
  position: fixed;
  top: 0;
  left: -320px;
  width: 300px;
  max-width: 80vw;
  height: 100vh;
  z-index: 10002;
  padding: 60px 24px 24px;
  overflow-y: auto;
  box-sizing: border-box;
  transition: left 0.3s ease;
}

#book-toc.book-toc-open {
  left: 0;
}

#book-toc.toc-dark {
  background: #1a1c2e;
  color: #e0d8c8;
}

#book-toc.toc-light {
  background: #f5f0e8;
  color: #1a1a1a;
}

.toc-close {
  position: absolute;
  top: 16px;
  right: 16px;
  background: none;
  border: none;
  font-size: 1.3rem;
  cursor: pointer;
  color: inherit;
  padding: 4px 8px;
  line-height: 1;
  opacity: 0.7;
}

.toc-close:hover {
  opacity: 1;
}

/* --------------------------------------------------------------------------
   TOC entries
   -------------------------------------------------------------------------- */

#book-toc .toc-list {
  padding: 0;
  margin: 0;
}

#book-toc .toc-entry {
  display: block;
  padding: 10px 12px;
  border-radius: 4px;
  cursor: pointer;
  margin-bottom: 2px;
  font-size: 0.95rem;
  font-weight: 400;
  text-decoration: none;
  color: inherit;
  border-left: 3px solid transparent;
  transition: background 0.15s ease;
}

#book-toc.toc-dark .toc-entry:hover {
  background: rgba(255, 255, 255, 0.06);
}

#book-toc.toc-light .toc-entry:hover {
  background: rgba(0, 0, 0, 0.05);
}

#book-toc .toc-entry.book-toc-active {
  border-left-color: #c4a35a;
}

#book-toc.toc-dark .toc-entry.book-toc-active {
  background: rgba(196, 163, 90, 0.1);
}

#book-toc.toc-light .toc-entry.book-toc-active {
  background: rgba(196, 163, 90, 0.12);
}

#book-toc .toc-entry.toc-archive {
  font-size: 0.9rem;
  padding-left: 20px;
  opacity: 0.7;
}

#book-toc .toc-entry.toc-archive:hover {
  opacity: 0.9;
}

/* Hide old floating arrows */
#book-prev, #book-next { display: none !important; }

/* --------------------------------------------------------------------------
   Top prev/next bar (#book-top-nav) — mirrors bottom bar exactly
   -------------------------------------------------------------------------- */

#book-top-nav {
  position: fixed;
  top: 48px;
  left: 0;
  width: 100%;
  height: 48px;
  z-index: 10000;
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#book-top-nav.top-nav-dark {
  background: rgba(26, 28, 46, 0.92);
  color: #e0d8c8;
  border-bottom: 1px solid rgba(100, 120, 180, 0.15);
}

#book-top-nav.top-nav-light {
  background: rgba(242, 234, 212, 0.92);
  color: #1a1a1a;
  border-bottom: 1px solid rgba(180, 160, 130, 0.3);
}

#book-top-nav .top-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  text-decoration: none;
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 16px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease;
}

#book-top-nav .top-nav-btn:first-child {
  border-right: 1px solid rgba(128, 128, 128, 0.2);
}

#book-top-nav .top-nav-btn:hover {
  background: rgba(128, 128, 128, 0.15);
}

#book-top-nav .top-nav-btn .arrow-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

#book-top-nav .top-nav-btn .arrow-icon.arrow-left {
  transform: rotate(45deg);
  margin-right: 8px;
}

#book-top-nav .top-nav-btn .arrow-icon.arrow-right {
  transform: rotate(-135deg);
  margin-left: 8px;
}

/* --------------------------------------------------------------------------
   Bottom nav bar — always visible on all screen sizes
   -------------------------------------------------------------------------- */

#book-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  width: 100%;
  height: 48px;
  z-index: 10000;
  display: flex;
  align-items: stretch;
  box-sizing: border-box;
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

#book-bottom-nav.bottom-nav-dark {
  background: rgba(26, 28, 46, 0.92);
  color: #e0d8c8;
  border-top: 1px solid rgba(100, 120, 180, 0.15);
}

#book-bottom-nav.bottom-nav-light {
  background: rgba(242, 234, 212, 0.92);
  color: #1a1a1a;
  border-top: 1px solid rgba(180, 160, 130, 0.3);
}

#book-bottom-nav .bottom-nav-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: inherit;
  text-decoration: none;
  font-family: 'Noto Serif', Georgia, serif;
  font-size: 0.85rem;
  cursor: pointer;
  padding: 0 16px;
  border-radius: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s ease;
}

#book-bottom-nav .bottom-nav-btn:first-child {
  border-right: 1px solid rgba(128, 128, 128, 0.2);
}

#book-bottom-nav .bottom-nav-btn:hover {
  background: rgba(128, 128, 128, 0.15);
}

#book-bottom-nav .bottom-nav-btn .arrow-icon {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-left: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
}

#book-bottom-nav .bottom-nav-btn .arrow-icon.arrow-left {
  transform: rotate(45deg);
  margin-right: 8px;
}

#book-bottom-nav .bottom-nav-btn .arrow-icon.arrow-right {
  transform: rotate(-135deg);
  margin-left: 8px;
}

body.book-has-nav {
  padding-bottom: 48px;
}

/* --------------------------------------------------------------------------
   Comments section (#book-comments)
   -------------------------------------------------------------------------- */

#book-comments {
  max-width: 720px;
  margin: 60px auto 40px;
  padding: 0 24px;
  box-sizing: border-box;
}
