/*
  Quantstrip docs — shared stylesheet.
  Layout modeled on the Stripe API reference (docs.stripe.com/api, dark
  mode): a two-column grid per section — prose on the left, a stacked
  code/reference panel on the right — on a near-black ground. Accent is
  Quantstrip's own brand blue, not Stripe's. Dark theme only, no build
  step, no framework.
*/

:root {
  --bg:            #1a1c23;
  --fg:            #ececf1;
  --card:          #24262f;
  --card-2:        #1f212a;
  --muted-bg:      #1d1f27;
  --border:        #2d303c;
  --border-soft:   #24262f;
  --divider:       #3a3e4c;
  --muted:         #767d8c;
  --text:          #9399a8;
  --primary:       #4bb6ec;
  --primary-soft:  rgba(75, 182, 236, 0.1);
  --primary-ink:   #0b1420;
  --radius:        8px;
  --radius-lg:     10px;
  --max:           1320px;
  --font-sans:     -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  --font-mono:     "Source Code Pro", Menlo, Monaco, monospace;

  --sidebar-w: 260px;
  --header-h: 56px;
}

* { box-sizing: border-box; }

html {
  font-size: 106.25%; /* ~17px root - a small bump over the 16px default, scales every rem size */
  -webkit-text-size-adjust: 100%;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 6px; }
::-webkit-scrollbar-thumb:hover { background: var(--muted); }

body {
  margin: 0;
  background: var(--bg);
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--primary); text-decoration: none; }
a:hover { text-decoration: underline; }

h1, h2, h3, h4 {
  font-family: var(--font-sans);
  font-weight: 700;
  letter-spacing: -0.01em;
  line-height: 1.3;
  color: var(--fg);
  margin: 0 0 0.6em;
}
h1 { font-size: 1.7rem; }
h2 { font-size: 1.5rem; margin-top: 0; }
h3 { font-size: 1.1rem; margin-top: 1.6em; }
h4 { font-size: 0.95rem; margin-top: 1.2em; }

p { margin: 0 0 1em; color: var(--text); }
p.lead { color: var(--text); font-size: 1rem; }

strong, b { color: var(--fg); font-weight: 600; }

code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.4em;
  color: var(--fg);
}

pre {
  margin: 0;
  overflow-x: auto;
  background: none;
}
pre code {
  display: block;
  padding: 0;
  background: none;
  border: none;
  border-radius: 0;
  font-size: 0.82rem;
  line-height: 1.6;
  white-space: pre;
  color: #ecedf1;
}

ul, ol { padding-left: 1.3em; color: var(--text); }
li { margin-bottom: 0.4em; }

table {
  width: 100%;
  border-collapse: collapse;
  margin: 0 0 1.6em;
  font-size: 0.88rem;
}
th, td {
  text-align: left;
  padding: 10px 12px;
  border-bottom: 1px solid var(--border-soft);
  vertical-align: top;
}
td { color: var(--text); }
th {
  color: var(--muted);
  font-weight: 600;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
tbody tr:hover { background: var(--card-2); }

hr { border: none; border-top: 1px solid var(--divider); margin: 2.4em 0; }

/* ── Layout shell ─────────────────────────────────────────────────────── */

.docs-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */

.docs-header {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--header-h);
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border-soft);
}

.docs-header .brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--fg);
  letter-spacing: -0.01em;
  white-space: nowrap;
}
.docs-header .brand:hover { text-decoration: none; opacity: 0.85; }
.docs-header .brand .brand-logo {
  height: 20px;
  width: auto;
  display: block;
}
.docs-header .brand .tag {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 1rem;
  color: var(--primary);
  margin-left: 1px;
}

.docs-header .hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  width: 36px; height: 36px;
  align-items: center;
  justify-content: center;
  color: var(--fg);
  cursor: pointer;
  flex-shrink: 0;
}
.docs-header .hamburger svg { width: 18px; height: 18px; }

.docs-header .search-wrap {
  position: relative;
  flex: 1;
  max-width: 320px;
  margin-left: auto;
}
.docs-header .search-input {
  width: 100%;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: 7px;
  color: var(--fg);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  padding: 7px 12px 7px 32px;
}
.docs-header .search-input::placeholder { color: var(--muted); }
.docs-header .search-input:focus {
  outline: none;
  border-color: var(--primary);
}
.docs-header .search-wrap svg.icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 14px; height: 14px;
  color: var(--muted);
  pointer-events: none;
}
.docs-header .search-results {
  display: none;
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  max-height: 360px;
  overflow-y: auto;
  z-index: 50;
  box-shadow: 0 12px 32px rgba(0,0,0,0.5);
}
.docs-header .search-results.open { display: block; }
.docs-header .search-results a {
  display: block;
  padding: 9px 12px;
  border-bottom: 1px solid var(--border-soft);
  color: var(--fg);
  font-size: 0.85rem;
}
.docs-header .search-results a:last-child { border-bottom: none; }
.docs-header .search-results a:hover { background: var(--card-2); text-decoration: none; }
.docs-header .search-results .r-section {
  display: block;
  font-family: var(--font-mono);
  font-size: 0.66rem;
  color: var(--primary);
  margin-bottom: 2px;
}
.docs-header .search-results .r-empty {
  padding: 12px; color: var(--muted); font-size: 0.85rem;
}

