/* ─── ScalyClaw Docs — Shared Styles ─────────────────── */

/* ─── Reset & Tokens ──────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }
:root {
  --bg: #050505;
  --bg-card: #0a0a0a;
  --bg-card-hover: #111111;
  --border: #1a1a1a;
  --border-hover: #2a2a2a;
  --text: #e5e5e5;
  --text-muted: #737373;
  --text-dim: #525252;
  --accent: #10b981;
  --accent-light: #34d399;
  --accent-dark: #059669;
  --accent-glow: rgba(16, 185, 129, 0.15);
  --purple: #8b5cf6;
  --blue: #3b82f6;
  --cyan: #06b6d4;
  --amber: #f59e0b;
  --rose: #f43f5e;
  --font: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --mono: 'JetBrains Mono', 'Fira Code', monospace;
  --header-h: 60px;
  --sidebar-w: 280px;
}
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}
a { color: inherit; text-decoration: none; }
button { font-family: inherit; cursor: pointer; border: none; background: none; }

/* ─── Scrollbar ───────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #333; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #555; }

/* ─── Header ──────────────────────────────────────────── */
.docs-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 100;
  height: var(--header-h);
  background: rgba(5, 5, 5, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
}
.docs-header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}
.docs-header-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.docs-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.125rem;
  letter-spacing: -0.02em;
  white-space: nowrap;
}
.docs-logo svg { width: 28px; height: 28px; flex-shrink: 0; }
.docs-logo-sep {
  width: 1px;
  height: 20px;
  background: var(--border);
  margin: 0 4px;
}
.docs-logo-label {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
}

/* Search */
.docs-search {
  position: relative;
  width: 280px;
}
.docs-search-input {
  width: 100%;
  padding: 8px 12px 8px 36px;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 0.8125rem;
  font-family: var(--font);
  outline: none;
  transition: all 0.2s;
}
.docs-search-input::placeholder { color: var(--text-dim); }
.docs-search-input:focus {
  border-color: var(--accent);
  background: rgba(255,255,255,0.06);
}
.docs-search-icon {
  position: absolute;
  left: 10px; top: 50%;
  transform: translateY(-50%);
  width: 16px; height: 16px;
  color: var(--text-dim);
  pointer-events: none;
}
.docs-search-kbd {
  position: absolute;
  right: 8px; top: 50%;
  transform: translateY(-50%);
  font-size: 0.6875rem;
  font-family: var(--mono);
  color: var(--text-dim);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  pointer-events: none;
}
.docs-search-results {
  position: absolute;
  top: calc(100% + 6px);
  left: 0; right: 0;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  max-height: 360px;
  overflow-y: auto;
  display: none;
  z-index: 200;
  box-shadow: 0 12px 40px rgba(0,0,0,0.6);
}
.docs-search-results.open { display: block; }
.docs-search-result {
  display: block;
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  transition: background 0.15s;
}
.docs-search-result:last-child { border-bottom: none; }
.docs-search-result:hover { background: rgba(255,255,255,0.04); }
.docs-search-result-title {
  font-size: 0.8125rem;
  font-weight: 600;
  margin-bottom: 2px;
}
.docs-search-result-snippet {
  font-size: 0.75rem;
  color: var(--text-muted);
  line-height: 1.4;
}
.docs-search-result mark {
  background: rgba(16,185,129,0.2);
  color: var(--accent-light);
  border-radius: 2px;
  padding: 0 2px;
}
.docs-search-empty {
  padding: 20px 14px;
  text-align: center;
  font-size: 0.8125rem;
  color: var(--text-dim);
}

/* Header links */
.docs-header-links {
  display: flex;
  align-items: center;
  gap: 16px;
}
.docs-header-link {
  font-size: 0.8125rem;
  font-weight: 500;
  color: var(--text-muted);
  transition: color 0.2s;
  display: flex;
  align-items: center;
  gap: 6px;
}
.docs-header-link:hover { color: var(--text); }
.docs-header-link svg { width: 16px; height: 16px; }

/* Mobile hamburger */
.docs-hamburger {
  display: none;
  width: 32px; height: 32px;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  cursor: pointer;
}
.docs-hamburger span {
  display: block;
  width: 20px; height: 2px;
  background: var(--text);
  border-radius: 1px;
  transition: all 0.3s;
}

/* ─── Layout ──────────────────────────────────────────── */
.docs-layout {
  display: flex;
  padding-top: var(--header-h);
  min-height: 100vh;
}

