/* Illusion Docs — dark-first documentation theme. */
:root,
[data-theme="dark"] {
  --bg: #0b0b0c;
  --bg-raised: #131315;
  --bg-hover: #1c1c1f;
  --bg-active: #232327;
  --border: #26262b;
  --border-strong: #34343a;
  --text: #ececee;
  --text-soft: #b4b4bc;
  --text-muted: #8a8a94;
  --accent: #3b82f6;
  --accent-soft: rgba(59, 130, 246, 0.14);
  --code-bg: #17171a;
  --cta-bg: #ffffff;
  --cta-text: #0b0b0c;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.55);
  color-scheme: dark;
}
[data-theme="light"] {
  --bg: #ffffff;
  --bg-raised: #f6f6f7;
  --bg-hover: #efeff1;
  --bg-active: #e7e7ea;
  --border: #e4e4e8;
  --border-strong: #d4d4da;
  --text: #121214;
  --text-soft: #3e3e45;
  --text-muted: #6b6b75;
  --accent: #2563eb;
  --accent-soft: rgba(37, 99, 235, 0.1);
  --code-bg: #f3f3f5;
  --cta-bg: #121214;
  --cta-text: #ffffff;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.15);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { scroll-padding-top: 84px; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.65 Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Noto Sans", sans-serif;
  -webkit-font-smoothing: antialiased;
}
a { color: inherit; }
img { max-width: 100%; height: auto; }
kbd {
  font: 500 11px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  padding: 3px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 6px;
  background: var(--bg-raised);
  color: var(--text-soft);
  white-space: nowrap;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 12px; top: 12px; z-index: 100; background: var(--cta-bg); color: var(--cta-text); padding: 8px 12px; border-radius: 8px; }

/* ── Top bar ───────────────────────────────────────────── */
.topbar {
  position: sticky; top: 0; z-index: 40;
  height: 64px;
  display: flex; align-items: center; gap: 16px;
  padding: 0 20px;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
}
.brand { display: flex; align-items: center; gap: 8px; text-decoration: none; font: 700 16px Satoshi, Inter, sans-serif; }
.brand-docs { color: var(--text-muted); font-weight: 500; }
.tabs { display: flex; gap: 4px; margin: 0 auto; }
.tab { padding: 6px 12px; border-radius: 8px; color: var(--text-soft); text-decoration: none; font-size: 14px; }
.tab:hover { color: var(--text); background: var(--bg-hover); }
.tab.active { color: var(--text); font-weight: 600; }
.top-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn, .menu-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent; background: transparent; color: var(--text-soft); cursor: pointer;
}
.icon-btn:hover, .menu-btn:hover { background: var(--bg-hover); color: var(--text); }
.menu-btn { display: none; }
.search-btn {
  display: flex; align-items: center; gap: 8px;
  height: 36px; min-width: 210px; padding: 0 8px 0 12px;
  border: 1px solid var(--border); border-radius: 10px;
  background: var(--bg-raised); color: var(--text-muted); cursor: pointer; font: inherit; font-size: 14px;
}
.search-btn:hover { border-color: var(--border-strong); color: var(--text-soft); }
.search-btn kbd { margin-left: auto; }
.cta {
  display: inline-flex; align-items: center; height: 36px; padding: 0 14px;
  border-radius: 10px; background: var(--cta-bg); color: var(--cta-text);
  font-weight: 600; font-size: 14px; text-decoration: none; white-space: nowrap;
}
.cta:hover { opacity: 0.9; }

/* ── Layout ────────────────────────────────────────────── */
.shell { display: grid; grid-template-columns: 260px minmax(0, 1fr) 220px; max-width: 1480px; margin: 0 auto; }
body.home .shell { grid-template-columns: 260px minmax(0, 1fr); }
.sidebar {
  position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto;
  padding: 24px 12px 40px; border-right: 1px solid var(--border);
}
.nav-section { margin-bottom: 22px; }
.nav-title { padding: 0 10px 6px; font-size: 13px; font-weight: 700; color: var(--text); }
.nav-link {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: 8px;
  color: var(--text-muted); text-decoration: none; font-size: 14px; line-height: 1.4;
}
.nav-link:hover { color: var(--text); background: var(--bg-hover); }
.nav-link.active { color: var(--text); background: var(--bg-active); font-weight: 600; }
.badge {
  font-size: 10px; font-weight: 700; padding: 1px 6px; border-radius: 999px;
  color: #fb923c; background: rgba(251, 146, 60, 0.12); border: 1px solid rgba(251, 146, 60, 0.35);
}
.content { min-width: 0; padding: 40px 56px 32px; }
body.home .content { padding: 40px 48px 32px; }

