/* ─── Reset & Base ─── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root,
[data-theme="dark"] {
  --bg:            rgb(34, 37, 43);
  --bg-sidebar:    rgb(29, 32, 38);
  --bg-code:       rgb(24, 26, 31);
  --surface:       rgb(41, 44, 51);
  --border:        rgb(55, 58, 66);
  --text:          rgb(231, 231, 231);
  --text-secondary:rgb(155, 156, 160);
  --text-muted:    rgb(100, 101, 106);
  --accent:        rgb(231, 231, 231);
  --accent-fg:     rgb(34, 37, 43);
  --code-kw:  #C586C0;
  --code-fn:  #DCDCAA;
  --code-str: #CE9178;
  --code-num: #B5CEA8;
  --code-cm:  rgb(100, 101, 106);
  --code-op:  #D4D4D4;
  --nav-bg:   rgba(29, 32, 38, 0.92);
  --sidebar-w: 260px;
  --font: 'Inter', system-ui, -apple-system, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;
  color-scheme: dark;
}

[data-theme="light"] {
  --bg:            #FFFFFF;
  --bg-sidebar:    #F6F6F7;
  --bg-code:       #F0F0F2;
  --surface:       #EBEBED;
  --border:        #E5E5E8;
  --text:          #0B0B0C;
  --text-secondary:#4A4A50;
  --text-muted:    #7A7A82;
  --accent:        #1A1A1C;
  --accent-fg:     #FFFFFF;
  --code-kw:  #8B5CF6;
  --code-fn:  #1F51B6;
  --code-str: #A04900;
  --code-num: #2B7A00;
  --code-cm:  #7A7A82;
  --code-op:  #333;
  --nav-bg:   rgba(246, 246, 247, 0.92);
  color-scheme: light;
}

html { scroll-behavior: smooth; -webkit-font-smoothing: antialiased; }

body {
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.65;
  color: var(--text);
  background: var(--bg);
}

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


/* ─── Layout ─── */
.layout {
  display: flex;
  min-height: 100vh;
}

/* ─── Theme label spans (show-dark / show-light) ─── */
.show-dark  { display: inline; }
.show-light { display: none; }
html[data-theme="light"] .show-dark  { display: none; }
html[data-theme="light"] .show-light { display: inline; }


/* ─── Sidebar ─── */
.sidebar {
  width: var(--sidebar-w);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow-y: hidden;
  z-index: 50;
}

.sidebar-header {
  height: 52px;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 8px 0;
  flex: 1;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sidebar-logo {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.sidebar-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-muted);
  letter-spacing: 0.03em;
}

.sidebar-nav {
  padding: 8px 0;
  flex: 1;
}

.nav-section {
  padding: 0 8px;
  margin-bottom: 4px;
}

.nav-section-title {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  padding: 14px 8px 5px 8px;
}

.nav-link {
  position: relative;
  display: block;
  padding: 7px 8px 7px 16px;
  font-size: 13px;
  font-weight: 400;
  color: var(--text-secondary);
  border-radius: 4px;
  transition: color 0.1s;
  cursor: pointer;
}

.nav-link:hover {
  color: var(--text);
}

.nav-link.active {
  color: var(--text);
}

/* Accent bar — matches app: width 2px, height 1rem, right-rounded */
.nav-link.active::before {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  width: 2px;
  height: 1rem;
  background: var(--accent);
  border-radius: 0 999px 999px 0;
}

.sidebar-footer { display: none; }


/* ─── Theme toggle ─── */
.theme-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px; height: 28px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: none;
  cursor: pointer;
  color: var(--text-muted);
  transition: color 0.15s, border-color 0.15s;
  flex-shrink: 0;
}

.theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

.icon-sun  { visibility: hidden; width: 0; }
.icon-moon { visibility: visible; }
html[data-theme="light"] .icon-sun  { visibility: visible; width: auto; }
html[data-theme="light"] .icon-moon { visibility: hidden; width: 0; }


