/* CHVEX Docs - Dark Tech Premium. No external requests. */
@font-face {
  font-family: "Inter";
  src: url("/assets/fonts/inter-latin-wght-normal.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #050b18;
  --bg2: #0d1b32;
  --surface: #142d4e;
  --primary: #008cff;
  --accent: #18c8ff;
  --text: #f8fafc;
  --muted: #94a3b8;
  --line: #1f3a63;
  --radius: 12px;
  --topbar-h: 64px;
  --sidebar-w: 280px;
  --toc-w: 230px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }
html { scroll-padding-top: calc(var(--topbar-h) + 16px); -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  font-size: 1rem;
  line-height: 1.7;
}
img { max-width: 100%; height: auto; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: #fff; }
:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; border-radius: 4px; }
:target { scroll-margin-top: calc(var(--topbar-h) + 16px); }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip {
  position: absolute; left: 8px; top: -60px; z-index: 100;
  background: var(--accent); color: var(--bg); padding: 10px 16px; border-radius: 8px; font-weight: 600;
}
.skip:focus { top: 8px; }

kbd {
  font: 600 0.75rem/1 "Inter", sans-serif;
  background: var(--bg2); color: var(--muted);
  border: 1px solid var(--line); border-radius: 6px; padding: 3px 7px;
}

/* ---------- top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 50; height: var(--topbar-h);
  display: flex; align-items: center; gap: 16px; padding: 0 20px;
  background: rgba(5, 11, 24, 0.94); border-bottom: 1px solid var(--line);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; flex: none; }
.brand img { display: block; }
.brand-sub { color: var(--muted); font-weight: 600; font-size: 0.9rem; border-left: 1px solid var(--line); padding-left: 10px; }
.toplinks { margin-left: auto; }
.toplinks ul { display: flex; gap: 4px; list-style: none; margin: 0; padding: 0; }
.toplinks a {
  display: block; padding: 8px 12px; border-radius: 8px; color: var(--text);
  text-decoration: none; font-size: 0.9rem; font-weight: 500;
}
.toplinks a:hover { background: var(--surface); }
.toplinks li:last-child a { background: var(--primary); color: var(--bg); font-weight: 600; }
.toplinks li:last-child a:hover { background: var(--accent); color: var(--bg); }

.menu-btn {
  display: none; flex: none; width: 44px; height: 44px; align-items: center; justify-content: center;
  background: transparent; border: 1px solid var(--line); border-radius: 10px; color: var(--text); cursor: pointer;
}
.menu-icon, .menu-icon::before, .menu-icon::after {
  display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; content: "";
}
.menu-icon { position: relative; }
.menu-icon::before { position: absolute; top: -6px; }
.menu-icon::after { position: absolute; top: 6px; }

/* ---------- search ---------- */
.search { position: relative; flex: 1 1 320px; max-width: 420px; }
.search input {
  width: 100%; height: 42px; padding: 0 40px 0 14px; font: inherit; font-size: 0.95rem;
  color: var(--text); background: var(--bg2); border: 1px solid var(--line); border-radius: 10px;
}
.search input::placeholder { color: var(--muted); opacity: 1; }
.search input:focus { border-color: var(--accent); outline: 2px solid var(--accent); outline-offset: 0; }
.search-key { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); pointer-events: none; }
.results {
  position: absolute; left: 0; right: 0; top: calc(100% + 8px); z-index: 60;
  list-style: none; margin: 0; padding: 6px; max-height: min(70vh, 480px); overflow: auto;
  background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
}
.results[hidden] { display: none; }
.results a { display: block; padding: 10px 12px; border-radius: 8px; text-decoration: none; color: var(--text); }
.results a:hover, .results a.active { background: var(--surface); }
.res-cat { display: block; font-size: 0.75rem; color: var(--muted); text-transform: uppercase; letter-spacing: 0.04em; }
.res-title { display: block; font-weight: 600; }
.res-snip { display: block; font-size: 0.85rem; color: var(--muted); line-height: 1.5; margin-top: 2px; }
.res-empty { padding: 12px; color: var(--muted); font-size: 0.9rem; }
mark { background: rgba(24, 200, 255, 0.22); color: #fff; border-radius: 3px; padding: 0 2px; }

/* ---------- layout ---------- */
.layout { display: flex; align-items: flex-start; }
.sidebar {
  position: sticky; top: var(--topbar-h); flex: none; width: var(--sidebar-w);
  height: calc(100vh - var(--topbar-h)); overflow-y: auto; padding: 24px 16px 40px 20px;
  border-right: 1px solid var(--line); background: var(--bg);
}
.cat { margin-bottom: 22px; }
.cat-title { margin: 0 0 6px; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); font-weight: 700; }
.cat-title a { color: inherit; text-decoration: none; }
.cat-title a:hover { color: var(--text); }
.cat ul { list-style: none; margin: 0; padding: 0; }
.cat li a {
  display: block; padding: 6px 10px; margin-left: -10px; border-radius: 8px;
  color: #cbd5e1; text-decoration: none; font-size: 0.92rem; line-height: 1.4;
}
.cat li a:hover { background: var(--bg2); color: var(--text); }
.cat li a[aria-current="page"] { background: var(--surface); color: #fff; font-weight: 600; }
.drawer-links { display: none; }

.content-col { flex: 1; min-width: 0; display: flex; flex-direction: column; min-height: calc(100vh - var(--topbar-h)); }
main { flex: 1; padding: 40px 32px 24px; }
main:focus { outline: none; }
.doc-grid { display: flex; gap: 40px; max-width: 1060px; margin: 0 auto; }
.doc { flex: 1; min-width: 0; max-width: 760px; }
.toc {
  flex: none; width: var(--toc-w); position: sticky; top: calc(var(--topbar-h) + 24px);
  align-self: flex-start; max-height: calc(100vh - var(--topbar-h) - 48px); overflow-y: auto; font-size: 0.85rem;
}
.toc h2 { font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); margin: 0 0 8px; }
.toc ul { list-style: none; margin: 0; padding: 0; border-left: 1px solid var(--line); }
.toc a { display: block; padding: 4px 12px; color: var(--muted); text-decoration: none; line-height: 1.4; margin-left: -1px; border-left: 2px solid transparent; }
.toc a:hover { color: var(--text); }
.toc a.active { color: var(--accent); border-left-color: var(--accent); }
.toc .toc-l3 a { padding-left: 26px; }
.toc-inline { display: none; margin: 0 0 24px; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius); padding: 10px 16px; }
.toc-inline summary { cursor: pointer; font-weight: 600; }
.toc-inline ul { margin: 8px 0 4px; padding-left: 18px; }