/* ── Article ───────────────────────────────────────────── */
.prose { max-width: 780px; }
body.home .prose { max-width: 1040px; margin: 0 auto; }
.prose h1 { font: 700 40px/1.15 Satoshi, Inter, sans-serif; letter-spacing: -0.02em; margin: 0 0 12px; }
.prose h2 { font: 700 24px/1.3 Satoshi, Inter, sans-serif; margin: 44px 0 12px; padding-top: 8px; }
.prose h3 { font-size: 17px; font-weight: 650; margin: 28px 0 8px; }
.prose h1 .anchor, .prose h2 .anchor, .prose h3 .anchor { display: none; }
.prose h2:hover .anchor, .prose h3:hover .anchor {
  display: inline; margin-left: -1em; padding-right: 0.25em; color: var(--text-muted); text-decoration: none;
}
.prose p, .prose li { color: var(--text-soft); }
.prose strong { color: var(--text); font-weight: 650; }
.prose a { color: var(--accent); text-decoration: none; }
.prose a:hover { text-decoration: underline; }
.prose ul, .prose ol { padding-left: 1.3em; }
.prose li { margin: 4px 0; }
.prose li > p { margin: 4px 0; }
.prose code {
  font: 0.88em ui-monospace, SFMono-Regular, Menlo, monospace;
  background: var(--code-bg); border: 1px solid var(--border); border-radius: 6px; padding: 1px 6px; color: var(--text);
}
.prose pre { background: var(--code-bg); border: 1px solid var(--border); border-radius: 12px; padding: 14px 16px; overflow-x: auto; }
.prose pre code { border: 0; padding: 0; background: none; }
.prose hr { border: 0; border-top: 1px solid var(--border); margin: 36px 0; }
.prose img { display: block; border: 1px solid var(--border); border-radius: 14px; margin: 18px 0; box-shadow: var(--shadow); }
.prose .lead { font-size: 18px; color: var(--text-soft); margin: 0 0 24px; }
.table-wrap { overflow-x: auto; margin: 16px 0; border: 1px solid var(--border); border-radius: 12px; }
.prose table { width: 100%; border-collapse: collapse; font-size: 14px; }
.prose th, .prose td { padding: 10px 14px; text-align: left; border-bottom: 1px solid var(--border); vertical-align: top; }
.prose th { color: var(--text); font-weight: 650; background: var(--bg-raised); }
.prose tr:last-child td { border-bottom: 0; }
.prose td:first-child { white-space: nowrap; }
.callout {
  margin: 18px 0; padding: 12px 16px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg-raised);
}
.callout p { margin: 4px 0; }
.callout-tip { border-color: rgba(59, 130, 246, 0.4); background: var(--accent-soft); }
.callout-warning { border-color: rgba(251, 146, 60, 0.45); background: rgba(251, 146, 60, 0.08); }

/* ── Home: hero + cards ────────────────────────────────── */
.hero {
  display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.1fr); gap: 32px; align-items: center;
  padding: 40px; margin-bottom: 56px;
  background: var(--bg-raised); border: 1px solid var(--border); border-radius: 28px;
}
.hero h1 { font-size: 46px; margin-bottom: 14px; }
.hero h1 .dim { color: var(--text-muted); display: block; }
.hero p { font-size: 17px; }
.hero img { margin: 0; border-radius: 16px; }
.hero-actions { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 22px; }
.btn {
  display: inline-flex; align-items: center; gap: 6px; height: 40px; padding: 0 16px;
  border-radius: 999px; border: 1px solid var(--border-strong); color: var(--text) !important;
  font-weight: 600; font-size: 14px; text-decoration: none !important;
}
.btn:hover { background: var(--bg-hover); }
.btn.primary { background: var(--cta-bg); color: var(--cta-text) !important; border-color: var(--cta-bg); }
.btn.primary:hover { opacity: 0.9; background: var(--cta-bg); }
.cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 16px; margin: 18px 0 48px; }
.card {
  display: flex; flex-direction: column; gap: 6px;
  padding: 22px; border-radius: 22px;
  background: var(--bg-raised); border: 1px solid var(--border);
  color: var(--text) !important; text-decoration: none !important;
  transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--border-strong); transform: translateY(-2px); }