.docs-header .dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 7px 12px;
  white-space: nowrap;
}
.docs-header .dashboard-link:hover { text-decoration: none; border-color: var(--primary); }

/* Body: sidebar + main */

.docs-body {
  flex: 1;
  display: flex;
  width: 100%;
}

.docs-sidebar {
  width: var(--sidebar-w);
  flex-shrink: 0;
  padding: 24px 16px 40px;
  align-self: flex-start;
  position: sticky;
  top: var(--header-h);
  max-height: calc(100vh - var(--header-h));
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) var(--bg);
}

.docs-sidebar .group { margin-bottom: 22px; }
.docs-sidebar .group + .group {
  border-top: 1px solid var(--border-soft);
  padding-top: 18px;
}
.docs-sidebar .group-title {
  font-family: var(--font-sans);
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
  padding: 0 10px;
  margin-bottom: 8px;
}
.docs-sidebar ul { list-style: none; margin: 0; padding: 0; }
.docs-sidebar li { margin: 0; }
.docs-sidebar a {
  display: block;
  padding: 6px 10px;
  border-radius: 4px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}
.docs-sidebar a:hover { background: var(--card-2); color: var(--fg); }
.docs-sidebar a.active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 600;
}

.docs-main {
  flex: 1;
  min-width: 0;
  padding: 32px 40px 80px;
}

.breadcrumb {
  font-size: 0.8rem;
  color: var(--muted);
  margin-bottom: 20px;
  display: flex;
  align-items: center;
  gap: 6px;
}
.breadcrumb a { color: var(--muted); }
.breadcrumb a:hover { color: var(--primary); }
.breadcrumb .sep { opacity: 0.5; }
.breadcrumb .current { color: var(--fg); }

.page-header { margin-bottom: 1.4em; max-width: 720px; }
.page-kicker {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.72rem;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  margin-bottom: 8px;
}
.page-header .lead { font-size: 0.98rem; }

/* Table-name headers on the schema page - no category grouping above them,
   so each one needs to read clearly as its own section on its own. */
h2.table-name {
  font-family: var(--font-mono);
  color: var(--fg);
  font-size: 1.35rem;
  font-weight: 700;
  margin-top: 1.6em;
  margin-bottom: 0.25em;
  padding-top: 1em;
  border-top: 1px solid var(--divider);
}
h2.table-name:first-of-type { margin-top: 1.4em; padding-top: 0; border-top: none; }
h2.table-name + p { margin-top: 0; }
h2.table-name + .api-section { padding-top: 4px; }

/* ── Stripe-style two-column sections ─────────────────────────────────── */
/* .api-section = one full-width row, divided by a rule below it.
   .api-section-left = prose. .api-section-right = stacked code/reference
   panels, sticky so they stay in view while the (usually longer) prose
   column scrolls past. */

.api-section {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 40px;
  padding: 34px 0;
}
.api-section:first-child { padding-top: 6px; }
.api-section + hr.section-divider { margin: 0; }
/* Sections with no genuinely relevant code example just run the left
   column full width instead of leaving an empty right column. */
.api-section.api-section-full { grid-template-columns: 1fr; }
.api-section.api-section-full .api-section-left { max-width: 760px; }

.api-section-left h2 { margin-bottom: 0.7em; }
.api-section-left h3 { font-size: 0.98rem; margin-top: 1.5em; margin-bottom: 0.3em; color: var(--fg); }
.api-section-left > p:first-of-type { margin-top: 0; }

.api-section-right {
  position: sticky;
  top: calc(var(--header-h) + 24px);
  align-self: start;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Dark code/reference panel - header bar + body, matches the Stripe
   "BASE URL" / "AUTHENTICATED REQUEST" card shape. */

.code-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--card-2);
}
.code-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
}
.code-panel-header .label {
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.code-panel-header .tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--muted);
}
.code-panel pre {
  padding: 14px 16px;
  overflow-x: auto;
}
.code-panel .note {
  padding: 12px 14px;
  font-size: 0.82rem;
  color: var(--text);
  border-top: 1px solid var(--border);
}
.code-panel .note:first-child { border-top: none; }
.code-panel .note code { background: var(--card); }
.code-panel .note p { margin: 0 0 0.5em; font-size: inherit; }
.code-panel .note p:last-child { margin-bottom: 0; }

