/*! zdoc default theme — a VitePress-style documentation layout.
 *
 * Three columns: a fixed sidebar of the current section's pages, the content,
 * and a sticky table of contents. Dark mode follows the OS preference.
 */

:root {
  --sidebar-width: 280px;
  --toc-width: 240px;
  --content-max: 780px;

  --bg: #ffffff;
  --bg-soft: #f7f8fa;
  --bg-code: #f6f8fa;
  --border: #e2e5e9;
  --text: #24292e;
  --text-dim: #57606a;
  --accent: #3451b2;
  --accent-soft: #e6ecff;
  --warn-bg: #fff8e6;
  --warn-border: #f0d68a;
  --warn-text: #7a5c00;

  /* Syntax tokens, keyed to the class names emitted by src/highlight.zig. */
  --tk-comment: #6a737d;
  --tk-keyword: #cf222e;
  --tk-string: #0a3069;
  --tk-number: #0550ae;
  --tk-function: #8250df;
  --tk-type: #953800;
  --tk-variable: #24292e;
  --tk-operator: #0550ae;
  --tk-builtin: #116329;
  --tk-constant: #0550ae;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #0d1117;
    --bg-soft: #161b22;
    --bg-code: #161b22;
    --border: #30363d;
    --text: #e6edf3;
    --text-dim: #9198a1;
    --accent: #7d9bff;
    --accent-soft: #1c2b52;
    --warn-bg: #2a2410;
    --warn-border: #6b5518;
    --warn-text: #e3c268;

    --tk-comment: #8b949e;
    --tk-keyword: #ff7b72;
    --tk-string: #a5d6ff;
    --tk-number: #79c0ff;
    --tk-function: #d2a8ff;
    --tk-type: #ffa657;
    --tk-variable: #e6edf3;
    --tk-operator: #79c0ff;
    --tk-builtin: #7ee787;
    --tk-constant: #79c0ff;
  }
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Noto Sans",
    "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", Helvetica, Arial,
    sans-serif;
  font-size: 16px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
}

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

a:hover {
  text-decoration: underline;
}

/* ---------- Layout ---------- */

.layout {
  display: flex;
  min-height: 100vh;
}

/* A landing page has no sidebar and no table of contents, so it centres its
   content instead of sitting in a column between them. */
.layout--bare {
  display: block;
}

.layout--bare .home {
  max-width: 896px;
  margin: 0 auto;
  padding: 0 24px 96px;
}

.sidebar {
  width: var(--sidebar-width);
  flex: 0 0 var(--sidebar-width);
  border-right: 1px solid var(--border);
  padding: 24px 16px 48px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar__title {
  font-size: 17px;
  font-weight: 600;
  margin: 0 0 4px;
  display: block;
  color: var(--text);
}

.sidebar__group {
  margin: 20px 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
}

.sidebar__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.sidebar__link {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
}

/* The sidebar is a flat list; the nesting depth is carried by the class the
   builder assigns, and turned into indentation here. */
a.sidebar__item {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text-dim);
  font-size: 14px;
}

/* A directory that has no index page: a label, not a link. */
span.sidebar__item {
  display: block;
  padding: 5px 10px;
  border-radius: 6px;
  color: var(--text);
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin-top: 8px;
}

.sidebar__item--d0 {
  padding-left: 10px;
}

.sidebar__item--d1 {
  padding-left: 24px;
}

.sidebar__item--d2 {
  padding-left: 38px;
}

.sidebar__item--d3 {
  padding-left: 52px;
}

.sidebar__link:hover,
a.sidebar__item:hover,
span.sidebar__item:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

a.sidebar__item:hover {
  text-decoration: none;
}

.sidebar__link.is-active,
.sidebar__item.is-active {
  background: var(--accent-soft);
  color: var(--accent);
  font-weight: 500;
}

.content {
  flex: 1 1 auto;
  min-width: 0;
  padding: 40px 48px 96px;
}

.doc {
  max-width: var(--content-max);
}

/* ---------- Table of contents ---------- */

.toc {
  width: var(--toc-width);
  flex: 0 0 var(--toc-width);
  padding: 40px 24px 48px 0;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  font-size: 13px;
}

.toc__title {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-dim);
  margin: 0 0 10px;
}

.toc ul {
  list-style: none;
  margin: 0;
  padding: 0;
  border-left: 1px solid var(--border);
}

.toc li {
  margin: 0;
}

.toc a {
  display: block;
  padding: 3px 0 3px 12px;
  margin-left: -1px;
  border-left: 2px solid transparent;
  color: var(--text-dim);
}

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

.toc a.is-active {
  color: var(--accent);
  border-left-color: var(--accent);
}

/* ---------- Headings ---------- */

