/* GrowthRouter docs. Layout: the same framed column as the homepage, split into a
   sidebar rail and a reading column. Uses only tokens from tokens.css. */

.docs-page { --side-w: 248px; --read: 46rem; }
html:has(.docs-page) { scroll-padding-top: 88px; }

.docs-crumb { display: inline-flex; align-items: center; gap: .9rem; margin-left: -1rem; font: 500 var(--text-sm)/1 var(--font-body); color: var(--text-muted); }
.docs-crumb::before { content: ""; width: 1px; height: 18px; background: var(--border-loud); }
.nav a[aria-current="page"] { color: var(--text-default); }

.docs-band { border-top: 0; }
.docs-shell { display: grid; grid-template-columns: var(--side-w) minmax(0, 1fr); align-items: start; }

/* ---------- sidebar ---------- */
.docs-side {
  position: sticky; top: var(--header-h); align-self: start;
  max-height: calc(100vh - var(--header-h)); overflow-y: auto;
  padding: var(--space-8) 0 var(--space-10);
}
.side-toggle { display: none; }
.side-nav { display: flex; flex-direction: column; }
.side-group { margin: var(--space-6) var(--space-6) var(--space-2); font: 500 var(--text-xs)/1.2 var(--font-body); color: var(--text-faint); }
.side-group:first-child { margin-top: 0; }
.side-nav a {
  position: relative; display: block; padding: .42rem var(--space-6);
  font-size: var(--text-sm); line-height: 1.4; color: var(--text-muted); text-decoration: none;
  transition: color var(--dur-fast), background-color var(--dur-fast);
}
.side-nav a:hover { color: var(--text-default); }
.side-nav a[aria-current="true"] { color: var(--text-default); background: var(--surface); }
.side-nav a[aria-current="true"]::before { content: ""; position: absolute; left: -1px; top: 6px; bottom: 6px; width: 2px; background: var(--text-accent); }
.side-nav a:focus-visible { outline-offset: -2px; }

/* ---------- reading column ---------- */
.docs-main { min-width: 0; border-left: 1px solid var(--border-muted); min-height: calc(100vh - var(--header-h)); }
.doc-sec { position: relative; padding: var(--space-16) clamp(1.25rem, 5vw, 4rem) var(--space-12); border-top: 1px solid var(--border-muted); scroll-margin-top: var(--header-h); }
.doc-sec:first-child { border-top: 0; padding-top: clamp(3rem, 6vw, 4.5rem); }
.doc-sec::before {
  /* crosshair where the section line meets the sidebar rail */
  content: ""; position: absolute; left: -5px; top: -5px; width: 9px; height: 9px;
  background:
    linear-gradient(var(--border-loud), var(--border-loud)) center / 1px 100% no-repeat,
    linear-gradient(var(--border-loud), var(--border-loud)) center / 100% 1px no-repeat;
}
.doc-sec:first-child::before { display: none; }
.doc-sec > * { max-width: var(--read); }
.doc-sec > .route, .doc-sec > .table-wrap, .doc-sec > .snip { max-width: 52rem; }

.doc-kicker { font-size: var(--text-sm); color: var(--text-accent); font-weight: 500; }
.doc-title { margin-top: var(--space-4); font-size: var(--text-h1); line-height: 1.04; letter-spacing: var(--tracking-hero); max-width: 17ch; }
.doc-lede { margin-top: var(--space-5); font-size: var(--text-lg); line-height: 1.55; color: var(--text-muted); }
.doc-lede strong { color: var(--text-default); font-weight: 500; }

.doc-h { font-size: clamp(1.6rem, 2.6vw, 2.15rem); line-height: 1.1; letter-spacing: var(--tracking-head); }
.doc-sec h2:not(.doc-h) { margin-top: var(--space-12); font-size: var(--text-xl); letter-spacing: var(--tracking-title); line-height: 1.2; }
.doc-sec h3 { margin-top: var(--space-10); font-size: var(--text-md); letter-spacing: -.01em; line-height: 1.3; }
.doc-sec h2, .doc-sec h3 { scroll-margin-top: calc(var(--header-h) + 16px); }
.doc-sec p { margin-top: var(--space-4); color: var(--text-muted); }
.doc-sec h2 + p, .doc-sec h3 + p { margin-top: var(--space-3); }
.doc-sec p strong, .doc-sec li strong { color: var(--text-default); font-weight: 500; }
.doc-sec a:not(.btn):not(.anchor) { color: var(--text-default); text-decoration: underline; text-decoration-color: var(--signal-56); text-underline-offset: 3px; text-decoration-thickness: 1px; }
.doc-sec a:not(.btn):not(.anchor):hover { color: var(--text-accent); }

