/* rut code-token colors for the built book.
 *
 * Pairs with integrations/rut-highlightjs (grammar + register.js): one
 * small palette over single-segment hljs scopes — keyword, literal,
 * type, string, comment, number, subst (f-string `{hole}`), title
 * (member calls), property (member fields).
 *
 * mdbook puts the active theme class on <html> and swaps its built-in
 * highlight stylesheets by toggling `disabled`, so this palette is
 * scoped per theme family and only re-tints token classes: dark = ayu
 * (the book's default) / coal / navy, light = light / rust.
 */

/* ---- dark themes (ayu-flavored) ----------------------------------- */
html.ayu .hljs-keyword, html.coal .hljs-keyword, html.navy .hljs-keyword {
  color: #ff8f40;
}
html.ayu .hljs-literal, html.coal .hljs-literal, html.navy .hljs-literal,
html.ayu .hljs-number, html.coal .hljs-number, html.navy .hljs-number {
  color: #d2a6ff;
}
html.ayu .hljs-type, html.coal .hljs-type, html.navy .hljs-type {
  color: #59c2ff;
}
html.ayu .hljs-string, html.coal .hljs-string, html.navy .hljs-string {
  color: #aad94c;
}
html.ayu .hljs-comment, html.coal .hljs-comment, html.navy .hljs-comment {
  color: #626a73;
  font-style: italic;
}
/* the f-string `{hole}` expression pops against its green string */
html.ayu .hljs-subst, html.coal .hljs-subst, html.navy .hljs-subst {
  color: #f29668;
  font-weight: 600;
}
html.ayu .hljs-title, html.coal .hljs-title, html.navy .hljs-title {
  color: #ffd173;
}
html.ayu .hljs-property, html.coal .hljs-property, html.navy .hljs-property {
  color: #95e6cb;
}
html.ayu .hljs-meta, html.coal .hljs-meta, html.navy .hljs-meta {
  color: #899ba6;
}

/* ---- light themes (github-flavored) -------------------------------- */
html.light .hljs-keyword, html.rust .hljs-keyword {
  color: #cf222e;
}
html.light .hljs-literal, html.rust .hljs-literal,
html.light .hljs-number, html.rust .hljs-number {
  color: #0550ae;
}
html.light .hljs-type, html.rust .hljs-type {
  color: #6639ba;
}
html.light .hljs-string, html.rust .hljs-string {
  color: #0a3069;
}
html.light .hljs-comment, html.rust .hljs-comment {
  color: #6e7781;
  font-style: italic;
}
html.light .hljs-subst, html.rust .hljs-subst {
  color: #953800;
  font-weight: 600;
}
html.light .hljs-title, html.rust .hljs-title {
  color: #8250df;
}
html.light .hljs-property, html.rust .hljs-property {
  color: #116329;
}
html.light .hljs-meta, html.rust .hljs-meta {
  color: #59636e;
}

/* .rut-run — the in-book run controls (theme/rut-book.js). Qualifying
   blocks (```rut with `pub fn main`) carry this class on their <pre>
   with a ▶ Run button and a collapsed output panel below. Colors
   follow the same theme families as the token palette above. */
pre.rut-run {
  position: relative;
}

.rut-run-btn {
  position: absolute;
  top: 0.45em;
  right: 2.7em; /* left of mdbook's copy button — the two overlap at right: 0.45em, and copy swallows the clicks */
  padding: 0.15em 0.7em;
  font-size: 0.8em;
  font-family: var(--mono, "Source Code Pro", Menlo, monospace);
  line-height: 1.4;
  cursor: pointer;
  border-radius: 4px;
  border: 1px solid transparent;
  opacity: 0.75;
  transition: opacity 0.15s ease;
}
.rut-run-btn:hover,
.rut-run-btn:focus-visible {
  opacity: 1;
}
.rut-run-btn:disabled {
  cursor: default;
  opacity: 0.5;
}

/* the output panel: monospace, the code block's own box language */
.rut-run-out {
  margin: -0.6em 0 1.5em;
  padding: 0.8em 1em;
  font-family: var(--mono, "Source Code Pro", Menlo, monospace);
  font-size: 0.85em;
  line-height: 1.5;
  border-radius: 5px;
  overflow-x: auto;
}
.rut-run-out[hidden] {
  display: none;
}
/* the `▶ running…` busy state */
.rut-run-out.rut-run-busy .rut-run-muted {
  animation: rut-run-pulse 1s ease-in-out infinite;
}
@keyframes rut-run-pulse {
  50% {
    opacity: 0.35;
  }
}

