/*
 * Omnis documentation theme — shadcn/ui design system.
 *
 * The token block is the entire design surface: change a token and every component follows. Tokens
 * are bare HSL channels, the shadcn convention, so they compose with `hsl(var(--token) / <alpha>)`
 * without needing a second variable per opacity.
 */

/* ── Tokens ─────────────────────────────────────────────────────────────── */

:root,
[data-theme="light"] {
  --background: 0 0% 100%;
  --foreground: 240 10% 3.9%;
  --card: 0 0% 100%;
  --muted: 240 4.8% 95.9%;
  --muted-foreground: 240 3.8% 46.1%;
  --accent: 240 4.8% 95.9%;
  --accent-foreground: 240 5.9% 10%;
  --primary: 240 5.9% 10%;
  --primary-foreground: 0 0% 98%;
  --border: 240 5.9% 90%;
  --ring: 240 5.9% 10%;
  --destructive: 0 84% 60%;
  --success: 142 71% 45%;
  --warning: 38 92% 50%;
  --info: 221 83% 53%;
  --shadow: 240 5.9% 10%;
}

[data-theme="dark"] {
  --background: 240 10% 3.9%;
  --foreground: 0 0% 98%;
  --card: 240 10% 5.9%;
  --muted: 240 3.7% 15.9%;
  --muted-foreground: 240 5% 64.9%;
  --accent: 240 3.7% 15.9%;
  --accent-foreground: 0 0% 98%;
  --primary: 0 0% 98%;
  --primary-foreground: 240 5.9% 10%;
  --border: 240 3.7% 15.9%;
  --ring: 240 4.9% 83.9%;
  --destructive: 0 63% 51%;
  --success: 142 69% 58%;
  --warning: 38 92% 60%;
  --info: 213 94% 68%;
  --shadow: 0 0% 0%;
}

:root {
  --font-sans: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "Cascadia Code", Menlo, monospace;
  --radius: 0.5rem;
  --header-height: 3.5rem;
  --sidebar-width: 17rem;
  --toc-width: 15rem;
  --content-max: 46rem;
}

/* ── Reset ──────────────────────────────────────────────────────────────── */

*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; scroll-padding-top: calc(var(--header-height) + 1rem); }

body {
  margin: 0;
  background: hsl(var(--background));
  color: hsl(var(--foreground));
  font-family: var(--font-sans);
  font-size: 15px;
  line-height: 1.7;
  -webkit-font-smoothing: antialiased;
  font-feature-settings: "cv02", "cv03", "cv04", "cv11";
}

svg { width: 1rem; height: 1rem; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: hsl(var(--primary)); color: hsl(var(--primary-foreground));
  padding: 0.5rem 1rem; border-radius: var(--radius);
}
.skip-link:focus { left: 1rem; top: 1rem; }

/* ── Header ─────────────────────────────────────────────────────────────── */

.header {
  position: sticky; top: 0; z-index: 40;
  height: var(--header-height);
  background: hsl(var(--background) / 0.8);
  border-bottom: 1px solid hsl(var(--border));
  backdrop-filter: saturate(180%) blur(12px);
}

.header__inner {
  display: flex; align-items: center; gap: 1rem;
  height: 100%; padding: 0 1.25rem; max-width: 100rem; margin: 0 auto;
}

.header__brand {
  display: flex; align-items: center; gap: 0.55rem;
  color: inherit; text-decoration: none; font-weight: 600; letter-spacing: -0.015em;
  flex-shrink: 0;
}

/* A rounded square outline with a solid core: a cell, reduced to a mark. Drawn from tokens with
   borders rather than a mask, so it needs no colour literal and inverts with the palette. */
.header__mark {
  position: relative;
  width: 1.05rem; height: 1.05rem;
  border: 1.5px solid hsl(var(--foreground));
  border-radius: 4px;
}
.header__mark::after {
  content: ""; position: absolute; inset: 3px;
  background: hsl(var(--foreground)); border-radius: 1px;
}

.header__search { position: relative; flex: 1; max-width: 26rem; margin-left: auto; }

