/* ================================================================
   mongoose9.css — Vue-style three-column docs layout.
   Keeps Mongoose brand colors and dark/light theming from mongoose5.
   Typography leans on Open Sans; code highlighting lives in github.css.
================================================================ */


/* ----------------------------------------------------------------
   Theme tokens — light (default)
---------------------------------------------------------------- */
:root,
[data-theme="light"] {
  --bg-primary: #ffffff;
  --bg-secondary: #f6f6f7;
  --bg-tertiary: #fafafa;
  --bg-raised: #ffffff;
  --text-primary: #1a1a1a;
  --text-secondary: #3c3c43;
  --text-muted: #6e6e7a;
  --border-color: #e5e5e7;
  --border-color-soft: #ebebef;
  --code-bg: #f5f5f5;
  --code-text: #333;
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.08);

  --focus-ring: #0971B2;
  --focus-ring-width: 3px;
  --focus-ring-shadow: rgba(9, 113, 178, 0.15);

  --brand-primary: #800;
  --brand-primary-hover: #990000;
  --brand-primary-subtle: rgba(136, 0, 0, 0.08);

  --accent: var(--brand-primary);
  --accent-hover: var(--brand-primary-hover);
  --accent-subtle: var(--brand-primary-subtle);
  --link-color: var(--accent);
  --link-hover: var(--accent-hover);

  --btn-bg: #444;
  --btn-text-shadow: #222;
  --tagline-text-shadow: #f8f8f8;

  --callout-info-bg: #f6f6f7;
  --callout-info-border: #dcdce0;
  --callout-info-text: var(--text-secondary);
}

/* ----------------------------------------------------------------
   Theme tokens — dark (system preference, no JS)
---------------------------------------------------------------- */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #1b1b1f;
    --bg-secondary: #202127;
    --bg-tertiary: #23232a;
    --bg-raised: #252529;
    --text-primary: rgba(255, 255, 245, 0.86);
    --text-secondary: rgba(235, 235, 245, 0.7);
    --text-muted: rgba(235, 235, 245, 0.7);
    --border-color: #2e2e32;
    --border-color-soft: #35353a;
    --code-bg: #25252b;
    --code-text: rgba(235, 235, 245, 0.86);
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);

    --focus-ring: #FFB4B4;
    --focus-ring-shadow: rgba(255, 180, 180, 0.2);

    --brand-primary: #FF7878;
    --brand-primary-hover: #FF9898;
    --brand-primary-subtle: rgba(255, 120, 120, 0.12);
    --accent: var(--brand-primary);
    --accent-hover: var(--brand-primary-hover);
    --accent-subtle: var(--brand-primary-subtle);
    --link-color: var(--accent);
    --link-hover: var(--accent-hover);

    --callout-info-bg: #202127;
    --callout-info-border: #2e2e32;

    --btn-bg: #444;
    --btn-text-shadow: #222;
    --tagline-text-shadow: #222;
  }
}

/* ----------------------------------------------------------------
   Theme tokens — dark (manual toggle, overrides system preference)
---------------------------------------------------------------- */
[data-theme="dark"] {
  --bg-primary: #1b1b1f;
  --bg-secondary: #202127;
  --bg-tertiary: #23232a;
  --bg-raised: #252529;
  --text-primary: rgba(255, 255, 245, 0.86);
  --text-secondary: rgba(235, 235, 245, 0.7);
  --text-muted: rgba(235, 235, 245, 0.7);
  --border-color: #2e2e32;
  --border-color-soft: #35353a;
  --code-bg: #25252b;
  --code-text: rgba(235, 235, 245, 0.86);
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);

  --focus-ring: #FFB4B4;
  --focus-ring-shadow: rgba(255, 180, 180, 0.2);

  --brand-primary: #FF7878;
  --brand-primary-hover: #FF9898;
  --brand-primary-subtle: rgba(255, 120, 120, 0.12);
  --accent: var(--brand-primary);
  --accent-hover: var(--brand-primary-hover);
  --accent-subtle: var(--brand-primary-subtle);
  --link-color: var(--accent);
  --link-hover: var(--accent-hover);

  --callout-info-bg: #202127;
  --callout-info-border: #2e2e32;

  --btn-bg: #444;
  --btn-text-shadow: #222;
  --tagline-text-shadow: #222;
}


