/* /docs: three-column documentation layout on the site palette (site.css
   tokens). Sidebar nav, article, on-page contents. Without JavaScript every
   article is shown in order; docs.js turns it into one article per hash. */

.docs-shell {
  display: grid;
  grid-template-columns: 250px minmax(0, 1fr) 210px;
  gap: 2.2rem;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 1.5rem 4rem;
}

/* ── Sidebar ─────────────────────────────────────────────────────────── */
.docs-side {
  position: sticky; top: 56px; align-self: start;
  max-height: calc(100vh - 56px); overflow-y: auto;
  padding: 1.4rem .2rem 2rem 0;
  font-size: .88rem;
}
.docs-side .docs-home-link {
  display: block; color: var(--text); font-weight: 600; text-decoration: none;
  padding: .35rem .6rem; border-radius: 6px; margin-bottom: .6rem;
}
.docs-side .docs-home-link:hover { background: var(--panel-subtle); }
.docs-cat { margin: 0 0 .5rem; }
.docs-cat > button {
  display: flex; align-items: center; justify-content: space-between; width: 100%;
  background: none; border: 0; cursor: pointer; font: inherit; text-align: left;
  color: var(--muted-bright); font-size: .72rem; font-weight: 700; letter-spacing: .08em;
  text-transform: uppercase; padding: .55rem .6rem .35rem;
}
.docs-cat > button::after { content: "\25BE"; font-size: .9em; transition: transform .15s; }
.docs-cat.collapsed > button::after { transform: rotate(-90deg); }
.docs-cat.collapsed ul { display: none; }
.docs-cat ul { list-style: none; margin: 0; padding: 0; }
.docs-cat li a {
  display: block; color: var(--text1); text-decoration: none;
  padding: .3rem .6rem .3rem .9rem; border-left: 2px solid transparent; border-radius: 0 6px 6px 0;
  line-height: 1.35;
}
.docs-cat li a:hover { color: var(--text); background: var(--panel-subtle); }
.docs-cat li a.active { color: var(--text); border-left-color: var(--accent); background: var(--accent-soft); }

.docs-menu-btn { display: none; }

/* ── Article ─────────────────────────────────────────────────────────── */
.docs-main { min-width: 0; padding-top: 1.2rem; }
.docs-main h1 { font-size: 2rem; font-weight: 700; letter-spacing: -.02em; margin: .8rem 0 .4rem; }
.docs-lead { color: var(--text1); font-size: 1rem; max-width: 720px; }
.doc { max-width: 780px; }
.doc + .doc { margin-top: 3rem; border-top: 1px solid var(--border); padding-top: 1rem; }
.js-docs .doc + .doc { margin-top: 0; border-top: 0; padding-top: 0; }
.js-docs .doc, .js-docs .docs-landing { display: none; }
.js-docs .doc.shown, .js-docs .docs-landing.shown { display: block; }
.doc .crumb { color: var(--muted); font-size: .78rem; font-weight: 600; letter-spacing: .06em; text-transform: uppercase; margin-top: .8rem; }
.doc h2 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; margin: .3rem 0 .8rem; scroll-margin-top: 72px; }
.doc h3 { font-size: 1.12rem; font-weight: 600; color: var(--text); margin: 2rem 0 .5rem; scroll-margin-top: 72px; }
.doc h4 { font-size: .98rem; font-weight: 600; color: var(--text); margin: 1.3rem 0 .4rem; }
/* Crawlable article pages promote the source headings one level. Keep their
   existing sizes and spacing while giving each page a real h1. */
