/* =====================================================================
   RespMech documentation page — layout + doc components.
   Reuses the design tokens from styles.css (:root). Light "scientific
   instrument" look, matching the content sections of the landing page.
   ===================================================================== */

/* ---- page header ------------------------------------------------------ */
.docs-head { background: var(--surface); border-bottom: 1px solid var(--border); }
.docs-head .wrap { padding: clamp(2rem, 5vw, 3.4rem) var(--gutter) clamp(1.4rem, 3vw, 2rem); }
.docs-head .eyebrow { color: var(--orange-text); font-weight: 700; letter-spacing: .06em;
  text-transform: uppercase; font-size: .78rem; }
.docs-head h1 { font-size: clamp(1.9rem, 4.5vw, 2.9rem); line-height: 1.08; margin: .35rem 0 .5rem;
  letter-spacing: -.02em; text-wrap: balance; }
.docs-head p { color: var(--muted); max-width: 62ch; font-size: 1.05rem; }

/* ---- two-column layout: sticky sidebar + content --------------------- */
.docs-layout { display: grid; grid-template-columns: 15rem minmax(0, 1fr);
  gap: clamp(1.5rem, 3.5vw, 2.8rem); max-width: 1320px; margin: 0 auto;
  padding: 2.4rem var(--gutter) 4rem; align-items: start; }

.docs-sidebar { position: sticky; top: 4.6rem; max-height: calc(100vh - 5.5rem);
  overflow-y: auto; padding-right: .5rem; font-size: .9rem; overscroll-behavior: contain; }
.docs-sidebar .toc-title { font-size: .74rem; text-transform: uppercase; letter-spacing: .08em;
  color: var(--muted); font-weight: 700; margin: 0 0 .55rem; padding-left: .1rem; }
.docs-toc, .docs-toc ul { list-style: none; margin: 0; padding: 0; }
.docs-toc > li { margin: 0 0 .1rem; }
.docs-toc > li > a { display: block; padding: .28rem .55rem; border-radius: var(--radius-sm);
  color: var(--text-2); font-weight: 600; text-decoration: none; border-left: 2px solid transparent; }
.docs-toc ul { margin: .05rem 0 .35rem; }
.docs-toc ul a { display: block; padding: .2rem .55rem .2rem .95rem; border-radius: var(--radius-sm);
  color: var(--muted); font-weight: 500; text-decoration: none; font-size: .86rem;
  border-left: 2px solid transparent; }
.docs-toc a:hover { background: var(--steel-soft); color: var(--steel-press); }
.docs-toc a.is-current { color: var(--steel-press); background: var(--steel-soft);
  border-left-color: var(--steel); }
.docs-toc .toc-group { margin: .9rem 0 .2rem; font-size: .72rem; text-transform: uppercase;
  letter-spacing: .07em; color: var(--muted); font-weight: 700; padding-left: .1rem; }

/* ---- content ---------------------------------------------------------- */
/* The column fills the track; prose keeps a readable measure while tables, figures and
   code blocks use the FULL width — so wide param tables no longer overflow on desktop. */
.docs-content { min-width: 0; max-width: none; }
.docs-content p, .docs-content ul, .docs-content ol,
.docs-content .callout, .docs-content .formula, .docs-content .pr-intro,
.doc-section > h2, .doc-section > h3, .doc-section > h4 { max-width: 74ch; }
.doc-section { scroll-margin-top: 4.8rem; padding-bottom: 1.6rem; margin-bottom: 2.4rem;
  border-bottom: 1px solid var(--grid); }
.doc-section:last-child { border-bottom: 0; }
.doc-section > h2 { font-size: clamp(1.5rem, 3.2vw, 2rem); line-height: 1.12; letter-spacing: -.015em;
  margin: .6rem 0 .9rem; scroll-margin-top: 4.8rem; }
.doc-section h3 { font-size: 1.22rem; margin: 1.8rem 0 .7rem; scroll-margin-top: 4.8rem;
  color: var(--text); }