/* ----------------------------------------------------------------
   Layout tokens
---------------------------------------------------------------- */
:root {
  --site-header-height: 56px;
  --left-sidebar-width: 272px;
  --right-sidebar-width: 240px;
  --content-max-width: 768px;
  --site-max-width: 1440px;
  --site-gutter: 24px;
}


/* ----------------------------------------------------------------
   Base reset / typography
---------------------------------------------------------------- */
*, *::before, *::after {
  box-sizing: border-box;
}

html {
  color-scheme: light dark;
  scroll-behavior: smooth;
  scroll-padding-top: calc(var(--site-header-height) + 16px);
}

body {
  margin: 0;
  font-family: 'Open Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.6;
  color: var(--text-primary);
  background-color: var(--bg-primary);
  transition: background-color 0.2s ease, color 0.2s ease;
}

a {
  color: var(--accent);
  font-weight: 500;
  text-decoration: none;
  transition: color 0.15s ease;
}
a:hover { color: var(--accent-hover); }

a:focus-visible,
button:focus-visible,
input:focus-visible {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: 2px;
  border-radius: 2px;
}

p {
  margin: 16px 0;
  line-height: 1.65;
}

img { max-width: 100%; height: auto; }

hr {
  border: none;
  border-top: 1px solid var(--border-color);
  margin: 32px 0;
}


/* ----------------------------------------------------------------
   Site header (top navbar, fixed)
---------------------------------------------------------------- */
.site-header {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--site-header-height);
  background-color: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  z-index: 100;
  transition: background-color 0.2s ease, border-color 0.2s ease;
}

.site-header-inner {
  display: flex;
  align-items: center;
  gap: 16px;
  height: 100%;
  padding: 0 var(--site-gutter);
  max-width: var(--site-max-width);
  margin: 0 auto;
}

/* ----------------------------------------------------------------
   Logo
---------------------------------------------------------------- */
.site-logo {
  display: inline-flex;
  align-items: center;
  align-self: stretch;
  color: var(--accent);
  flex-shrink: 0;
  margin-right: 8px;
}

.site-logo:hover {
  color: var(--accent-hover);
}

.site-logo-inner {
  display: flex;
  align-items: center;
  gap: 10px;
}

.site-logo-mark {
  display: block;
  flex: 0 0 auto;
  width: 34px;
  height: 20px;
  background-color: currentColor;
  -webkit-mask-image: url('/docs/images/mongoose.svg');
  mask-image: url('/docs/images/mongoose.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.site-logo-text {
  display: block;
  font-size: 22px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

/* ----------------------------------------------------------------
   Header search
---------------------------------------------------------------- */
.site-search {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 1 260px;
}

.site-search input {
  width: 100%;
  height: 34px;
  padding: 0 36px 0 12px;
  font: inherit;
  font-size: 14px;
  color: var(--text-primary);
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease, background-color 0.2s ease;
}

.site-search input::placeholder {
  color: var(--text-muted);
}

.site-search input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring-shadow);
}

.site-search-button {
  position: absolute;
  right: 4px;
  top: 4px;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  color: var(--text-muted);
  padding: 0;
}

.site-search-button:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.site-search-button img {
  width: 14px;
  height: 14px;
  opacity: 0.8;
}

/* ----------------------------------------------------------------
   Top navbar (primary links)
---------------------------------------------------------------- */
.top-navbar {
  display: flex;
  align-items: stretch;
  height: 100%;
  margin-left: auto;
}

.top-navbar-link {
  display: inline-flex;
  align-items: center;
  height: 100%;
  padding: 0 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-bottom: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
}

.top-navbar-link:hover {
  color: var(--text-primary);
}

.top-navbar-link.active {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* ----------------------------------------------------------------
   Header actions (theme toggle, GitHub link)
---------------------------------------------------------------- */
.site-actions {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-left: 12px;
  margin-left: 4px;
  border-left: 1px solid var(--border-color);
  height: 24px;
  box-sizing: content-box;
}

.icon-button,
.icon-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, color 0.15s ease;
  text-decoration: none;
  position: relative;
}