.rut-run-err {
  color: #ff7373;
}
.rut-run-fuel,
.rut-run-muted {
  font-style: italic;
  opacity: 0.75;
}

/* the LOUD missing/invalid-artifact panel (no silent fallback) */
.rut-run-loud {
  border: 1px solid #ff7373;
  border-radius: 5px;
  padding: 0.6em 0.9em;
}
.rut-run-loud-head {
  font-weight: 700;
}
.rut-run-loud-why {
  opacity: 0.75;
  margin-top: 0.2em;
}
.rut-run-loud-fix {
  margin-top: 0.5em;
}
.rut-run-loud code {
  display: block;
  margin-top: 0.3em;
  padding: 0.4em 0.6em;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---- dark themes (ayu-flavored) ------------------------------------ */
html.ayu .rut-run-btn,
html.coal .rut-run-btn,
html.navy .rut-run-btn {
  color: #899ba6;
  background: rgba(0, 0, 0, 0.25);
  border-color: #2a3542;
}
html.ayu .rut-run-btn:hover,
html.coal .rut-run-btn:hover,
html.navy .rut-run-btn:hover,
html.ayu .rut-run-btn:focus-visible,
html.coal .rut-run-btn:focus-visible,
html.navy .rut-run-btn:focus-visible {
  color: #ffd173;
  border-color: #ffd173;
}
html.ayu .rut-run-out,
html.coal .rut-run-out,
html.navy .rut-run-out {
  background: rgba(0, 0, 0, 0.2);
  border: 1px solid #2a3542;
}
html.ayu .rut-run-loud code,
html.coal .rut-run-loud code,
html.navy .rut-run-loud code {
  background: rgba(0, 0, 0, 0.3);
}

/* ---- light themes (github-flavored) -------------------------------- */
html.light .rut-run-btn,
html.rust .rut-run-btn {
  color: #59636e;
  background: rgba(255, 255, 255, 0.7);
  border-color: #d0d7de;
}
html.light .rut-run-btn:hover,
html.rust .rut-run-btn:hover,
html.light .rut-run-btn:focus-visible,
html.rust .rut-run-btn:focus-visible {
  color: #8250df;
  border-color: #8250df;
}
html.light .rut-run-out,
html.rust .rut-run-out {
  background: #f6f8fa;
  border: 1px solid #d0d7de;
}
html.light .rut-run-err,
html.rust .rut-run-err {
  color: #cf222e;
}
html.light .rut-run-loud code,
html.rust .rut-run-loud code {
  background: #ffffff;
}

/* .rut-lang-btn — the EN/中文 switch (theme/lang-toggle.js). A text
   button in mdbook's sticky menu bar (the top-right strip that owns
   print/theme/search), rightmost, on every page of BOTH editions; it
   navigates to the same page in the other edition. Styled like the
   menu bar's own icon buttons but with a text label, in the theme's
   icon color so it reads as a control, not decoration. Hidden in
   print, like the rest of the bar. */
.rut-lang-btn {
  appearance: none;
  background: none;
  border: none;
  margin: 0;
  padding: 5px 10px;
  font-family: var(--sans, "Helvetica Neue", Helvetica, Arial, sans-serif);
  font-size: 0.8em;
  line-height: 1.4;
  cursor: pointer;
  color: var(--icons, #999);
  transition: color 0.15s ease;
}
.rut-lang-btn:hover,
.rut-lang-btn:focus-visible {
  color: var(--link, #4183c4);
}
.rut-lang-btn:disabled {
  cursor: default;
  opacity: 0.5;
  color: var(--icons, #999);
}

/* ---- dark themes (ayu-flavored) ------------------------------------ */
html.ayu .rut-lang-btn,
html.coal .rut-lang-btn,
html.navy .rut-lang-btn {
  color: #a6adb8;
}
html.ayu .rut-lang-btn:hover,
html.coal .rut-lang-btn:hover,
html.navy .rut-lang-btn:hover,
html.ayu .rut-lang-btn:focus-visible,
html.coal .rut-lang-btn:focus-visible,
html.navy .rut-lang-btn:focus-visible {
  color: #ffd173;
}

/* ---- light themes (github-flavored) -------------------------------- */
html.light .rut-lang-btn,
html.rust .rut-lang-btn {
  color: #59636e;
}
html.light .rut-lang-btn:hover,
html.rust .rut-lang-btn:hover,
html.light .rut-lang-btn:focus-visible,
html.rust .rut-lang-btn:focus-visible {
  color: #8250df;
}

@media print {
  .rut-lang-btn {
    display: none;
  }
}
