/* ==========================================================================
   moat docs — stylesheet
   ========================================================================== */

/* --------------------------------------------------------------------------
   Design tokens
   -------------------------------------------------------------------------- */
:root {
  /* Brand palette (aligns with moat marketing site) */
  --brand:          #6B6EF5;
  --brand-dark:     #4547C9;
  --brand-soft:     #EEF0FF;
  --brand-softer:   #F6F7FF;

  /* Ink */
  --ink:            #0D0D2B;
  --ink-2:          #303050;
  --ink-3:          #5A5E78;
  --ink-4:          #8A8EA5;

  /* Surface */
  --bg:             #FFFFFF;
  --bg-muted:       #F8F9FC;
  --bg-code:        #0F1025;
  --bg-code-soft:   #F3F4FA;

  /* Border */
  --border:         #E4E6EF;
  --border-strong:  #CACDDB;

  /* Status */
  --success:        #1F9D55;
  --warn:           #C47A00;
  --danger:         #D0342C;
  --info:           #2563EB;

  /* Layout */
  --sidebar-w:      280px;
  --nav-h:          64px;
  --radius:         8px;
  --radius-lg:      12px;

  /* Type */
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

/* --------------------------------------------------------------------------
   Base
   -------------------------------------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html, body { margin: 0; padding: 0; }

body {
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.65;
  color: var(--ink-2);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--brand-dark);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 120ms ease;
}
a:hover { border-bottom-color: var(--brand-dark); }

h1, h2, h3, h4 {
  color: var(--ink);
  line-height: 1.25;
  margin: 2em 0 0.6em;
  font-weight: 600;
  letter-spacing: -0.01em;
}
h1 { font-size: 2rem; margin-top: 0; letter-spacing: -0.02em; }
h2 { font-size: 1.375rem; padding-top: 0.4em; }
h3 { font-size: 1.1rem; }
h4 { font-size: 1rem; }

p { margin: 0 0 1em; }

ul, ol { padding-left: 1.4em; margin: 0 0 1em; }
li { margin-bottom: 0.35em; }
li > p { margin-bottom: 0.35em; }

strong { color: var(--ink); font-weight: 600; }
hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }

code {
  font-family: var(--font-mono);
  font-size: 0.88em;
  padding: 0.12em 0.4em;
  border-radius: 4px;
  background: var(--bg-code-soft);
  color: var(--ink);
  border: 1px solid var(--border);
}

pre {
  background: var(--bg-code);
  color: #E6E8F2;
  border-radius: var(--radius);
  padding: 1em 1.1em;
  overflow-x: auto;
  margin: 1em 0 1.4em;
  position: relative;
  font-size: 13px;
  line-height: 1.55;
}
pre code {
  background: none;
  border: none;
  color: inherit;
  padding: 0;
  font-size: inherit;
}
pre.lang::before {
  content: attr(data-lang);
  position: absolute;
  top: 0.5em;
  right: 0.8em;
  font-family: var(--font-sans);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: #8A8EA5;
  pointer-events: none;
}

/* --------------------------------------------------------------------------
   Top nav
   -------------------------------------------------------------------------- */
.docs-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: var(--nav-h);
  padding: 0 1.8rem;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  position: sticky;
  top: 0;
  z-index: 100;
}
.docs-nav a { border-bottom: none; }

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: var(--ink);
  font-weight: 600;
}
.logo-box {
  width: 32px;
  height: 32px;
  background: var(--ink);
  color: #fff;
  border-radius: 7px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 14px;
  font-weight: 700;
  letter-spacing: -0.5px;
}
.logo-text { display: flex; align-items: baseline; gap: 0.35rem; }
.brand-name { font-size: 1.05rem; letter-spacing: -0.01em; }
.docs-label {
  font-size: 0.85rem;
  color: var(--ink-4);
  font-weight: 500;
  padding-left: 0.35rem;
  border-left: 1px solid var(--border-strong);
}

.nav-links {
  display: flex;
  gap: 1.8rem;
  list-style: none;
  padding: 0;
  margin: 0;
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}
.nav-links li { margin: 0; }
.nav-links a {
  color: var(--ink-2);
  font-size: 0.92rem;
  font-weight: 500;
  padding: 0.4em 0;
}
.nav-links a:hover { color: var(--brand-dark); border-bottom: none; }

