/* ═══════════════════════════════════════════════════════════════
   Left sidebar navigation
   See foundations/tokens.css for the breakpoint contract.

   < xl (1280px): hidden (drawer is the only entry point)
   ≥ xl (1280px): sticky in-grid on doc pages
   No JS:         in-grid sidebar still renders; burger is hidden
   ═══════════════════════════════════════════════════════════════ */

/* ─── Default: hidden (drawer renders via the burger toggle). ─── */
.doc-sidebar {
  display: none;
}

/* ─── No JS: hide the burger menu at all breakpoints ─── */
.no-js .doc-sidebar-toggle {
  display: none !important;
}

/* ─── Sidebar nav structure ─── */
.doc-sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

/* ─── Section group ─── */
.doc-sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

/* ─── Section heading ─── */
.doc-sidebar-heading {
  font-size: var(--font-size-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text-muted);
  padding: 0.25rem 0.5rem;
  margin-bottom: 0.25rem;
}

/* ─── Collapsible sections ─── */
.doc-sidebar-collapsible {
  border: none;
}

.doc-sidebar-collapsible > .doc-sidebar-heading {
  cursor: pointer;
  list-style: none;
  display: flex;
  align-items: center;
  gap: 0.375rem;
  user-select: none;
  border-radius: var(--radius-sm);
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}
.doc-sidebar-collapsible > .doc-sidebar-heading:hover {
  color: var(--color-text);
  background: var(--color-bg-hover);
}

/* Hide default marker */
.doc-sidebar-collapsible > .doc-sidebar-heading::-webkit-details-marker {
  display: none;
}

/* Chevron indicator */
.doc-sidebar-collapsible > .doc-sidebar-heading::before {
  content: "";
  display: inline-block;
  width: 0;
  height: 0;
  border-left: 4px solid currentColor;
  border-top: 3px solid transparent;
  border-bottom: 3px solid transparent;
  transition: transform var(--transition-fast);
  flex-shrink: 0;
}
.doc-sidebar-collapsible[open] > .doc-sidebar-heading::before {
  transform: rotate(90deg);
}

/* ─── Link lists ─── */
.doc-sidebar-list {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
}

.doc-sidebar-nested {
  display: flex;
  flex-direction: column;
  gap: 0.0625rem;
  padding-left: 0.75rem;
}

/* ─── Sidebar items ─── */
.doc-sidebar-item {
  display: flex;
  flex-direction: column;
}

.doc-sidebar-link {
  display: block;
  padding: 0.3rem 0.5rem;
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
  border-radius: var(--radius-sm);
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
  line-height: 1.4;
}
.doc-sidebar-link:hover {
  color: var(--color-text);
  background: var(--color-bg-hover);
}

/* Active state */
.doc-sidebar-item.active > .doc-sidebar-link {
  color: var(--color-text);
  background: var(--color-accent-subtle);
  font-weight: 500;
}

/* Expanded state — show nested children */
.doc-sidebar-item.expanded > .doc-sidebar-nested {
  display: flex;
}
.doc-sidebar-item:not(.expanded) > .doc-sidebar-nested {
  display: none;
}

/* Nested links — slightly smaller */
.doc-sidebar-nested .doc-sidebar-link {
  font-size: 0.8125rem;
  padding: 0.2rem 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════
   Sidebar modal — JS-powered overlay for mobile/tablet
   ═══════════════════════════════════════════════════════════════ */

.doc-sidebar-modal {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: none;
}

.doc-sidebar-modal[open] {
  display: flex;
}

.doc-sidebar-modal-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay-bg);
  z-index: 0;
}

.doc-sidebar-modal-panel {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  min-width: min(300px, 85vw);
  width: max-content;
  max-width: 85vw;
  z-index: 1;
  background: var(--color-bg);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
  padding: 1.5rem 1rem 2rem 1.5rem;
  scrollbar-width: thin;
  animation: sidebar-slide-in var(--transition-normal) forwards;
}

@keyframes sidebar-slide-in {
  from {
    transform: translateX(-100%);
  }
  to {
    transform: translateX(0);
  }
}

/* ─── Close button inside modal ─── */
.doc-sidebar-modal-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  margin-left: auto;
  margin-bottom: 1rem;
  padding: 0;
  border: none;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-secondary);
  cursor: pointer;
  transition:
    color var(--transition-fast),
    background var(--transition-fast);
}
.doc-sidebar-modal-close:hover {
  color: var(--color-text);
  background: var(--color-bg-hover);
}
.doc-sidebar-modal-close svg {
  width: 18px;
  height: 18px;
}

/* The home page never shows an in-page sidebar (the drawer is enough). */
.doc-home .doc-sidebar {
  display: none;
}

/* ═══════════════════════════════════════════════════════════════
   xl — persistent sidebar appears on doc pages
   ═══════════════════════════════════════════════════════════════ */
@media (--bp-xl) {
  .doc-layout .doc-sidebar {
    display: block;
    position: sticky;
    top: var(--header-height);
    left: auto;
    bottom: auto;
    height: calc(100vh - var(--header-height));
    width: auto;
    max-width: none;
    z-index: auto;
    background: transparent;
    border-right: 1px solid var(--color-border-subtle);
    transition: border-color var(--transition-fast);
    overflow-y: auto;
    padding: 1.5rem 1rem 2rem 1.5rem;
    scrollbar-width: thin;
  }
}
