/* ============================================================
   Aves docs — v3 theme override for mdBook
   Layered on top of mdBook's default CSS via additional-css.
   ============================================================ */

/* ---- mdBook variable aliases ------------------------------ */
/* The shared palette lives in tokens.css. mdBook expects its own
   variable names (--sidebar-bg, --links, --searchbar-bg, etc.), so we
   alias each to the appropriate shared token. Both .light and .navy
   share the alias rules — the underlying tokens already differ per
   theme, so var() resolution at use-time picks up the right values. */

.light, .navy {
  --sidebar-bg:        var(--bg-alt);
  --sidebar-fg:        var(--fg-soft);
  --sidebar-active:    var(--accent);
  --sidebar-spacer:    var(--rule);

  --icons:             var(--muted);
  --icons-hover:       var(--accent);

  --links:             var(--accent);
  --inline-code-color: var(--accent);

  --theme-popup-bg:     var(--bg);
  --theme-popup-border: var(--rule);
  --theme-hover:        var(--bg-alt);

  --quote-bg:     var(--bg-alt);
  --quote-border: var(--accent);

  --table-border-color: var(--rule);
  --table-header-bg:    var(--bg-alt);

  --searchbar-bg:               var(--bg);
  --searchbar-fg:               var(--fg);
  --searchbar-border-color:     var(--rule);
  --searchbar-shadow-color:     rgba(0, 0, 0, 0);
  --searchresults-header-fg:    var(--muted);
  --searchresults-border-color: var(--rule);
  --searchresults-li-bg:        var(--bg-alt);
  --search-mark-bg:             var(--accent);

  --warning-border: var(--accent);
}

/* mdBook variables that don't map cleanly to shared tokens */
.light {
  --sidebar-non-existant: #b3a98e;
  --scrollbar:            #c0b59a;
  --table-alternate-bg:   #f0eadc;
}
.navy {
  --sidebar-non-existant: #4a4540;
  --scrollbar:            #2a2620;
  --table-alternate-bg:   #11100d;
}

/* ---- Typography ------------------------------------------- */

/* System sans for prose, sidebar, and chrome — same stack as the
   landing page (index3.html) to keep the docs visually continuous.
   !important forces a win over mdBook's `html { font-family: "Open Sans" }`
   and any future-added body/main rules in upstream stylesheets. */
html,
body,
main,
.sidebar,
.content,
.content p,
.content li,
.content td,
.content th,
.content blockquote,
.content dl,
.content dt,
.content dd {
  font-family: var(--font-sans) !important;
}

.content {
  max-width: 760px;
  font-size: 16px;
  line-height: 1.6;
  color: var(--fg-soft);
}
.content p,
.content li {
  line-height: 1.6;
}

.content h1,
.content h2,
.content h3,
.content h4,
.content h5,
.content h6 {
  font-family: var(--font-serif);
  font-weight: 500;
  letter-spacing: -0.012em;
  margin-top: 1.6em;
  color: var(--fg);
}
.content h1 { font-size: 2.1em; line-height: 1.12; letter-spacing: -0.018em; margin-top: 0.6em; }
.content h2 { font-size: 1.55em; line-height: 1.2; }
.content h3 { font-size: 1.25em; line-height: 1.3; }
.content h4 { font-size: 1.1em; }

.content p,
.content ul,
.content ol {
  margin-top: 0.6em;
  margin-bottom: 0.9em;
}

code, pre, kbd, samp,
.hljs {
  font-family: var(--font-mono);
  font-size: 0.93em;
}

/* Headings have an autolink anchor — keep it discreet */
.content a.header:link,
.content a.header:visited {
  color: inherit;
  text-decoration: none;
  border: none;
}

/* ---- Sharp corners, no shadows ---------------------------- */

pre,
code,
.menu-bar,
.sidebar,
.theme-popup,
.searchbar-outer,
#searchbar,
button,
input,
.content blockquote,
.warning,
.table-wrapper table {
  border-radius: 0 !important;
}

.menu-bar,
.theme-popup,
pre,
.searchbar-outer,
.sidebar,
#searchresults {
  box-shadow: none !important;
}

/* ---- Links ------------------------------------------------ */

.content a:link,
.content a:visited {
  color: var(--links);
  text-decoration: underline;
  text-decoration-style: dotted;
  text-decoration-thickness: from-font;
  text-underline-offset: 3px;
}
.content a:hover {
  text-decoration-style: solid;
}