.doc-section h4 { font-size: 1.02rem; margin: 1.2rem 0 .5rem; color: var(--text-2); }
.docs-content p { margin: .7rem 0; line-height: 1.66; color: var(--text-2); }
.docs-content ul, .docs-content ol { margin: .7rem 0 .9rem; padding-left: 1.2rem; line-height: 1.6; color: var(--text-2); }
.docs-content ul { list-style: disc; }
.docs-content ol { list-style: decimal; }
.docs-content li { margin: .3rem 0; }
.docs-content li ul, .docs-content li ol { margin: .3rem 0; }
.docs-content a { color: var(--steel); text-decoration: none; border-bottom: 1px solid var(--steel-soft); }
.docs-content a:hover { border-bottom-color: var(--steel); }
.docs-content code { font-family: var(--font-mono); font-size: .87em; background: var(--surface-alt);
  border: 1px solid var(--border); border-radius: 5px; padding: .06em .34em; color: var(--text); }
.docs-content strong { color: var(--text); }

/* ---- parameter tables ------------------------------------------------- */
.param-table { width: 100%; border-collapse: collapse; margin: 1rem 0 1.3rem; font-size: .88rem;
  display: block; overflow-x: auto; }
.param-table thead th { text-align: left; background: var(--surface-alt); color: var(--text-2);
  font-weight: 700; font-size: .78rem; text-transform: uppercase; letter-spacing: .03em;
  padding: .5rem .7rem; border-bottom: 2px solid var(--border-strong); }
.param-table td { padding: .55rem .7rem; border-bottom: 1px solid var(--grid); vertical-align: top;
  color: var(--text-2); line-height: 1.5; }
.param-table tbody tr:nth-child(even) { background: var(--surface-alt); }
.param-table td:nth-child(2) code { overflow-wrap: anywhere; }
.param-table td:first-child { font-weight: 600; color: var(--text); min-width: 8rem; }
.param-table .gotcha { color: var(--warn); display: inline-block; margin-top: .2rem; }

/* ---- formulas --------------------------------------------------------- */
.formula { display: flex; flex-wrap: wrap; align-items: baseline; gap: .8rem; margin: .9rem 0;
  padding: .7rem .95rem; background: var(--surface-alt); border: 1px solid var(--border);
  border-left: 3px solid var(--steel); border-radius: var(--radius-sm); }
.formula code { background: none; border: 0; padding: 0; font-size: 1rem; color: var(--text);
  font-family: var(--font-mono); }
.formula .formula-units { margin-left: auto; color: var(--muted); font-size: .82rem;
  font-family: var(--font-mono); white-space: nowrap; }

/* ---- callouts --------------------------------------------------------- */
.callout { margin: 1.1rem 0; padding: .8rem 1rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border); border-left: 4px solid var(--muted); background: var(--surface-alt);
  color: var(--text-2); line-height: 1.55; }