.header__search input {
  width: 100%; height: 2.1rem;
  padding: 0 2.2rem 0 2.1rem;
  font: inherit; font-size: 0.83rem;
  color: hsl(var(--foreground));
  background: hsl(var(--muted));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  outline: none;
  transition: border-color 120ms ease, box-shadow 120ms ease;
}
.header__search input::placeholder { color: hsl(var(--muted-foreground)); }
.header__search input:focus {
  border-color: hsl(var(--ring) / 0.5);
  box-shadow: 0 0 0 3px hsl(var(--ring) / 0.12);
}
.header__search input::-webkit-search-cancel-button { display: none; }

.header__search-icon {
  position: absolute; left: 0.65rem; top: 50%; transform: translateY(-50%);
  color: hsl(var(--muted-foreground)); pointer-events: none;
}

.header__kbd {
  position: absolute; right: 0.5rem; top: 50%; transform: translateY(-50%);
  font-family: var(--font-mono); font-size: 0.68rem; line-height: 1;
  color: hsl(var(--muted-foreground));
  background: hsl(var(--background));
  border: 1px solid hsl(var(--border)); border-radius: 4px;
  padding: 0.18rem 0.32rem; pointer-events: none;
}

.header__actions { display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }

.icon-button {
  display: inline-flex; align-items: center; justify-content: center;
  width: 2.1rem; height: 2.1rem; padding: 0;
  color: hsl(var(--muted-foreground));
  background: transparent; border: 1px solid transparent; border-radius: var(--radius);
  cursor: pointer; transition: background-color 120ms ease, color 120ms ease;
}
.icon-button:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }

.header__menu { display: none; }
[data-theme="dark"] .icon-sun,
[data-theme="light"] .icon-moon { display: none; }

/* ── Search results ─────────────────────────────────────────────────────── */