.nav-dropdown { position: relative; }
.nav-dropdown-menu {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%) translateY(4px);
  opacity: 0;
  visibility: hidden;
  padding-top: 0.4rem;
  transition: opacity 120ms ease, visibility 120ms ease;
}
.nav-dropdown:hover .nav-dropdown-menu {
  opacity: 1;
  visibility: visible;
}
.nav-dropdown-menu-inner {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0.5rem;
  box-shadow: 0 10px 24px rgba(13,13,43,0.12);
  min-width: 200px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.nav-dropdown-menu-inner a {
  padding: 0.5em 0.75em;
  border-radius: 6px;
  font-size: 0.9rem;
  white-space: nowrap;
}
.nav-dropdown-menu-inner a:hover { background: var(--bg-muted); }

.nav-actions {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}
.btn-ghost, .btn-primary {
  padding: 0.55em 1em;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 500;
  transition: background 120ms ease, color 120ms ease;
}
.btn-ghost { color: var(--ink-2); }
.btn-ghost:hover { background: var(--bg-muted); border-bottom: none; }
.btn-primary {
  background: var(--brand);
  color: #fff;
}
.btn-primary:hover {
  background: var(--brand-dark);
  border-bottom: none;
}

/* --------------------------------------------------------------------------
   Layout
   -------------------------------------------------------------------------- */
.docs-layout {
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  max-width: 1400px;
  margin: 0 auto;
}

/* --------------------------------------------------------------------------
   Sidebar
   -------------------------------------------------------------------------- */
.docs-sidebar {
  padding: 1.5rem 0.25rem 2rem 1.8rem;
  border-right: 1px solid var(--border);
  position: sticky;
  top: var(--nav-h);
  height: calc(100vh - var(--nav-h));
  overflow-y: auto;
  font-size: 0.905rem;
}

.docs-sidebar-section { margin-bottom: 1.5rem; }
.docs-sidebar-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--ink-4);
  padding: 0.4em 0.8em;
  margin-bottom: 0.3em;
}
.docs-sidebar ul {
  list-style: none;
  padding: 0;
  margin: 0;
}
.docs-sidebar li { margin: 0; }
.docs-sidebar a {
  display: block;
  padding: 0.38em 0.8em;
  color: var(--ink-3);
  border-radius: 5px;
  border-bottom: none;
  font-weight: 450;
  line-height: 1.45;
  transition: background 80ms ease, color 80ms ease;
}
.docs-sidebar a:hover {
  background: var(--bg-muted);
  color: var(--ink);
}
.docs-sidebar a.active {
  background: var(--brand-soft);
  color: var(--brand-dark);
  font-weight: 600;
}

/* --------------------------------------------------------------------------
   Main content
   -------------------------------------------------------------------------- */
.docs-main {
  padding: 2rem 3rem 4rem;
  min-width: 0; /* allow pre to scroll */
  max-width: 880px;
}

.docs-breadcrumb {
  font-size: 0.85rem;
  color: var(--ink-4);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35em;
}
.docs-breadcrumb a {
  color: var(--ink-3);
  border-bottom: none;
}
.docs-breadcrumb a:hover { color: var(--brand-dark); }
.docs-breadcrumb .sep { color: var(--border-strong); margin: 0 0.1em; }
.docs-breadcrumb span:last-child { color: var(--ink-2); }

.docs-content { }

.lede {
  font-size: 1.1rem;
  color: var(--ink-3);
  margin: 0 0 1.8em;
  line-height: 1.55;
}

/* --------------------------------------------------------------------------
   Endpoint chip
   -------------------------------------------------------------------------- */
.endpoint {
  display: inline-flex;
  align-items: stretch;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  margin: 0.4em 0 1.2em;
  font-family: var(--font-mono);
  font-size: 13px;
  background: var(--bg-muted);
}
.endpoint .method {
  padding: 0.55em 0.85em;
  font-weight: 700;
  color: #fff;
  letter-spacing: 0.5px;
  display: inline-flex;
  align-items: center;
}
.endpoint .method.get    { background: #1F9D55; }
.endpoint .method.post   { background: var(--brand); }
.endpoint .method.delete { background: var(--danger); }
.endpoint .path {
  padding: 0.55em 0.9em;
  color: var(--ink);
  border-left: 1px solid var(--border);
  background: #fff;
  display: inline-flex;
  align-items: center;
}

/* --------------------------------------------------------------------------
   Callouts
   -------------------------------------------------------------------------- */
.callout {
  border-left: 3px solid var(--border-strong);
  background: var(--bg-muted);
  padding: 0.9em 1.1em;
  border-radius: 0 var(--radius) var(--radius) 0;
  margin: 1.2em 0 1.4em;
}
.callout-body { }
.callout-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 0.35em;
  color: var(--ink-3);
}
.callout-body p { margin: 0 0 0.5em; }
.callout-body p:last-child { margin-bottom: 0; }
.callout-body ul, .callout-body ol { margin-bottom: 0.25em; }

