/* Sticky on-this-page contents, shared by every /docs page. */
html.docs-has-toc {
  scroll-behavior: smooth;
}
body.docs-has-toc {
  max-width: none !important;
  margin: 0 !important;
  padding: 0 !important;
}

.docs-layout {
  display: block;
}

.docs-toc {
  font-family: var(--font-body, 'Archivo', system-ui, sans-serif);
  background: var(--panel, rgba(6, 18, 12, 0.72));
  border: 1px solid var(--panel-border, rgba(34, 242, 143, 0.12));
  border-radius: 14px;
  padding: 14px 16px 16px;
  margin: 16px 28px 0;
  box-shadow: var(--shadow, none);
  backdrop-filter: blur(10px);
}
.docs-toc-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.docs-toc .docs-toc-label {
  font-family: var(--font-mono, ui-monospace, monospace);
  text-transform: uppercase;
  letter-spacing: 0.22em;
  font-size: 9.5px;
  color: var(--muted, #6b7280);
  margin: 0;
}
.docs-toc-toggle {
  display: none;
  flex: 0 0 auto;
  width: 36px;
  height: 36px;
  margin: 0;
  padding: 0;
  border-radius: 8px;
  border: 1px solid var(--panel-border, rgba(34, 242, 143, 0.22));
  background: rgba(0, 0, 0, 0.28);
  color: var(--emerald, #22f28f);
  cursor: pointer;
  align-items: center;
  justify-content: center;
}
.docs-toc-toggle:hover,
.docs-toc-toggle:focus-visible {
  border-color: var(--emerald, #22f28f);
  outline: none;
}
.docs-toc-toggle-icon {
  display: block;
  width: 10px;
  height: 10px;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg) translate(-1px, -1px);
  transition: transform 0.15s ease;
}
.docs-toc.is-open .docs-toc-toggle-icon {
  transform: rotate(225deg) translate(-1px, -1px);
}
.docs-toc-toggle-text {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.docs-toc ol {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
}
.docs-toc li { margin: 0; }
.docs-toc a {
  display: block;
  color: var(--muted, #6b7280);
  text-decoration: none;
  font-size: 13px;
  line-height: 1.35;
  padding: 5px 8px 5px 10px;
  border-left: 2px solid transparent;
  border-radius: 0 6px 6px 0;
}
.docs-toc a:hover {
  color: var(--emerald-bright, var(--emerald, #008080));
  text-decoration: none;
}
.docs-toc a.is-active {
  color: var(--text, #111);
  border-left-color: var(--emerald, #22f28f);
  background: rgba(34, 242, 143, 0.08);
}

body.docs-has-toc h2,
body.docs-has-toc .section-label[id] {
  scroll-margin-top: 18px;
}

/* Legal pages (privacy / terms) have no .container until the script wraps them. */
.docs-plain {
  max-width: 800px;
  margin: 0 auto;
  padding: 20px 24px 64px;
}

@media (min-width: 1080px) {
  .docs-layout {
    display: grid;
    grid-template-columns: 240px minmax(0, 720px);
    justify-content: center;
    align-items: start;
    column-gap: 28px;
    padding: 0 24px 0 16px;
  }
  .docs-layout.is-wide {
    grid-template-columns: 240px minmax(0, 960px);
  }
  .docs-layout.is-plain {
    grid-template-columns: 240px minmax(0, 800px);
  }
  .docs-toc {
    position: sticky;
    top: 24px;
    align-self: start;
    max-height: calc(100vh - 48px);
    overflow: auto;
    margin: 48px 0 24px;
    width: 100%;
  }
  .docs-layout > .container {
    margin-left: 0;
    margin-right: 0;
    max-width: none;
    width: 100%;
  }
  /* Worked-example B/C/D grids used to pull 80vw and would slide under the TOC. */
  .docs-has-toc .worked-grid.cols-3 {
    width: 100%;
    margin-left: 0;
  }
}

@media (max-width: 1079px) {
  .docs-toc {
    position: sticky;
    top: 0;
    z-index: 30;
    margin: 0;
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    padding: 8px 14px;
  }
  .docs-toc-toggle {
    display: inline-flex;
  }
  .docs-toc ol {
    display: none;
    margin-top: 8px;
    padding-bottom: 6px;
  }
  .docs-toc.is-open {
    max-height: 70vh;
    overflow: auto;
  }
  .docs-toc.is-open ol {
    display: block;
  }
  body.docs-has-toc h2,
  body.docs-has-toc .section-label[id] {
    scroll-margin-top: 4.25rem;
  }
}

/* Light legal pages: keep the rail readable on white. */
body.docs-plain-body .docs-toc {
  background: #f7faf9;
  border-color: #d5e4e0;
  box-shadow: none;
}
body.docs-plain-body .docs-toc-toggle {
  background: #fff;
  border-color: #d5e4e0;
  color: #008080;
}
body.docs-plain-body .docs-toc a.is-active {
  color: #006060;
  background: rgba(0, 128, 128, 0.08);
  border-left-color: #008080;
}