.anchor { margin-left: .45rem; color: var(--text-faint); text-decoration: none; font-weight: 400; opacity: 0; transition: opacity var(--dur-fast); }
h2:hover > .anchor, h3:hover > .anchor, .anchor:focus-visible { opacity: 1; }
.anchor:hover { color: var(--text-accent); }

:not(pre) > code {
  font: 400 .86em/1 var(--font-mono); color: var(--text-default);
  background: var(--surface-raised); border: 1px solid var(--border-faint);
  border-radius: 5px; padding: .16em .38em; overflow-wrap: break-word;
}

.plain { margin-top: var(--space-4); display: grid; gap: var(--space-2); }
.plain li { position: relative; padding-left: 1.2rem; color: var(--text-muted); }
.plain li::before { content: ""; position: absolute; left: 0; top: .68em; width: 6px; height: 1px; background: var(--text-faint); }

.hint { padding-left: var(--space-4); border-left: 2px solid var(--border-loud); font-size: var(--text-sm); color: var(--text-faint) !important; }

.soon {
  display: inline-flex; align-items: center; white-space: nowrap;
  font: 500 var(--text-micro)/1 var(--font-body); color: var(--text-accent);
  background: var(--signal-8); border: 1px solid var(--signal-24);
  padding: .28rem .5rem; border-radius: var(--radius-xs); vertical-align: .1em;
}

/* ---------- status note ---------- */
.status { margin-top: var(--space-8); padding: var(--space-5) var(--space-6); background: var(--signal-4); border: 1px solid var(--signal-24); border-radius: var(--radius-lg); }
.status-h { margin: 0 !important; font: 600 var(--text-base)/1.3 var(--font-display); color: var(--text-default) !important; }
.status ul { margin-top: var(--space-3); display: grid; gap: var(--space-2); }
.status li { position: relative; padding-left: 1.1rem; font-size: var(--text-sm); color: var(--text-muted); }
.status li::before { content: ""; position: absolute; left: 0; top: .62em; width: 5px; height: 5px; border-radius: 50%; background: var(--text-accent); }

/* ---------- the route: one campaign id from post to result ---------- */
.route { position: relative; margin-top: var(--space-8); display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); border: 1px solid var(--border-muted); border-radius: var(--radius-xl); background: var(--surface-dark); overflow: hidden; }
.route::before {
  /* the lime route line, running through every node */
  content: ""; position: absolute; left: calc(var(--space-5) + 14px); right: calc(25% - var(--space-5) - 14px); top: calc(var(--space-6) + 13px); height: 2px;
  background: linear-gradient(90deg, var(--border-loud), var(--text-accent));
}
.route-step { position: relative; padding: var(--space-6) var(--space-5) var(--space-6); border-left: 1px solid var(--border-faint); display: flex; flex-direction: column; }
.route-step:first-child { border-left: 0; }
.route-n {
  position: relative; display: inline-grid; place-items: center; width: 28px; height: 28px;
  border-radius: var(--radius-sm); border: 1px solid var(--border-loud); background: var(--surface);
  font: 500 var(--text-micro)/1 var(--font-mono); color: var(--text-muted);
}
.route-step.is-end .route-n { background: var(--action-bg); border-color: var(--action-edge); color: var(--action-text); box-shadow: 0 0 0 5px var(--signal-12); }
.route-k { margin-top: var(--space-5) !important; font: 600 var(--text-base)/1.25 var(--font-display); color: var(--text-default) !important; }
.route-v { margin-top: var(--space-2) !important; font-size: var(--text-sm); line-height: 1.5; flex: 1; }
.route-c { margin-top: var(--space-4); align-self: flex-start; max-width: 100%; font: 500 var(--text-micro)/1.4 var(--font-mono); color: var(--text-accent); background: var(--signal-8); border: 1px solid var(--signal-24); border-radius: var(--radius-xs); padding: .3rem .5rem; overflow-wrap: anywhere; }