/* ─── Navbar (top bar for docs) ─── */
.docs-navbar {
  position: fixed;
  top: 0; left: var(--sidebar-w); right: 0;
  height: 52px;
  background: var(--nav-bg, var(--bg));
  border-bottom: 1px solid var(--border);
  z-index: 40;
  display: flex;
  align-items: center;
  padding: 0 40px;
  gap: 24px;
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

/* Search */
.docs-search {
  flex: 1;
  max-width: 380px;
  position: relative;
}

.docs-search input {
  width: 100%;
  height: 32px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0 10px 0 32px;
  font-size: 13px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.docs-search input::placeholder { color: var(--text-muted); }
.docs-search input:focus { border-color: var(--text-muted); }

.docs-search-icon {
  position: absolute;
  left: 9px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

/* Search results dropdown */
.search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-sidebar);
  border: 1px solid var(--border);
  border-radius: 6px;
  z-index: 200;
  max-height: 320px;
  overflow-y: auto;
  display: none;
  box-shadow: 0 8px 24px rgba(0,0,0,0.3);
}

.search-results.visible { display: block; }

.search-result-item {
  display: block;
  padding: 10px 14px;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
}
.search-result-item:last-child { border-bottom: none; }
.search-result-item:hover, .search-result-item.active-result { background: var(--surface); }

.search-result-item .sr-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 2px;
}
.search-result-item .sr-section {
  font-size: 11px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.search-result-item mark {
  background: rgba(231,231,231,0.2);
  color: var(--text);
  border-radius: 2px;
  padding: 0;
  font-weight: 600;
}

.docs-nav-links {
  display: flex;
  align-items: center;
  gap: 24px;
  margin-left: auto;
  flex-shrink: 0;
}

.docs-nav-links a {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color 0.15s;
}
.docs-nav-links a:hover { color: var(--text); }

.docs-nav-btn {
  background: var(--accent);
  color: var(--accent-fg) !important;
  padding: 5px 14px;
  border-radius: 4px;
  font-weight: 600 !important;
  font-size: 13px !important;
  transition: opacity 0.15s;
}
.docs-nav-btn:hover { opacity: 0.85; }

/* ─── Main ─── */
.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0;
}

.content {
  max-width: 780px;
  margin: 0 auto;
  padding: 80px 40px 120px;
}

/* Home page overrides .content constraints */
.content:has(#page-home.active) {
  max-width: none;
  padding: 0;
}


/* ─── Content Typography ─── */
.content h1 {
  font-size: 1.75rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 8px;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
}

.content h1 + .subtitle {
  color: var(--text-secondary);
  font-size: 15px;
  margin-bottom: 40px;
}

.content h2 {
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin-top: 48px;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}

.content h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-top: 32px;
  margin-bottom: 8px;
}

.content h4 {
  font-size: 0.875rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 6px;
  color: var(--text-secondary);
}

.content p {
  margin-bottom: 16px;
  color: var(--text-secondary);
}

.content > ul, .content > ol {
  margin-bottom: 16px;
  padding-left: 20px;
  color: var(--text-secondary);
}

.content li {
  margin-bottom: 6px;
}

.content strong { color: var(--text); }

.content code {
  font-family: var(--mono);
  font-size: 0.85em;
  background: var(--bg-code);
  padding: 2px 6px;
  border-radius: 3px;
  border: 1px solid var(--border);
}

.content pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 18px 20px;
  overflow-x: auto;
  margin-bottom: 20px;
  font-size: 13px;
  line-height: 1.6;
  font-family: var(--mono);
}

.content pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: inherit;
}

/* Syntax highlighting */
.kw { color: var(--code-kw); }
.fn { color: var(--code-fn); }
.str { color: var(--code-str); }
.num { color: var(--code-num); }
.cm { color: var(--code-cm); }
.op { color: var(--code-op); }


/* ─── Tables ─── */
.content table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 20px;
  font-size: 13px;
}

.content th {
  text-align: left;
  font-weight: 600;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
}

.content td {
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  color: var(--text-secondary);
  vertical-align: top;
}

