/* =========================================================================
   Documentation layout for index.html: a sticky table of contents beside a
   single reading column. Loaded after styles.css and reuses its tokens and
   its paper components (.printlog, .custody, .builder__card, .cmp, .proof,
   .manifest); this file only adds the docs scaffolding and prose styles.
   ========================================================================= */

.docs {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  gap: clamp(32px, 5vw, 64px);
  padding: var(--space-10) 0 clamp(64px, 9vw, 112px);
}

/* ---------- Table of contents ---------- */
.docs__toc {
  position: sticky; top: 90px; align-self: start;
  max-height: calc(100vh - 110px); overflow-y: auto;
}
.toc__title {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.16em;
  text-transform: uppercase; color: var(--text-2);
  list-style: none; margin-bottom: var(--space-3); cursor: default;
}
.toc__title::-webkit-details-marker { display: none; }
/* Desktop: the summary is a label, not a toggle. */
@media (min-width: 901px) { .toc__title { pointer-events: none; } }
.toc__list a {
  display: block; padding: var(--space-1-5) var(--space-3);
  border-left: 2px solid var(--border-soft);
  color: var(--text-2); font-size: var(--fs-sm); line-height: 1.35;
  transition: color var(--dur-base), border-color var(--dur-base);
}
.toc__list ol a { padding-left: var(--space-6); font-size: var(--fs-xs); }
.toc__list a:hover { color: var(--text); }
.toc__list a.is-active { color: var(--text); border-left-color: var(--accent); }

/* ---------- Reading column ---------- */
.doc { min-width: 0; max-width: 780px; }
.doc-section { padding: 0; margin-top: clamp(56px, 7vw, 80px); }
.doc-section--first { margin-top: 0; }

.doc__eyebrow {
  font-family: var(--font-mono); font-size: var(--fs-xs); letter-spacing: 0.12em;
  text-transform: uppercase; color: var(--steel);
}
.doc h1 { font-size: clamp(3rem, 6vw, 4.4rem); margin-top: var(--space-2); }
.doc__lead { color: var(--text-2); font-size: clamp(1.04rem, 1.4vw, 1.16rem); margin-top: var(--space-4-5); max-width: 66ch; }

.doc h2 {
  font-size: clamp(1.9rem, 3.4vw, 2.5rem);
  padding-bottom: var(--space-3); margin-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-soft);
}
.sec-num {
  display: inline-block; margin-right: var(--space-3);
  font-family: var(--font-mono); font-size: 0.55em; color: var(--steel-dim);
  vertical-align: 0.2em;
}
/* styles.css sets h3 in the display face; prose subheads read better in the body face. */
.doc h3 {
  font-family: var(--font-body); font-weight: 700; font-size: 1.15rem;
  text-transform: none; letter-spacing: 0; line-height: 1.3;
  margin: var(--space-9, 36px) 0 var(--space-2-5);
}
.doc > section > p, .doc-section > p, .override-figure p { color: var(--text-2); max-width: 70ch; margin-top: var(--space-3-5); }
.doc h2 + p, .doc h3 + p { margin-top: 0; }
.doc p strong, .doc li strong { color: var(--text); }
.doc p a, .doc li a, .docmeta a {
  color: var(--text); text-decoration: underline;
  text-underline-offset: 3px; text-decoration-color: var(--steel-dim);
}
.doc p a:hover, .doc li a:hover, .docmeta a:hover { text-decoration-color: var(--steel); }
.doc code {
  font-family: var(--font-mono); font-size: 0.9em;
  background: var(--wash); border: 1px solid var(--border-soft);
  border-radius: 3px; padding: 0 var(--space-1-5);
}
.doc__caption { color: var(--text-2); font-size: var(--fs-sm); margin-top: var(--space-2); }

.doc__bullets, .doc__steps { color: var(--text-2); padding-left: 1.3em; display: grid; gap: var(--space-2); max-width: 70ch; }
.doc__bullets { list-style: disc; }
.doc__steps { list-style: decimal; }
.doc__bullets li::marker, .doc__steps li::marker { color: var(--steel-dim); font-family: var(--font-mono); }