.callout p { margin: .3rem 0; }
.callout p:first-child { margin-top: 0; } .callout p:last-child { margin-bottom: 0; }
.callout--tip  { border-left-color: var(--ok);    background: #F0F7F2; }
.callout--warn { border-left-color: var(--warn);  background: #FBF4E7; }
.callout--note { border-left-color: var(--steel); background: var(--steel-soft); }
.callout strong { color: var(--text); }

/* ---- command blocks --------------------------------------------------- */
.cmd, pre.cmd { background: var(--slate-bot); color: var(--on-dark); border-radius: var(--radius-sm);
  padding: .7rem .95rem; overflow-x: auto; margin: .8rem 0; font-size: .88rem; }
.cmd code { background: none; border: 0; color: inherit; padding: 0; font-family: var(--font-mono); }
.docs-content pre:not(.cmd) { background: var(--surface-alt); border: 1px solid var(--border);
  border-radius: var(--radius-sm); padding: .85rem 1rem; overflow-x: auto; margin: .9rem 0;
  font-size: .85rem; line-height: 1.5; }
.docs-content pre:not(.cmd) code { background: none; border: 0; padding: 0; color: var(--text); }

/* ---- figures ---------------------------------------------------------- */
.doc-figure { margin: 1.3rem 0; }
.doc-figure img { width: 100%; height: auto; display: block; border: 1px solid var(--border);
  border-radius: var(--radius-sm); background: var(--surface); }
.doc-figure figcaption { color: var(--muted); font-size: .84rem; margin-top: .5rem; line-height: 1.45; }
.before-after { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin: 1.3rem 0; }
.before-after figure { margin: 0; }
@media (max-width: 620px) { .before-after { grid-template-columns: 1fr; } }

/* ---- back-to-top / footer nav ---------------------------------------- */
.docs-content .back-top { display: inline-block; margin-top: 1.5rem; font-weight: 600; }

/* ---- responsive: sidebar becomes a collapsible block on top ---------- */
@media (max-width: 900px) {
  .docs-layout { grid-template-columns: 1fr; }
  .docs-sidebar { position: static; max-height: none; margin-bottom: 1rem;
    background: var(--surface-alt); border: 1px solid var(--border); border-radius: var(--radius);
    padding: 1rem 1.1rem; }
  .docs-content { max-width: none; }
}

/* ---- parameter-reference group intro + cross-links -------------------- */
.pr-intro { color: var(--muted); font-size: .92rem; margin: .35rem 0 .7rem; line-height: 1.5; }
.pr-see { color: var(--text-2); }
.pr-see a { font-weight: 600; white-space: nowrap; }

/* ---- responsive param tables: stack into labelled cards on narrow screens */
@media (max-width: 720px) {
  .param-table { display: block; overflow: visible; }
  .param-table thead { position: absolute; width: 1px; height: 1px; overflow: hidden;
    clip: rect(0 0 0 0); white-space: nowrap; }
  .param-table tbody { display: block; }
  .param-table tr { display: block; border: 1px solid var(--border); border-radius: var(--radius-sm);
    margin: 0 0 .85rem; padding: .65rem .85rem; background: var(--surface); }
  .param-table tbody tr:nth-child(even) { background: var(--surface); }
  .param-table td { display: block; border: 0; padding: .28rem 0; }
  .param-table td::before { content: attr(data-label); display: block; font-size: .66rem;
    text-transform: uppercase; letter-spacing: .04em; color: var(--muted); font-weight: 700;
    margin-bottom: .1rem; }
  .param-table td:first-child { font-size: 1.02rem; font-weight: 700; color: var(--text);
    padding-bottom: .35rem; border-bottom: 1px solid var(--grid); margin-bottom: .25rem; }
  .param-table td:first-child::before { content: none; }
  .param-table td:empty { display: none; }
}

/* ---- parameter CARDS: meta column (name/key/default/unit) beside the description ----- */
/* Used on desktop and mobile alike; uses the page width without forcing TOML keys to wrap. */
.pcards { display: grid; gap: .8rem; margin: 1.1rem 0 1.5rem; }
.pcard { display: grid; grid-template-columns: 17rem minmax(0, 1fr); gap: .35rem 1.6rem;
  align-items: start; border: 1px solid var(--border); border-radius: var(--radius-sm);
  padding: .85rem 1.05rem; background: var(--surface); }
.pcard-meta { display: flex; flex-direction: column; gap: .32rem; min-width: 0; }
.pcard-name { font-weight: 700; color: var(--text); font-size: 1.03rem; line-height: 1.25; }
.pcard-key { line-height: 1.2; }
.pcard-key code { font-family: var(--font-mono); font-size: .82rem; overflow-wrap: anywhere;
  background: var(--surface-alt); border: 1px solid var(--border); border-radius: 5px;
  padding: .12em .36em; color: var(--text); display: inline-block; }
.pcard-fact { font-size: .85rem; color: var(--text-2); }
.pcard-label { font-size: .62rem; text-transform: uppercase; letter-spacing: .04em;
  color: var(--muted); font-weight: 700; margin-right: .35rem; }
.pcard-desc { color: var(--text-2); line-height: 1.58; min-width: 0; }
.pcard-desc .gotcha { color: var(--warn); display: inline-block; margin-top: .3rem; }
@media (max-width: 760px) {
  .pcard { grid-template-columns: 1fr; gap: .5rem; }
  .pcard-meta { padding-bottom: .5rem; border-bottom: 1px solid var(--grid); }
}
