/* Docs page: one long page with a sticky contents sidebar. Builds on ../site.css (tokens, titlebar, buttons,
   .copy, .strip). The content area is plain (no CRT scanlines or flicker) so long text stays easy to read. */
body.docs-body { display: block; padding: 24px 16px 20px; }
.docs-term { width: 1240px; max-width: 100%; margin: 0 auto; }
.docs-term .ethchip { white-space: nowrap; }

.docs-layout {
  display: grid;
  grid-template-columns: 272px minmax(0, 1fr);
  background: var(--crt);
  box-shadow: inset 0 0 60px rgba(176, 38, 255, 0.05);
}

/* ---- sidebar ---- */
.docs-side {
  position: sticky; top: 0; align-self: start;
  max-height: 100vh; overflow-y: auto; overscroll-behavior: contain;
  border-right: 2px solid var(--ink);
  background: linear-gradient(180deg, var(--slate-lo), var(--crt) 240px);
  padding: 14px 10px 24px;
  scrollbar-width: thin; scrollbar-color: var(--slate) transparent;
}
.side-row { display: flex; gap: 8px; align-items: center; }
.docs-q { width: 100%; min-width: 0; flex: 1; font-size: 13px; }
.docs-q::placeholder { color: var(--dim); }
.docs-q:focus { outline: none; border-color: var(--neon); box-shadow: 0 0 10px rgba(176, 38, 255, 0.35); }
.toc-toggle { display: none; flex: none; }
.q-status { font-family: var(--mono); font-size: 11px; color: var(--muted); min-height: 1.4em; margin: 6px 2px 0; }
.toc { margin-top: 6px; }
.toc-grp { margin-bottom: 10px; }
.toc a {
  display: block; padding: 3px 8px;
  color: var(--muted); text-decoration: none;
  font-size: 13px; line-height: 1.35;
  border-left: 2px solid transparent;
  overflow-wrap: anywhere;
}
.toc a.toc-h {
  font-weight: 800; font-size: 10px; letter-spacing: 0.24em; text-transform: uppercase;
  color: var(--muted); padding-top: 10px; padding-bottom: 4px;
}
.toc a.sub { padding-left: 20px; font-size: 12px; }
.toc a:hover { color: var(--amber); }
.toc a.active { color: var(--lavender); border-left-color: var(--neon); background: rgba(176, 38, 255, 0.1); }
.toc a.toc-h.active { color: var(--neon); background: none; }

/* ---- content ---- */
.docs-main { min-width: 0; padding: 18px 34px 34px; font-size: 15px; line-height: 1.62; color: var(--lavender); }
.docs-main .promptline { margin-top: 2px; }
.docs-main h1 { font-weight: 800; font-size: 30px; letter-spacing: 0.08em; text-transform: uppercase; margin: 6px 0 10px;
  text-shadow: 0 0 14px rgba(176, 38, 255, 0.55); }
