/* ==========================================================================
   Foliox Docs — built on the shared design tokens (/assets/tokens.css), so the docs look and behave like the rest of the
   site: same colours, accent, radius, type and light/dark handling. Only docs-specific layout lives here.
   ========================================================================== */

:root {
  /* names the docs markup and script already use, mapped onto the shared tokens */
  --text-muted: var(--text-2);
  --text-faint: var(--text-3);
  --accent-hover: var(--accent-strong);
  --accent-text: var(--on-accent);
  --accent-soft-strong: color-mix(in oklab, var(--accent) 22%, transparent);
  --warn: var(--warning);
  --warn-bg: var(--warning-soft);
  --warn-border: color-mix(in oklab, var(--warning) 38%, transparent);
  --code-bg: light-dark(#f3f4f7, #0b0b0e);
  --code-text: var(--text);
  --radius-sm: var(--r-sm);
  --radius: var(--r-lg);
  --radius-lg: var(--r-xl);
  --font-sans: var(--font);
  --font-mono: var(--mono);
  --topbar-h: 62px;
  --content-max: 780px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto !important; }
  *, *::before, *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
    scroll-behavior: auto !important;
  }
}

/* ==========================================================================
   Reset & base
   ========================================================================== */

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background:
    radial-gradient(900px 420px at 78% -8%, color-mix(in oklab, var(--accent) 11%, transparent), transparent 70%),
    radial-gradient(700px 380px at 6% 0%, color-mix(in oklab, var(--accent-2) 7%, transparent), transparent 70%),
    var(--bg);
  background-repeat: no-repeat;
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.68;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; text-underline-offset: 3px; }

img, svg { display: block; }

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 4px;
}

.skip-link {
  position: absolute;
  left: -9999px;
  top: 0;
  background: var(--accent);
  color: var(--accent-text);
  padding: 10px 16px;
  border-radius: 0 0 var(--radius-sm) 0;
  font-size: 13px;
  font-weight: 600;
  z-index: 100;
}
.skip-link:focus-visible { left: 0; outline-offset: -2px; }

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

/* ==========================================================================
   Top bar: brand (back to the home page), crumb to the docs index, site links, account buttons
   ========================================================================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: 40;
  height: var(--topbar-h);
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: color-mix(in oklab, var(--bg) 78%, transparent);
  -webkit-backdrop-filter: saturate(1.5) blur(16px);
  backdrop-filter: saturate(1.5) blur(16px);
}

.topbar-inner {
  width: 100%;
  max-width: 1320px;
  margin: 0 auto;
  padding: 0 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  font-weight: 700;
  font-size: 15.5px;
  letter-spacing: -0.02em;
}
.brand:hover { text-decoration: none; }
.brand-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: none;
  filter: drop-shadow(0 2px 8px color-mix(in oklab, var(--accent) 40%, transparent));
}
.crumb-sep { color: var(--text-faint); font-weight: 300; font-size: 20px; line-height: 1; }
.crumb {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 15px;
  padding: 6px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
}
.crumb:hover { text-decoration: none; background: var(--accent-soft-strong); }

.nav-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  cursor: pointer;
}
.nav-toggle:hover { background: var(--surface-hover); }
.nav-toggle svg { width: 18px; height: 18px; }

.topbar-actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
}
/* buttons/icons here are the shared .btn/.icon components (components.css) - only this one small weight tweak
   (matching the homepage's own nav) is docs-specific. */
.topbar-actions .btn.ghost.text {
  font-weight: 600;
}

@media (max-width: 640px) {
  .topbar-inner { padding: 0 14px; gap: 8px; }
  .brand span { display: none; }
  .topbar-actions .btn.primary { display: none; } /* the dock's "Start free" is right there; "Sign in" stays */
}

/* ==========================================================================
   Page shell: sidenav / content / toc
   ========================================================================== */

.nav-backdrop {
  position: fixed;
  inset: 0;
  background: var(--overlay);
  z-index: 45;
}

.shell {
  max-width: 1320px;
  margin: 0 auto;
  padding: 40px 24px 72px;
  display: grid;
  grid-template-columns: 236px minmax(0, 1fr);
  gap: 44px;
  align-items: start;
}

