/* ─────────────────────────  Cobalt Docs  ─────────────────────────
 * Stripe / Linear / Tailwind-tier documentation page.
 * Three-column sticky layout, refined typography, code-first.
 * ────────────────────────────────────────────────────────────────── */

.docs-page {
  color-scheme: light dark;

  /* Light tokens */
  --bg:            #ffffff;
  --bg-muted:      #f7f8fa;
  --bg-code:       #0f1115;
  --surface:       #ffffff;
  --surface-2:     #fafbfc;
  --border:        #e6e8ec;
  --border-strong: #d1d5db;

  --text:          #0f1115;
  --text-muted:    #5b6472;
  --text-faint:    #8b94a3;
  --text-invert:   #f5f7fa;

  --accent:        #2a4cf6;
  --accent-soft:   rgba(42, 76, 246, 0.09);
  --accent-line:   rgba(42, 76, 246, 0.30);

  --warn:          #c2410c;
  --warn-soft:     #fff4ec;
  --warn-line:     #fdba74;

  --note:          #0e7490;
  --note-soft:     #ecfeff;
  --note-line:     #67e8f9;

  --get:           #0e7490;
  --get-soft:      #ecfeff;
  --post:          #047857;
  --post-soft:     #ecfdf5;

  --shadow-sm:     0 1px 2px rgba(15, 17, 21, 0.04);
  --shadow-md:     0 4px 16px rgba(15, 17, 21, 0.06);

  --radius-sm:     4px;
  --radius:        6px;
  --radius-lg:     10px;

  --font-sans:     ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --font-mono:     ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;

  --topbar-h:      56px;
  --sidebar-w:     260px;
  --toc-w:         220px;
  --gutter:        2rem;
}

@media (prefers-color-scheme: dark) {
  .docs-page {
    --bg:            #0b0d11;
    --bg-muted:      #0f1217;
    --bg-code:       #07080b;
    --surface:       #11141a;
    --surface-2:     #14181f;
    --border:        #20242c;
    --border-strong: #2a2f3a;

    --text:          #e9ecf2;
    --text-muted:    #a0a8b4;
    --text-faint:    #6b7280;
    --text-invert:   #0b0d11;

    --accent:        #7da2ff;
    --accent-soft:   rgba(125, 162, 255, 0.12);
    --accent-line:   rgba(125, 162, 255, 0.35);

    --warn:          #fdba74;
    --warn-soft:     rgba(253, 186, 116, 0.08);
    --warn-line:     rgba(253, 186, 116, 0.35);

    --note:          #67e8f9;
    --note-soft:     rgba(103, 232, 249, 0.07);
    --note-line:     rgba(103, 232, 249, 0.35);

    --get:           #67e8f9;
    --get-soft:      rgba(103, 232, 249, 0.10);
    --post:          #6ee7b7;
    --post-soft:     rgba(110, 231, 183, 0.10);
  }
}

/* ─── Reset ────────────────────────────────────────────────────── */

.docs-page *, .docs-page *::before, .docs-page *::after { box-sizing: border-box; }

.docs-page, .docs-page { margin: 0; padding: 0; }

