/* Collapsible left nav and right TOC sidebars.
 *
 * Body classes set by sidebar-toggle.js:
 *   .kf-nav-collapsed  — left sidebar collapsed to 28px rail
 *   .kf-toc-collapsed  — right TOC collapsed to 28px rail
 *   .kf-no-transition  — suppresses animation during initial page load
 */

/* ── Transition setup ───────────────────────────────────────────── */

.nav-container {
  transition: width 0.18s ease !important;
}

aside.toc.sidebar {
  transition: width 0.18s ease, min-width 0.18s ease;
}

body.kf-no-transition .nav-container,
body.kf-no-transition aside.toc.sidebar {
  transition: none !important;
}

/* ── Left sidebar ───────────────────────────────────────────────── */
/*
 * Antora sizes the nav via .nav-container (width: 15rem at ≥769px),
 * not aside.nav directly. Target .nav-container with !important.
 * aside.nav is the positioning anchor for the injected button.
 */

body.kf-nav-collapsed .nav-container {
  width: 28px !important;
  min-width: 28px !important;
  overflow: hidden;
}

aside.nav {
  position: relative;
}

body.kf-nav-collapsed aside.nav .nav-panel-menu,
body.kf-nav-collapsed aside.nav .nav-panel-explore,
body.kf-nav-collapsed aside.nav .panels {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

aside.nav .nav-panel-menu,
aside.nav .nav-panel-explore,
aside.nav .panels {
  opacity: 1;
  transition: opacity 0.12s ease 0.06s;
}

/* Hide Antora's expand/collapse-all button — overlaps our toggle button */
aside.nav .nav-menu-toggle {
  display: none !important;
}

/* ── Right TOC panel ────────────────────────────────────────────── */
/*
 * The bundle sets flex-basis: 12rem at ≥1216px. Override with !important
 * so flex layout respects the collapsed state.
 */

aside.toc.sidebar {
  flex-basis: 16rem !important;
  width: 16rem;
  min-width: 16rem;
  overflow: hidden;
  border-left: 1px solid var(--nav-border-color, #e1e4e8);
  background: var(--nav-background, #fff);
  flex-shrink: 0;
  position: relative;
}

body.kf-toc-collapsed aside.toc.sidebar {
  flex-basis: 28px !important;
  width: 28px !important;
  min-width: 28px !important;
}

/* Let the article fill the freed space — lift the bundle's 46rem cap */
body.kf-toc-collapsed .doc {
  max-width: none !important;
}

body.kf-toc-collapsed aside.toc.sidebar .toc-panel-inner {
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

aside.toc.sidebar .toc-panel-inner {
  width: 16rem;
  opacity: 1;
  transition: opacity 0.12s ease 0.06s;
}

/* ── Toggle buttons ─────────────────────────────────────────────── */

.kf-nav-toggle-btn,
.kf-toc-toggle-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  background: none;
  border: 1px solid var(--nav-border-color, #e1e4e8);
  border-radius: 5px;
  color: var(--nav-muted-color, #8a90a0);
  cursor: pointer;
  font-size: 11px;
  line-height: 1;
  flex-shrink: 0;
}

.kf-nav-toggle-btn:hover,
.kf-toc-toggle-btn:hover {
  background: var(--nav-hover-background, #f4f5f7);
  color: var(--nav-heading-font-color, #2c313c);
}

.kf-nav-toggle-btn .kf-toggle-icon,
.kf-toc-toggle-btn .kf-toggle-icon {
  pointer-events: none;
}

/* Left sidebar button — top-right corner of aside.nav */
.kf-nav-toggle-btn {
  position: absolute;
  top: 10px;
  right: 6px;
  z-index: 10;
}

body.kf-nav-collapsed aside.nav .kf-nav-toggle-btn {
  right: 0;
  left: 0;
  margin: 10px auto 0;
  position: relative;
  top: auto;
}

/* Right TOC button — top-left corner of aside.toc.sidebar */
.kf-toc-toggle-btn {
  position: absolute;
  top: 10px;
  left: 6px;
  z-index: 10;
}

body.kf-toc-collapsed aside.toc.sidebar .kf-toc-toggle-btn {
  left: 0;
  right: 0;
  margin: 10px auto 0;
  position: relative;
  top: auto;
}

/* ── Responsive ─────────────────────────────────────────────────── */

@media screen and (max-width: 1023.5px) {
  /* Below the desktop breakpoint the collapse-to-28px rail doesn't apply — the
   * bundle's mobile nav takes over. Restore the CONTAINER (the element Antora
   * sizes), not just the inner aside.nav; otherwise the 28px + overflow:hidden
   * clamp from `body.kf-nav-collapsed .nav-container` above leaves the re-opened
   * panel as a clipped sliver with off-screen-but-focusable links. */
  body.kf-nav-collapsed .nav-container {
    width: var(--nav-width, 16rem) !important;
    min-width: var(--nav-width, 16rem) !important;
    overflow: visible;
  }

  body.kf-nav-collapsed aside.nav {
    width: var(--nav-width, 16rem);
    min-width: var(--nav-width, 16rem);
  }

  body.kf-nav-collapsed aside.nav .nav-panel-menu,
  body.kf-nav-collapsed aside.nav .nav-panel-explore,
  body.kf-nav-collapsed aside.nav .panels {
    opacity: 1;
    pointer-events: auto;
  }

  aside.toc.sidebar,
  body.kf-toc-collapsed aside.toc.sidebar {
    width: 0;
    min-width: 0;
    flex-basis: 0 !important;
    border: none;
  }
}