.card strong { font-size: 17px; }
.card span { color: var(--text-muted); font-size: 14px; }
.card .meta { margin-top: auto; padding-top: 14px; border-top: 1px solid var(--border); display: flex; justify-content: space-between; font-size: 13px; }

/* ── Outline + pager + footer ──────────────────────────── */
.toc { position: sticky; top: 64px; height: calc(100vh - 64px); overflow-y: auto; padding: 40px 16px 40px 8px; font-size: 13px; }
.toc-title { font-weight: 700; color: var(--text); margin-bottom: 8px; }
.toc-link { display: block; padding: 4px 0; color: var(--text-muted); text-decoration: none; line-height: 1.35; }
.toc-link.depth-3 { padding-left: 12px; }
.toc-link:hover, .toc-link.active { color: var(--text); }
.pager { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; max-width: 780px; margin-top: 56px; }
.pager-link {
  display: flex; flex-direction: column; gap: 2px; padding: 14px 16px;
  border: 1px solid var(--border); border-radius: 14px; text-decoration: none; font-weight: 600;
}
.pager-link span { font-size: 12px; font-weight: 500; color: var(--text-muted); }
.pager-link:hover { border-color: var(--border-strong); background: var(--bg-raised); }
.pager-link.next { text-align: right; }
.docs-footer { display: flex; gap: 18px; max-width: 780px; margin-top: 48px; padding-top: 20px; border-top: 1px solid var(--border); font-size: 13px; color: var(--text-muted); }
.docs-footer a { color: var(--text-muted); text-decoration: none; }
.docs-footer a:hover { color: var(--text); }

/* ── Search ────────────────────────────────────────────── */
.search-modal { position: fixed; inset: 0; z-index: 100; display: flex; justify-content: center; padding-top: 12vh; }
.search-modal[hidden] { display: none; }
.search-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.6); backdrop-filter: blur(4px); }
.search-panel {
  position: relative; width: min(640px, calc(100vw - 32px)); max-height: 70vh; display: flex; flex-direction: column;
  background: var(--bg-raised); border: 1px solid var(--border-strong); border-radius: 16px; box-shadow: var(--shadow); overflow: hidden;
}
.search-field { display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border); color: var(--text-muted); }
.search-field input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--text); font: inherit; font-size: 16px; }
.search-results { list-style: none; margin: 0; padding: 8px; overflow-y: auto; }
.search-results li a { display: block; padding: 10px 12px; border-radius: 10px; text-decoration: none; }
.search-results li a .r-title { font-weight: 600; color: var(--text); }
.search-results li a .r-section { font-size: 12px; color: var(--text-muted); }
.search-results li a .r-snippet { display: block; font-size: 13px; color: var(--text-muted); margin-top: 2px; }
.search-results li a mark { background: var(--accent-soft); color: var(--text); border-radius: 3px; }
.search-results li.selected a, .search-results li a:hover { background: var(--bg-active); }
.search-empty { padding: 18px; color: var(--text-muted); text-align: center; }

/* ── Responsive ────────────────────────────────────────── */
@media (max-width: 1200px) {
  .shell { grid-template-columns: 240px minmax(0, 1fr); }
  .toc { display: none; }
  .tabs { display: none; }
  .top-actions { margin-left: auto; }
}
@media (max-width: 860px) {
  .menu-btn { display: inline-flex; }
  .shell, body.home .shell { grid-template-columns: minmax(0, 1fr); }
  .sidebar {
    position: fixed; top: 64px; left: 0; bottom: 0; width: 280px; height: auto; z-index: 30;
    background: var(--bg); transform: translateX(-100%); transition: transform 0.2s ease; box-shadow: var(--shadow);
  }
  body.nav-open .sidebar { transform: none; }
  .content, body.home .content { padding: 28px 18px; }
  .search-btn { min-width: 0; }
  .search-btn span, .search-btn kbd { display: none; }
  .hero { grid-template-columns: 1fr; padding: 26px; }
  .hero h1 { font-size: 34px; }
  .cards { grid-template-columns: 1fr; }
  .prose h1 { font-size: 32px; }
  .brand-docs { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  .card, .sidebar { transition: none; }
}