/* ---- Code blocks (always dark, like v3) ------------------- */

/* Code blocks always render dark, even under .light, to match v3. */
.light pre,
.light pre > code,
.light pre code.hljs {
  background: var(--code-bg) !important;
  color: var(--code-fg) !important;
}
/* Inline code (in prose, not in pre blocks) */
:not(pre) > code {
  color: var(--inline-code-color);
  background: var(--bg-alt);
  padding: 0 4px;
}

pre {
  border: 1px solid var(--code-border);
  padding: 14px 18px !important;
  line-height: 1.6;
}

/* Make sure the copy-to-clipboard icon stays visible */
pre > .buttons {
  opacity: 0.6;
}
pre:hover > .buttons {
  opacity: 1;
}

/* ---- Sidebar --------------------------------------------- */

.sidebar {
  font-size: 0.92em;
  border-right: 1px solid var(--sidebar-spacer);
}

.chapter li.chapter-item {
  line-height: 1.6;
  padding: 1px 0;
}

/* mdBook v0.5.x emits invalid HTML where each part-title is wrapped
   in <li class="chapter-item">…<li class="part-title">…</li></li>.
   The HTML parser auto-closes the outer li, leaving an empty ghost
   chapter-item before each section. Hide those ghosts. */
.sidebar .chapter > li.chapter-item:empty {
  display: none !important;
}

/* Section titles (rendered as siblings of chapter-items after parsing) */
.sidebar .chapter > li.part-title {
  list-style: none;
  font-family: var(--font-serif);
  font-style: italic;
  font-weight: 600;
  font-size: 1.22em;
  letter-spacing: 0.005em;
  color: var(--fg);
  margin: 1.6em 0 0.3em;
  padding-left: 0;
  text-transform: none;
}
.sidebar .chapter > li.part-title:first-child {
  margin-top: 0.5em;
}

/* Make the active chapter bolder (mdBook only colors it by default). */
.chapter li.chapter-item a.active {
  font-weight: 600;
}

/* Numbered chapter prefixes, if section labels are ever turned on. */
.chapter li.chapter-item strong {
  color: var(--sidebar-non-existant);
  font-weight: 500;
}

/* ---- Menu bar / page header ----------------------------- */

.menu-bar {
  border-bottom: 1px solid var(--sidebar-spacer);
  background: var(--bg);
}

.menu-title {
  font-family: var(--font-serif);
  font-weight: 500;
  font-size: 1.1em;
  letter-spacing: 0;
}

.menu-bar i, .menu-bar .icon-button {
  color: var(--icons);
}
.menu-bar i:hover, .menu-bar .icon-button:hover {
  color: var(--icons-hover);
}

/* ---- Blockquote ------------------------------------------ */

.content blockquote {
  border-left: 3px solid var(--quote-border);
  padding: 10px 18px;
  background: var(--quote-bg);
  margin: 1.2em 0;
}

/* ---- Tables ---------------------------------------------- */

.content table {
  border-collapse: collapse;
  margin: 1em 0;
  font-size: 0.94em;
}
.content table th,
.content table td {
  border: 1px solid var(--table-border-color);
  padding: 6px 12px;
}
.content table th {
  background: var(--table-header-bg);
  font-weight: 600;
}
.content table tr:nth-child(even) td {
  background: var(--table-alternate-bg);
}

/* ---- Search --------------------------------------------- */

#searchbar {
  border: 1px solid var(--searchbar-border-color);
  background: var(--searchbar-bg);
  color: var(--searchbar-fg);
  padding: 8px 12px;
}
#searchbar:focus {
  outline: 1px solid var(--links);
  outline-offset: -1px;
}

/* ---- Theme picker: lock to Auto / Light / Navy ----------- */

#mdbook-theme-list li:has(#mdbook-theme-rust),
#mdbook-theme-list li:has(#mdbook-theme-coal),
#mdbook-theme-list li:has(#mdbook-theme-ayu) {
  display: none !important;
}

/* ---- Responsive ------------------------------------------ */

@media (max-width: 700px) {
  .content { font-size: 15.5px; }
  .content h1 { font-size: 1.8em; }
  .content h2 { font-size: 1.4em; }
}