.sidenav {
  position: sticky;
  top: calc(var(--topbar-h) + 28px);
  max-height: calc(100vh - var(--topbar-h) - 56px);
  overflow-y: auto;
  padding-right: 6px;
}
.sidenav-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 22px 0 8px 12px;
}
.sidenav-label:first-child { margin-top: 0; }
.sidenav-list { display: flex; flex-direction: column; gap: 2px; }
.sidenav-list a {
  position: relative;
  display: block;
  padding: 8px 12px;
  border-radius: 10px;
  color: var(--text-muted);
  font-size: 14px;
  font-weight: 550;
  transition: background 0.15s, color 0.15s;
}
.sidenav-list a:hover { background: var(--surface-3); color: var(--text); text-decoration: none; }
.sidenav-list a.active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 650;
}
.sidenav-list a.active::before {
  content: '';
  position: absolute;
  left: -2px;
  top: 9px;
  bottom: 9px;
  width: 3px;
  border-radius: 3px;
  background: var(--accent);
}

.content { min-width: 0; max-width: var(--content-max); }

.toc-rail { display: none; }
.toc-label {
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-faint);
  margin: 0 0 10px;
}
.toc-list { display: flex; flex-direction: column; gap: 6px; font-size: 13px; }
.toc-list a {
  color: var(--text-muted);
  border-left: 2px solid var(--border);
  padding-left: 12px;
  line-height: 1.4;
  transition: color 0.15s, border-color 0.15s;
}
.toc-list a.toc-h3 { padding-left: 24px; font-size: 12.5px; }
.toc-list a:hover { color: var(--text); text-decoration: none; }
.toc-list a.active { color: var(--accent); border-left-color: var(--accent); font-weight: 650; }

@media (min-width: 1180px) {
  .shell { grid-template-columns: 236px minmax(0, var(--content-max)) 208px; }
  .toc-rail { display: block; position: sticky; top: calc(var(--topbar-h) + 28px); }
}

@media (max-width: 899px) {
  .nav-toggle { display: flex; }
  .shell { grid-template-columns: 1fr; padding: 28px 20px 56px; }
  .sidenav {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 46;
    width: min(310px, 86vw);
    max-height: none;
    padding: 88px 18px 24px;
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: var(--shadow-lg);
    transform: translateX(-100%);
    transition: transform 0.22s var(--ease);
    overflow-y: auto;
  }
  .sidenav.open { transform: translateX(0); }
}

/* ==========================================================================
   Content typography
   ========================================================================== */

h1 {
  font-size: clamp(30px, 4.2vw, 40px);
  font-weight: 750;
  letter-spacing: -0.03em;
  line-height: 1.15;
  margin: 0 0 14px;
  background: linear-gradient(120deg, var(--text) 30%, color-mix(in oklab, var(--accent) 70%, var(--text)));
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}
h2 {
  font-size: 23px;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 54px 0 14px;
  padding-top: 22px;
  border-top: 1px solid var(--border);
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
h2:first-of-type { border-top: none; padding-top: 0; margin-top: 30px; }
h3 {
  font-size: 16.5px;
  font-weight: 650;
  margin: 28px 0 10px;
  scroll-margin-top: calc(var(--topbar-h) + 20px);
}
p { margin: 0 0 15px; color: var(--text); }
.lede {
  color: var(--text-muted);
  font-size: 18px;
  line-height: 1.55;
  margin-bottom: 30px;
  max-width: 64ch;
}
ul, ol { margin: 0 0 16px; padding-left: 22px; }
li { margin-bottom: 8px; }
li:last-child { margin-bottom: 0; }
li::marker { color: var(--accent); }
strong { font-weight: 650; }

/* ==========================================================================
   Code
   ========================================================================== */

code {
  font-family: var(--font-mono);
  background: var(--code-bg);
  color: var(--code-text);
  padding: 2px 6px;
  border-radius: 6px;
  border: 1px solid var(--border);
  font-size: 0.86em;
}

.code-block { position: relative; margin: 4px 0 22px; }
pre {
  position: relative;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  overflow-x: auto;
  font-size: 13.5px;
  line-height: 1.65;
  margin: 0;
  box-shadow: var(--shadow-sm);
}
pre::before {
  content: '';
  position: absolute;
  left: 18px;
  right: 18px;
  top: -1px;
  height: 2px;
  border-radius: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2), transparent);
  opacity: 0.7;
}
pre code {
  background: none;
  border: 0;
  color: inherit;
  padding: 0;
  font-size: 1em;
}

.copy-btn {
  position: absolute;
  top: 10px;
  right: 10px;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font: inherit;
  font-size: 12px;
  font-weight: 650;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text-muted);
  padding: 5px 10px;
  opacity: 0;
  transition: opacity 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}