.content td code {
  font-size: 0.8em;
}

.content tr:last-child td { border-bottom: none; }


/* ─── Callouts / Notes ─── */
.callout {
  padding: 14px 18px;
  border-left: 3px solid var(--border);
  margin-bottom: 20px;
  font-size: 13px;
  color: var(--text-secondary);
  background: var(--surface);
  border-radius: 0 4px 4px 0;
}

.callout-warn {
  border-left-color: #FACC15;
}

.callout-info {
  border-left-color: #60A5FA;
}

.callout strong {
  display: block;
  margin-bottom: 4px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}


/* ─── HTTP Method badges ─── */
.method {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  font-family: var(--mono);
  padding: 2px 7px;
  border-radius: 3px;
  letter-spacing: 0.02em;
  vertical-align: middle;
  margin-right: 6px;
}

.method-get    { background: rgba(74,222,128,0.12); color: #4ADE80; }
.method-post   { background: rgba(96,165,250,0.12); color: #60A5FA; }
.method-patch  { background: rgba(250,204,21,0.12); color: #FACC15; }
.method-delete { background: rgba(248,113,113,0.12); color: #F87171; }

.endpoint {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text);
}


/* ─── Copy button ─── */
.pre-wrapper {
  position: relative;
  margin-bottom: 20px;
}

.pre-wrapper pre {
  margin-bottom: 0;
}

.copy-btn {
  position: absolute;
  top: 8px; right: 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 8px;
  font-size: 11px;
  font-family: var(--font);
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.15s, color 0.15s;
  pointer-events: none;
}

.pre-wrapper:hover .copy-btn {
  opacity: 1;
  pointer-events: auto;
}

/* Always visible on touch devices */
@media (hover: none) {
  .copy-btn { opacity: 1; pointer-events: auto; }
}

.copy-btn:hover { color: var(--text); }
.copy-btn.copied { color: #4ADE80; border-color: #4ADE80; }


/* ─── Doc cross-links ─── */
.doc-link {
  color: var(--text);
  text-decoration: underline;
  text-underline-offset: 3px;
  text-decoration-color: var(--border);
  transition: text-decoration-color 0.15s;
  cursor: pointer;
}
.doc-link:hover { text-decoration-color: var(--text-muted); }


/* ─── Sections / Pages ─── */
.doc-section {
  display: none;
}

.doc-section.active {
  display: block;
}


.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 49;
}

/* ─── Docs hamburger (mobile only) ─── */
.docs-hamburger {
  display: none;
  background: none;
  border: 1px solid var(--border);
  cursor: pointer;
  padding: 5px 12px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
  font-family: var(--font);
  line-height: 1;
  flex-shrink: 0;
  margin-right: 4px;
}

/* Sidebar theme toggle row — desktop hidden, mobile visible */
.sidebar-theme-row {
  display: none;
  padding: 12px 20px;
  border-top: 1px solid var(--border);
}

.sidebar-theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font);
  padding: 0;
}

.sidebar-theme-btn:hover { color: var(--text); }


/* ─── Mobile breakpoint ─── */
@media (max-width: 768px) {
  /* Sidebar: slides in below the single navbar */
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.25s cubic-bezier(0.16,1,0.3,1);
    top: 52px;
    z-index: 60;
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay.active {
    display: block;
    top: 52px; /* overlay also starts below navbar */
  }

  /* Single navbar: full width from top */
  .docs-navbar {
    left: 0;
    top: 0;
    padding: 0 16px;
    gap: 8px;
  }

  /* Show hamburger, always show branding */
  .docs-hamburger {
    display: inline-flex;
  }

  /* Hide theme toggle icon from navbar on mobile */
  .docs-navbar .theme-toggle {
    display: none;
  }

  /* Show sidebar theme toggle row on mobile */
  .sidebar-theme-row {
    display: block;
  }

  .nav-home-brand {
    display: flex;
  }

  /* Hide search input on mobile */
  .docs-search {
    display: none;
  }

  /* Content: only 52px navbar to account for */
  .main {
    margin-left: 0;
  }

  .content {
    padding: 68px 20px 80px;
  }

  /* Home mode: no hamburger (sidebar hidden on home) */
  body.home-mode .docs-hamburger {
    display: none;
  }

  /* (footer handled mobile-first below media query) */

  /* Home */
  .home-hero {
    padding: 72px 20px 36px;
  }

  .home-title {
    font-size: 1.65rem;
  }

  .home-sub {
    font-size: 14px;
  }

  .home-cards {
    padding: 0 16px 60px;
    grid-template-columns: 1fr;
    gap: 10px;
  }

  /* Tables: horizontal scroll */
  .content table {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  /* Headings */
  .content h1 { font-size: 1.4rem; }
  .content h2 { font-size: 1.05rem; }
}


/* ─── Nav home brand (only shown in home-mode) ─── */
.nav-home-brand {
  display: none;
  align-items: center;
  gap: 8px;
  margin-right: 16px;
  flex-shrink: 0;
}

body.home-mode .nav-home-brand { display: flex; }


/* ─── Home mode layout ─── */
body.home-mode .sidebar {
  display: none;
}

body.home-mode .docs-navbar {
  left: 0;
}

body.home-mode .main {
  margin-left: 0;
}

body.home-mode .docs-search {
  display: none;
}


/* ─── Docs footer ─── */
.docs-footer {
  border-top: 1px solid var(--border);
  padding: 20px;
  margin-top: 0;
}

.docs-footer-inner {
  max-width: 780px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  text-align: center;
  font-size: 12px;
  color: var(--text-muted);
}

.docs-footer-links {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  justify-content: center;
}

.docs-footer-links a {
  color: var(--text-muted);
  font-size: 12px;
  transition: color 0.15s;
}

.docs-footer-links a:hover { color: var(--text); }

@media (min-width: 769px) {
  .docs-footer {
    padding: 24px 40px;
  }

  .docs-footer-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0;
    text-align: left;
  }

  .docs-footer-links {
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 20px;
  }
}


/* ─── Scrollbar ─── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }


/* ─── Home Landing Page ─── */
#page-home {
  max-width: none;
  padding: 0;
}