.doc h1,
.doc h2,
.doc h3,
.doc h4,
.doc h5,
.doc h6 {
  line-height: 1.3;
  margin: 1.8em 0 0.8em;
  font-weight: 600;
  scroll-margin-top: 24px;
}

.doc h1 {
  margin-top: 0;
  font-size: 2em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.doc h2 {
  font-size: 1.5em;
  padding-bottom: 0.3em;
  border-bottom: 1px solid var(--border);
}

.doc h3 { font-size: 1.25em; }
.doc h4 { font-size: 1.05em; }

/* Anchor link revealed on hover, matching VitePress. */
.doc .header-anchor {
  float: left;
  margin-left: -0.9em;
  padding-right: 0.25em;
  opacity: 0;
  color: var(--text-dim);
  text-decoration: none;
}

.doc h1:hover .header-anchor,
.doc h2:hover .header-anchor,
.doc h3:hover .header-anchor,
.doc h4:hover .header-anchor,
.doc h5:hover .header-anchor,
.doc h6:hover .header-anchor,
.doc .header-anchor:focus {
  opacity: 1;
}

/* ---------- Content ---------- */

.doc p,
.doc ul,
.doc ol,
.doc blockquote,
.doc table,
.doc pre {
  margin: 1em 0;
}

.doc ul,
.doc ol {
  padding-left: 1.5em;
}

.doc blockquote {
  margin-left: 0;
  padding: 0.2em 1em;
  color: var(--text-dim);
  border-left: 3px solid var(--border);
}

.doc hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 2em 0;
}

.doc table {
  width: 100%;
  border-collapse: collapse;
  display: block;
  overflow-x: auto;
}

.doc th,
.doc td {
  border: 1px solid var(--border);
  padding: 6px 12px;
  text-align: left;
}

.doc th {
  background: var(--bg-soft);
  font-weight: 600;
}

.doc img {
  max-width: 100%;
}

.doc :not(pre) > code {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.1em 0.35em;
  font-size: 0.875em;
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
}

.doc pre {
  background: var(--bg-code);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 14px 16px;
  overflow-x: auto;
  line-height: 1.55;
}

.doc pre code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas,
    "Liberation Mono", monospace;
  font-size: 0.875em;
  background: none;
  border: none;
  padding: 0;
}

/* Task lists: SuperMD keeps `[ ]` markers as list items, so style the boxes
   when a checkbox is present. */
.doc li:has(> input[type="checkbox"]) {
  list-style: none;
  margin-left: -1.2em;
}

.doc input[type="checkbox"] {
  margin-right: 0.4em;
}

/* ---------- Syntax highlighting ---------- */

/* `highlight.zig` emits semantic tree-sitter token classes; these rules are
   language-agnostic so they cover zig, bash, sql and the rest alike. */
pre code .comment,
pre code .line_comment,
pre code .block_comment {
  color: var(--tk-comment);
  font-style: italic;
}

pre code .keyword,
pre code .operator,
pre code .punctuation,
pre code .tag {
  color: var(--tk-keyword);
}

pre code .string,
pre code .string_literal,
pre code .char_literal,
pre code .escape_sequence,
pre code .raw_string_literal {
  color: var(--tk-string);
}

pre code .number,
pre code .numeric_literal,
pre code .integer_literal,
pre code .float_literal,
pre code .integer,
pre code .float {
  color: var(--tk-number);
}

pre code .function,
pre code .function_call,
pre code .call_expression,
pre code .call {
  color: var(--tk-function);
}

pre code .type,
pre code .type_identifier,
pre code .primitive_type,
pre code .struct_item,
pre code .struct_type,
pre code .enum_item,
pre code .class_name {
  color: var(--tk-type);
}

pre code .variable,
pre code .identifier,
pre code .field_identifier,
pre code .property_identifier {
  color: var(--tk-variable);
}

pre code .builtin,
pre code .builtin_type,
pre code .predefined,
pre code .predefined_constant,
pre code .attribute {
  color: var(--tk-builtin);
}

pre code .constant,
pre code .boolean,
pre code .nil,
pre code .null {
  color: var(--tk-constant);
}

/* Mermaid blocks are rendered client-side, so keep them unstyled by the
   highlighter and let mermaid take over. */
pre.mermaid {
  background: transparent;
  border: none;
  text-align: center;
  overflow-x: auto;
}

/* Once mermaid has replaced the source with an <svg>, drop the code
   formatting entirely. */
pre.mermaid svg {
  max-width: 100%;
  height: auto;
}

.task-list-item {
  list-style: none;
}

.doc li.task-list-item {
  margin-left: -1.2em;
}

/* ---------- Small screens ---------- */

@media (max-width: 1100px) {
  .toc {
    display: none;
  }
}