.copy-btn svg { width: 13px; height: 13px; }
.code-block:hover .copy-btn,
.copy-btn:focus-visible,
.copy-btn.copied { opacity: 1; }
.copy-btn:hover { color: var(--text); border-color: var(--accent); }
.copy-btn.copied { color: var(--accent); border-color: var(--accent); opacity: 1; }

@media (hover: none) { .copy-btn { opacity: 1; } }

/* ==========================================================================
   Tables
   ========================================================================== */

.table-scroll {
  overflow-x: auto;
  margin: 4px 0 24px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  box-shadow: var(--shadow-sm);
}
table { width: 100%; border-collapse: collapse; font-size: 14px; }
th, td {
  text-align: left;
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
}
tr:last-child td { border-bottom: none; }
th {
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  background: var(--surface-2);
}
tbody tr:hover td, tr:hover > td { background: color-mix(in oklab, var(--accent) 4%, transparent); }
td code { white-space: nowrap; }
/* a link inside a table cell sits in running prose, so it needs more than colour to stand out (WCAG 1.4.1) */
td a { text-decoration: underline; text-underline-offset: 2px; }

/* ==========================================================================
   Callouts
   ========================================================================== */

.callout {
  background: linear-gradient(135deg, var(--accent-softer), transparent 70%), var(--surface);
  border: 1px solid color-mix(in oklab, var(--accent) 28%, var(--border));
  border-radius: var(--radius);
  padding: 18px 22px;
  margin: 24px 0;
  box-shadow: var(--shadow-sm);
}
.callout h3 { margin-top: 0; margin-bottom: 8px; font-size: 15px; }
.callout p:last-child { margin-bottom: 0; }
.callout.warn {
  background: linear-gradient(135deg, var(--warn-bg), transparent 80%), var(--surface);
  border-color: var(--warn-border);
}
.callout.warn h3 { color: var(--warn); }

.icon-line { display: inline-flex; align-items: center; gap: 6px; }
.icon { width: 15px; height: 15px; flex-shrink: 0; }

/* ==========================================================================
   Card grid (SDK links)
   ========================================================================== */

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 14px;
  margin: 22px 0;
}
.doc-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  color: var(--text);
  display: block;
  box-shadow: var(--shadow-sm);
  transition: transform 0.16s var(--ease), border-color 0.16s, box-shadow 0.16s;
}
.doc-card:hover {
  border-color: color-mix(in oklab, var(--accent) 55%, var(--border));
  transform: translateY(-3px);
  box-shadow: 0 14px 34px -14px color-mix(in oklab, var(--accent) 45%, transparent), var(--shadow-md);
  text-decoration: none;
}
.doc-card h3 { margin: 0 0 6px; font-size: 15px; display: flex; align-items: center; gap: 8px; }
.doc-card p { margin: 0; color: var(--text-muted); font-size: 13.5px; }

.badge {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 700;
  background: var(--accent-soft);
  color: var(--accent);
}

/* ==========================================================================
   Key box (public key display)
   ========================================================================== */

.key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  font-family: var(--font-mono);
  font-size: 12.5px;
  color: var(--code-text);
  word-break: break-all;
  margin: 10px 0 4px;
}
.key-box button {
  flex-shrink: 0;
  font: inherit;
  font-family: var(--font-sans);
  font-weight: 650;
  cursor: pointer;
  border-radius: 8px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  padding: 6px 12px;
  font-size: 12.5px;
  transition: border-color 0.12s ease, color 0.12s ease;
}
.key-box button:hover { border-color: var(--accent); color: var(--accent); }
.key-box button.copied { border-color: var(--accent); color: var(--accent); }

/* ==========================================================================
   Numbered step list ("How it works")
   ========================================================================== */

.steps { list-style: none; padding: 0; margin: 0 0 20px; counter-reset: step; }
.steps li {
  position: relative;
  padding-left: 42px;
  margin-bottom: 18px;
  counter-increment: step;
}
.steps li::before {
  content: counter(step);
  position: absolute;
  left: 0;
  top: -1px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: var(--accent-text);
  font-size: 13px;
  font-weight: 750;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ==========================================================================
   Footer
   ========================================================================== */

footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 13px;
  padding: 40px 0 12px;
  margin-top: 24px;
  border-top: 1px solid var(--border);
}
footer a { color: var(--text-muted); }

@media (max-width: 520px) {
  .lede { font-size: 16.5px; }
  .layout, .shell { padding-left: 16px; padding-right: 16px; }
}
