/* AegisMesh docs: page list, rendered Markdown and table of contents. Builds on site.css. */

.docs { --doc-side: 232px; --doc-toc: 200px; }

.doc-layout {
  display: grid;
  grid-template-columns: var(--doc-side) minmax(0, 1fr) var(--doc-toc);
  gap: 48px;
  align-items: start;
  padding-block: 40px 64px;
}

/* ------------------------------------------------------------------ page list */

.doc-side,
.doc-toc {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  max-height: calc(100vh - var(--header-h) - 48px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.doc-nav-toggle { display: none; }

.doc-nav__title {
  margin: 22px 0 6px;
  color: var(--eyebrow);
  font-size: .74rem;
  font-weight: 800;
  letter-spacing: .08em;
  text-transform: uppercase;
}
.doc-nav__title:first-child { margin-top: 0; }

.doc-nav a,
.doc-toc a {
  display: block;
  padding: 6px 12px;
  border-radius: 10px;
  color: var(--ink-2);
  font-size: .93rem;
  font-weight: 600;
  line-height: 1.4;
  text-decoration: none;
  transition: background-color .15s, color .15s;
}
.doc-nav a:hover { background: #eaf0ff; color: var(--ink); }
.doc-nav a[aria-current="page"] { background: #e3ebff; color: var(--blue-deep); box-shadow: inset 3px 0 0 var(--blue); }

.doc-nav .doc-nav__console {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 24px;
  color: var(--blue);
}
.doc-nav__console .icon { width: 1em; height: 1em; stroke-width: 2.2; }

.doc-toc a { padding: 4px 0 4px 12px; border-left: 2px solid var(--line); border-radius: 0; color: var(--muted); font-size: .86rem; font-weight: 500; }
.doc-toc a:hover { color: var(--ink); border-left-color: var(--blue); }

/* ------------------------------------------------------------------ article */

.doc-main { min-width: 0; }

.doc {
  max-width: 76ch;
  color: var(--ink-2);
  font-size: 1.02rem;
  line-height: 1.72;
}
.doc[aria-busy="true"] { opacity: .55; transition: opacity .2s .15s; }

.doc > * + * { margin-top: 1em; }
.doc h1 { font-size: clamp(2rem, 4vw, 2.6rem); line-height: 1.15; letter-spacing: -.02em; outline: none; }
.doc h1 + p { color: var(--muted); font-size: 1.12rem; }
.doc h2 { margin-top: 2.2em; padding-top: .2em; font-size: 1.5rem; line-height: 1.25; letter-spacing: -.01em; }
.doc h3 { margin-top: 1.8em; font-size: 1.15rem; line-height: 1.35; }
.doc h4 { margin-top: 1.5em; font-size: 1rem; color: var(--ink); }
.doc h2, .doc h3, .doc h4 { position: relative; scroll-margin-top: calc(var(--header-h) + 16px); }

.doc-anchor {
  position: absolute;
  right: 100%;
  padding-right: .35em;
  color: var(--line-strong);
  font-weight: 600;
  text-decoration: none;
  opacity: 0;
  transition: opacity .15s;
}
.doc h2:hover .doc-anchor,
.doc h3:hover .doc-anchor { opacity: 1; }

.doc strong { color: var(--ink); }
.doc a { font-weight: 600; }
.doc hr { margin-block: 2.4em; border: 0; border-top: 1px solid var(--line); }

.doc ul,
.doc ol { padding-left: 1.4em; }
.doc ul { list-style: disc; }
.doc ol { list-style: decimal; }
.doc li + li { margin-top: .35em; }
.doc li > ul,
.doc li > ol { margin-top: .35em; }
.doc li::marker { color: var(--eyebrow); font-weight: 700; }

.doc :not(pre) > code {
  padding: .12em .4em;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef2fc;
  color: var(--ink);
  font-size: .86em;
  overflow-wrap: anywhere;
}

.doc blockquote {
  margin-inline: 0;
  padding: .2em 0 .2em 1.1em;
  border-left: 3px solid var(--line-strong);
  color: var(--muted);
}
.doc blockquote > * + *,
.doc-callout > * + * { margin-top: .6em; }

.doc-callout {
  padding: 14px 18px;
  border: 1px solid #cddcff;
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  background: #f0f5ff;
  font-size: .97rem;
}
.doc-callout--tip { border-color: #bfeadb; border-left-color: var(--teal); background: #ecfaf4; }
.doc-callout--important { border-color: #dcd0ff; border-left-color: var(--violet); background: #f4f0ff; }
.doc-callout--warning { border-color: #f3d9a8; border-left-color: #c77700; background: #fff7e8; }

/* code blocks */
.doc-code {
  position: relative;
  border-radius: 14px;
  background: #0b1442;
  box-shadow: var(--shadow-sm);
}
.doc-code pre {
  margin: 0;
  padding: 18px 20px;
  overflow-x: auto;
  color: #dbe5ff;
  font-family: var(--mono);
  font-size: .86rem;
  line-height: 1.65;
  tab-size: 2;
}
.doc-code pre:focus-visible { outline-offset: -3px; }
.doc-copy {
  position: absolute;
  top: 8px;
  right: 8px;
  padding: 5px 10px;
  border: 1px solid rgb(255 255 255 / .16);
  border-radius: 8px;
  background: rgb(11 20 66 / .85);
  color: #c8d6ff;
  font: inherit;
  font-size: .76rem;
  font-weight: 700;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, background-color .15s;
}
.doc-code:hover .doc-copy,
.doc-copy:focus-visible,
.doc-copy.is-copied { opacity: 1; }
.doc-copy:hover { background: #1c2a6b; }
.doc-copy.is-copied { color: #7cf0c5; }
@media (hover: none) { .doc-copy { opacity: 1; } }

/* tables */
.doc-table {
  overflow-x: auto;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
}
.doc-table table { width: 100%; border-collapse: collapse; font-size: .93rem; line-height: 1.5; }
.doc-table th,
.doc-table td { padding: 10px 14px; text-align: left; vertical-align: top; }
.doc-table .align-right { text-align: right; }
.doc-table .align-center { text-align: center; }
.doc-table th { background: #f3f6fd; color: var(--ink); font-size: .8rem; font-weight: 700; letter-spacing: .02em; white-space: nowrap; }
.doc-table tr + tr td,
.doc-table tbody tr:first-child td { border-top: 1px solid var(--line); }

/* previous / next */
.doc-pager {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
  max-width: 76ch;
  margin-top: 56px;
}
.doc-pager a {
  display: grid;
  gap: 2px;
  padding: 14px 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--surface);
  color: var(--ink);
  font-weight: 700;
  text-decoration: none;
  transition: border-color .15s, transform .15s;
}
.doc-pager a:hover { border-color: var(--blue); transform: translateY(-1px); }
.doc-pager a span { color: var(--muted); font-size: .8rem; font-weight: 600; }
.doc-pager__next { grid-column: 2; text-align: right; }

.doc-footer .footer-bottom { margin-top: 0; }
.doc-footer a { color: inherit; }
.doc-footer .icon { display: inline; width: 1em; height: 1em; vertical-align: -.15em; }

/* ------------------------------------------------------------------ responsive */

@media (max-width: 1179.98px) {
  .doc-layout { grid-template-columns: var(--doc-side) minmax(0, 1fr); }
  .doc-toc { display: none; }
}

@media (max-width: 859.98px) {
  .doc-layout { grid-template-columns: minmax(0, 1fr); gap: 20px; padding-top: 16px; }
  .doc-side { position: static; max-height: none; overflow: visible; }

  .js .doc-nav-toggle {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    min-height: 48px;
    padding: 10px 14px;
    border: 1px solid var(--line-strong);
    border-radius: 14px;
    background: var(--surface);
    color: var(--ink);
    font: inherit;
    font-weight: 700;
    text-align: left;
    cursor: pointer;
  }
  .doc-nav-toggle .icon { color: var(--blue); }
  .doc-nav-toggle__label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .doc-nav-toggle__chevron { transition: transform .2s; }
  .doc-nav-toggle[aria-expanded="true"] .doc-nav-toggle__chevron { transform: rotate(180deg); }

  .js .doc-nav { display: none; margin-top: 8px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface); box-shadow: var(--shadow); }
  .js .doc-nav.is-open { display: block; }
  .doc-nav a { padding-block: 10px; }

  .doc-anchor { display: none; }
}

@media (max-width: 519.98px) {
  .doc { font-size: 1rem; }
  .doc-code pre { padding: 16px; font-size: .8rem; }
  .doc-pager { grid-template-columns: minmax(0, 1fr); }
  .doc-pager__next { grid-column: auto; }
}

@media print {
  .doc-side,
  .doc-toc,
  .doc-pager,
  .doc-copy { display: none; }
  .doc-layout { display: block; }
}