.search-results {
  position: absolute; top: calc(100% + 0.4rem); left: 0; right: 0;
  max-height: 24rem; overflow-y: auto;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  box-shadow: 0 12px 32px -8px hsl(var(--shadow) / 0.25);
  padding: 0.3rem;
}
.search-results a {
  display: block; padding: 0.45rem 0.6rem; border-radius: calc(var(--radius) - 2px);
  color: inherit; text-decoration: none;
}
.search-results a:hover, .search-results a.is-active { background: hsl(var(--accent)); }
.search-results__title { font-size: 0.83rem; font-weight: 550; }
.search-results__text {
  font-size: 0.75rem; color: hsl(var(--muted-foreground));
  overflow: hidden; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.search-results__empty {
  padding: 0.7rem; font-size: 0.8rem; color: hsl(var(--muted-foreground)); text-align: center;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */

.layout {
  display: grid;
  grid-template-columns: var(--sidebar-width) minmax(0, 1fr) var(--toc-width);
  gap: 2.5rem;
  max-width: 100rem; margin: 0 auto; padding: 0 1.25rem;
  align-items: start;
}

.sidebar, .toc {
  position: sticky; top: var(--header-height);
  max-height: calc(100vh - var(--header-height));
  overflow-y: auto;
  padding: 1.75rem 0 3rem;
}

.content { min-width: 0; padding: 1.75rem 0 4rem; max-width: var(--content-max); }

/* ── Sidebar navigation ─────────────────────────────────────────────────── */

.nav { list-style: none; margin: 0; padding: 0; }
.nav--depth-1, .nav--depth-2 { margin-left: 0.55rem; padding-left: 0.5rem; border-left: 1px solid hsl(var(--border)); }

.nav__label {
  display: block; margin: 1.1rem 0 0.35rem;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}
.nav--depth-1 .nav__label { margin-top: 0.6rem; text-transform: none; letter-spacing: 0; font-size: 0.78rem; }

.nav__link {
  display: block; padding: 0.28rem 0.5rem; margin: 0.05rem 0;
  font-size: 0.83rem; color: hsl(var(--muted-foreground));
  text-decoration: none; border-radius: calc(var(--radius) - 2px);
  transition: background-color 110ms ease, color 110ms ease;
  overflow-wrap: anywhere;
}
.nav__link:hover { background: hsl(var(--accent)); color: hsl(var(--accent-foreground)); }
.nav__link--active {
  background: hsl(var(--accent)); color: hsl(var(--foreground)); font-weight: 550;
}

/* ── Table of contents ──────────────────────────────────────────────────── */

/* A page with no headings reserves no column; the content simply centres. */
.layout:has(.toc--empty) { grid-template-columns: var(--sidebar-width) minmax(0, 1fr); }

.toc__title {
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.05em; text-transform: uppercase;
  color: hsl(var(--muted-foreground)); margin-bottom: 0.6rem;
}
.toc__list, .toc__list ul { list-style: none; margin: 0; padding: 0; }
.toc__list ul { margin-left: 0.75rem; }
.toc__list a {
  display: block; padding: 0.2rem 0 0.2rem 0.7rem;
  font-size: 0.78rem; line-height: 1.45;
  color: hsl(var(--muted-foreground)); text-decoration: none;
  border-left: 2px solid transparent;
}
.toc__list a:hover { color: hsl(var(--foreground)); }
.toc__list a.is-active { color: hsl(var(--foreground)); border-left-color: hsl(var(--foreground)); }

/* ── Prose ──────────────────────────────────────────────────────────────── */

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

.prose h1 {
  font-size: 2.1rem; font-weight: 700; letter-spacing: -0.028em; line-height: 1.15;
  margin: 0 0 1.25rem;
}
.prose h2 {
  font-size: 1.4rem; font-weight: 650; letter-spacing: -0.02em; line-height: 1.3;
  margin: 2.75rem 0 1rem; padding-bottom: 0.45rem;
  border-bottom: 1px solid hsl(var(--border));
}
.prose h3 { font-size: 1.1rem; font-weight: 600; letter-spacing: -0.014em; margin: 2rem 0 0.75rem; }
.prose h4 { font-size: 0.95rem; font-weight: 600; margin: 1.5rem 0 0.5rem; }

.prose p, .prose ul, .prose ol { margin: 0 0 1rem; }
.prose li { margin: 0.28rem 0; }
.prose li > ul, .prose li > ol { margin: 0.28rem 0; }

.prose a { color: inherit; text-decoration: underline; text-decoration-color: hsl(var(--muted-foreground) / 0.45); text-underline-offset: 3px; }
.prose a:hover { text-decoration-color: hsl(var(--foreground)); }

.prose strong { font-weight: 620; }
.prose hr { border: none; border-top: 1px solid hsl(var(--border)); margin: 2.5rem 0; }

.prose blockquote {
  margin: 1.25rem 0; padding: 0.1rem 0 0.1rem 1rem;
  border-left: 2px solid hsl(var(--border));
  color: hsl(var(--muted-foreground));
}

.prose del { color: hsl(var(--muted-foreground)); }

.headerlink { opacity: 0; margin-left: 0.4rem; text-decoration: none; color: hsl(var(--muted-foreground)); }
.prose h1:hover .headerlink, .prose h2:hover .headerlink,
.prose h3:hover .headerlink, .prose h4:hover .headerlink { opacity: 1; }

/* ── Code ───────────────────────────────────────────────────────────────── */

.prose code {
  font-family: var(--font-mono); font-size: 0.83em;
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  border-radius: calc(var(--radius) - 3px); padding: 0.1em 0.35em;
}

.prose pre {
  margin: 1.25rem 0; padding: 0;
  background: hsl(var(--muted)); border: 1px solid hsl(var(--border));
  border-radius: var(--radius); overflow-x: auto;
}
.prose pre code {
  display: block; padding: 0.95rem 1.1rem;
  background: transparent; border: none; border-radius: 0;
  font-size: 0.8rem; line-height: 1.65;
}
.prose .highlight { margin: 1.25rem 0; }
.prose .highlight pre { margin: 0; }

/* Pygments — tuned per palette rather than shipping two stylesheets. */
.prose .c, .prose .c1, .prose .cm, .prose .cs { color: hsl(var(--muted-foreground)); font-style: italic; }
.prose .k, .prose .kd, .prose .kn, .prose .kt, .prose .kc { color: hsl(280 60% 60%); }
.prose .s, .prose .s1, .prose .s2, .prose .sb, .prose .sd { color: hsl(var(--success)); }
.prose .n, .prose .nx { color: hsl(var(--foreground)); }
.prose .nf, .prose .nc { color: hsl(var(--info)); }
.prose .mi, .prose .mf, .prose .m { color: hsl(var(--warning)); }
.prose .o, .prose .p { color: hsl(var(--muted-foreground)); }
.prose .err { color: hsl(var(--destructive)); }

/* ── Tables — the dominant content type in these docs ───────────────────── */

.prose table {
  width: 100%; margin: 1.25rem 0;
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  border-collapse: separate; border-spacing: 0;
  font-size: 0.82rem; overflow: hidden;
  display: block; overflow-x: auto;
}
.prose thead th {
  background: hsl(var(--muted)); text-align: left; font-weight: 600;
  padding: 0.6rem 0.85rem; border-bottom: 1px solid hsl(var(--border));
  white-space: nowrap;
}
.prose tbody td { padding: 0.6rem 0.85rem; border-top: 1px solid hsl(var(--border)); vertical-align: top; }
.prose tbody tr:first-child td { border-top: none; }
.prose tbody tr:hover { background: hsl(var(--muted) / 0.45); }

/* ── Admonitions ────────────────────────────────────────────────────────── */

.prose .admonition, .prose details {
  margin: 1.25rem 0; padding: 0.85rem 1rem;
  background: hsl(var(--card));
  border: 1px solid hsl(var(--border)); border-left-width: 3px;
  border-radius: var(--radius); font-size: 0.87rem;
}
.prose .admonition-title, .prose summary {
  margin: 0 0 0.4rem; font-weight: 600; cursor: pointer;
}
.prose .admonition > *:last-child, .prose details > *:last-child { margin-bottom: 0; }
.prose .note { border-left-color: hsl(var(--info)); }
.prose .tip, .prose .success { border-left-color: hsl(var(--success)); }
.prose .warning { border-left-color: hsl(var(--warning)); }
.prose .danger, .prose .failure { border-left-color: hsl(var(--destructive)); }

/* ── Pager and footer ───────────────────────────────────────────────────── */

.pager {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 3rem; padding-top: 1.5rem; border-top: 1px solid hsl(var(--border));
}
.pager__link {
  flex: 1; max-width: 20rem; padding: 0.7rem 0.9rem;
  border: 1px solid hsl(var(--border)); border-radius: var(--radius);
  color: inherit; text-decoration: none;
  transition: border-color 120ms ease, background-color 120ms ease;
}
.pager__link:hover { background: hsl(var(--accent)); border-color: hsl(var(--ring) / 0.35); }
.pager__link--next { text-align: right; }
.pager__label { display: block; font-size: 0.7rem; color: hsl(var(--muted-foreground)); }
.pager__title { display: block; font-size: 0.85rem; font-weight: 550; }

.footer {
  display: flex; justify-content: space-between; gap: 1rem;
  margin-top: 2.5rem; padding-top: 1.25rem;
  border-top: 1px solid hsl(var(--border));
  font-size: 0.78rem; color: hsl(var(--muted-foreground));
}
.footer a { color: inherit; }

/* ── Responsive ─────────────────────────────────────────────────────────── */

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

@media (max-width: 900px) {
  .layout { grid-template-columns: minmax(0, 1fr); gap: 0; }
  .header__menu { display: inline-flex; }
  .header__kbd { display: none; }
  .sidebar {
    display: none; position: fixed; inset: var(--header-height) 0 0 0;
    z-index: 30; max-height: none; padding: 1.25rem;
    background: hsl(var(--background)); border-right: 1px solid hsl(var(--border));
    overflow-y: auto;
  }
  .sidebar.is-open { display: block; }
  .prose h1 { font-size: 1.7rem; }
}

@media print {
  .header, .sidebar, .toc, .pager { display: none; }
  .layout { display: block; }
  .content { max-width: none; }
}

/* ---------------------------------------------------------------------------------------------
   Version and project switcher

   Sits above the navigation because it changes what the navigation means: every link below it
   resolves within whichever build is selected. Hidden until `versions.json` says there is more
   than one build, so a single-version site shows no dead control.
   --------------------------------------------------------------------------------------------- */
.switcher {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0 0 1rem;
  margin: 0 0 1rem;
  border-bottom: 1px solid hsl(var(--border));
}

.switcher__group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.switcher__label {
  font-size: 0.6875rem;
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: hsl(var(--muted-foreground));
}

.switcher__select {
  width: 100%;
  padding: 0.375rem 0.5rem;
  font: inherit;
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius);
  cursor: pointer;
  color-scheme: light;
}

[data-theme="dark"] .switcher__select {
  color-scheme: dark;
}

.switcher__select:focus-visible {
  outline: 2px solid hsl(var(--ring));
  outline-offset: 2px;
}

.switcher__select option {
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
}
