/* ============================================
   Custom Comprehensive Navigation (cn-nav)
   ============================================ */

/* Hide native MkDocs nav immediately to prevent flash */
.md-nav--primary {
  display: none !important;
}

.cn-nav {
  padding: 0 0.5rem 1rem 0.5rem;
  margin-top: -0.6rem;
}

.cn-item {
  margin-bottom: 0.2rem;
}

.cn-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.3rem 0.5rem;
  border-radius: 0.2rem;
}

.cn-header:hover {
  background-color: var(--md-default-fg-color--lightest);
}

.cn-label {
  font-size: 14px;
  font-family: var(--md-text-font);
  font-weight: 500;
  letter-spacing: 0;
  color: #1f2937 !important;
  text-decoration: none;
  flex-grow: 1;
  line-height: 1.3;
}

.cn-label:hover {
  color: var(--md-primary-fg-color);
  text-decoration: none;
}

.cn-label--active,
.cn-item--active .cn-label {
  color: var(--md-primary-fg-color) !important;
}

.cn-item--active {
  border-left: 2px solid var(--md-primary-fg-color);
  padding-left: 0.3rem;
  margin-left: -0.3rem;
}

/* ── Toggle arrows ───────────────────────────────────────────── */

.cn-arrow {
  font-size: 1rem;
  color: var(--md-default-fg-color--light);
  transition: transform 0.2s ease, opacity 0.15s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.2rem;
  height: 1.2rem;
  flex-shrink: 0;
  cursor: pointer;
  user-select: none;
}

.cn-arrow:hover {
  color: var(--md-primary-fg-color);
}

/* Main-heading arrows: always visible */
.cn-arrow:not(.cn-arrow--sub) {
  opacity: 1;
}

.cn-header:hover .cn-arrow:not(.cn-arrow--sub) {
  opacity: 1;
}

/* Sub-level arrows: always visible */
.cn-arrow--sub {
  font-size: 0.85rem;
  width: 1rem;
  height: 1rem;
  opacity: 1;
}

/* ── Sub-page lists ──────────────────────────────────────────── */

/* OPTION A: Enhanced Indentation + Subtle Lines (FINAL) */

.cn-sublist {
  list-style: none;
  margin: 0;
  padding: 0;
  position: relative;
}

.cn-subitem {
  margin: 0;
  position: relative;
}

/* Add vertical connector line for nested items */
.cn-sublist--depth-1::before,
.cn-sublist--depth-2::before {
  content: '';
  position: absolute;
  left: 0.6rem;
  top: 0;
  bottom: 0;
  width: 1px;
  background-color: rgba(0, 0, 0, 0.15);
}

/* Horizontal connector for each item */
.cn-sublist--depth-1 > .cn-subitem::before,
.cn-sublist--depth-2 > .cn-subitem::before {
  content: '';
  position: absolute;
  left: 0.6rem;
  top: 50%;
  width: 0.6rem;
  height: 1px;
  background-color: rgba(0, 0, 0, 0.15);
}

.cn-subheader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 0.2rem;
}

.cn-subheader:hover {
  background-color: var(--md-default-fg-color--lightest);
}