/* ─── Sidebar ─────────────────────────────────────────── */
.docs-sidebar {
  position: fixed;
  top: var(--header-h);
  left: 0;
  bottom: 0;
  width: var(--sidebar-w);
  background: var(--bg);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 20px 0 40px;
  z-index: 50;
}
.docs-sidebar-backdrop {
  display: none;
}
.docs-sidebar-group {
  margin-bottom: 4px;
}
.docs-sidebar-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  font-size: 0.6875rem;
  font-weight: 700;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  cursor: pointer;
  user-select: none;
  transition: color 0.2s;
}
.docs-sidebar-heading:hover { color: var(--text-muted); }
.docs-sidebar-chevron {
  width: 14px; height: 14px;
  transition: transform 0.2s;
  flex-shrink: 0;
}
.docs-sidebar-group.collapsed .docs-sidebar-chevron {
  transform: rotate(-90deg);
}
.docs-sidebar-links {
  list-style: none;
  overflow: hidden;
  transition: max-height 0.25s ease;
}
.docs-sidebar-group.collapsed .docs-sidebar-links {
  max-height: 0 !important;
}
.docs-sidebar-link {
  display: block;
  padding: 5px 20px 5px 24px;
  font-size: 0.8125rem;
  color: var(--text-muted);
  border-left: 2px solid transparent;
  transition: all 0.15s;
  line-height: 1.5;
}
.docs-sidebar-link:hover {
  color: var(--text);
  background: rgba(255,255,255,0.02);
}
.docs-sidebar-link.active {
  color: var(--accent);
  border-left-color: var(--accent);
  background: rgba(16,185,129,0.04);
}
.docs-sidebar-link.page-active {
  color: var(--text);
  font-weight: 500;
}

/* ─── Main Content ────────────────────────────────────── */
.docs-main {
  flex: 1;
  margin-left: var(--sidebar-w);
  padding: 40px 48px 80px;
  max-width: calc(100% - var(--sidebar-w));
}
.docs-content {
  max-width: 800px;
  margin: 0 auto;
}

/* ─── Typography ──────────────────────────────────────── */
.docs-content h1 {
  font-size: 2.25rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 12px;
}
.docs-content h2 {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-top: 56px;
  margin-bottom: 16px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 80px;
}
.docs-content h3 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-top: 36px;
  margin-bottom: 12px;
  scroll-margin-top: 80px;
}
.docs-content h4 {
  font-size: 0.9375rem;
  font-weight: 600;
  margin-top: 24px;
  margin-bottom: 8px;
  scroll-margin-top: 80px;
}
.docs-content p {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 16px;
}
.docs-content a:not(.docs-search-result) {
  color: var(--accent);
  text-decoration: underline;
  text-underline-offset: 2px;
  text-decoration-color: rgba(16,185,129,0.3);
  transition: text-decoration-color 0.2s;
}
.docs-content a:not(.docs-search-result):hover {
  text-decoration-color: var(--accent);
}
.docs-content strong { color: var(--text); font-weight: 600; }
.docs-content em { font-style: italic; }
.docs-content hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 40px 0;
}
.docs-content ul, .docs-content ol {
  margin-bottom: 16px;
  padding-left: 24px;
}
.docs-content li {
  font-size: 0.9375rem;
  line-height: 1.8;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.docs-content li strong { color: var(--text); }

/* Inline code */
.docs-content code:not([class]) {
  font-family: var(--mono);
  font-size: 0.8125rem;
  background: rgba(255,255,255,0.06);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent-light);
}

/* ─── Code Blocks ─────────────────────────────────────── */
.code-block {
  margin: 16px 0 24px;
  border: 1px solid var(--border);
  border-radius: 10px;
  overflow: hidden;
  background: #0c0c0c;
}
.code-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 14px;
  background: rgba(255,255,255,0.02);
  border-bottom: 1px solid var(--border);
}
.code-block-lang {
  font-family: var(--mono);
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.code-block-copy {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px; height: 30px;
  border-radius: 6px;
  border: 1px solid transparent;
  color: var(--text-dim);
  transition: all 0.2s;
}
.code-block-copy:hover {
  border-color: var(--border);
  color: var(--text-muted);
}
.code-block-copy.copied {
  color: var(--accent);
}
.code-block pre {
  padding: 16px 18px;
  overflow-x: auto;
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.7;
  color: var(--text-muted);
  tab-size: 2;
}

/* Syntax tokens */
.kw { color: var(--purple); }
.str { color: var(--accent-light); }
.num { color: var(--amber); }
.cmt { color: var(--text-dim); font-style: italic; }
.fn { color: var(--blue); }
.cmd { color: var(--accent); }
.typ { color: var(--cyan); }
.op { color: var(--text-dim); }
.prop { color: var(--rose); }

/* ─── Callout Boxes ───────────────────────────────────── */
.callout {
  margin: 20px 0 24px;
  padding: 16px 18px;
  border-radius: 8px;
  border-left: 3px solid;
  font-size: 0.875rem;
  line-height: 1.7;
}
.callout p { margin-bottom: 0; font-size: 0.875rem; }
.callout p + p { margin-top: 8px; }
.callout-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 600;
  font-size: 0.8125rem;
  margin-bottom: 6px;
}
.callout-label svg { width: 16px; height: 16px; }

.callout-tip {
  border-color: var(--accent);
  background: rgba(16,185,129,0.04);
}
.callout-tip .callout-label { color: var(--accent); }

.callout-warn {
  border-color: var(--amber);
  background: rgba(245,158,11,0.04);
}
.callout-warn .callout-label { color: var(--amber); }

.callout-danger {
  border-color: var(--rose);
  background: rgba(244,63,94,0.04);
}
.callout-danger .callout-label { color: var(--rose); }