.icon-button:hover,
.icon-link:hover,
.icon-button.active {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}

.icon-button:disabled {
  color: var(--border-color);
  background-color: transparent;
  cursor: not-allowed;
  opacity: 0.6;
}

.icon-button:disabled:hover {
  background-color: transparent;
  color: var(--border-color);
}

.icon-button svg,
.icon-link svg {
  width: 20px;
  height: 20px;
}

.mobile-toc-toggle {
  display: none;
}

/* Theme toggle — crossfade the two icons already in markup */
#theme-icon-light,
#theme-icon-dark {
  position: absolute;
  top: 50%;
  left: 50%;
  width: 18px;
  height: 18px;
  transform: translate(-50%, -50%);
  transition: opacity 0.2s ease, transform 0.3s ease;
}

#theme-icon-dark { opacity: 1; transform: translate(-50%, -50%) rotate(0deg); }
#theme-icon-light { opacity: 0; transform: translate(-50%, -50%) rotate(90deg); pointer-events: none; }

[data-theme="dark"] #theme-icon-dark { opacity: 0; transform: translate(-50%, -50%) rotate(90deg); pointer-events: none; }
[data-theme="dark"] #theme-icon-light { opacity: 1; transform: translate(-50%, -50%) rotate(0deg); pointer-events: auto; }


/* ----------------------------------------------------------------
   Site body — three-column grid
---------------------------------------------------------------- */
.site-body {
  display: grid;
  grid-template-columns: var(--left-sidebar-width) minmax(0, 1fr) var(--right-sidebar-width);
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding-top: var(--site-header-height);
}


/* ----------------------------------------------------------------
   Left sidebar
---------------------------------------------------------------- */
.left-sidebar {
  grid-column: 1;
  position: sticky;
  top: var(--site-header-height);
  align-self: start;
  height: calc(100vh - var(--site-header-height));
  overflow-y: auto;
  padding: 24px 16px 48px 24px;
  border-right: 1px solid var(--border-color);
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
}

.left-sidebar::-webkit-scrollbar {
  width: 6px;
}
.left-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}
.left-sidebar::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}


/* ----------------------------------------------------------------
   Version picker (replaces "API preference" box)
---------------------------------------------------------------- */
.version-picker {
  position: relative;
  margin-bottom: 24px;
}

.version-picker-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 6px 2px;
}

.version-picker-button {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  width: 100%;
  min-height: 38px;
  padding: 8px 10px 8px 12px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  cursor: pointer;
  text-align: left;
  transition: background-color 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.version-picker-button:hover {
  background-color: var(--bg-tertiary);
  border-color: var(--text-muted);
}

.version-picker.open .version-picker-button {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--focus-ring-shadow);
}

.version-picker-current {
  display: inline-block;
}

.version-picker-caret {
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  color: var(--text-muted);
  transition: transform 0.2s ease;
}

.version-picker.open .version-picker-caret {
  transform: rotate(180deg);
}

.version-picker-menu {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  right: 0;
  z-index: 20;
  list-style: none;
  margin: 0;
  padding: 0;
  display: none;
  background-color: var(--bg-raised);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.version-picker.open .version-picker-menu {
  display: block;
}

.version-picker-item {
  display: block;
  padding: 8px 12px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.35;
}

.version-picker-item:hover {
  color: var(--text-primary);
  background-color: var(--bg-secondary);
}


/* ----------------------------------------------------------------
   Sidebar navigation
---------------------------------------------------------------- */
.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.sidebar-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.sidebar-section-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 6px 0;
  padding: 0 8px;
  letter-spacing: -0.01em;
}

.sidebar-section-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  border-radius: 4px;
}

.sidebar-section-toggle:hover {
  color: var(--accent);
}

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

.sidebar-section-caret {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
  transition: transform 0.15s ease;
}

.sidebar-section-collapsible.collapsed .sidebar-section-caret {
  transform: rotate(-90deg);
}

.sidebar-section-collapsible.collapsed .sidebar-list {
  display: none;
}

.sidebar-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar-item {
  margin: 0;
}

