/* QueryLines docs -- layout additions on top of style.css.
   Loaded after style.css on every /docs/* page: reuses all paper & ledger
   ink tokens (--accent, --hairline, --font-mono, .panel, .copy-btn,
   .data-table, .price-tag, .mcp-tool-price, etc.) and adds only what the
   docs section needs -- a slim collapsing sidebar, prose measure, callouts,
   a tab switcher, and prev/next pager. */

/* ---------- docs nav state (header) ---------- */

.nav-links a.current {
  color: var(--ink);
}

.nav-links a.current::after {
  content: "";
  display: block;
  height: 2px;
  margin-top: 4px;
  background: var(--accent);
  border-radius: 1px;
}

/* ---------- shell: slim sidebar + content ---------- */

/* vertical padding only (padding-top/bottom, never the shorthand): the same
   element is also .wrap, whose 0 24px horizontal padding must survive */
.docs-shell {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 3rem;
  align-items: start;
  padding-top: 3rem;
  padding-bottom: 5rem;
}

@media (max-width: 800px) {
  .docs-shell {
    grid-template-columns: 1fr;
    gap: 1.5rem;
    padding-top: 2rem;
    padding-bottom: 3.5rem;
  }
}

.docs-sidebar {
  position: sticky;
  top: 88px;
}

@media (max-width: 800px) {
  .docs-sidebar {
    position: static;
  }
}

.docs-nav-label {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--ink-muted);
  margin: 0 0 0.75rem;
}

.docs-nav-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  border-left: 1px solid var(--hairline);
}

@media (max-width: 800px) {
  .docs-nav-list {
    flex-direction: row;
    flex-wrap: wrap;
    border-left: none;
    border-bottom: 1px solid var(--hairline);
    padding-bottom: 0.75rem;
    gap: 0.3rem 1.1rem;
  }
}

.docs-nav-list a {
  display: block;
  padding: 0.4rem 0 0.4rem 0.9rem;
  margin-left: -1px;
  border-left: 2px solid transparent;
  font-size: 0.88rem;
  color: var(--ink-secondary);
  text-decoration: none;
  transition: color 0.15s ease, border-color 0.15s ease;
}

@media (max-width: 800px) {
  .docs-nav-list a {
    padding: 0.2rem 0;
    border-left: none;
    border-bottom: 2px solid transparent;
  }
}

.docs-nav-list a:hover {
  color: var(--ink);
}

.docs-nav-list a.active {
  color: var(--accent);
  border-color: var(--accent);
  font-weight: 600;
}

/* ---------- content column ---------- */

.docs-content {
  min-width: 0;
  max-width: 74ch;
}

.docs-content h1 {
  font-size: clamp(1.9rem, 3.6vw, 2.6rem);
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0.4rem 0 0.85rem;
}

.docs-intro {
  font-size: 1.04rem;
  color: var(--ink-secondary);
  margin: 0 0 2.5rem;
  max-width: 62ch;
}

.docs-content h2 {
  font-size: 1.35rem;
  margin: 3rem 0 0.9rem;
  padding-top: 1.75rem;
  border-top: 1px solid var(--hairline);
}

.docs-content section:first-of-type h2:first-child,
.docs-content > h2:first-child {
  margin-top: 0;
  padding-top: 0;
  border-top: none;
}

.docs-content h3 {
  font-size: 1.05rem;
  margin: 1.75rem 0 0.6rem;
}

.docs-content p {
  color: var(--ink-secondary);
  margin: 0 0 1rem;
}

.docs-content ul,
.docs-content ol {
  color: var(--ink-secondary);
  padding-left: 1.3rem;
  margin: 0 0 1.1rem;
}

.docs-content li {
  margin-bottom: 0.4rem;
}

.docs-content li code,
.docs-content p code {
  color: var(--ink);
  background: var(--surface-sunken);
  padding: 0.1em 0.4em;
  border-radius: 4px;
}

.docs-content a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid rgba(39, 64, 224, 0.3);
}

.docs-content a:hover {
  border-color: var(--accent);
}