/* Plain (non-code) reference panel - same shell, prose body, used for
   "scope of this page" / pointer-only admin lists in the right column. */
.ref-panel {
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  background: var(--card-2);
  overflow: hidden;
}
.ref-panel-header {
  padding: 10px 14px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  font-family: var(--font-sans);
  font-weight: 700;
  font-size: 0.68rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text);
}
.ref-panel-body { padding: 14px 16px; font-size: 0.85rem; color: var(--text); }
.ref-panel-body p { font-size: inherit; margin: 0 0 0.6em; }
.ref-panel-body p:last-child { margin-bottom: 0; }
.ref-panel-body code { background: var(--card); }

/* Method label inside a left-column prose block, pairs with its code panel */
.method-name {
  font-family: var(--font-mono);
  font-size: 0.95rem;
  color: var(--fg);
  font-weight: 400;
}
.method-name .owner { color: var(--muted); font-weight: 400; }
.method-name .fn { color: var(--primary); font-weight: 600; }
/* Long signatures: one argument per line, hanging-indented under the
   opening parenthesis - plain text with real newlines/spaces, so this
   just needs them preserved instead of collapsed. */
.method-name.wrapped { white-space: pre; }

/* Callouts */

.callout {
  border: 1px solid var(--border);
  border-left: 3px solid var(--primary);
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 14px 16px;
  margin: 1.4em 0;
  font-size: 0.88rem;
  color: var(--text);
}
.callout strong { color: var(--fg); }

/* Diagrams (Mermaid) */

.diagram {
  border: 1px solid var(--border);
  background: var(--card-2);
  border-radius: var(--radius);
  padding: 18px;
  margin: 1.6em 0;
  overflow-x: auto;
}
.diagram .mermaid { display: flex; justify-content: center; }
.diagram-sm .mermaid svg { width: 75% !important; max-width: 75% !important; height: auto !important; }
.diagram-caption {
  margin: -0.8em 0 1.6em;
  color: var(--muted);
  font-size: 0.82rem;
  text-align: center;
}

/* Cards (used on hub pages) */