.doc.generated-doc-article h1 { font-size: 1.75rem; font-weight: 700; letter-spacing: -.015em; margin: .3rem 0 .8rem; scroll-margin-top: 72px; }
.doc.generated-doc-article h2 { font-size: 1.12rem; font-weight: 600; letter-spacing: normal; color: var(--text); margin: 2rem 0 .5rem; scroll-margin-top: 72px; }
.doc.generated-doc-article h3 { font-size: .98rem; font-weight: 600; color: var(--text); margin: 1.3rem 0 .4rem; }
.doc p, .doc li { color: var(--text1); font-size: .95rem; line-height: 1.65; }
.doc p { margin: .6rem 0; }
.doc ul, .doc ol { margin: .5rem 0 .7rem 1.3rem; }
.doc li { margin: .3rem 0; }
.doc strong { color: var(--text); }
.doc code { font-family: var(--mono, ui-monospace, Consolas, monospace); font-size: .86em; background: var(--panel2); padding: .08rem .35rem; border-radius: 4px; color: var(--text); }
.doc a { color: var(--accent-hover, #1aa3ff); }
.doc .note-small { color: var(--muted); font-size: .86rem; }

/* Tables: scroll inside the column on narrow screens. */
.doc .table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: .9rem 0; }
.doc table { border-collapse: collapse; width: 100%; font-size: .87rem; }
.doc th, .doc td { border-bottom: 1px solid var(--border); padding: .5rem .6rem; text-align: left; vertical-align: top; color: var(--text1); }
.doc th { color: var(--text); font-weight: 600; background: var(--panel); }
.doc table.num td:not(:first-child), .doc table.num th:not(:first-child) { text-align: right; white-space: nowrap; }
.doc .table-cap { color: var(--muted); font-size: .82rem; margin-top: -.4rem; }

/* Callouts. */
.callout { border: 1px solid var(--border); border-left: 3px solid var(--accent); background: var(--panel); border-radius: 8px; padding: .75rem 1rem; margin: 1rem 0; }
.callout > .callout-title { display: block; font-size: .74rem; font-weight: 700; letter-spacing: .07em; text-transform: uppercase; margin-bottom: .2rem; color: var(--accent-hover, #1aa3ff); }
.callout p { margin: .3rem 0; }
.callout.important { border-left-color: var(--amber, #f5b301); }
.callout.important > .callout-title { color: var(--amber, #f5b301); }
.callout.technical { border-left-color: var(--teal, #34d399); }
.callout.technical > .callout-title { color: var(--teal, #34d399); }

/* Technical details: collapsible second level. */
details.tech { border: 1px solid var(--border); border-radius: 8px; margin: 1.3rem 0; background: var(--bg-deep, #131418); }
details.tech > summary { cursor: pointer; padding: .7rem 1rem; font-weight: 600; color: var(--teal, #34d399); font-size: .92rem; list-style: none; }
details.tech > summary::-webkit-details-marker { display: none; }
details.tech > summary::before { content: "\25B8"; display: inline-block; margin-right: .5rem; transition: transform .15s; }
details.tech[open] > summary::before { transform: rotate(90deg); }
details.tech > .tech-body { padding: 0 1rem .8rem; }

/* Landing cards. */
.docs-cards { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; margin: 1.6rem 0; max-width: 900px; }
.docs-card { display: block; background: var(--panel); border: 1px solid var(--border); border-radius: 12px; padding: 1.1rem 1.2rem; text-decoration: none; transition: border-color .15s, background .15s; }
.docs-card:hover { border-color: var(--accent-border, rgba(0,145,234,.5)); background: var(--panel2); }
.docs-card h2 { color: var(--text); font-size: 1.05rem; margin: 0 0 .35rem; }
.docs-card p { color: var(--text1); font-size: .9rem; margin: 0 0 .5rem; line-height: 1.55; }
.docs-card ul { margin: 0; padding: 0; list-style: none; color: var(--muted-bright); font-size: .82rem; line-height: 1.6; }

/* Prev / next. */
.docs-pager { display: flex; justify-content: space-between; gap: 1rem; margin: 3rem 0 0; max-width: 780px; border-top: 1px solid var(--border); padding-top: 1.2rem; }
.docs-pager a { flex: 1 1 0; display: block; border: 1px solid var(--border); border-radius: 10px; padding: .7rem .9rem; text-decoration: none; color: var(--text); font-weight: 600; font-size: .92rem; }
.docs-pager a:hover { border-color: var(--accent-border, rgba(0,145,234,.5)); }
.docs-pager a span { display: block; color: var(--muted); font-size: .75rem; font-weight: 500; margin-bottom: .15rem; }
.docs-pager a.next { text-align: right; }
.docs-pager a[hidden] { visibility: hidden; display: block; }

/* On-page contents. */
.docs-toc { position: sticky; top: 56px; align-self: start; padding: 1.6rem 0 2rem; font-size: .82rem; max-height: calc(100vh - 56px); overflow-y: auto; }
.docs-toc .toc-title { color: var(--muted); font-size: .72rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; margin-bottom: .5rem; }
.docs-toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.docs-toc a { display: block; color: var(--muted-bright); text-decoration: none; padding: .25rem 0 .25rem .8rem; margin-left: -1px; border-left: 1px solid transparent; line-height: 1.35; }
.docs-toc a:hover { color: var(--text); }
.docs-toc a.active { color: var(--text); border-left-color: var(--accent); }
.docs-toc:empty { display: none; }

@media (max-width: 1100px) {
  .docs-shell { grid-template-columns: 230px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); padding: 0 16px 3rem; gap: 0; }
  .docs-menu-btn {
    display: flex; align-items: center; gap: .5rem; margin: 1rem 0 0; width: 100%;
    background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
    color: var(--text); font: inherit; font-size: .9rem; font-weight: 600; padding: .6rem .9rem; cursor: pointer;
  }
  .docs-side { display: none; position: static; max-height: none; padding: .6rem 0 0; }
  .docs-side.open { display: block; border-bottom: 1px solid var(--border); padding-bottom: 1rem; }
  .docs-cards { grid-template-columns: minmax(0, 1fr); }
  .docs-main h1 { font-size: 1.6rem; }
  .doc h2 { font-size: 1.45rem; }
  .doc.generated-doc-article h1 { font-size: 1.45rem; }
}

/* Charts (inline SVG from docs tables) and solver screenshots. */
.chart, .docshot { margin: 1.2rem 0 1.4rem; background: var(--panel); border: 1px solid var(--border); border-radius: 10px; padding: .8rem .9rem .7rem; }
.chart-title { color: var(--text); font-weight: 600; font-size: .9rem; margin-bottom: .3rem; }
.chart svg { display: block; width: 100%; height: auto; }
.chart .grid { stroke: rgba(255,255,255,.07); stroke-width: 1; }
.chart .axis { stroke: rgba(255,255,255,.25); stroke-width: 1; }
.chart .tick, .chart .val { fill: var(--muted-bright); font: 11px Inter, system-ui, sans-serif; }
.chart .val { fill: var(--text1); font-size: 10.5px; }
.chart .ax-label { fill: var(--muted); font: 11px Inter, system-ui, sans-serif; }
.chart .ln { fill: none; stroke-width: 2.4; stroke-linejoin: round; stroke-linecap: round; }
.chart .ln.dash { stroke-dasharray: 6 5; }
.chart .pt { stroke: var(--panel); stroke-width: 1.5; }
.chart .ln.s1 { stroke: var(--accent, #0091ea); } .chart .pt.s1, .chart .cbar.s1 { fill: var(--accent, #0091ea); }
.chart .ln.s2 { stroke: var(--amber, #f5b301); } .chart .pt.s2, .chart .cbar.s2 { fill: var(--amber, #f5b301); }
.chart .ln.s3 { stroke: var(--teal, #34d399); } .chart .pt.s3, .chart .cbar.s3 { fill: var(--teal, #34d399); }
.chart .ln.s4 { stroke: #a78bfa; } .chart .pt.s4, .chart .cbar.s4 { fill: #a78bfa; }
.chart .cbar { opacity: .9; } .chart .cbar:hover { opacity: 1; }
.chart-legend { display: flex; flex-wrap: wrap; gap: .3rem 1rem; margin-top: .35rem; font-size: .8rem; color: var(--text1); }
.chart-legend .lg { display: inline-flex; align-items: center; gap: .4rem; }
.chart-legend i { width: 12px; height: 12px; border-radius: 3px; display: inline-block; }
.chart-legend i.s1 { background: var(--accent, #0091ea); } .chart-legend i.s2 { background: var(--amber, #f5b301); }
.chart-legend i.s3 { background: var(--teal, #34d399); } .chart-legend i.s4 { background: #a78bfa; }
.chart-cap, .docshot figcaption { color: var(--muted); font-size: .8rem; margin: .45rem 0 0; line-height: 1.5; }
.docshot img { display: block; width: 100%; height: auto; border-radius: 6px; border: 1px solid var(--border); }
.docshot.narrow img { max-width: 360px; margin: 0 auto; }
.docshot-row { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 1rem; align-items: start; }
.docshot-row .docshot { margin: 0; }
@media (max-width: 700px) { .docshot-row { grid-template-columns: minmax(0, 1fr); } }

.doc-breadcrumb { font-size: .8rem; color: var(--muted); margin-bottom: .8rem; }
.doc-related { margin-top: 1.5rem; border-top: 1px solid var(--border); padding-top: 1rem; }