.docs-content .panel,
.docs-content .panel-dark {
  margin: 0 0 1.4rem;
}

.docs-content .panel pre,
.docs-content .panel-dark pre {
  max-height: none;
}

/* stacking curl + response panel-heads inside one panel (no column grid) */
.docs-content pre + .panel-head {
  border-top: 1px solid var(--hairline);
}

/* ---------- callouts ---------- */

.doc-note,
.doc-warn {
  border-radius: var(--radius-card);
  padding: 1rem 1.2rem;
  margin: 0 0 1.4rem;
  font-size: 0.92rem;
}

.doc-note {
  background: var(--accent-wash);
  border: 1px solid rgba(39, 64, 224, 0.22);
  color: var(--ink);
}

.doc-note strong,
.doc-warn strong {
  color: var(--ink);
}

.doc-warn {
  background: rgba(196, 61, 61, 0.06);
  border: 1px solid rgba(196, 61, 61, 0.25);
  color: var(--ink);
}

.doc-note p:last-child,
.doc-warn p:last-child {
  margin-bottom: 0;
}

/* ---------- step markers (Step 0 wallet, 402 flow) ---------- */

.doc-step {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  margin-bottom: 1.4rem;
}

.doc-step-num {
  flex-shrink: 0;
  width: 1.9rem;
  height: 1.9rem;
  border-radius: 50%;
  background: var(--ink);
  color: var(--bg);
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-step-body {
  min-width: 0;
  flex: 1;
}

.doc-step-body h3 {
  margin-top: 0;
}

/* ---------- flow diagram (402 request/response chain) ---------- */

/* selector carries element+class specificity so the generic
   .docs-content ol/li spacing rules above can't leak into the card */
ol.doc-flow {
  list-style: none;
  margin: 0 0 1.4rem;
  padding: 0;
  counter-reset: flow;
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  overflow: hidden;
}

/* Positioned number bubble, NOT flex on the li: the li holds a sentence with
   inline code chips, and flex would blockify each chip into its own column. */
ol.doc-flow li {
  counter-increment: flow;
  position: relative;
  margin: 0;
  padding: 0.85rem 1.1rem 0.85rem 3.4rem;
  font-size: 0.88rem;
  line-height: 1.6;
  color: var(--ink-secondary);
  border-bottom: 1px solid var(--hairline);
  background: var(--surface);
}

ol.doc-flow li:last-child {
  border-bottom: none;
}

ol.doc-flow li::before {
  content: counter(flow);
  position: absolute;
  left: 1.1rem;
  top: 0.85rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
  border: 1px solid currentColor;
  width: 1.4rem;
  height: 1.4rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.doc-flow code {
  color: var(--ink);
}

/* ---------- tabs (curl / TypeScript / Python / Go) ---------- */

.tabset {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  overflow: hidden;
  margin: 0 0 1.4rem;
  background: var(--surface);
}

.tab-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.2rem;
  padding: 0.5rem 0.6rem;
  background: var(--surface-raised);
  border-bottom: 1px solid var(--hairline);
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  font-weight: 600;
  color: var(--ink-secondary);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.35rem 0.85rem;
  cursor: pointer;
  transition: color 0.15s ease, background-color 0.15s ease;
}

.tab-btn:hover {
  color: var(--ink);
}

.tab-btn[aria-selected="true"] {
  color: var(--accent-ink);
  background: var(--accent);
}

/* code panels flip to the dark ledger theme; prose panels (wallet setup)
   stay on paper, so the dark tokens are scoped away from them */
.tab-panel:not(.tab-panel-prose) {
  --bg: #0b0e14;
  --surface: #12161f;
  --surface-raised: #171c28;
  --ink: #f2f3f6;
  --ink-secondary: #a8aebb;
  --ink-muted: #7a8090;
  --hairline: rgba(255, 255, 255, 0.08);
  --hairline-strong: rgba(255, 255, 255, 0.17);
  --accent: #96a2ff;
}

.tab-panel[hidden] {
  display: none;
}

.tab-panel pre {
  margin: 0;
  border-radius: 0;
  max-height: none;
  background: var(--surface);
  color: var(--ink);
}

.tab-panel .panel-head {
  border-bottom: 1px solid var(--hairline);
  background: var(--surface-raised);
}

.tab-panel-prose {
  padding: 1.5rem 1.4rem 0.2rem;
}

/* ---------- wallet FAQ (native disclosure, no JS) ---------- */

.doc-faq {
  margin: 0 0 1.6rem;
}

.doc-faq details {
  background: var(--surface);
  border: 1px solid var(--hairline);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-card);
  padding: 0.85rem 1.1rem;
  margin-bottom: 0.6rem;
}

