/* ==========================================================================
   Book Reader Theme & Navigation Styles (Modern Tufte + Full Left Sidebar)
   ========================================================================== */

:root {
  --sidebar-width: 280px;
  --sidebar-bg: #f8fafc;
  --sidebar-border: #e2e8f0;
  --nav-text: #334155;
  --nav-active-text: #1d4ed8;
  --nav-active-bg: #eff6ff;
}

/* Base Book Layout */
.book-layout {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-color, #fffff8);
}

/* ==========================================================================
   FULL LEFT NAVIGATION SIDEBAR
   ========================================================================== */

.book-sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  height: 100vh;
  position: sticky;
  top: 0;
  overflow-y: auto;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  padding: 1.25rem 1rem 3rem 1rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  scrollbar-width: thin;
}

.book-sidebar::-webkit-scrollbar {
  width: 5px;
}
.book-sidebar::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.sidebar-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: 0.85rem;
  border-bottom: 1px solid var(--sidebar-border);
}

.sidebar-title {
  font-weight: 900;
  font-size: 0.95rem;
  letter-spacing: -0.01em;
  color: #0f172a;
  text-decoration: none;
}

.sidebar-playbook-btn {
  font-size: 0.725rem;
  font-weight: 800;
  background: #0f172a;
  color: #ffffff !important;
  padding: 0.25rem 0.55rem;
  border-radius: 4px;
  text-decoration: none !important;
  transition: opacity 0.15s ease;
}

.sidebar-playbook-btn:hover {
  opacity: 0.85;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.nav-section {
  display: flex;
  flex-direction: column;
}

.nav-head-link {
  display: block;
  font-weight: 800;
  font-size: 0.9rem;
  color: #1e40af;
  text-decoration: none;
  padding: 0.35rem 0.5rem;
  border-radius: 4px;
  background: #ffffff;
  border: 1px solid var(--sidebar-border);
}

.nav-head-link:hover {
  background: #eff6ff;
  text-decoration: none;
}

.nav-section-title {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #64748b;
  margin-bottom: 0.4rem;
  padding-left: 0.4rem;
}

.nav-item {
  display: block;
  font-weight: 750;
  font-size: 0.825rem;
  color: #1e293b;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  text-decoration: none;
  transition: all 0.12s ease;
}

.nav-item:hover {
  background: #e2e8f0;
  color: #0f172a;
  text-decoration: none;
}

.nav-sub-item {
  display: block;
  font-size: 0.775rem;
  font-weight: 500;
  color: #475569;
  padding: 0.25rem 0.5rem 0.25rem 1.1rem;
  border-left: 2px solid #e2e8f0;
  margin-left: 0.45rem;
  text-decoration: none;
  transition: all 0.12s ease;
  line-height: 1.35;
}

.nav-sub-item:hover {
  color: var(--nav-active-text);
  border-left-color: var(--nav-active-text);
  background: #f1f5f9;
  text-decoration: none;
}

/* ==========================================================================
   MAIN CONTENT STAGE
   ========================================================================== */

.book-content-wrapper {
  flex: 1;
  min-width: 0;
  padding: 1.5rem 3.5rem 5rem 3.5rem;
  max-width: 1280px;
}

.book-header {
  border-bottom: 1px solid var(--sidebar-border);
  padding: 0.5rem 0 1rem 0;
  margin-bottom: 2.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.book-header-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-sidebar-toggle {
  display: none;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.8rem;
  font-weight: 750;
  background: #f1f5f9;
  border: 1px solid var(--sidebar-border);
  border-radius: 4px;
  padding: 0.35rem 0.65rem;
  color: #0f172a;
  cursor: pointer;
}

.book-header-brand {
  font-weight: 800;
  font-size: 1.05rem;
  color: #0f172a;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 0.45rem;
}

.book-header-badge {
  font-size: 0.65rem;
  font-weight: 800;
  background: #eff6ff;
  color: #1d4ed8;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  border: 1px solid #bfdbfe;
  text-transform: uppercase;
}

.btn-back-cards {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: #0f172a;
  color: #ffffff !important;
  font-size: 0.8rem;
  font-weight: 700;
  padding: 0.4rem 0.85rem;
  border-radius: 4px;
  text-decoration: none !important;
  transition: opacity 0.15s ease;
}

.btn-back-cards:hover {
  opacity: 0.88;
}

/* Callout Alerts */
blockquote {
  margin: 1.5rem 0;
  padding: 0.75rem 1rem;
  background: #f8fafc;
  border-left: 4px solid #1976d2;
  border-radius: 0 4px 4px 0;
  color: #334155;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  line-height: 1.5;
}

blockquote p {
  width: 100% !important;
  margin: 0.35rem 0 !important;
}

blockquote.alert-important {
  border-left-color: #dc2626;
  background: #fef2f2;
}

/* Chapter Footers & Navigation */
.chapter-nav {
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--sidebar-border);
  display: flex;
  justify-content: space-between;
  width: 65%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

@media (max-width: 760px) {
  .chapter-nav {
    width: 100%;
  }
}

.chapter-nav a {
  font-weight: 750;
  font-size: 0.875rem;
}

/* ==========================================================================
   MOBILE & TABLET RESPONSIVE DRAWER
   ========================================================================== */

.sidebar-backdrop {
  display: none;
}

@media (max-width: 1024px) {
  .book-sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    width: 290px;
    transform: translateX(-100%);
    transition: transform 0.22s ease-in-out;
    box-shadow: 4px 0 15px rgba(15, 23, 42, 0.15);
  }

  body.sidebar-open .book-sidebar {
    transform: translateX(0);
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.4);
    z-index: 90;
    backdrop-filter: blur(2px);
  }

  body.sidebar-open .sidebar-backdrop {
    display: block;
  }

  .btn-sidebar-toggle {
    display: inline-flex;
  }

  .book-content-wrapper {
    padding: 1rem 1.5rem 4rem 1.5rem;
  }
}