.home-hero {
  max-width: 640px;
  margin: 0 auto;
  padding: 80px 40px 60px;
  text-align: center;
}

.home-eyebrow {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.home-title {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.03em;
  line-height: 1.15;
  color: var(--text);
  margin-bottom: 16px;
  border: none;
  padding: 0;
}

.home-sub {
  font-size: 16px;
  color: var(--text-secondary);
  line-height: 1.6;
  margin-bottom: 32px;
}

/* Big search on home */
.home-search-wrap {
  position: relative;
  max-width: 480px;
  margin: 0 auto;
}

.home-search-input {
  width: 100%;
  height: 48px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 0 16px 0 44px;
  font-size: 15px;
  font-family: var(--font);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}

.home-search-input::placeholder { color: var(--text-muted); }

.home-search-input:focus {
  border-color: var(--text-muted);
  box-shadow: 0 0 0 3px rgba(155,156,160,0.1);
}

.home-search-icon {
  position: absolute;
  left: 14px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  pointer-events: none;
}

.home-search-results {
  top: calc(100% + 8px);
  text-align: left;
}

/* Cards grid */
.home-cards {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 40px 100px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 12px;
}

.home-card {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  text-decoration: none;
}

.home-card:hover {
  border-color: var(--text-muted);
  background: var(--bg-code);
}

.home-card-icon {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  background: var(--bg-code);
  border: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  flex-shrink: 0;
}

.home-card:hover .home-card-icon {
  color: var(--text);
}

.home-card-content {
  flex: 1;
  min-width: 0;
}

.home-card-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 3px;
}

.home-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  line-height: 1.45;
}

.home-card-arrow {
  color: var(--text-muted);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.home-card:hover .home-card-arrow {
  opacity: 1;
  transform: translateX(2px);
}
