/* docs.hiveloom.cloud — hand-written, no framework. */

:root {
  --bg: #0a0e14;
  --bg-elevated: #0f1419;
  --bg-code: #0d1117;
  --border: #1c2531;
  --border-subtle: #151b23;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --text-faint: #6e7681;
  --accent: #56d4ff;
  --accent-dim: #2a9fd6;
  --font-sans: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, sans-serif;
  --font-mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  --sidebar-w: 250px;
  --toc-w: 210px;
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #ffffff;
    --bg-elevated: #f6f8fa;
    --bg-code: #f6f8fa;
    --border: #d8dee4;
    --border-subtle: #eaeef2;
    --text: #1f2328;
    --text-dim: #59636e;
    --text-faint: #818b98;
    --accent: #0969da;
    --accent-dim: #0550ae;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: 5rem; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.65;
  -webkit-font-smoothing: antialiased;
}

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

.skip {
  position: absolute;
  left: -9999px;
}
.skip:focus {
  left: 1rem;
  top: 1rem;
  z-index: 100;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
}

/* ---------------------------------------------------------------- topbar */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  height: 3.5rem;
  padding: 0 1.5rem;
  background: color-mix(in srgb, var(--bg) 88%, transparent);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-subtle);
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 600;
  letter-spacing: -0.01em;
}
.brand:hover { text-decoration: none; }
.brand img { display: block; border-radius: 4px; }

.badge {
  font-size: 0.7rem;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 0.05rem 0.45rem;
}

.topnav {
  margin-left: auto;
  display: flex;
  gap: 1.25rem;
  font-size: 0.9rem;
}
.topnav a { color: var(--text-dim); }
.topnav a:hover { color: var(--text); text-decoration: none; }

.menu-toggle {
  display: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  border-radius: 6px;
  padding: 0.3rem 0.65rem;
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}

/* ---------------------------------------------------------------- shell */

.shell {
  display: grid;
  grid-template-columns: var(--sidebar-w) minmax(0, 1fr) var(--toc-w);
  gap: 2.5rem;
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.5rem;
}

.sidebar {
  position: sticky;
  top: 3.5rem;
  align-self: start;
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 2rem 0 3rem;
}

.nav-section + .nav-section { margin-top: 1.75rem; }

.nav-title {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-faint);
}

.sidebar ul, .toc ul { list-style: none; margin: 0; padding: 0; }

.sidebar li a {
  display: block;
  padding: 0.3rem 0.7rem;
  margin-left: -0.7rem;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 0.9rem;
}
.sidebar li a:hover { color: var(--text); background: var(--bg-elevated); text-decoration: none; }
.sidebar li a.active { color: var(--accent); background: var(--bg-elevated); font-weight: 500; }

.toc {
  position: sticky;
  top: 3.5rem;
  align-self: start;
  max-height: calc(100vh - 3.5rem);
  overflow-y: auto;
  padding: 2rem 0 3rem;
  border-left: 1px solid var(--border-subtle);
  padding-left: 1.25rem;
}
.toc li a {
  display: block;
  padding: 0.2rem 0;
  color: var(--text-dim);
  font-size: 0.82rem;
  line-height: 1.4;
}
.toc li a:hover { color: var(--accent); text-decoration: none; }

main { min-width: 0; padding: 2rem 0 4rem; }

/* ---------------------------------------------------------------- prose */

.prose { max-width: 46rem; }

.prose h1 {
  margin: 0 0 1.5rem;
  font-size: 2.1rem;
  line-height: 1.2;
  letter-spacing: -0.02em;
  font-weight: 650;
}

.prose h2 {
  margin: 3rem 0 1rem;
  padding-top: 0.5rem;
  font-size: 1.4rem;
  letter-spacing: -0.01em;
  font-weight: 600;
  border-top: 1px solid var(--border-subtle);
}

.prose h3 { margin: 2rem 0 0.75rem; font-size: 1.1rem; font-weight: 600; }
.prose h4 { margin: 1.5rem 0 0.5rem; font-size: 0.98rem; font-weight: 600; }

.anchor {
  margin-left: 0.4rem;
  color: var(--text-faint);
  opacity: 0;
  font-weight: 400;
  text-decoration: none;
}
h2:hover .anchor, h3:hover .anchor { opacity: 1; }

.prose p { margin: 0 0 1.1rem; }
.prose ul, .prose ol { margin: 0 0 1.1rem; padding-left: 1.4rem; }
.prose li { margin: 0.3rem 0; }
.prose li > ul, .prose li > ol { margin: 0.3rem 0; }