.callout-info {
  border-color: var(--blue);
  background: rgba(59,130,246,0.04);
}
.callout-info .callout-label { color: var(--blue); }

/* ─── Tables ──────────────────────────────────────────── */
.docs-content table {
  width: 100%;
  border-collapse: collapse;
  margin: 16px 0 24px;
  font-size: 0.8125rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}
.docs-content thead {
  background: rgba(255,255,255,0.03);
}
.docs-content th {
  padding: 10px 14px;
  text-align: left;
  font-weight: 600;
  color: var(--text);
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
.docs-content td {
  padding: 10px 14px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border);
  line-height: 1.6;
}
.docs-content tr:last-child td { border-bottom: none; }
.docs-content tr:hover td { background: rgba(255,255,255,0.015); }

/* ─── Badges ──────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.6875rem;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 20px;
  letter-spacing: 0.02em;
}
.badge-green { background: rgba(16,185,129,0.1); color: var(--accent); }
.badge-blue { background: rgba(59,130,246,0.1); color: var(--blue); }
.badge-purple { background: rgba(139,92,246,0.1); color: var(--purple); }
.badge-amber { background: rgba(245,158,11,0.1); color: var(--amber); }
.badge-rose { background: rgba(244,63,94,0.1); color: var(--rose); }

/* ─── Page Navigation (prev/next) ─────────────────────── */
.docs-page-nav {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  margin-top: 64px;
  padding-top: 32px;
  border-top: 1px solid var(--border);
}
.docs-page-nav-link {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 16px 20px;
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: all 0.2s;
  flex: 1;
  max-width: 50%;
  text-decoration: none !important;
}
.docs-page-nav-link:hover {
  border-color: var(--accent);
  background: rgba(16,185,129,0.03);
}
.docs-page-nav-link.next { align-items: flex-end; text-align: right; }
.docs-page-nav-dir {
  font-size: 0.6875rem;
  font-weight: 600;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.docs-page-nav-title {
  font-size: 0.9375rem;
  font-weight: 600;
  color: var(--accent);
}

/* ─── Intro page feature grid ─────────────────────────── */
.docs-features {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin: 24px 0;
}
.docs-feature {
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  transition: border-color 0.2s;
}
.docs-feature:hover { border-color: var(--border-hover); }
.docs-feature h4 {
  margin: 0 0 6px;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
}
.docs-feature p {
  margin: 0;
  font-size: 0.8125rem;
  color: var(--text-muted);
  line-height: 1.5;
}

/* ─── Directory tree ──────────────────────────────────── */
.dir-tree {
  font-family: var(--mono);
  font-size: 0.8125rem;
  line-height: 1.8;
  color: var(--text-muted);
  padding: 16px 20px;
  background: #0c0c0c;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0 24px;
  overflow-x: auto;
}
.dir-tree .dir { color: var(--blue); }
.dir-tree .file { color: var(--text-muted); }
.dir-tree .cmt { color: var(--text-dim); }

/* ─── Flow diagram (text-based) ───────────────────────── */
.flow-diagram {
  font-family: var(--mono);
  font-size: 0.75rem;
  line-height: 1.6;
  color: var(--text-muted);
  padding: 20px 24px;
  background: #0c0c0c;
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 16px 0 24px;
  overflow-x: auto;
  text-align: center;
}
.flow-diagram .node {
  color: var(--accent);
  font-weight: 600;
}
.flow-diagram .arrow { color: var(--text-dim); }

/* ─── Footer ──────────────────────────────────────────── */
.docs-footer {
  margin-left: var(--sidebar-w);
  padding: 24px 48px;
  border-top: 1px solid var(--border);
  text-align: center;
}
.docs-footer p {
  font-size: 0.75rem;
  color: var(--text-dim);
}

/* ─── Mobile (<=900px) ────────────────────────────────── */
@media (max-width: 900px) {
  .docs-hamburger { display: flex; }
  .docs-search { width: 180px; }
  .docs-header-links { display: none; }

  .docs-sidebar {
    transform: translateX(-100%);
    transition: transform 0.3s ease;
    z-index: 90;
    background: var(--bg);
  }
  .docs-sidebar.open { transform: translateX(0); }
  .docs-sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    top: var(--header-h);
    background: rgba(0,0,0,0.5);
    z-index: 80;
  }
  .docs-sidebar-backdrop.open { display: block; }

  .docs-main {
    margin-left: 0;
    max-width: 100%;
    padding: 32px 20px 60px;
  }
  .docs-footer {
    margin-left: 0;
    padding: 24px 20px;
  }
  .docs-content h1 { font-size: 1.75rem; }
  .docs-content h2 { font-size: 1.25rem; margin-top: 40px; }
  .docs-features { grid-template-columns: 1fr; }
  .docs-page-nav { flex-direction: column; }
  .docs-page-nav-link { max-width: 100%; }
}

@media (max-width: 500px) {
  .docs-search { width: 140px; }
  .docs-search-kbd { display: none; }
  .docs-logo-sep, .docs-logo-label { display: none; }
}