.card-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 16px;
  margin: 1.6em 0;
}
.card {
  display: block;
  background: var(--card-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  color: var(--fg);
  text-decoration: none;
  transition: border-color .15s ease, transform .15s ease;
}
.card:hover {
  border-color: var(--primary);
  text-decoration: none;
  transform: translateY(-2px);
}
.card .card-icon {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: var(--card);
  border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center;
  color: var(--primary);
  margin-bottom: 14px;
}
.card .card-icon svg { width: 17px; height: 17px; }
.card h3 { margin: 0 0 6px; font-size: 1.02rem; font-family: var(--font-mono); }
.card p { margin: 0; color: var(--text); font-size: 0.86rem; }

/* Small link-cards used in mini indexes on section pages */
.mini-links {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 1.2em 0;
}
.mini-links a {
  display: block;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  color: var(--fg);
  font-size: 0.88rem;
  font-weight: 600;
}
.mini-links a:hover { border-color: var(--primary); background: var(--card-2); text-decoration: none; }
.mini-links a span {
  display: block;
  font-weight: 400;
  color: var(--muted);
  font-size: 0.8rem;
  margin-top: 3px;
}

/* Hero (docs homepage only) */

.docs-hero {
  position: relative;
  overflow: hidden;
  padding: 30px 0 10px;
}
.docs-hero::before {
  content: "";
  position: absolute;
  top: -60px; left: 50%;
  width: 520px; height: 260px;
  transform: translateX(-50%);
  background: radial-gradient(closest-side, rgba(75,182,236,0.18), transparent);
  pointer-events: none;
  z-index: -1;
}
.docs-hero .kicker {
  font-family: var(--font-sans);
  font-weight: 700;
  color: var(--primary);
  font-size: 0.78rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  margin-bottom: 10px;
}
.docs-hero h1 { font-size: 2rem; max-width: 640px; }
.docs-hero p.lead { max-width: 580px; font-size: 1rem; }

/* Badges / pills */

.pill {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
  color: var(--muted);
  background: var(--card-2);
}
.pill.status-live { color: #4bd98a; border-color: rgba(75, 217, 138, 0.35); background: rgba(75, 217, 138, 0.08); }
.pill.status-only { color: #e6a23c; border-color: rgba(230, 162, 60, 0.35); background: rgba(230, 162, 60, 0.08); }

/* Method / API entries (used outside the two-column section grid, e.g.
   contract lists) */

.api-entry {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card-2);
  padding: 16px 18px;
  margin: 0 0 14px;
}
.api-entry .sig {
  font-family: var(--font-mono);
  font-size: 0.86rem;
  color: var(--fg);
  margin-bottom: 8px;
}
.api-entry .sig .fn { color: var(--primary); }
.api-entry p { margin-bottom: 0.6em; font-size: 0.88rem; }
.api-entry p:last-child { margin-bottom: 0; }
.api-entry .returns {
  font-size: 0.83rem;
  color: var(--muted);
  margin-top: 8px;
}
.api-entry .returns code { margin-right: 2px; }

/* Integration-pattern matrix (2x2) — horizontally scrollable on narrow
   viewports rather than squeezed, matching wide tables elsewhere. */

.pattern-matrix-wrap { overflow-x: auto; margin: 1.6em 0; }
.pattern-matrix {
  display: grid;
  grid-template-columns: 150px 1fr 1fr;
  gap: 1px;
  background: var(--border);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  min-width: 640px;
}
.pattern-matrix > div { background: var(--card-2); padding: 14px 16px; }
.pm-corner { background: var(--card); }
.pm-col-head, .pm-row-head {
  background: var(--card);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--fg);
  display: flex;
  align-items: center;
}
.pm-row-head span { display: block; color: var(--muted); font-weight: 400; font-size: 0.78rem; }
.pm-cell p { margin: 0 0 8px; font-size: 0.88rem; color: var(--text); }
.pm-cell p:last-child { margin-bottom: 0; }
.pm-cell code { display: inline-block; margin: 2px 0; }
.pm-current { box-shadow: inset 0 0 0 2px var(--primary); }
.pm-current .pm-tag {
  display: block; color: var(--primary); font-size: 0.72rem;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 700;
  margin-bottom: 6px;
}
.pm-empty { opacity: 0.6; }

/* Flow diagrams (inline SVG) — horizontally scrollable on narrow viewports
   rather than squeezed, matching how wide tables/code blocks behave. */

.flow-diagram {
  overflow-x: auto;
  margin: 1.6em 0 2em;
  padding: 4px 2px 14px;
}
.flow-diagram svg { display: block; width: 100%; max-width: 300px; margin: 0 auto; }

/* Screenshots — self-upgrading placeholder. Shows a dashed placeholder box
   until a correctly-named file exists at assets/screenshots/, at which
   point the onerror handler never fires and the real image just renders. */

figure.screenshot {
  margin: 1.6em 0;
  padding: 0;
}
figure.screenshot img {
  display: block;
  width: 100%;
  border: 1px solid var(--border);
}
figure.screenshot .screenshot-fallback {
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  aspect-ratio: 16 / 9.5;
  width: 100%;
  border: 1px dashed var(--border);
  background: var(--card-2);
  color: var(--muted);
  text-align: center;
  padding: 24px;
}
figure.screenshot.missing img { display: none; }
figure.screenshot.missing .screenshot-fallback { display: flex; }
figure.screenshot .screenshot-fallback svg { width: 30px; height: 30px; opacity: 0.6; }
figure.screenshot .screenshot-fallback .path {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--fg);
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 3px 8px;
}
figure.screenshot .screenshot-fallback .hint { font-size: 0.78rem; max-width: 320px; }
figure.screenshot figcaption {
  margin-top: 8px;
  font-size: 0.8rem;
  color: var(--muted);
  text-align: center;
}

/* Footer */

.docs-footer {
  border-top: 1px solid var(--border-soft);
  padding: 22px 40px;
  color: var(--muted);
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.docs-footer a { color: var(--muted); }
.docs-footer a:hover { color: var(--primary); }

/* 404 */
.notfound {
  text-align: center;
  padding: 80px 20px;
}
.notfound .code {
  font-family: var(--font-mono);
  font-size: 4rem;
  color: var(--primary);
  letter-spacing: -0.02em;
  margin-bottom: 6px;
}

/* Mobile */

.sidebar-overlay { display: none; }

@media (max-width: 980px) {
  .api-section { grid-template-columns: 1fr; }
  .api-section-right { position: static; }
}

@media (max-width: 880px) {
  .docs-header .hamburger { display: inline-flex; }
  .docs-header .search-wrap { display: none; }
  .docs-header .dashboard-link span.txt { display: none; }

  .docs-sidebar {
    position: fixed;
    top: var(--header-h);
    left: 0;
    height: calc(100vh - var(--header-h));
    width: 280px;
    max-width: 82vw;
    background: var(--bg);
    border-right: 1px solid var(--border);
    transform: translateX(-100%);
    transition: transform .2s ease;
    z-index: 45;
  }
  .docs-sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open {
    display: block;
    position: fixed;
    inset: var(--header-h) 0 0 0;
    background: rgba(0,0,0,0.5);
    z-index: 44;
  }

  .docs-main { padding: 26px 20px 60px; }
  .card-grid, .mini-links { grid-template-columns: 1fr; }
  .docs-hero h1 { font-size: 1.6rem; }
  .docs-footer { padding: 18px 20px; }
}