.doc-faq summary {
  cursor: pointer;
  font-weight: 600;
  font-size: 0.94rem;
  color: var(--ink);
}

.doc-faq details[open] summary {
  margin-bottom: 0.5rem;
}

.doc-faq details p {
  margin: 0;
  font-size: 0.92rem;
  color: var(--ink-secondary);
}

/* ---------- small-print / reference tables ---------- */

.docs-content .data-table {
  font-size: 0.86rem;
  margin-bottom: 1.6rem;
}

.docs-content .data-table td,
.docs-content .data-table th {
  padding: 0.55rem 0.8rem;
}

.docs-content .data-table td code {
  background: none;
  padding: 0;
}

/* ---------- endpoint reference cards (rendered from /openapi.json) ---------- */

.endpoint-list {
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
  margin: 0 0 1.6rem;
}

.endpoint-card {
  border: 1px solid var(--hairline);
  border-radius: var(--radius-card);
  padding: 1rem 1.2rem;
  background: var(--surface);
}

.endpoint-card-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.6rem;
  margin-bottom: 0.4rem;
}

.endpoint-method {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--good);
  border: 1px solid currentColor;
  border-radius: 4px;
  padding: 0.1rem 0.4rem;
}

.endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  font-weight: 700;
  color: var(--ink);
}

.endpoint-summary {
  font-size: 0.88rem;
  color: var(--ink-secondary);
  margin: 0 0 0.6rem;
}

.endpoint-params {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin: 0;
  padding: 0;
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.endpoint-params li span {
  color: var(--ink-secondary);
}

.endpoint-params .req {
  color: var(--accent);
  font-weight: 700;
}

.docs-fetch-status {
  font-family: var(--font-mono);
  font-size: 0.76rem;
  color: var(--ink-muted);
  margin: 0 0 1rem;
}

.docs-fetch-status.err {
  color: var(--down);
}

.docs-fallback {
  display: none;
}

.docs-fallback.show {
  display: block;
}

/* ---------- pager ---------- */

.docs-pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--hairline);
}

.docs-pager-link {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  text-decoration: none;
  border: none;
  max-width: 45%;
}

.docs-pager-link:last-child {
  text-align: right;
  margin-left: auto;
}

.docs-pager-dir {
  font-family: var(--font-mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-muted);
}

.docs-pager-title {
  font-weight: 600;
  color: var(--ink);
  border-bottom: 1px solid transparent;
}

.docs-pager-link:hover .docs-pager-title {
  color: var(--accent);
  border-color: var(--accent);
}

/* ---------- mobile safety ---------- */

/* long inline commands/URLs in prose must wrap rather than widen the page.
   break-word (not anywhere): only breaks words that would actually overflow
   their line, and doesn't let code chips collapse in intrinsic sizing. */
.docs-content p code,
.docs-content li code {
  overflow-wrap: break-word;
}

/* tables can't shrink below their content's min width; .table-scroll
   (style.css) scrolls them instead. Undo its landing-page bottom margin
   double-up next to docs' own table spacing. */
.docs-content .table-scroll {
  margin-bottom: 1.4rem;
}

/* short label columns read as units ("C# / .NET", "x402-payments"): don't
   let table auto-layout wrap them; the .table-scroll wrapper scrolls instead */
.docs-content .data-table th:first-child,
.docs-content .data-table td:first-child,
.sdk-table td:nth-child(2) {
  white-space: nowrap;
}