/* ---------- typography ---------- */
h1 { font-size: 2.1rem; line-height: 1.2; margin: 0 0 12px; letter-spacing: -0.02em; }
.lead { font-size: 1.1rem; color: var(--muted); margin: 0 0 28px; }
.prose h2 { font-size: 1.5rem; line-height: 1.3; margin: 2.2em 0 0.6em; padding-top: 0.4em; border-top: 1px solid var(--line); letter-spacing: -0.01em; }
.prose h2:first-child { border-top: 0; margin-top: 0; }
.prose h3 { font-size: 1.15rem; margin: 1.8em 0 0.5em; }
.prose h4 { font-size: 1rem; margin: 1.5em 0 0.4em; }
.prose p, .prose ul, .prose ol, .prose pre, .prose .table-wrap, .prose .callout { margin: 0 0 1.1em; }
.prose ul, .prose ol { padding-left: 1.4em; }
.prose li { margin: 0.3em 0; }
.prose li > ul, .prose li > ol { margin: 0.3em 0; }
.anchor {
  margin-left: 8px; font-weight: 400; text-decoration: none; color: var(--muted); opacity: 0;
}
h2:hover .anchor, h3:hover .anchor, h4:hover .anchor, .anchor:focus { opacity: 1; }
code {
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace; font-size: 0.88em;
  background: var(--bg2); border: 1px solid var(--line); border-radius: 6px; padding: 1px 6px;
}
pre {
  position: relative; background: var(--bg2); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px; overflow-x: auto; line-height: 1.55;
}
pre code { background: none; border: 0; padding: 0; font-size: 0.88rem; }
.copy-btn {
  position: absolute; top: 8px; right: 8px; font: inherit; font-size: 0.75rem; font-weight: 600;
  color: var(--text); background: var(--surface); border: 1px solid var(--line); border-radius: 6px; padding: 4px 10px; cursor: pointer;
}
.copy-btn:hover { border-color: var(--accent); }
hr { border: 0; border-top: 1px solid var(--line); margin: 2em 0; }
blockquote { margin: 0 0 1.1em; padding: 4px 16px; border-left: 3px solid var(--line); color: var(--muted); }

.table-wrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--radius); }
table { border-collapse: collapse; width: 100%; font-size: 0.93rem; }
th, td { text-align: left; padding: 10px 14px; border-bottom: 1px solid var(--line); vertical-align: top; }
th { background: var(--bg2); font-weight: 600; white-space: nowrap; }
tr:last-child td { border-bottom: 0; }