.docs-page {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

.docs-page { min-height: 100vh; }

.docs-page a { color: var(--accent); text-decoration: none; }
.docs-page a:hover { text-decoration: underline; text-underline-offset: 2px; }

.docs-page img, .docs-page svg { display: block; max-width: 100%; }

.docs-page button { font: inherit; cursor: pointer; }

.docs-page .skip-link {
  position: absolute;
  top: -40px; left: 8px;
  padding: 6px 10px;
  background: var(--text);
  color: var(--text-invert);
  border-radius: var(--radius-sm);
  z-index: 100;
}
.docs-page .skip-link:focus { top: 8px; }

/* ─── Topbar ──────────────────────────────────────────────────── */

.docs-page .topbar {
  position: sticky; top: 0;
  z-index: 50;
  background: color-mix(in srgb, var(--bg) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
  height: var(--topbar-h);
}
.docs-page .topbar__inner {
  height: 100%;
  display: flex; align-items: center; gap: 1.5rem;
  padding: 0 1.5rem;
  max-width: 1480px; margin: 0 auto;
}
.docs-page .topbar__brand {
  display: inline-flex; align-items: center; gap: 0.55rem;
  color: var(--text);
  font-weight: 600;
}
.docs-page .topbar__brand:hover { text-decoration: none; }
.docs-page .topbar__logo { color: var(--accent); }
.docs-page .topbar__name { letter-spacing: -0.01em; font-size: 0.95rem; }
.docs-page .topbar__tag {
  font-size: 0.72rem; font-weight: 500;
  padding: 2px 6px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
}

.docs-page .topbar__nav {
  display: flex; gap: 1.25rem;
  margin-left: 1rem;
}
.docs-page .topbar__nav a {
  color: var(--text-muted);
  font-size: 0.875rem;
  font-weight: 500;
  padding: 4px 0;
}
.docs-page .topbar__nav a:hover { color: var(--text); text-decoration: none; }

.docs-page .topbar__tools {
  margin-left: auto;
  display: flex; align-items: center; gap: 0.75rem;
}

.docs-page .topbar__search {
  position: relative;
  display: inline-flex; align-items: center;
  width: 280px;
  height: 32px;
  padding: 0 0.65rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.docs-page .topbar__search-icon { color: var(--text-faint); flex-shrink: 0; }
.docs-page .topbar__search input {
  flex: 1;
  margin-left: 0.5rem;
  background: transparent;
  border: 0;
  outline: 0;
  font: inherit;
  font-size: 0.85rem;
  color: var(--text);
}
.docs-page .topbar__search input::placeholder { color: var(--text-faint); }
.docs-page .topbar__kbd {
  font-family: var(--font-mono);
  font-size: 0.7rem;
  padding: 1px 5px;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  border-radius: 3px;
  color: var(--text-muted);
}

.docs-page .topbar__github {
  display: inline-flex; align-items: center; gap: 0.4rem;
  height: 32px;
  padding: 0 0.65rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 500;
}
.docs-page .topbar__github:hover { color: var(--text); text-decoration: none; border-color: var(--border-strong); }
.docs-page .topbar__github-stars {
  display: inline-flex; align-items: center; gap: 3px;
  padding-left: 0.4rem;
  margin-left: 0.1rem;
  border-left: 1px solid var(--border);
  font-variant-numeric: tabular-nums;
}

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

.docs-page .layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: var(--gutter);
  max-width: 1480px;
  margin: 0 auto;
  padding: 0 1.5rem;
  align-items: start;
}

@media (max-width: 1100px) {
  .docs-page .layout { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .docs-page .toc-rail { display: none; }
}

@media (max-width: 820px) {
  .docs-page .layout { grid-template-columns: minmax(0, 1fr); padding: 0 1rem; }
  .docs-page .sidebar { display: none; }
}

/* ─── Sidebar ─────────────────────────────────────────────────── */

.docs-page .sidebar {
  position: sticky;
  top: var(--topbar-h);
  height: calc(100vh - var(--topbar-h));
  overflow-y: auto;
  padding: 1.75rem 0.5rem 2rem 0;
  border-right: 1px solid var(--border);
}

.docs-page .sidebar__nav { display: flex; flex-direction: column; gap: 0.4rem; }

.docs-page .sidebar__group {
  border: 0;
  padding: 0;
  margin: 0;
}

.docs-page .sidebar__summary {
  list-style: none;
  cursor: pointer;
  padding: 6px 10px;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--text-faint);
  display: flex; align-items: center; justify-content: space-between;
  user-select: none;
}
.docs-page .sidebar__summary::-webkit-details-marker { display: none; }
.docs-page .sidebar__summary::after {
  content: "";
  width: 8px; height: 8px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(-45deg);
  transition: transform 120ms ease;
  margin-right: 4px;
}
.docs-page .sidebar__group[open] .sidebar__summary::after { transform: rotate(45deg); }

.docs-page .sidebar__list,
.docs-page .sidebar__sublist {
  list-style: none;
  padding: 4px 0 8px 0;
  margin: 0;
}
.docs-page .sidebar__list > li > a,
.docs-page .sidebar__sublist > li > a {
  display: block;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  font-size: 0.86rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
}
.docs-page .sidebar__list > li > a:hover,
.docs-page .sidebar__sublist > li > a:hover {
  color: var(--text);
  background: var(--bg-muted);
  text-decoration: none;
}
.docs-page .sidebar__list a.is-active {
  color: var(--accent);
  background: var(--accent-soft);
  border-left-color: var(--accent);
  font-weight: 500;
}
.docs-page .sidebar__sublist {
  padding-left: 0.85rem;
  margin-top: 2px;
  border-left: 1px solid var(--border);
}
.docs-page .sidebar__sublist > li > a {
  font-size: 0.82rem;
  padding-left: 0.65rem;
}

/* ─── Main column ─────────────────────────────────────────────── */

.docs-page .main {
  min-width: 0;
  padding: 2.25rem 0 4rem 0;
}

.docs-page .article { max-width: 720px; }

.docs-page .article__head {
  margin-bottom: 2rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}
.docs-page .article__kicker {
  margin: 0 0 0.4rem 0;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent);
}
.docs-page .article__title {
  margin: 0 0 0.75rem 0;
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.15;
}
.docs-page .article__deck {
  margin: 0;
  font-size: 1.0625rem;
  color: var(--text-muted);
  line-height: 1.55;
}

/* ─── Mobile TOC (in markup, hidden on desktop) ──────────────── */

.docs-page .article__toc-mobile {
  display: none;
  margin: 0 0 2rem 0;
  padding: 1rem 1.1rem;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}
.docs-page .article__toc-mobile-title {
  margin: 0 0 0.5rem 0;
  font-size: 0.78rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.05em;
  color: var(--text-faint);
}
.docs-page .article__toc-mobile ol { margin: 0; padding-left: 1.1rem; font-size: 0.9rem; }
@media (max-width: 1100px) {
  .docs-page .article__toc-mobile { display: block; }
}

/* ─── Sections ────────────────────────────────────────────────── */

.docs-page .article__section { margin: 2.5rem 0; }
.docs-page .article__section h2 {
  margin: 0 0 0.75rem 0;
  font-size: 1.5rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
}
.docs-page .article__section h3 {
  margin: 2rem 0 0.6rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  scroll-margin-top: calc(var(--topbar-h) + 1rem);
  display: flex; align-items: center; gap: 0.6rem;
  flex-wrap: wrap;
}
.docs-page .article__section h4 {
  margin: 1.5rem 0 0.5rem 0;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.docs-page .article__section p {
  margin: 0 0 0.9rem 0;
  color: var(--text);
}

/* ─── Inline code ─────────────────────────────────────────────── */

.docs-page code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  padding: 1.5px 5px;
  background: var(--bg-muted);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text);
}