.prose strong { font-weight: 620; color: var(--text); }

.prose blockquote {
  margin: 1.25rem 0;
  padding: 0.75rem 1.1rem;
  border-left: 3px solid var(--accent-dim);
  background: var(--bg-elevated);
  border-radius: 0 6px 6px 0;
  color: var(--text-dim);
}
.prose blockquote p:last-child { margin-bottom: 0; }

.prose img {
  max-width: 100%;
  height: auto;
  display: block;
  margin: 1.5rem 0;
  border: 1px solid var(--border-subtle);
  border-radius: 8px;
  background: #fff;
}

.prose hr { border: 0; border-top: 1px solid var(--border-subtle); margin: 2.5rem 0; }

/* code */

.prose code {
  font-family: var(--font-mono);
  font-size: 0.86em;
  background: var(--bg-elevated);
  border: 1px solid var(--border-subtle);
  border-radius: 5px;
  padding: 0.1em 0.35em;
}

pre.code {
  margin: 0 0 1.25rem;
  padding: 1rem 1.1rem;
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.85rem;
  line-height: 1.6;
}
pre.code code {
  background: none;
  border: 0;
  padding: 0;
  font-size: inherit;
}

/* tables */

.table-wrap, .prose table { }
.prose table {
  display: block;
  width: 100%;
  overflow-x: auto;
  border-collapse: collapse;
  margin: 0 0 1.5rem;
  font-size: 0.88rem;
}
.prose th, .prose td {
  border: 1px solid var(--border);
  padding: 0.5rem 0.75rem;
  text-align: left;
  white-space: nowrap;
}
.prose th { background: var(--bg-elevated); font-weight: 600; }
.prose td:first-child, .prose th:first-child { white-space: normal; }

/* ---------------------------------------------------------------- pager */

.pager {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
  max-width: 46rem;
  margin-top: 3.5rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--border-subtle);
}
.pager a {
  display: block;
  flex: 0 1 48%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-weight: 500;
  font-size: 0.92rem;
}
.pager a:hover { border-color: var(--accent-dim); text-decoration: none; }
.pager a span { display: block; font-size: 0.75rem; font-weight: 400; color: var(--text-faint); }
.pager-next { text-align: right; margin-left: auto; }

.pagefoot {
  max-width: 46rem;
  margin-top: 2rem;
  font-size: 0.82rem;
  color: var(--text-faint);
}
.pagefoot a { color: var(--text-dim); }

/* ---------------------------------------------------------------- hljs */

.hljs-comment, .hljs-quote { color: var(--text-faint); font-style: italic; }
.hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #ff7b72; }
.hljs-string, .hljs-meta .hljs-string { color: #a5d6ff; }
.hljs-number, .hljs-symbol, .hljs-bullet { color: #79c0ff; }
.hljs-title, .hljs-section, .hljs-title.function_ { color: #d2a8ff; }
.hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #7ee787; }
.hljs-built_in, .hljs-class .hljs-title, .hljs-type { color: #ffa657; }
.hljs-meta { color: var(--text-dim); }
.hljs-emphasis { font-style: italic; }
.hljs-strong { font-weight: 600; }

@media (prefers-color-scheme: light) {
  .hljs-keyword, .hljs-selector-tag, .hljs-literal, .hljs-doctag { color: #cf222e; }
  .hljs-string, .hljs-meta .hljs-string { color: #0a3069; }
  .hljs-number, .hljs-symbol, .hljs-bullet { color: #0550ae; }
  .hljs-title, .hljs-section, .hljs-title.function_ { color: #8250df; }
  .hljs-attr, .hljs-attribute, .hljs-variable, .hljs-template-variable { color: #116329; }
  .hljs-built_in, .hljs-class .hljs-title, .hljs-type { color: #953800; }
}

/* ---------------------------------------------------------------- responsive */

@media (max-width: 1180px) {
  .shell { grid-template-columns: var(--sidebar-w) minmax(0, 1fr); }
  .toc { display: none; }
}

@media (max-width: 860px) {
  .shell { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .menu-toggle { display: block; }
  .topnav { margin-left: auto; }
  .sidebar {
    display: none;
    position: static;
    max-height: none;
    padding: 1.25rem 0;
    border-bottom: 1px solid var(--border-subtle);
  }
  body.nav-open .sidebar { display: block; }
  .prose h1 { font-size: 1.75rem; }
  .pager { flex-direction: column; }
  .pager a { flex: 1 1 auto; }
  .pager-next { text-align: left; margin-left: 0; }
}