.callout { border-radius: var(--radius); padding: 14px 18px; background: var(--bg2); border: 1px solid var(--line); border-left: 4px solid var(--primary); }
.callout p { margin: 0 0 0.6em; }
.callout p:last-child { margin-bottom: 0; }
.callout-title { font-weight: 700; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--accent); }
.callout-tip { border-left-color: #34d399; }
.callout-tip .callout-title { color: #6ee7b7; }
.callout-warning, .callout-important { border-left-color: #fbbf24; }
.callout-warning .callout-title, .callout-important .callout-title { color: #fcd34d; }

.crumbs { font-size: 0.85rem; margin-bottom: 16px; }
.crumbs ol { display: flex; flex-wrap: wrap; gap: 6px; list-style: none; margin: 0; padding: 0; color: var(--muted); }
.crumbs li + li::before { content: "/"; margin-right: 6px; color: var(--line); }
.crumbs a { color: var(--muted); }
.crumbs a:hover { color: var(--text); }
.meta { color: var(--muted); font-size: 0.88rem; margin: 40px 0 24px; padding-top: 16px; border-top: 1px solid var(--line); }
.pager { display: flex; gap: 16px; justify-content: space-between; }
.pager a {
  flex: 1; max-width: 48%; display: block; padding: 14px 18px; border: 1px solid var(--line);
  border-radius: var(--radius); background: var(--bg2); text-decoration: none; color: var(--text); font-weight: 600;
}
.pager a:hover { border-color: var(--accent); }
.pager a span { display: block; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--muted); font-weight: 600; }
.pager-next { text-align: right; margin-left: auto; }

/* ---------- home & cards ---------- */
.hero { max-width: 760px; margin: 0 auto; padding: 32px 0 24px; text-align: center; }
.hero h1 { font-size: 2.6rem; }
.hero .search { max-width: 560px; margin: 0 auto; text-align: left; }
.hero .search input { height: 54px; font-size: 1.05rem; border-radius: 14px; padding-left: 18px; }
.hero-hint { color: var(--muted); font-size: 0.85rem; margin-top: 14px; }
.home-section, .page-narrow { max-width: 960px; margin: 0 auto; }
.home-section { margin-top: 48px; }
.home-section h2 { font-size: 1.3rem; margin: 0 0 16px; }
.card-grid, .card-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 16px; }
.card-grid { grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); }
.card-list { grid-template-columns: 1fr; margin-top: 24px; }
.card {
  display: flex; flex-direction: column; gap: 6px; height: 100%; padding: 20px;
  background: linear-gradient(160deg, var(--bg2), var(--bg)); border: 1px solid var(--line);
  border-radius: 14px; text-decoration: none; color: var(--text); transition: border-color 0.15s, transform 0.15s;
}
.card:hover { border-color: var(--accent); transform: translateY(-2px); }
.card-title { font-size: 1.1rem; font-weight: 700; }
.card-desc { color: var(--muted); font-size: 0.93rem; line-height: 1.55; }
.card-count { margin-top: auto; padding-top: 8px; color: var(--accent); font-size: 0.82rem; font-weight: 600; }
.link-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 4px; }
.link-list a { display: block; padding: 10px 14px; border-radius: 10px; background: var(--bg2); text-decoration: none; }
.link-list a:hover { background: var(--surface); color: #fff; }
.help-cta { background: var(--bg2); border: 1px solid var(--line); border-radius: 16px; padding: 28px; }
.help-cta h2 { margin-bottom: 8px; }
.help-cta p { color: var(--muted); margin: 0 0 16px; }
.btn {
  display: inline-block; padding: 10px 20px; margin: 0 8px 8px 0; border-radius: 10px;
  background: var(--primary); color: var(--bg); font-weight: 700; text-decoration: none;
}
.btn:hover { background: var(--accent); color: var(--bg); }
.btn-ghost { background: transparent; color: var(--text); border: 1px solid var(--line); }
.btn-ghost:hover { background: var(--surface); color: #fff; }

.site-footer { padding: 28px 32px 40px; border-top: 1px solid var(--line); color: var(--muted); font-size: 0.85rem; }
.site-footer p { margin: 0 0 8px; max-width: 760px; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }

/* ---------- responsive ---------- */
@media (max-width: 1180px) {
  .toc { display: none; }
  .toc-inline { display: block; }
}
@media (max-width: 960px) {
  .menu-btn { display: inline-flex; }
  .toplinks { display: none; }
  .drawer-links { display: block; }
  .search { max-width: none; margin-left: auto; }
  .layout { display: block; }
  .js .sidebar {
    position: fixed; z-index: 70; top: 0; left: 0; bottom: 0; height: 100%; width: min(86vw, 320px);
    padding-top: 24px; background: var(--bg2); transform: translateX(-100%); visibility: hidden;
    transition: transform 0.2s ease, visibility 0.2s;
  }
  .js .nav-open .sidebar { transform: none; visibility: visible; }
  .scrim { position: fixed; inset: 0; z-index: 65; background: rgba(0, 0, 0, 0.6); }
  .scrim[hidden] { display: none; }
  .js .nav-open { overflow: hidden; }
  .sidebar { border-right: 0; border-bottom: 1px solid var(--line); position: static; width: auto; height: auto; }
  .js .sidebar { border-bottom: 0; border-right: 1px solid var(--line); }
  main { padding: 28px 16px 16px; }
  .site-footer { padding: 24px 16px 32px; }
}
@media (max-width: 560px) {
  .brand-sub { display: none; }
  .topbar { padding: 0 12px; gap: 10px; }
  h1 { font-size: 1.7rem; }
  .hero h1 { font-size: 2rem; }
  .pager { flex-direction: column; }
  .pager a { max-width: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
  .card:hover { transform: none; }
}