@media (max-width: 800px) {
  .layout {
    display: block;
  }

  .sidebar {
    width: auto;
    flex: none;
    height: auto;
    position: static;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }

  .content {
    padding: 24px 20px 64px;
  }

  .doc .header-anchor {
    display: none;
  }
}
/* ---------------------------------------------------------------- home page
 *
 * Rendered for `layout: home`. The hero is the page's pitch; the feature
 * cards below it are the short list of what the thing does. Everything is
 * driven from frontmatter, so a home page is a block of YAML and nothing
 * else.
 */

.hero {
  padding: 64px 0 48px;
  text-align: center;
}

.hero__name {
  margin: 0 0 8px;
  font-size: 48px;
  line-height: 1.1;
  letter-spacing: -0.02em;
  border: 0;
}

.hero__text {
  margin: 0 0 8px;
  font-size: 24px;
  font-weight: 500;
  color: var(--text-dim);
}

.hero__tagline {
  margin: 0 auto;
  max-width: 640px;
  color: var(--text-dim);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
  margin-top: 28px;
}

.hero__action {
  display: inline-block;
  padding: 10px 22px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-weight: 600;
  text-decoration: none;
  color: var(--text);
  background: var(--bg);
}

.hero__action:hover {
  border-color: var(--accent);
  color: var(--accent);
}

.hero__action--brand {
  border-color: transparent;
  color: #ffffff;
  background: var(--accent);
}

.hero__action--brand:hover {
  color: #ffffff;
  filter: brightness(1.1);
}

/* `.feature-grid` is the loop container: `:loop` repeats its children, so
   the element carrying `:loop` is emitted once and the cards inside it are
   what repeat. It is a grid so the cards lay themselves out. */
.feature-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 16px;
  margin-bottom: 48px;
}

.feature {
  padding: 20px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-soft);
}

.feature__title {
  margin: 0 0 8px;
  font-size: 17px;
  border: 0;
}

.feature__details {
  margin: 0;
  color: var(--text-dim);
}

/* The body of a home page sits below the feature cards and reads as an
   ordinary document rather than as part of the pitch. */
.doc--home {
  margin: 0 auto;
}

@media (max-width: 640px) {
  .hero__name {
    font-size: 34px;
  }

  .hero__text {
    font-size: 19px;
  }
}

/* The last-updated line. Sits under the content, quiet on purpose: it is
   metadata, not part of the document. */
.doc__footer {
  max-width: var(--content-max);
  margin-top: 48px;
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.doc__updated {
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}

/* ------------------------------------------------------------------ search
 *
 * The input sits above the sidebar list. Results are absolutely positioned
 * over the sidebar rather than pushed into the document flow, so opening the
 * list does not reflow the page under the reader's cursor.
 */

.search {
  position: relative;
  margin: 12px 16px 16px;
}

.search__input {
  width: 100%;
  padding: 7px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font: inherit;
  font-size: 14px;
}

.search__input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.search__results {
  position: absolute;
  z-index: 20;
  left: 0;
  right: 0;
  max-height: 60vh;
  overflow-y: auto;
  margin: 4px 0 0;
  padding: 4px;
  list-style: none;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
}

.search__results[hidden] {
  display: none;
}

.search__result {
  display: block;
  padding: 7px 10px;
  border-radius: 4px;
  text-decoration: none;
  color: var(--text);
}

.search__result:hover,
.search__result:focus {
  background: var(--accent-soft);
}

.search__result-title {
  display: block;
  font-weight: 600;
  font-size: 14px;
}

.search__result-page {
  display: block;
  color: var(--text-dim);
  font-size: 12px;
  /* A long page title should not push the result list sideways. */
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.search__empty {
  padding: 7px 10px;
  color: var(--text-dim);
  font-size: 14px;
}

/* -------------------------------------------------------------- containers
 *
 * `::: tip` and friends render as SuperMD block directives, which produce
 * `<div class="block tip">`. The colour is on the container and the padding
 * on the body, so that a container with several paragraphs reads as one box
 * rather than as several bordered boxes.
 */

.block {
  margin: 16px 0;
  padding: 12px 16px;
  border-left: 3px solid var(--border);
  border-radius: 0 6px 6px 0;
  background: var(--bg-soft);
}

.block > :first-child {
  margin-top: 0;
}

.block > :last-child {
  margin-bottom: 0;
}

.block.tip,
.block.info {
  border-left-color: #3b82f6;
  background: #eff6ff;
}

.block.warning {
  border-left-color: #d97706;
  background: var(--warn-bg);
}

.block.danger {
  border-left-color: #dc2626;
  background: #fef2f2;
}

.block.note,
.block.details,
.block.tabs,
.block.code-group {
  border-left-color: var(--border);
}

@media (prefers-color-scheme: dark) {
  .block.tip,
  .block.info {
    background: #0d1f38;
  }

  .block.danger {
    background: #2d1416;
  }
}