.callout.tip {
  background: var(--brand-softer);
  border-left-color: var(--brand);
}
.callout.tip .callout-label { color: var(--brand-dark); }

.callout.note {
  background: #EEF4FF;
  border-left-color: var(--info);
}
.callout.note .callout-label { color: var(--info); }

.callout.important {
  background: #FFF7E3;
  border-left-color: var(--warn);
}
.callout.important .callout-label { color: var(--warn); }

.callout.warning {
  background: #FFEFEE;
  border-left-color: var(--danger);
}
.callout.warning .callout-label { color: var(--danger); }

/* --------------------------------------------------------------------------
   Parameter tables
   -------------------------------------------------------------------------- */
table {
  width: 100%;
  border-collapse: collapse;
  margin: 1em 0 1.6em;
  font-size: 0.92rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
thead th {
  background: var(--bg-muted);
  color: var(--ink);
  text-align: left;
  font-weight: 600;
  padding: 0.6em 0.9em;
  font-size: 0.82rem;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  border-bottom: 1px solid var(--border);
}
tbody td {
  padding: 0.7em 0.9em;
  border-bottom: 1px solid var(--border);
  vertical-align: top;
  color: var(--ink-2);
}
tbody tr:last-child td { border-bottom: none; }
tbody td code { font-size: 0.92em; }

/* Badges inside tables */
.req, .opt {
  display: inline-block;
  padding: 0.12em 0.55em;
  border-radius: 10px;
  font-size: 10.5px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  white-space: nowrap;
}
.req {
  background: #FDEBEA;
  color: var(--danger);
}
.opt {
  background: var(--bg-code-soft);
  color: var(--ink-3);
}

/* --------------------------------------------------------------------------
   Page nav (prev / next)
   -------------------------------------------------------------------------- */
.docs-pagenav {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  margin-top: 3rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border);
}
.docs-pagenav a {
  display: flex;
  flex-direction: column;
  padding: 0.9em 1.1em;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  flex: 1 1 0;
  max-width: 48%;
  text-decoration: none;
  color: var(--ink);
  border-bottom: 1px solid var(--border);
  transition: border-color 120ms ease, background 120ms ease;
}
.docs-pagenav a:hover {
  border-color: var(--brand);
  background: var(--brand-softer);
}
.docs-pagenav a.prev { text-align: left; }
.docs-pagenav a.next { text-align: right; margin-left: auto; }
.docs-pagenav a.next:only-child { margin-left: auto; }
.docs-pagenav .pn-label {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--ink-4);
  margin-bottom: 0.2em;
}
.docs-pagenav .pn-title {
  font-size: 0.98rem;
  font-weight: 600;
  color: var(--ink);
}

/* --------------------------------------------------------------------------
   Responsive
   -------------------------------------------------------------------------- */
@media (max-width: 960px) {
  :root { --sidebar-w: 240px; }
  .docs-main { padding: 1.5rem 1.8rem 3rem; }
  h1 { font-size: 1.75rem; }
  h2 { font-size: 1.25rem; }
}

@media (max-width: 760px) {
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-sidebar {
    position: static;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    padding: 1rem 1.2rem 1.5rem;
    max-height: 60vh;
  }
  .docs-main {
    padding: 1.5rem 1.25rem 3rem;
  }
  .docs-nav {
    padding: 0 1rem;
    height: 56px;
  }
  .nav-links { display: none; }
  .nav-actions { gap: 0.4rem; }
  .btn-ghost, .btn-primary {
    padding: 0.5em 0.75em;
    font-size: 0.85rem;
  }
  .docs-pagenav { flex-direction: column; }
  .docs-pagenav a { max-width: 100%; }
  .docs-pagenav a.next { margin-left: 0; }
  h1 { font-size: 1.55rem; }
  table { font-size: 0.85rem; }
  thead th, tbody td { padding: 0.5em 0.6em; }
}

/* --------------------------------------------------------------------------
   Print
   -------------------------------------------------------------------------- */
@media print {
  .docs-nav, .docs-sidebar, .docs-pagenav { display: none; }
  .docs-layout { grid-template-columns: 1fr; }
  .docs-main { padding: 0; max-width: none; }
  pre { page-break-inside: avoid; border: 1px solid #ccc; }
  a { color: var(--ink); border-bottom: none; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 0.85em; color: #666; }
}