.docs-main .lead { font-size: 16px; color: var(--lavender); max-width: 78ch; }
.docs-main p, .docs-main li, .docs-main dd { max-width: 82ch; }
.docs-main p { margin: 0 0 12px; }
.docs-main ul, .docs-main ol { margin: 0 0 14px; padding-left: 22px; }
.docs-main li { margin: 4px 0; }
.docs-main li::marker { color: var(--neon); font-family: var(--mono); }
.docs-main b { font-weight: 600; color: #fff; }
.docs-main a { color: var(--amber); text-underline-offset: 2px; }
.docs-main a:hover { color: #ffb066; }
.md-only { display: none; }

.toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin: 14px 0 16px; }
.toolbar .btn { padding: 7px 12px; }
.tool-status { font-family: var(--mono); font-size: 11px; color: var(--ok); }
.tool-status.err { color: var(--red); }

.grp { margin-top: 34px; }
.grp > h2 {
  font-weight: 800; font-size: 13px; letter-spacing: 0.3em; text-transform: uppercase;
  color: var(--neon); text-shadow: 0 0 10px rgba(176, 38, 255, 0.6);
  margin: 0 0 6px; padding: 10px 0 8px; border-bottom: 1px solid var(--slate);
}
.doc-sec { padding-top: 14px; }
.doc-sec h3 { font-weight: 800; font-size: 21px; letter-spacing: 0.02em; margin: 6px 0 10px; color: #fff; }
.doc-sec.sub h3 { font-size: 18px; }
.doc-sec h4 { font-weight: 800; font-size: 12px; letter-spacing: 0.2em; text-transform: uppercase; color: var(--muted);
  margin: 18px 0 8px; }
.doc-sec h4 code { text-transform: none; letter-spacing: 0; font-size: 13px; }
.doc-sec h3 code { font-size: 0.82em; }
.anchor { margin-left: 8px; color: var(--dim); text-decoration: none; font-family: var(--mono); font-weight: 400; font-size: 0.8em; }
.docs-main a.anchor { color: var(--dim); }
.docs-main a.anchor:hover { color: var(--amber); }
.grp, .doc-sec, .doc-sec h4[id] { scroll-margin-top: 12px; }

.badge {
  display: inline-block; vertical-align: middle; margin-left: 10px;
  font-family: var(--font); font-weight: 800; font-size: 9px; letter-spacing: 0.16em; line-height: 1.6;
  padding: 1px 7px; border: 1px solid currentColor; text-transform: uppercase; text-shadow: none;
  white-space: nowrap;
}
.note .badge, td .badge { margin-left: 0; margin-right: 6px; }
.badge.soon { color: var(--amber); }
.badge.notlive { color: #ff6a50; }
.badge.live { color: #3ddc84; }

.note {
  margin: 12px 0 16px; padding: 10px 14px;
  border-left: 3px solid var(--neon); background: rgba(176, 38, 255, 0.08);
}
.note p:last-child { margin-bottom: 0; }
.note.warn { border-left-color: var(--amber); background: rgba(255, 120, 0, 0.08); }

/* inline code and code blocks */
.docs-main code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--ink); border: 1px solid var(--slate-lo); padding: 0 4px;
  overflow-wrap: anywhere;
}
.codewrap { position: relative; margin: 8px 0 14px; }
pre.code {
  margin: 8px 0 14px; padding: 12px 14px;
  background: var(--ink); border: 1px solid var(--slate);
  font-family: var(--mono); font-size: 12.5px; line-height: 1.5; color: var(--lavender);
  white-space: pre; overflow-x: auto; tab-size: 2;
  scrollbar-width: thin; scrollbar-color: var(--slate) transparent;
}
.codewrap pre.code { margin: 0; padding-right: 64px; }
pre.code code { font-size: inherit; background: none; border: 0; padding: 0; overflow-wrap: normal; }
.codewrap .copy { position: absolute; top: 8px; right: 8px; background: var(--ink); }
.codewrap .copy.done { color: var(--ok); border-color: var(--ok); }

/* tables */
.tbl { overflow-x: auto; margin: 8px 0 16px; border: 1px solid var(--slate-lo); background: rgba(13, 10, 19, 0.55);
  scrollbar-width: thin; scrollbar-color: var(--slate) transparent; }
.tbl table { width: 100%; border-collapse: collapse; font-size: 13px; line-height: 1.5; }
.tbl th { text-align: left; font-weight: 800; font-size: 10px; letter-spacing: 0.18em; text-transform: uppercase;
  color: var(--muted); border-bottom: 1px solid var(--slate); padding: 7px 10px; white-space: nowrap; }
.tbl td { padding: 7px 10px; border-bottom: 1px dashed var(--slate-lo); vertical-align: top; }
.tbl tr:last-child td { border-bottom: 0; }
.tbl td code { white-space: nowrap; overflow-wrap: normal; }
.tbl td:last-child code, .tbl td:nth-child(2) code { white-space: normal; overflow-wrap: anywhere; }
.tbl a.addr code { white-space: normal; overflow-wrap: anywhere; }

/* glossary */
dl.gloss { margin: 0 0 14px; display: grid; grid-template-columns: minmax(150px, 220px) minmax(0, 1fr); gap: 8px 18px; }
dl.gloss dt { font-weight: 800; color: #fff; font-size: 14px; }
dl.gloss dd { margin: 0; color: var(--lavender); }

.no-match { font-family: var(--mono); font-size: 13px; color: var(--amber); padding: 12px; border: 1px dashed var(--slate); }
.linkish { background: none; border: none; padding: 0; color: var(--amber); cursor: pointer; font: inherit; text-decoration: underline; }
.docs-foot { margin-top: 40px; padding-top: 14px; border-top: 1px solid var(--slate-lo); text-align: left;
  font-size: 10px; letter-spacing: 0.18em; color: var(--dim); text-transform: uppercase; }
.docs-foot a { color: var(--muted); }

@media (prefers-reduced-motion: reduce) {
  .promptline .cursor { animation: none; }
  html { scroll-behavior: auto; }
}
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

/* ---- narrow screens: the sidebar becomes a sticky bar with the search and a Contents button ---- */
@media (max-width: 900px) {
  body.docs-body { padding: 0; }
  .docs-term { border: 0; box-shadow: none; }
  .docs-layout { grid-template-columns: minmax(0, 1fr); }
  .docs-side {
    position: sticky; top: 0; z-index: 10;
    max-height: none; overflow: visible;
    border-right: 0; border-bottom: 2px solid var(--ink);
    padding: 10px 16px 6px;
    background: var(--slate-lo);
    box-shadow: 0 8px 18px rgba(0, 0, 0, 0.45);
  }
  .toc-toggle { display: inline-flex; }
  .docs-q { font-size: 16px; } /* iOS zooms into smaller fields */
  .toc { display: none; max-height: 62vh; overflow-y: auto; margin: 4px -16px 0; padding: 0 16px 10px; overscroll-behavior: contain; }
  .docs-side.open .toc { display: block; }
  .q-status:empty { min-height: 0; margin: 0; }
  .docs-main { padding: 16px 16px 28px; font-size: 15px; }
  .docs-main h1 { font-size: 24px; }
  .grp, .doc-sec, .doc-sec h4[id] { scroll-margin-top: 76px; }
  .doc-sec h3 { font-size: 19px; }
  .doc-sec.sub h3 { font-size: 17px; }
  dl.gloss { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  dl.gloss dd { margin-bottom: 10px; }
  .docs-term .titlebar .winbtns { display: none; }
}
@media (max-width: 680px) {
  /* without docs.js, wide tables scroll sideways inside their box instead of crushing their columns */
  .tbl:not(.stack) table:has(th:nth-child(3)) { min-width: 560px; }
  .tbl:not(.stack) table:has(th:nth-child(4)) { min-width: 660px; }
  .tbl:not(.stack) table:has(th:nth-child(6)) { min-width: 780px; }
  .tbl td code, .tbl td:last-child code, .tbl td:nth-child(2) code { white-space: normal; overflow-wrap: normal; }
  .tbl a.addr code { overflow-wrap: anywhere; }
  /* two-column tables fit: long values such as addresses break anywhere instead of running out of the box */
  .tbl table:not(:has(th:nth-child(3))) td code { overflow-wrap: anywhere; }
}
@media (max-width: 520px) {
  .docs-term .ethchip { display: none; }
  pre.code { font-size: 12px; }
  .tbl table { font-size: 12.5px; }
}

/* A table of 3 or more columns that doesn't fit its box (and every such table on a phone) becomes one card per
   row: the first cell as its title, every other cell after its column name. docs.js adds .stacked and the
   data-label of each cell, so no column is hidden off-screen. Last in the file, so it wins over the rules above. */
.tbl.stacked { overflow-x: visible; }
.tbl.stacked table, .tbl.stacked tbody, .tbl.stacked tr, .tbl.stacked td { display: block; }
.tbl.stacked thead { display: none; }
.tbl.stacked tr { padding: 9px 12px 10px; border-bottom: 1px dashed var(--slate); }
.tbl.stacked tr:last-child { border-bottom: 0; }
.tbl.stacked td { padding: 2px 0; border-bottom: 0; }
.tbl.stacked td:first-child { font-weight: 600; color: #fff; padding-bottom: 4px; }
.tbl.stacked td:empty { display: none; }
.tbl.stacked td[data-label]::before {
  content: attr(data-label); margin-right: 8px;
  font-weight: 800; font-size: 10px; letter-spacing: 0.16em; text-transform: uppercase; color: var(--muted);
}
.tbl.stacked td code { white-space: normal; overflow-wrap: anywhere; }
