/* ==========================================================================
   nav.css — Sidebar navigation, chapter groups, mobile menu, toast
   ========================================================================== */

/* --- Sidebar Shell --- */
.sidebar {
  position: fixed;
  left: 0;
  top: var(--progress-height, 3px);
  width: var(--sidebar-width);
  height: calc(100vh - var(--progress-height, 3px));
  background: var(--bg-secondary);
  border-right: 1px solid rgba(255, 255, 255, 0.06);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 900;
  display: flex;
  flex-direction: column;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.1) transparent;
}

.sidebar::-webkit-scrollbar {
  width: 4px;
}

.sidebar::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
}

/* --- Sidebar Header --- */
.sidebar-header {
  padding: 1.5rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.sidebar-header h1 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
  margin: 0 0 0.25rem;
}

.sidebar-header .reading-time {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin: 0;
}

/* --- Chapter Navigation --- */
.nav-chapters {
  flex: 1;
  padding: 0.75rem 0 2rem;
}

.nav-chapter {
  margin-bottom: 0.25rem;
}

/* --- Chapter Toggle (collapsible trigger) --- */
.chapter-toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  padding: 0.6rem 1.25rem;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.6875rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-secondary);
  transition: color 0.15s ease;
  text-align: left;
}

.chapter-toggle:hover {
  color: var(--text-primary);
}

.chapter-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-radius: 4px;
}

.chapter-number {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(129, 140, 248, 0.15);
  color: var(--accent-primary);
  font-size: 0.625rem;
  font-weight: 700;
  flex-shrink: 0;
}

.chapter-title {
  flex: 1;
}

.chapter-time {
  font-size: 0.625rem;
  font-weight: 400;
  opacity: 0.5;
}

.chevron {
  width: 0;
  height: 0;
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-top: 5px solid currentColor;
  opacity: 0.5;
  transition: transform 0.2s ease;
  flex-shrink: 0;
}

.chapter-toggle[aria-expanded="false"] .chevron {
  transform: rotate(-90deg);
}

/* --- Section Links --- */
.chapter-sections {
  list-style: none;
  margin: 0;
  padding: 0;
  max-height: 600px;
  overflow: hidden;
  transition: max-height 0.3s ease-in-out;
}

.chapter-toggle[aria-expanded="false"] + .chapter-sections {
  max-height: 0;
}

.nav-link {
  display: flex;
  align-items: center;
  position: relative;
  padding: 0.4rem 1.25rem 0.4rem 1.75rem;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  text-decoration: none;
  border-left: 3px solid transparent;
  transition: color 0.15s ease,
              background-color 0.15s ease,
              border-color 0.15s ease;
  line-height: 1.4;
}

.nav-link:hover {
  color: var(--text-primary);
  background: rgba(255, 255, 255, 0.03);
}

.nav-link:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
  border-radius: 4px;
}

/* Active section */
.nav-link.active {
  color: var(--text-primary);
  border-left-color: var(--accent-primary);
  background: rgba(129, 140, 248, 0.06);
  font-weight: 500;
}

/* Visited section — checkmark */
.nav-link.visited::after {
  content: '\2713';
  margin-left: auto;
  padding-left: 0.5rem;
  font-size: 0.7rem;
  color: var(--accent-primary);
  opacity: 0.7;
  flex-shrink: 0;
}

/* --- Hamburger Button (mobile) --- */
.hamburger-toggle {
  display: none;
  position: fixed;
  top: calc(var(--progress-height, 3px) + 0.75rem);
  left: 0.75rem;
  z-index: 950;
  width: 40px;
  height: 40px;
  padding: 0;
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  cursor: pointer;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease;
}

.hamburger-toggle:hover {
  background: var(--bg-card);
}

.hamburger-toggle:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: 2px;
}

.hamburger-toggle span {
  display: block;
  width: 18px;
  height: 2px;
  background: var(--text-primary);
  border-radius: 1px;
  margin: 3px auto;
  transition: transform 0.2s ease, opacity 0.2s ease;
}

/* ==========================================================================
   "Continue Where You Left Off" Toast
   ========================================================================== */
.continue-toast {
  position: fixed;
  bottom: 1.5rem;
  right: 1.5rem;
  z-index: 800;
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 8px;
  padding: 1rem 1.25rem;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  max-width: 320px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  transform: translateY(120%);
  opacity: 0;
  transition: transform 0.3s ease-out, opacity 0.3s ease-out;
}

.continue-toast.visible {
  transform: translateY(0);
  opacity: 1;
}

.continue-toast-text {
  flex: 1;
}

.continue-toast-label {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-bottom: 0.15rem;
}

.continue-toast-section {
  font-size: 0.875rem;
  color: var(--text-primary);
  font-weight: 500;
}

.continue-toast-btn {
  padding: 0.4rem 0.9rem;
  background: var(--accent-primary);
  color: #fff;
  border: none;
  border-radius: 4px;
  font-size: 0.8125rem;
  font-weight: 500;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s ease;
}

.continue-toast-btn:hover {
  background: #6366F1;
}

.continue-toast-dismiss {
  position: absolute;
  top: 0.35rem;
  right: 0.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 1rem;
  cursor: pointer;
  padding: 0.15rem;
  line-height: 1;
}

.continue-toast-dismiss:hover {
  color: var(--text-primary);
}

/* ==========================================================================
   Responsive: Mobile Sidebar
   ========================================================================== */
@media (max-width: 1024px) {
  .hamburger-toggle {
    display: flex;
  }

  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: none;
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }

  .continue-toast {
    bottom: 1rem;
    right: 1rem;
    left: 1rem;
    max-width: none;
  }
}
