/* Prevent white flash on dark mode load */
@media (prefers-color-scheme: dark) {
  html {
    background-color: #0d1117;
  }
}

/* Heading colors: match main docs site (light gray, not brand green) */
body {
  --color-api-name: var(--color-brand-content);
  --color-api-pre-name: var(--color-brand-content);
}

h1 {
  color: var(--color-foreground-primary) !important;
}

/* Prevent headings turning purple on click/visited */
h1 > a,
h2 > a,
h3 > a,
h4 > a,
h5 > a,
h6 > a,
.headerlink {
  color: inherit !important;
}

/* Mobile header: match desktop theme */
.mobile-header {
  background-color: var(--color-background-primary);
  color: var(--color-foreground-primary);
}

/* Left sidebar: gray by default, green when active */
.sidebar-tree .reference {
  color: var(--color-foreground-secondary) !important;
}

.sidebar-tree .current-page > .reference {
  color: var(--color-brand-primary) !important;
}

/* Left sidebar: smooth expand/collapse and arrow rotation */
.sidebar-tree .toctree-checkbox ~ ul {
  display: block !important;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.sidebar-tree .toctree-checkbox:checked ~ ul {
  max-height: 500em;
  transition: max-height 0.4s ease;
}

.sidebar-tree .toctree-checkbox ~ label .icon svg {
  transition: transform 0.2s ease;
}

/* Sidebar brand: logo + title, left-aligned */
.sidebar-brand {
  display: flex;
  flex-direction: column;
  align-items: flex-start !important;
  text-align: left !important;
  gap: 1rem;
}

.sidebar-logo {
  height: 28px;
  width: auto;
  margin: 1rem 0 0 0 !important;
}

.sidebar-brand-text {
  font-size: 1.25rem;
  line-height: 1.3;
}

.sidebar-brand-api-link {
  color: var(--color-foreground-primary);
  text-decoration: none;
}

.sidebar-brand-api-link:hover {
  color: var(--color-brand-primary);
}

/* Dark mode logo swap */
body[data-theme='dark'] .sidebar-logo {
  content: url('nt-logo-dark.webp');
}

@media (prefers-color-scheme: dark) {
  body:not([data-theme='light']) .sidebar-logo {
    content: url('nt-logo-dark.webp');
  }
}

/* Modules table: left-align */
.table-wrapper table {
  margin-left: 0;
  margin-right: auto;
}

/* Prevent visited link color change */
a:visited {
  color: inherit;
}

.sidebar-tree .reference:visited {
  color: var(--color-foreground-secondary) !important;
}

.sidebar-tree .current-page > .reference:visited {
  color: var(--color-brand-primary) !important;
}

a.reference:visited {
  color: var(--color-brand-content);
}

/* Right-hand TOC: collapse method lists under each class */
.toc-tree ul ul ul {
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.25s ease;
}

.toc-tree li.toc-expanded > ul {
  max-height: 500em;
  transition: max-height 0.4s ease;
}

/* Chevron for collapsible TOC items (matches left sidebar style) */
.toc-tree .toc-collapsible > a {
  cursor: pointer;
}

.toc-tree .toc-collapsible > .toc-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1rem;
  height: 1rem;
  margin-right: 0.25rem;
  cursor: pointer;
  color: var(--color-foreground-secondary);
  transition:
    transform 0.2s ease,
    color 0.15s ease;
  transform: rotate(90deg);
  vertical-align: middle;
  flex-shrink: 0;
}

.toc-tree .toc-collapsible.toc-expanded > .toc-toggle {
  transform: rotate(-90deg);
}

.toc-tree .toc-collapsible > .toc-toggle:hover {
  color: var(--color-brand-primary);
}

/* Hide toctree-generated list from page content (sidebar still works) */
.toctree-wrapper {
  display: none;
}

/* Hide "Made with Furo" text but keep copyright */
.bottom-of-page .left-details {
  font-size: 0;
}

.bottom-of-page .left-details > a {
  display: none;
}

.bottom-of-page .left-details .copyright {
  font-size: 0.8125rem;
}

/* Footer social icons: more spacing */
.bottom-of-page .icons {
  gap: 1rem;
}

/* Version badge in sidebar */
.sidebar-version {
  display: block;
  font-size: 0.75rem;
  color: var(--color-foreground-muted);
  padding: 0 var(--sidebar-item-spacing-horizontal);
}