.sidebar-link {
  display: block;
  padding: 5px 8px;
  font-size: 14px;
  color: var(--text-secondary);
  border-radius: 4px;
  line-height: 1.5;
  transition: color 0.15s ease, background-color 0.15s ease;
}

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

.sidebar-link.active {
  color: var(--accent);
  font-weight: 600;
}

/* Sub-items (conditional nested children, e.g. TLS/SSL under Connections) */
.sidebar-children {
  list-style: none;
  margin: 2px 0 4px 0;
  padding: 0 0 0 12px;
  border-left: 1px solid var(--border-color);
  margin-left: 14px;
}

.sidebar-children .sidebar-link {
  font-size: 13px;
  padding: 5px 8px;
  color: var(--text-muted);
}

.sidebar-children .sidebar-link.active {
  color: var(--accent);
}


/* ----------------------------------------------------------------
   Main content column
---------------------------------------------------------------- */
.site-main {
  grid-column: 2;
  min-width: 0;
  padding: 40px 48px 64px 48px;
}

.article {
  max-width: var(--content-max-width);
  margin: 0 auto;
  position: relative;
}

.article h1 {
  font-size: 32px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 24px 0;
}

.article-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}

.article-header h1 {
  flex: 1 1 auto;
  min-width: 0;
  margin-bottom: 0;
}

.article h2 {
  font-size: 24px;
  font-weight: 700;
  line-height: 1.3;
  letter-spacing: -0.01em;
  margin: 48px 0 16px 0;
  padding-top: 24px;
  border-top: 1px solid var(--border-color-soft);
}

.article h3 {
  font-size: 19px;
  font-weight: 600;
  line-height: 1.4;
  margin: 32px 0 12px 0;
  overflow-x: auto;
  overflow-y: hidden;
}

.article h4 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 8px 0;
}

.article h1 a,
.article h2 a,
.article h3 a,
.article h4 a {
  color: inherit;
  font-weight: inherit;
}

.article p {
  margin: 14px 0;
}

.article ul,
.article ol {
  padding-left: 24px;
  margin: 14px 0;
}

.article li {
  margin: 4px 0;
}

/* Inline code */
.article code,
.article :not(pre) > code {
  font-family: ui-monospace, 'SF Mono', Menlo, Consolas, 'Liberation Mono', monospace;
  font-size: 0.88em;
  padding: 2px 6px;
  background-color: var(--code-bg);
  color: var(--code-text);
  border-radius: 4px;
  border: 1px solid var(--border-color-soft);
}

/* Code blocks (github.css handles highlighting) */
.article pre {
  background-color: var(--code-bg);
  border: 1px solid var(--border-color-soft);
  border-radius: 8px;
  padding: 16px;
  overflow-x: auto;
  margin: 16px 0;
  line-height: 1.5;
}

.article pre code {
  background: transparent;
  border: none;
  padding: 0;
  font-size: 13.5px;
  color: var(--code-text);
}

.article blockquote {
  border-left: 3px solid var(--border-color);
  padding: 4px 0 4px 16px;
  margin: 16px 0;
  color: var(--text-secondary);
}

.article table {
  border-collapse: collapse;
  width: 100%;
  margin: 16px 0;
  font-size: 14px;
}

.article th,
.article td {
  padding: 8px 12px;
  border: 1px solid var(--border-color);
  text-align: left;
}

.article th {
  background-color: var(--bg-secondary);
  font-weight: 600;
}

/* Anchor icons on hover (carried from mongoose5.css) */
.article h1 a::before,
.article h2 a::before,
.article h3 a::before,
.article h4 a::before,
.article a.anchor::before {
  position: absolute;
  left: -28px;
  margin-top: 4px;
  width: 18px;
  height: 18px;
  background-color: var(--text-muted);
  -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/><path d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/></svg>");
  mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><path d='M10 13a5 5 0 0 0 7.54.54l3-3a5 5 0 0 0-7.07-7.07l-1.72 1.71'/><path d='M14 11a5 5 0 0 0-7.54-.54l-3 3a5 5 0 0 0 7.07 7.07l1.71-1.71'/></svg>");
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  content: '';
  opacity: 0;
  transition: opacity 0.15s ease;
}

