/*
 * Skopik Platform Documentation — simplified Vercel-style 3-column layout
 * wearing Skopik's typography (Space Grotesk + JetBrains Mono), pure grays,
 * hairline dividers, and #d4ff3a lime accent.
 */
@font-face { font-family: 'Space Grotesk'; font-weight: 400; font-display: swap; src: url(/fonts/space-grotesk-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 500; font-display: swap; src: url(/fonts/space-grotesk-latin-500-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 600; font-display: swap; src: url(/fonts/space-grotesk-latin-600-normal.woff2) format('woff2'); }
@font-face { font-family: 'Space Grotesk'; font-weight: 700; font-display: swap; src: url(/fonts/space-grotesk-latin-700-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 400; font-display: swap; src: url(/fonts/jetbrains-mono-latin-400-normal.woff2) format('woff2'); }
@font-face { font-family: 'JetBrains Mono'; font-weight: 500; font-display: swap; src: url(/fonts/jetbrains-mono-latin-500-normal.woff2) format('woff2'); }

:root {
  color-scheme: light dark;
  --lime: #d4ff3a;
  --on-lime: #0a0a0a;
  --bg: light-dark(#ffffff, #0e0e0e);
  --surface: light-dark(#f5f5f5, #181818);
  --surface-2: light-dark(#ebebeb, #242424);
  --border: light-dark(rgba(10, 10, 10, 0.09), rgba(255, 255, 255, 0.11));
  --border-strong: light-dark(rgba(10, 10, 10, 0.18), rgba(255, 255, 255, 0.2));
  --text: light-dark(#0a0a0a, #f2f2f2);
  --muted: light-dark(#595959, #9a9a9a);
  --code-bg: light-dark(#f4f4f4, #1b1b1b);
  --ink: #0c0c0c;
  --ink-field: #161616;
  --ink-border: rgba(255, 255, 255, 0.1);
  --ink-text: #efefef;
  --ink-muted: #8f8f8f;
  --focus: light-dark(#0a0a0a, #d4ff3a);
  --font: 'Space Grotesk', system-ui, sans-serif;
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --header-h: 60px;

  &:has(> head > meta[name="color-scheme"][content="dark"]) {
    color-scheme: dark;
  }
  &:has(> head > meta[name="color-scheme"][content="light"]) {
    color-scheme: light;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--header-h) + 24px); }
@media (prefers-reduced-motion: no-preference) { html { scroll-behavior: smooth; } }

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

a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; border-radius: 6px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px; z-index: 100;
  padding: 8px 14px; border-radius: 999px; background: var(--lime); color: var(--on-lime); font-weight: 600;
}
.skip-link:focus { top: 12px; }

/* Theme toggle icon visibility follows effective color scheme without JS */
.theme-to-light { display: none; }
.theme-to-dark { display: inline-flex; }
@media (prefers-color-scheme: dark) {
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-dark { display: none; }
  :root:not(:has(> head > meta[name="color-scheme"][content="light"])) .theme-to-light { display: inline-flex; }
}
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-dark { display: none; }
:root:has(> head > meta[name="color-scheme"][content="dark"]) .theme-to-light { display: inline-flex; }
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-to-dark { display: inline-flex; }
:root:has(> head > meta[name="color-scheme"][content="light"]) .theme-to-light { display: none; }

/* Sticky Top Header */
.docs-top {
  position: sticky; top: 0; z-index: 30;
  height: var(--header-h);
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: saturate(1.4) blur(12px);
  -webkit-backdrop-filter: saturate(1.4) blur(12px);
  border-bottom: 1px solid var(--border);
}
.docs-top-in {
  max-width: 1400px; height: 100%; margin: 0 auto; padding: 0 20px;
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.docs-top-left, .docs-top-right { display: flex; align-items: center; gap: 10px; }

.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 700; font-size: 16px; letter-spacing: -0.02em; }
.brand img { border-radius: 7px; display: block; }
.brand-sub { font-weight: 500; color: var(--muted); }
.brand-sep { color: var(--border-strong); font-weight: 400; }
.docs-badge {
  font-size: 13px; font-weight: 600; padding: 3px 10px; border-radius: 999px;
  background: var(--surface); border: 1px solid var(--border); color: var(--text);
}
.docs-badge:hover { background: var(--surface-2); }

.search-trigger {
  display: inline-flex; align-items: center; gap: 10px;
  height: 36px; padding: 0 10px 0 12px; min-width: 220px;
  border-radius: 10px; border: 1px solid var(--border);
  background: var(--surface); color: var(--muted); font-size: 14px;
  transition: border-color 0.15s, background-color 0.15s;
}
.search-trigger:hover { border-color: var(--border-strong); color: var(--text); }
.search-trigger svg { width: 15px; height: 15px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search-trigger kbd {
  margin-left: auto; font-family: var(--mono); font-size: 11px;
  padding: 2px 6px; border-radius: 5px; background: var(--bg);
  border: 1px solid var(--border); color: var(--muted);
}

.icon-btn {
  width: 36px; height: 36px; border: 1px solid transparent; border-radius: 9px;
  background: transparent; color: var(--muted);
  display: inline-flex; align-items: center; justify-content: center;
}
.icon-btn:hover { background: var(--surface); color: var(--text); }
.icon-btn svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 1.75; stroke-linecap: round; stroke-linejoin: round; }

.top-link {
  height: 36px; padding: 0 14px; border-radius: 999px;
  display: inline-flex; align-items: center; font-size: 14px; font-weight: 600;
  background: var(--lime); color: var(--on-lime);
}
.top-link:hover { filter: brightness(0.95); }

.mobile-only { display: none; }

/* 3-Column Documentation Shell */
.docs-shell {
  max-width: 1400px; margin: 0 auto;
  display: grid; grid-template-columns: 248px minmax(0, 1fr) 224px;
  align-items: start;
}

/* Left Sidebar */
.docs-sidebar {
  position: sticky; top: var(--header-h);
  height: calc(100svh - var(--header-h));
  overflow-y: auto; padding: 24px 16px 40px 20px;
  border-right: 1px solid var(--border);
  scrollbar-width: thin;
}
.nav-group { margin-bottom: 22px; }
.nav-group-title {
  margin: 0 0 6px; padding: 0 10px;
  font-size: 12px; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: var(--muted);
}
.nav-group ul { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.nav-group a {
  display: block; padding: 6px 10px; border-radius: 8px;
  font-size: 14px; color: var(--muted); font-weight: 500;
  transition: background-color 0.12s, color 0.12s;
}
.nav-group a:hover { background: var(--surface); color: var(--text); }
.nav-group a.active {
  background: var(--surface); color: var(--text); font-weight: 600;
  box-shadow: inset 3px 0 0 var(--lime);
}

/* Center Reading Column */
.docs-main {
  min-width: 0; max-width: 820px; width: 100%; margin: 0 auto;
  padding: 36px 40px 72px;
}

.docs-article-head { padding-bottom: 24px; border-bottom: 1px solid var(--border); margin-bottom: 28px; }
.docs-meta-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 12px; }
.docs-crumb { font-size: 13px; font-weight: 600; color: var(--muted); }
.docs-page-actions { display: flex; align-items: center; gap: 6px; }
.action-chip {
  display: inline-flex; align-items: center; height: 28px; padding: 0 10px;
  border-radius: 7px; border: 1px solid var(--border); background: var(--bg);
  font-size: 12.5px; font-weight: 500; color: var(--muted);
  transition: background-color 0.12s, color 0.12s, border-color 0.12s;
}
.action-chip:hover { background: var(--surface); color: var(--text); border-color: var(--border-strong); }

.docs-article-head h1 {
  margin: 0; font-size: clamp(28px, 3.2vw, 38px); line-height: 1.12; letter-spacing: -0.03em;
}
.docs-lede { margin: 12px 0 0; font-size: 17px; line-height: 1.55; color: var(--muted); max-width: 44em; }

/* Prose */
.docs-prose > *:first-child { margin-top: 0; }
.docs-prose h2 {
  position: relative; margin: 40px 0 14px; padding-top: 16px;
  border-top: 1px solid var(--border);
  font-size: 22px; line-height: 1.25; letter-spacing: -0.02em;
}
.docs-prose h2:first-child { margin-top: 0; padding-top: 0; border-top: 0; }
.docs-prose h3 {
  position: relative; margin: 28px 0 10px;
  font-size: 17.5px; line-height: 1.3; letter-spacing: -0.015em;
}
.docs-prose h4 { margin: 20px 0 8px; font-size: 15.5px; }
.docs-prose .anchor {
  position: absolute; left: -20px; color: var(--muted); opacity: 0;
  font-weight: 500; padding-right: 6px; transition: opacity 0.12s;
}
.docs-prose h2:hover .anchor, .docs-prose h3:hover .anchor, .docs-prose .anchor:focus-visible { opacity: 1; }

.docs-prose p { margin: 0 0 16px; }
.docs-prose ul, .docs-prose ol { margin: 0 0 18px; padding-left: 22px; }
.docs-prose li { margin-bottom: 6px; }
.docs-prose a:not(.anchor):not(.docs-card) {
  text-decoration: underline; text-decoration-color: var(--border-strong);
  text-underline-offset: 3px; font-weight: 500;
}
.docs-prose a:not(.anchor):not(.docs-card):hover { text-decoration-color: var(--text); }
.docs-prose code {
  font-family: var(--mono); font-size: 0.86em;
  background: var(--code-bg); border: 1px solid var(--border);
  padding: 0.12em 0.4em; border-radius: 6px;
}
.docs-prose hr { border: 0; border-top: 1px solid var(--border); margin: 32px 0; }

/* Code Blocks */
.code-block {
  margin: 18px 0; border-radius: 12px; overflow: hidden;
  background: var(--ink); color: var(--ink-text);
  border: 1px solid var(--ink-border);
}
.code-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 7px 10px 7px 14px; background: var(--ink);
  border-bottom: 1px solid var(--ink-border);
}
.code-lang { font-family: var(--mono); font-size: 12px; color: var(--ink-muted); }
.code-copy {
  border: 1px solid var(--ink-border); background: var(--ink-field); color: var(--ink-text);
  height: 26px; padding: 0 10px; border-radius: 6px; font-size: 12px; font-weight: 600;
}
.code-copy:hover { background: #262626; }
.code-block pre {
  margin: 0; padding: 14px 16px; overflow-x: auto;
  background: var(--ink-field); font-family: var(--mono); font-size: 13px; line-height: 1.6;
}
.code-block pre code { background: none; border: 0; padding: 0; font-size: inherit; color: inherit; }

/* Accessible Tabs (skopik / curl / MCP) */
.docs-tabs {
  margin: 20px 0; border-radius: 12px; overflow: hidden;
  border: 1px solid var(--border); background: var(--surface);
}
.docs-tablist {
  display: flex; overflow-x: auto; scrollbar-width: none;
  border-bottom: 1px solid var(--border); background: var(--surface);
  padding: 0 8px; gap: 4px;
}
.docs-tab {
  position: relative; flex: none; border: 0; background: transparent;
  padding: 10px 12px; font-family: var(--mono); font-size: 13px; font-weight: 500;
  color: var(--muted);
}
.docs-tab:hover { color: var(--text); }
.docs-tab[aria-selected="true"] { color: var(--text); }
.docs-tab[aria-selected="true"]::after {
  content: ""; position: absolute; inset: auto 4px 0;
  border-block-end: 2.5px solid var(--text);
}
.docs-tabpanels { display: grid; }
.docs-tabpanel { grid-area: 1 / 1; min-width: 0; }
.docs-tabpanel-inner { padding: 12px; }
.docs-tabpanel-inner .code-block { margin: 0; }

/* Callouts */
.callout {
  margin: 20px 0; padding: 14px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--surface);
}
.callout-title { margin: 0 0 4px !important; font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.04em; }
.callout p:last-child { margin-bottom: 0; color: var(--muted); }
.callout-tip { border-left: 3px solid var(--lime); }
.callout-warning { border-left: 3px solid #f59e0b; }
.callout-note, .callout-important { border-left: 3px solid var(--text); }

/* Responsive Tables */
.table-wrapper {
  margin: 20px 0; overflow: auto; max-inline-size: 100%; max-block-size: min(560px, 75vh);
  border: 1px solid var(--border); border-radius: 12px;
  container-type: inline-size;
}
.table-wrapper table {
  width: 100%; border-collapse: separate; border-spacing: 0;
  font-size: 14px; text-align: left;
}
.table-wrapper thead { position: sticky; inset-block-start: 0; z-index: 1; }
.table-wrapper th, .table-wrapper td {
  padding: 10px 14px; border-bottom: 1px solid var(--border); vertical-align: top;
}
.table-wrapper thead th {
  background: var(--surface); font-size: 12.5px; font-weight: 600;
  color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em;
}
.table-wrapper tbody th { font-weight: 600; color: var(--text); }
.table-wrapper tbody tr:last-child th, .table-wrapper tbody tr:last-child td { border-bottom: 0; }

@container (width < 520px) {
  .table-wrapper table, .table-wrapper thead, .table-wrapper tbody,
  .table-wrapper tr, .table-wrapper th, .table-wrapper td { display: block; }
  .table-wrapper thead { display: none; }
  .table-wrapper tr { border-bottom: 1px solid var(--border); padding: 10px 12px; }
  .table-wrapper tr:last-child { border-bottom: 0; }
  .table-wrapper th, .table-wrapper td { border: 0; padding: 4px 0; }
  .table-wrapper tbody th { font-size: 15px; padding-bottom: 6px; }
  .table-wrapper td[data-col="2"]::before { content: var(--label-2) ": "; font-weight: 600; color: var(--muted); }
  .table-wrapper td[data-col="3"]::before { content: var(--label-3) ": "; font-weight: 600; color: var(--muted); }
  .table-wrapper td[data-col="4"]::before { content: var(--label-4) ": "; font-weight: 600; color: var(--muted); }
  .table-wrapper td[data-col="5"]::before { content: var(--label-5) ": "; font-weight: 600; color: var(--muted); }
}

/* Quick-Link Card Grid */
.docs-card-grid {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 20px 0 28px;
}
.docs-card {
  display: flex; flex-direction: column; gap: 4px; padding: 16px 18px;
  border-radius: 12px; border: 1px solid var(--border); background: var(--bg);
  transition: border-color 0.14s, background-color 0.14s;
}
.docs-card:hover { border-color: var(--border-strong); background: var(--surface); }
.docs-card strong { font-size: 15.5px; color: var(--text); }
.docs-card span { font-size: 14px; color: var(--muted); line-height: 1.45; }

/* Prev / Next Pager */
.docs-pager {
  display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px;
  margin-top: 48px; padding-top: 24px; border-top: 1px solid var(--border);
}
.pager-card {
  display: flex; flex-direction: column; gap: 4px; padding: 14px 16px;
  border-radius: 12px; border: 1px solid var(--border);
  transition: border-color 0.14s, background-color 0.14s;
}
.pager-card:hover { border-color: var(--border-strong); background: var(--surface); }
.pager-card.next { text-align: right; }
.pager-label { font-size: 12px; color: var(--muted); font-weight: 500; }
.pager-card strong { font-size: 15px; }

.docs-foot {
  margin-top: 40px; padding-top: 20px; border-top: 1px solid var(--border);
  display: flex; flex-wrap: wrap; gap: 16px; font-size: 13px; color: var(--muted);
}
.docs-foot a:hover { color: var(--text); }

/* Right Sticky TOC */
.docs-toc {
  position: sticky; top: var(--header-h);
  height: calc(100svh - var(--header-h));
  overflow-y: auto; padding: 28px 20px 40px 12px;
  scrollbar-width: thin;
}
.toc-title {
  margin: 0 0 10px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.04em; text-transform: uppercase; color: var(--muted);
}
.toc-nav ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--border); }
.toc-nav a {
  display: block; padding: 4px 0 4px 12px; margin-left: -1px;
  font-size: 13px; line-height: 1.4; color: var(--muted);
  border-left: 2px solid transparent; transition: color 0.12s, border-color 0.12s;
}
.toc-nav .toc-l3 a { padding-left: 22px; font-size: 12.5px; }
.toc-nav a:hover { color: var(--text); }
.toc-nav a.active { color: var(--text); font-weight: 600; border-left-color: var(--lime); }

/* Mobile Navigation Drawer (scroll-snap modal <dialog>) */
.docs-drawer {
  --drawer-width: min(296px, 82dvw, 100dvw - 24px);
  --drawer-backdrop: 0;
  inset: 0; width: auto; height: auto; max-width: none; max-height: none;
  margin: 0; padding: 0; background: transparent; border: 0; overflow: visible;
}
.docs-drawer::backdrop {
  background: #000;
  opacity: calc(var(--drawer-backdrop) / 2);
}
.docs-drawer-scroller {
  position: relative; display: grid;
  grid-template-columns: var(--drawer-width) 100%;
  overflow-x: scroll; overscroll-behavior: none; scrollbar-width: none;
  scroll-snap-type: x mandatory;
}
@media (prefers-reduced-motion: no-preference) {
  .docs-drawer-scroller { scroll-behavior: smooth; }
}
.docs-drawer-scroller::after {
  content: ''; scroll-snap-align: end; scroll-initial-target: nearest;
}
.docs-drawer-sheet {
  display: grid; grid-template-rows: auto 1fr; height: 100svh;
  background: var(--bg); color: var(--text);
  border-right: 1px solid var(--border);
  overflow-y: auto; scroll-snap-align: start; scrollbar-width: thin;
}
.docs-drawer-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px 12px 18px; border-bottom: 1px solid var(--border);
}
.docs-drawer-body { padding: 16px 14px 32px; }

@supports (animation-timeline: scroll()) {
  .docs-drawer {
    timeline-scope: --docs-drawer-fade;
    animation: fade-docs-drawer linear both;
    animation-timeline: --docs-drawer-fade;
  }
  .docs-drawer-scroller { scroll-timeline: --docs-drawer-fade x; }
  @property --drawer-backdrop { syntax: '<number>'; inherits: true; initial-value: 0; }
  @keyframes fade-docs-drawer {
    0% { --drawer-backdrop: 1; }
    100% { --drawer-backdrop: 0; }
  }
}

/* Search Modal (<dialog closedby="any">) */
.search-dialog {
  width: min(600px, calc(100vw - 24px)); max-height: min(76vh, 560px);
  margin: min(12vh, 96px) auto auto; padding: 0;
  border: 1px solid var(--border-strong); border-radius: 16px;
  background: var(--bg); color: var(--text);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.28);
  overflow: hidden;
}
.search-dialog::backdrop {
  background: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(3px);
}
.search-box { display: flex; flex-direction: column; max-height: inherit; }
.search-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--border);
}
.search-icon { width: 18px; height: 18px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round; flex-shrink: 0; }
.search-head input {
  flex: 1; min-width: 0; border: 0; background: transparent; color: var(--text);
  font: inherit; font-size: 15.5px; outline: none;
}
.search-close {
  border: 1px solid var(--border); background: var(--surface); color: var(--muted);
  border-radius: 6px; padding: 3px 8px; font-family: var(--mono); font-size: 11px;
}
.search-close:hover { color: var(--text); }
.search-results { overflow-y: auto; padding: 8px; max-height: 440px; }
.search-item {
  display: flex; flex-direction: column; gap: 2px;
  padding: 10px 12px; border-radius: 10px;
}
.search-item:hover, .search-item[aria-selected="true"] { background: var(--surface); }
.search-item-meta { font-size: 11.5px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.search-item-title { font-size: 14.5px; font-weight: 600; color: var(--text); }
.search-item-desc { font-size: 13px; color: var(--muted); }
.search-empty { padding: 24px 12px; text-align: center; color: var(--muted); font-size: 14px; }

/* Responsive Breakpoints */
@media (max-width: 1160px) {
  .docs-shell { grid-template-columns: 236px minmax(0, 1fr); }
  .docs-toc { display: none; }
}
@media (max-width: 860px) {
  .docs-shell { grid-template-columns: minmax(0, 1fr); }
  .docs-sidebar { display: none; }
  .mobile-only { display: inline-flex; }
  .docs-main { padding: 24px 20px 56px; }
  .search-trigger { min-width: auto; }
  .search-placeholder, .search-trigger kbd { display: none; }
}
@media (max-width: 560px) {
  .hide-sm, .brand-sub { display: none; }
  .docs-card-grid, .docs-pager { grid-template-columns: minmax(0, 1fr); }
  .pager-card.next { text-align: left; }
}