/* ---------- Project metadata block ---------- */
.docmeta {
  margin: var(--space-6) 0 var(--space-8);
  border: 1px solid var(--border-soft); border-radius: var(--radius);
  background: var(--card);
}
.docmeta > div {
  display: grid; grid-template-columns: 120px 1fr; gap: var(--space-4);
  padding: var(--space-3) var(--space-4-5);
  border-top: 1px solid var(--border-soft);
}
.docmeta > div:first-child { border-top: 0; }
.docmeta dt {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.1em;
  text-transform: uppercase; color: var(--text-2); padding-top: 0.2em;
}
.docmeta dd { margin: 0; font-size: var(--fs-sm); color: var(--text); }

/* ---------- Tables ---------- */
.doc .table-scroll { margin-top: var(--space-4); }
.doc-table { width: 100%; border-collapse: collapse; background: var(--card); font-size: var(--fs-sm); }
.doc-table th, .doc-table td { padding: var(--space-3) var(--space-4); text-align: left; vertical-align: top; border-bottom: 1px solid var(--border-soft); }
.doc-table thead th {
  font-family: var(--font-mono); font-weight: 700; font-size: var(--fs-2xs);
  letter-spacing: 0.08em; text-transform: uppercase; color: var(--text-2); background: var(--bg-2);
}
.doc-table td { color: var(--text-2); }
.doc-table td:first-child { color: var(--text); white-space: nowrap; }
.doc-table tbody tr:last-child td { border-bottom: 0; }

/* ---------- Override: inset clip beside the text, then the try-it box ---------- */
.override-figure { display: flex; gap: var(--space-5); align-items: flex-start; }
.override-figure .override-inset { width: 86px; }
.override-figure p:first-child { margin-top: 0; }
.note {
  margin-top: var(--space-5); padding: var(--space-4) var(--space-4-5);
  border: 1px solid var(--border-soft); border-left: 3px solid var(--steel-dim);
  border-radius: var(--radius-sm); background: var(--wash);
}
.note__label { font-family: var(--font-mono); font-size: var(--fs-xs); color: var(--text-2); }

/* ---------- Reused components, retuned for a narrower column ---------- */
.doc .proof { margin-bottom: 0; }
.doc .wiring { margin-top: var(--space-6); }
.doc .manifest__row { padding: var(--space-6) var(--space-1-5); }
.doc .custody { margin-top: var(--space-4); }
.doc .printlog { margin-top: var(--space-4); }
.doc .builder__card { max-width: none; }
.builder__name { font-family: var(--font-display); font-size: clamp(2.2rem, 4.4vw, 3rem); line-height: 1; text-transform: uppercase; margin-bottom: var(--space-2); }

.brand__docs {
  font-family: var(--font-mono); font-size: var(--fs-2xs); letter-spacing: 0.1em;
  color: var(--text-2); border: 1px solid var(--border); border-radius: 3px;
  padding: 0 var(--space-1-5); margin-left: var(--space-1);
}

/* ---------- Narrow screens: the TOC becomes a collapsible block on top ---------- */
@media (max-width: 900px) {
  .docs { grid-template-columns: minmax(0, 1fr); gap: var(--space-6); padding-top: var(--space-6); }
  .docs__toc { position: static; max-height: none; overflow: visible; }
  .toc {
    border: 1px solid var(--border-soft); border-radius: var(--radius);
    background: var(--card); padding: var(--space-3) var(--space-4);
  }
  .toc__title { margin-bottom: 0; cursor: pointer; display: flex; justify-content: space-between; }
  .toc__title::after { content: "+"; font-size: var(--fs-md); line-height: 1; }
  .toc[open] .toc__title { margin-bottom: var(--space-3); }
  .toc[open] .toc__title::after { content: "\2212"; }
}
@media (max-width: 560px) {
  .docmeta > div { grid-template-columns: 1fr; gap: var(--space-1); }
  .override-figure { flex-direction: column; }
}