/* ---------- numbered lists that really are sequences ---------- */
.rules { margin-top: var(--space-4); counter-reset: rule; display: grid; gap: var(--space-3); }
.rules li { counter-increment: rule; position: relative; padding-left: 2.2rem; color: var(--text-muted); }
.rules li::before { content: counter(rule); position: absolute; left: 0; top: .1rem; display: grid; place-items: center; width: 22px; height: 22px; border-radius: 6px; border: 1px solid var(--border-loud); font: 500 var(--text-label)/1 var(--font-mono); color: var(--text-muted); }

.steps-doc { margin-top: var(--space-8); counter-reset: step; }
.steps-doc > li { counter-increment: step; position: relative; padding: 0 0 var(--space-10) 3rem; }
.steps-doc > li:last-child { padding-bottom: var(--space-2); }
.steps-doc > li::before {
  content: counter(step); position: absolute; left: 0; top: -.1rem; display: grid; place-items: center;
  width: 30px; height: 30px; border-radius: var(--radius-sm); background: var(--surface); border: 1px solid var(--border-loud);
  font: 500 var(--text-micro)/1 var(--font-mono); color: var(--text-default);
}
.steps-doc > li::after { content: ""; position: absolute; left: 14.5px; top: 2.2rem; bottom: .5rem; width: 1px; background: var(--border-muted); }
.steps-doc > li:last-child::after { display: none; }
.steps-doc > li > h3 { margin-top: 0; }
.steps-doc > li > * { max-width: calc(var(--read) - 3rem); }