.article h1 a:hover::before,
.article h2 a:hover::before,
.article h3 a:hover::before,
.article h4 a:hover::before,
.article a.anchor:hover::before {
  opacity: 0.6;
}


/* ----------------------------------------------------------------
   Doc action links (edit / copy-as-md)
---------------------------------------------------------------- */
.doc-links {
  display: flex;
  flex: 0 0 auto;
  gap: 6px;
}

.edit-docs-link,
.copy-markdown-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.edit-docs-link:hover,
.copy-markdown-link:hover {
  background-color: var(--bg-tertiary);
  color: var(--text-primary);
}

.edit-docs-link img {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

[data-theme="dark"] .edit-docs-link img {
  filter: invert(1);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .edit-docs-link img {
    filter: invert(1);
  }
}

.copy-markdown-link svg {
  width: 16px;
  height: 16px;
}

.copy-markdown-link.copied {
  border-color: #16a34a;
  color: #16a34a;
}


/* ----------------------------------------------------------------
   Right sidebar — TOC + ads + jobs
---------------------------------------------------------------- */
.right-sidebar {
  grid-column: 3;
  position: sticky;
  top: var(--site-header-height);
  align-self: start;
  height: calc(100vh - var(--site-header-height));
  overflow-y: auto;
  padding: 40px 12px 12px 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--border-color) transparent;
  display: flex;
  flex-direction: column;
}

.right-sidebar::-webkit-scrollbar { width: 6px; }
.right-sidebar::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

/* Table of contents */
.toc {
  margin-bottom: 32px;
}

.right-sidebar .toc {
  overflow-y: auto;
}

@media (min-height: 840px) {
  .right-sidebar .toc {
    height: calc(100vh - 310px);
  }
}

.toc.toc-empty { display: none; }

.toc-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin: 0 0 14px 0;
}

.toc-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.toc-item {
  margin: 0;
}

.toc-item-h3 {
  padding-left: 2px;
}

.toc-link {
  display: block;
  padding: 4px 8px;
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.4;
  border-left: 2px solid transparent;
  transition: color 0.15s ease, border-color 0.15s ease;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.toc-link:hover {
  color: var(--text-primary);
}

.toc-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}

/* Ads + jobs live under the TOC */
.right-sidebar-aside {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.right-sidebar .cpc-ad {
  margin: 0;
}

.affiliate-ad {
  margin: 0;
  flex-shrink: 0;
  min-height: 432px;
}

.affiliate-ad a,
.affiliate-ad img {
  display: block;
  width: 100%;
  height: auto;
  border-radius: 8px;
}

@media (max-height: 767px) {
  .affiliate-ad {
    display: none;
  }
}

/* Jobs block, inlined into the right sidebar (no longer fixed-position) */
.jobs {
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  background-color: var(--bg-primary);
}

.jobs-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-primary);
  margin: 0;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-soft);
  background-color: var(--bg-secondary);
}

.job-listing {
  display: grid;
  grid-template-columns: 32px 1fr;
  gap: 10px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-color-soft);
  color: var(--text-primary);
  text-decoration: none;
  transition: background-color 0.15s ease;
}

.job-listing:last-child {
  border-bottom: none;
}

.job-listing:hover {
  background-color: var(--bg-secondary);
}

.job-listing .company-logo {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.job-listing .company-logo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  border: 0;
}

.job-listing .company {
  font-weight: 600;
  font-size: 12px;
  color: var(--text-primary);
}

.job-listing .title {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.job-listing .location {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
}

.jobs-view-more {
  padding: 8px 12px;
  text-align: center;
  font-size: 12px;
  background-color: var(--bg-secondary);
}

.jobs-view-more a {
  color: var(--accent);
  font-weight: 500;
}

.jobs-view-more a:hover {
  color: var(--accent-hover);
}


/* ----------------------------------------------------------------
   Mobile menu toggle (hidden on desktop)
---------------------------------------------------------------- */
.mobile-menu-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  padding: 0;
  color: var(--text-primary);
  cursor: pointer;
  border-radius: 6px;
  margin-right: 4px;
}

.mobile-menu-toggle:hover {
  background-color: var(--bg-secondary);
}