/* ─── Code blocks ─────────────────────────────────────────────── */

.docs-page pre {
  margin: 1rem 0 1.25rem 0;
  padding: 1rem 1.1rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow-x: auto;
  font-size: 0.84rem;
  line-height: 1.55;
  color: #d8dde6;
}
.docs-page pre code {
  background: transparent;
  border: 0;
  padding: 0;
  color: inherit;
  font-size: inherit;
}
.docs-page pre code.language-bash     { color: #c8e1ff; }
.docs-page pre code.language-typescript { color: #d8dde6; }
.docs-page pre code.language-json     { color: #c5e8c7; }

.docs-page .codeblock {
  margin: 1rem 0 1.25rem 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--bg-code);
}
.docs-page .codeblock__head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.45rem 0.85rem;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.docs-page .codeblock__lang {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: #8b94a3;
}
.docs-page .codeblock pre { margin: 0; border: 0; border-radius: 0; }

.docs-page .copy-button {
  display: inline-flex; align-items: center; gap: 0.35rem;
  padding: 3px 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: #c8cfd9;
  font-size: 0.75rem;
}
.docs-page .copy-button:hover { background: rgba(255, 255, 255, 0.1); color: #fff; }

/* ─── Endpoint blocks ─────────────────────────────────────────── */

.docs-page .endpoint {
  padding: 1.25rem 1.4rem 1.5rem 1.4rem;
  margin: 1.75rem 0;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
}
.docs-page .endpoint:hover { border-color: var(--border-strong); }

.docs-page .endpoint__path {
  font-family: var(--font-mono);
  font-size: 0.92rem;
  padding: 2px 8px;
}

.docs-page .endpoint__sub {
  margin-top: 1.5rem !important;
}

.docs-page .method {
  display: inline-flex; align-items: center;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
  text-transform: uppercase;
  flex-shrink: 0;
}
.docs-page .method--get  { background: var(--get-soft);  color: var(--get); }
.docs-page .method--post { background: var(--post-soft); color: var(--post); }

/* ─── Tables ──────────────────────────────────────────────────── */

.docs-page table.params {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0 1.25rem 0;
  font-size: 0.875rem;
}
.docs-page table.params th,
.docs-page table.params td {
  text-align: left;
  vertical-align: top;
  padding: 0.65rem 0.85rem;
  border-bottom: 1px solid var(--border);
}
.docs-page table.params thead th {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
  background: var(--bg-muted);
  border-bottom: 1px solid var(--border-strong);
}
.docs-page table.params tbody tr:hover { background: var(--bg-muted); }
.docs-page table.params td:nth-child(3) { color: var(--text-muted); }
.docs-page table.params td:nth-child(4) { color: var(--text-muted); }

/* ─── Errors definition list ─────────────────────────────────── */

.docs-page .errors {
  margin: 1.25rem 0;
  display: grid;
  grid-template-columns: 180px 1fr;
  gap: 0.5rem 1.25rem;
}
.docs-page .errors dt {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 0.4rem 0;
  color: var(--text);
}
.docs-page .errors dt code {
  background: transparent;
  border: 0;
  padding: 0;
  font-size: inherit;
  color: var(--warn);
}
.docs-page .errors dd {
  margin: 0;
  padding: 0.4rem 0;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
}
.docs-page .errors dt { border-bottom: 1px solid var(--border); }
.docs-page .errors dt:last-of-type, .docs-page .errors dd:last-of-type { border-bottom: 0; }

/* ─── Callouts ────────────────────────────────────────────────── */

.docs-page .callout {
  display: flex; gap: 0.85rem;
  margin: 1.25rem 0;
  padding: 1rem 1.1rem;
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: var(--radius);
  background: var(--surface-2);
}
.docs-page .callout__icon {
  flex-shrink: 0;
  width: 22px; height: 22px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 999px;
  margin-top: 1px;
}
.docs-page .callout__body { flex: 1; min-width: 0; }
.docs-page .callout__body strong {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 0.2rem;
}
.docs-page .callout__body p { margin: 0; color: var(--text-muted); }

.docs-page .callout--note {
  background: var(--note-soft);
  border-color: var(--note-line);
  border-left-color: var(--note);
}
.docs-page .callout--note .callout__icon { color: var(--note); }
.docs-page .callout--note .callout__body strong { color: var(--note); }

.docs-page .callout--warning {
  background: var(--warn-soft);
  border-color: var(--warn-line);
  border-left-color: var(--warn);
}
.docs-page .callout--warning .callout__icon { color: var(--warn); }
.docs-page .callout--warning .callout__body strong { color: var(--warn); }

/* ─── Article footer ──────────────────────────────────────────── */

.docs-page .article__foot {
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}

.docs-page .feedback {
  display: flex; align-items: center; gap: 0.5rem;
  margin-bottom: 1rem;
}
.docs-page .feedback__label {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-right: 0.5rem;
}
.docs-page .feedback__btn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  padding: 5px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 0.83rem;
}
.docs-page .feedback__btn:hover { border-color: var(--border-strong); background: var(--bg-muted); }

.docs-page .article__edit {
  display: inline-flex; align-items: center; gap: 0.4rem;
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.docs-page .article__edit:hover { color: var(--text); }

.docs-page .article__pager {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}
.docs-page .pager__link {
  display: flex; align-items: center; gap: 0.7rem;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
}
.docs-page .pager__link:hover { border-color: var(--accent); text-decoration: none; }
.docs-page .pager__link--next {
  justify-content: flex-end;
  text-align: right;
  flex-direction: row;
}
.docs-page .pager__link span { display: block; }
.docs-page .pager__dir {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.docs-page .pager__title { font-size: 0.95rem; font-weight: 500; }

/* ─── Right TOC rail ──────────────────────────────────────────── */

.docs-page .toc-rail {
  position: sticky;
  top: calc(var(--topbar-h) + 1.5rem);
  align-self: start;
  padding: 1.75rem 0;
  max-height: calc(100vh - var(--topbar-h) - 2rem);
  overflow-y: auto;
}
.docs-page .toc-rail__title {
  margin: 0 0 0.7rem 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-faint);
}
.docs-page .toc-rail__list,
.docs-page .toc-rail__list ol {
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.83rem;
}
.docs-page .toc-rail__list ol {
  border-left: 1px solid var(--border);
  margin: 4px 0 6px 0;
  padding-left: 0.75rem;
}
.docs-page .toc-rail__list li > a {
  display: block;
  padding: 4px 0;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  margin-left: -2px;
  padding-left: 8px;
}
.docs-page .toc-rail__list li > a:hover { color: var(--text); text-decoration: none; }
.docs-page .toc-rail__list a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.docs-page .toc-rail__list samp {
  font-family: var(--font-mono);
  font-size: 0.78rem;
}
.docs-page .toc-rail__meta {
  margin: 1.5rem 0 0 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.78rem;
  color: var(--text-faint);
}
.docs-page .toc-rail__meta var {
  font-family: var(--font-mono);
  font-style: normal;
  color: var(--text-muted);
}