/* ---------- code blocks ---------- */
.snip { margin: var(--space-5) 0 0; background: var(--surface-dark); border: 1px solid var(--border-muted); border-radius: var(--radius-md); overflow: hidden; }
.snip figcaption { display: flex; align-items: center; gap: var(--space-3); min-height: 40px; padding: .35rem .45rem .35rem var(--space-4); border-bottom: 1px solid var(--border-faint); background: var(--background-lighter); }
.snip-name { font: 400 var(--text-micro)/1.3 var(--font-mono); color: var(--text-faint); min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.snip .copy { margin-left: auto; flex: 0 0 auto; transition: color var(--dur-fast), border-color var(--dur-fast); }
.snip .copy.is-done { color: var(--text-accent); border-color: var(--signal-40); }
.snip pre { margin: 0; padding: var(--space-4) var(--space-5) var(--space-5); overflow-x: auto; font: 400 var(--text-xs)/1.75 var(--font-mono); color: var(--code-text); tab-size: 2; scrollbar-width: thin; scrollbar-color: var(--border-loud) transparent; }
.snip pre code { font: inherit; }
.snip-out pre { color: var(--text-accent); }
.snip-prompt pre { color: var(--text-default); font-family: var(--font-body); font-size: var(--text-sm); }
.snip + .snip { margin-top: var(--space-2); }
.n { color: var(--accent-gold); }

/* ---------- tables ---------- */
.table-wrap { margin-top: var(--space-5); border: 1px solid var(--border-muted); border-radius: var(--radius-md); overflow-x: auto; scrollbar-width: thin; scrollbar-color: var(--border-loud) transparent; }
.table-wrap table { width: 100%; border-collapse: collapse; font-size: var(--text-sm); }
.table-wrap caption { caption-side: top; text-align: left; padding: var(--space-3) var(--space-4); border-bottom: 1px solid var(--border-muted); color: var(--text-muted); font-size: var(--text-xs); }
.table-wrap th { text-align: left; font: 500 var(--text-xs)/1.3 var(--font-body); color: var(--text-faint); padding: var(--space-3) var(--space-4); background: var(--background-lighter); }
.table-wrap td { vertical-align: top; padding: .8rem var(--space-4); border-top: 1px solid var(--border-faint); color: var(--text-muted); line-height: 1.5; }
.table-wrap td:first-child { color: var(--text-default); width: 38%; }
.table-wrap td:first-child code { background: transparent; border: 0; padding: 0; color: var(--text-default); font-size: .9em; line-height: 1.5; }
.args { font: 400 var(--text-micro)/1.6 var(--font-mono); color: var(--text-faint); }

/* ---------- FAQ (reuses the homepage disclosure style) ---------- */
.doc-faq { margin-top: var(--space-4); padding: 0; }
.doc-faq details p { margin-top: 0; }

.doc-end { padding: var(--space-8) clamp(1.25rem, 5vw, 4rem) var(--space-12); border-top: 1px solid var(--border-muted); font-size: var(--text-sm); color: var(--text-faint); }
.doc-end a { color: var(--text-default); }

/* ---------- responsive: sidebar becomes a sticky section picker ---------- */
@media (max-width: 960px) {
  .docs-shell { grid-template-columns: 1fr; }
  .docs-main { border-left: 0; }
  .docs-side {
    top: var(--header-h); z-index: 15; max-height: none; overflow: visible; padding: 0;
    border-right: 0; border-bottom: 1px solid var(--border-muted);
    background: var(--header-bg); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px);
  }
  .side-toggle {
    display: flex; align-items: center; gap: var(--space-3); width: 100%; height: 48px; padding: 0 var(--frame-pad);
    background: transparent; border: 0; color: var(--text-default); font: inherit; font-size: var(--text-sm); cursor: pointer; text-align: left;
  }
  .side-toggle-k { color: var(--text-faint); }
  .side-toggle-v { font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .side-toggle svg { width: 16px; height: 16px; margin-left: auto; color: var(--text-muted); transition: transform var(--dur-base) var(--ease-out); }
  .side-toggle[aria-expanded="true"] svg { transform: rotate(180deg); }
  .side-toggle:focus-visible { outline-offset: -3px; }
  .side-nav {
    display: none; position: absolute; left: 0; right: 0; top: 100%;
    max-height: calc(100vh - var(--header-h) - 48px); overflow-y: auto;
    padding: var(--space-2) 0 var(--space-6); background: var(--surface-dark);
    border-bottom: 1px solid var(--border-muted); box-shadow: var(--shadow-float);
  }
  .side-nav.is-open { display: flex; }
  .side-group, .side-nav a { padding-inline: var(--frame-pad); margin-inline: 0; }
  .side-nav a { padding-block: .62rem; }
  html:has(.docs-page) { scroll-padding-top: 128px; }
  .doc-sec, .doc-sec h2, .doc-sec h3 { scroll-margin-top: calc(var(--header-h) + 64px); }
  .doc-sec::before { display: none; }
  .docs-crumb { display: none; }
}
@media (max-width: 760px) {
  .route { grid-template-columns: 1fr; }
  .route::before { left: calc(var(--space-5) + 13px); right: auto; top: 2.4rem; bottom: 2.4rem; width: 2px; height: auto; background: linear-gradient(180deg, var(--border-loud), var(--text-accent)); }
  .route-step { display: grid; grid-template-columns: 28px minmax(0, 1fr); column-gap: var(--space-4); border-left: 0; border-top: 1px solid var(--border-faint); padding: var(--space-5); }
  .route-step:first-child { border-top: 0; }
  .route-n { grid-row: 1 / span 3; }
  .route-k { margin-top: .2rem !important; }
  .route-c { grid-column: 2; justify-self: start; margin-top: var(--space-3); }
  .table-wrap td:first-child { width: auto; }
}
@media (max-width: 520px) {
  .doc-sec { padding-top: var(--space-12); padding-bottom: var(--space-10); }
  .steps-doc > li { padding-left: 2.6rem; }
  .snip pre { font-size: var(--text-micro); padding: var(--space-4); }
  .snip figcaption { flex-wrap: wrap; row-gap: .3rem; padding-bottom: .45rem; }
  .snip figcaption .soon { order: 3; }
  .table-wrap table, .table-wrap thead, .table-wrap tbody, .table-wrap tr, .table-wrap td { display: block; }
  .table-wrap thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .table-wrap tr { padding: .75rem var(--space-4); border-top: 1px solid var(--border-faint); }
  .table-wrap tbody tr:first-child { border-top: 0; }
  .table-wrap td { padding: 0; border: 0; }
  .table-wrap td + td { margin-top: .3rem; }
}