.mobile-menu-toggle svg {
  width: 22px;
  height: 22px;
}


/* ----------------------------------------------------------------
   Responsive breakpoints
---------------------------------------------------------------- */

/* Narrow desktop: drop the right sidebar */
@media (max-width: 1279px) {
  .site-body {
    grid-template-columns: var(--left-sidebar-width) minmax(0, 1fr);
  }

  .mobile-toc-toggle {
    display: inline-flex;
  }

  .right-sidebar {
    display: none;
    position: fixed;
    top: var(--site-header-height);
    right: 0;
    width: min(86vw, 320px);
    height: calc(100vh - var(--site-header-height));
    padding: 24px 16px;
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-md);
    z-index: 95;
  }

  .right-sidebar.active {
    display: flex;
  }

  .right-sidebar .toc {
    height: auto;
    max-height: none;
  }

  .right-sidebar-aside {
    display: none;
  }
}

/* Tablet / mobile: drawer sidebar + compact header */
@media (max-width: 960px) {
  :root {
    --site-gutter: 16px;
  }

  .site-body {
    grid-template-columns: minmax(0, 1fr);
  }

  .mobile-menu-toggle {
    display: inline-flex;
  }

  .top-navbar {
    display: none;
  }

  .site-actions {
    margin-left: auto;
    padding-left: 12px;
  }

  .site-search {
    flex: 1 1 auto;
    max-width: none;
  }

  .left-sidebar {
    display: none;
    position: fixed;
    top: var(--site-header-height);
    left: 0;
    width: min(86vw, 320px);
    height: calc(100vh - var(--site-header-height));
    background-color: var(--bg-primary);
    box-shadow: var(--shadow-md);
    z-index: 95;
  }

  #layout.active .left-sidebar,
  .left-sidebar.active {
    display: block;
  }

  .site-main {
    padding: 24px 20px 48px 20px;
  }

  .article h1 { font-size: 28px; }
  .article h2 { font-size: 22px; }
}

@media (max-width: 560px) {
  .site-logo-text { display: none; }
  .site-search { flex-basis: 0; min-width: 0; }
}


/* ----------------------------------------------------------------
   Print
---------------------------------------------------------------- */
@media print {
  .site-header,
  .mobile-menu-toggle,
  .left-sidebar,
  .right-sidebar,
  .doc-links { display: none !important; }

  .site-body {
    grid-template-columns: 1fr;
    padding-top: 0;
    max-width: none;
  }

  .site-main { padding: 0; }
  .article { max-width: none; }

  body { background: white; color: black; }
  a { color: black; text-decoration: underline; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #666; }
  pre { page-break-inside: avoid; }
  h1, h2, h3, h4 { page-break-after: avoid; }
}


/* ----------------------------------------------------------------
   API pages — neutralize the legacy fixed-position .api-nav; its job
   is covered by .right-sidebar .toc now. api_split.pug also emits an
   inline "jump list" of props at the top of .api-content which we
   keep, just trimmed.
---------------------------------------------------------------- */
.api-nav {
  display: none !important;
}

.api-content {
  margin-top: 0;
}

.api-content > ul:first-of-type {
  /* The top-of-page jump list is redundant with the right-sidebar TOC */
  display: none;
}

hr.separate-api-elements {
  margin: 32px 0;
  border: 0;
  height: 1px;
  background: var(--border-color-soft);
}


/* ----------------------------------------------------------------
   Mongoose brand buttons (used occasionally in marketing pages)
---------------------------------------------------------------- */
.mongoose-btn-outline,
.mongoose-btn-solid {
  border-radius: 6px;
  padding: 6px 18px;
  cursor: pointer;
  font: inherit;
  font-size: 14px;
  font-weight: 500;
  transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.mongoose-btn-outline {
  background-color: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.mongoose-btn-outline:hover {
  color: var(--accent-hover);
  background-color: var(--accent-subtle);
}

.mongoose-btn-solid {
  background-color: var(--accent);
  color: #fff;
  border: 1px solid transparent;
}

.mongoose-btn-solid:hover {
  color: #fff;
  background-color: var(--accent-hover);
}
