/* Fonts — must precede all rules (CSS @import requirement). Text uses
   Noto Sans CJK SC (Latin + Chinese); code uses JetBrains Mono. Loaded
   from Google Fonts; fallbacks cover offline. */
@import url("https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;700&family=Noto+Sans+SC:wght@400;500;700&display=swap");

/* Widen mdBook content + apply Robonix brand color (#283689). */
:root {
    --content-max-width: 1100px;
    /* mdBook applies the mono font via `var(--mono-font) !important`, so a
       plain `code { font-family }` rule can't win — override the variable.
       --code-font-size shrinks code (JetBrains Mono renders large). */
    --mono-font: "JetBrains Mono", "Noto Sans CJK SC", "Noto Sans SC",
        ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    --code-font-size: 0.82em;
}

/* Hide the big prev/next chapter arrows on each page. */
.nav-chapters,
.nav-wrapper,
.nav-wide-wrapper,
.previous,
.next {
    display: none !important;
}

/* Replace mdbook's default `❱` fold indicator with a clear chevron.
   The toggle is rendered as <a><div>❱</div></a>; we hide the inner div
   and inject a CSS triangle via ::before that rotates on expand. */
.chapter-fold-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.6em;
    height: 1.6em;
    margin-left: 0.4em;
    color: inherit;
    opacity: 0.75;
    cursor: pointer;
    border-radius: 4px;
    transition: opacity 0.15s ease;
}
.chapter-fold-toggle > div {
    display: none;
}
.chapter-fold-toggle::before {
    content: "";
    display: block;
    width: 0.38em;
    height: 0.38em;
    border-right: 1.5px solid currentColor;
    border-bottom: 1.5px solid currentColor;
    transform: rotate(-45deg); /* collapsed: points right */
    transform-origin: center;
    transition: transform 0.15s ease;
}
.chapter-fold-toggle:hover {
    opacity: 1;
    background: rgba(127, 127, 127, 0.18);
}
/* When the chapter is expanded, the chevron points down. The -2px nudge
   keeps the rotated box optically centred. */
.chapter-item.expanded > .chapter-link-wrapper > .chapter-fold-toggle::before {
    transform: rotate(45deg) translate(-1px, -1px);
}

/* Constrain large diagrams (e.g. cap-lifecycle.png) — full-width is ugly. */
img[src$="cap-lifecycle.png"] {
    display: block;
    max-width: 560px;
    width: 100%;
    margin: 1em auto;
}

/* Light theme: override accent colors to Robonix blue. */
.light {
    --links: #283689;
    --sidebar-active: #283689;
    --searchresults-header-fg: #283689;
}

/* Rust theme uses the same palette as light for our purposes. */
.rust {
    --links: #283689;
    --sidebar-active: #283689;
}

/* Dark themes get a lighter variant of the brand color for contrast. */
.coal, .navy, .ayu {
    --links: #6178c8;
    --sidebar-active: #6178c8;
}

/* ── Muted syntax highlighting (light themes) ─────────────────────────
   Default mdbook highlight palette is too neon. Tone it down to a
   github-light-ish scheme that harmonises with the brand navy. */
.light .hljs, .rust .hljs {
    background: #f6f8fa;
    color: #24292e;
}
.light .hljs-keyword, .rust .hljs-keyword,
.light .hljs-built_in, .rust .hljs-built_in {
    color: #283689;
    font-weight: 600;
}
.light .hljs-string, .rust .hljs-string {
    color: #1f6f43;
}
.light .hljs-comment, .rust .hljs-comment {
    color: #8a929b;
    font-style: italic;
}
.light .hljs-number, .rust .hljs-number,
.light .hljs-literal, .rust .hljs-literal {
    color: #b15c1a;
}
.light .hljs-title, .rust .hljs-title,
.light .hljs-function .hljs-title, .rust .hljs-function .hljs-title {
    color: #4b3789;
    font-weight: 600;
}
.light .hljs-type, .rust .hljs-type,
.light .hljs-class, .rust .hljs-class {
    color: #2c5282;
}
.light .hljs-attr, .rust .hljs-attr,
.light .hljs-symbol, .rust .hljs-symbol {
    color: #5a6b85;
}

/* RIDL syntax: keywords bold, title/attr/symbol/type distinct colors */
pre code.language-ridl .hljs-comment {
    color: #6a737d;
    font-style: italic;
}
pre code.language-ridl .hljs-keyword {
    font-weight: bold;
}
pre code.language-ridl .hljs-title {
    color: #0030f2;
    font-weight: 600;
}
pre code.language-ridl .hljs-attr {
    color: #0d7377;
}
pre code.language-ridl .hljs-symbol {
    color: #6b4e9e;
}
pre code.language-ridl .hljs-type,
pre code.language-ridl .hljs-variable {
    color: #0d7377;
}
pre code.language-ridl .hljs-built_in {
    color: #b21e00;
}

/* ── Typography ──────────────────────────────────────────────────────────
   Body text: Noto Sans CJK SC (Latin + Chinese).
   Code / monospace: JetBrains Mono, with CJK falling back to Noto Sans CJK SC
   (JetBrains Mono has no CJK glyphs). */
html,
body,
.content,
.content p,
.content li,
.content td,
.menu-title {
    font-family: "Noto Sans CJK SC", "Noto Sans SC",
        -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Make links whose text is inline `code` read as clickable — link colour +
   underline, so a payload like `chassis/srv/…` doesn't look like plain
   monospace text. */
a > code,
.content a code {
    color: var(--links);
    text-decoration: underline;
}