.cn-sublist--depth-1 > .cn-subitem > .cn-sublink,
.cn-sublist--depth-1 > .cn-subitem > .cn-subheader > .cn-sublink {
  padding: 0.35rem 0.5rem 0.35rem 1.5rem;
  font-size: 14px;
  font-family: var(--md-text-font);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.cn-sublist--depth-2 > .cn-subitem > .cn-sublink,
.cn-sublist--depth-2 > .cn-subitem > .cn-subheader > .cn-sublink {
  padding: 0.32rem 0.5rem 0.32rem 2.3rem;
  font-size: 13.5px;
  font-family: var(--md-text-font);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

.cn-sublist--depth-3 > .cn-subitem > .cn-sublink,
.cn-sublist--depth-3 > .cn-subitem > .cn-subheader > .cn-sublink {
  padding: 0.3rem 0.5rem 0.3rem 3.1rem;
  font-size: 13px;
  font-family: var(--md-text-font);
  font-weight: 400;
  letter-spacing: 0;
  line-height: 1.4;
  position: relative;
  z-index: 1;
}

/* Dark mode adjustments for connector lines */
[data-md-color-scheme="slate"] .cn-sublist--depth-1::before,
[data-md-color-scheme="slate"] .cn-sublist--depth-2::before,
[data-md-color-scheme="slate"] .cn-sublist--depth-1 > .cn-subitem::before,
[data-md-color-scheme="slate"] .cn-sublist--depth-2 > .cn-subitem::before {
  background-color: rgba(255, 255, 255, 0.2);
}

.cn-sublink {
  display: block;
  flex-grow: 1;
  font-size: 14px;
  font-family: var(--md-text-font);
  font-weight: 400;
  line-height: 1.3;
  color: var(--md-default-fg-color) !important;
  transition: background-color 0.15s, color 0.15s;
}

.cn-sublink:not(.cn-sublink--parent):hover {
  background-color: var(--md-default-fg-color--lightest);
  color: var(--md-default-fg-color);
  text-decoration: none;
}

.cn-sublink--active {
  color: var(--md-primary-fg-color) !important;
  font-weight: 500;
}

.cn-sublink--parent {
  font-weight: 400;
  color: var(--md-default-fg-color);
}

.cn-sublink--parent:hover {
  color: var(--md-primary-fg-color);
  text-decoration: none;
}

/* ── Sidebar divider lines & ToC Shifting ──────────────────────────────────── */

/* Right edge of the left (primary) sidebar keeps full height box-shadow */
.md-sidebar--primary .md-sidebar__scrollwrap {
  box-shadow: 1px 0 0 0 rgba(0, 0, 0, 0.08);
}

/* 1. Remove the default full-height infinite line from the right scrollwrap */
.md-sidebar--secondary .md-sidebar__scrollwrap {
  box-shadow: none !important;
}

/* 2. Shift the ENTIRE right sidebar left so it moves closer to the content */
@media screen and (min-width: 1220px) {
  .md-sidebar--secondary {
    margin-left: -2.5rem; /* Adjust this value to shift the whole ToC closer or further */
  }
}

/* 3. Apply a solid border to the inner container. 
   Using border-left ensures it doesn't get clipped by hidden overflows.
   Since it's on the inner wrapper, the line ends exactly where the text ends. */
.md-sidebar--secondary .md-sidebar__inner {
  border-left: 1px solid rgba(0, 0, 0, 0.08) !important;
  padding-left: 0.8rem !important; /* Space between the line and the ToC text */
}

/* Dark-mode adjustments */
[data-md-color-scheme="slate"] .md-sidebar--primary .md-sidebar__scrollwrap {
  box-shadow: 1px 0 0 0 rgba(255, 255, 255, 0.08);
}

[data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__scrollwrap {
  box-shadow: none !important;
}

[data-md-color-scheme="slate"] .md-sidebar--secondary .md-sidebar__inner {
  border-left: 1px solid rgba(255, 255, 255, 0.08) !important;
}

/* ── Legacy / comprehensive-nav classes (unchanged) ─────────────────────── */

.comprehensive-nav .md-nav__item--section > .md-nav__link {
  font-weight: 500;
  font-size: 0.8rem;
  cursor: pointer !important;
  display: flex;
  justify-content: space-between;
  align-items: center;
  user-select: none;
  pointer-events: auto !important;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.05rem;
  line-height: 1.5;
  min-height: auto;
  height: auto;
}

.comprehensive-nav .md-nav__item--section > .md-nav__link:hover {
  background-color: var(--md-default-fg-color--lightest) !important;
}

.comprehensive-nav .md-nav__item--section > .md-nav__link a {
  color: inherit;
  text-decoration: none;
  line-height: inherit;
  padding: 0;
  margin: 0;
}

.comprehensive-nav .md-nav__item--section > .md-nav__link a:hover {
  text-decoration: none;
}

.comprehensive-nav .md-nav__item--section > .md-nav__link a.md-nav__link--active {
  color: var(--md-primary-fg-color);
  font-weight: 600;
}

.comprehensive-nav .md-nav__item--section > .md-nav__link.md-nav__link--active {
  color: var(--md-primary-fg-color);
}

.comprehensive-nav .md-nav__item:not(.md-nav__item--section) > .md-nav__link {
  font-weight: 500;
  font-size: 0.8rem;
  padding: 0.35rem 0.6rem;
  margin-bottom: 0.05rem;
  line-height: 1.5;
  height: auto;
}

.comprehensive-nav .md-nav__item {
  padding: 0;
  margin-bottom: 0;
  margin-top: 0;
}

.comprehensive-nav .md-nav__link {
  margin-top: 0;
  border-radius: 0.2rem;
  transition: background-color 0.2s;
  display: block;
}

.comprehensive-nav .md-nav__link:hover {
  background-color: var(--md-default-fg-color--lightest);
}

.comprehensive-nav .md-nav[data-md-level="1"] .md-nav__link {
  padding: 0.35rem 0.6rem 0.35rem 0.6rem;
  font-size: 0.64rem;
  font-weight: 400;
  margin-bottom: 0.05rem;
  line-height: 1.5;
  font-family: inherit;
  color: var(--md-default-fg-color--light);
}

.comprehensive-nav .md-nav[data-md-level="1"] {
  margin: 0;
  padding: 0;
  max-height: none;
  overflow: visible;
}

.comprehensive-nav .md-nav__item--section.expanded .md-nav[data-md-level="1"] {
  display: block !important;
  margin: 0;
  padding: 0;
}

.comprehensive-nav .md-nav__toggle {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.comprehensive-nav .md-nav__link--active {
  color: var(--md-primary-fg-color);
  font-weight: 500;
}