/* Castellan docs core: tokens, layout, typography, mdbook chrome. */

@import url("https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap");

:root {
  --castellan-coordination: #0d9488;
  --castellan-coordination-bright: #14b8a6;
  --castellan-evolve: #d97706;
  --castellan-evolve-bright: #f59e0b;
  --castellan-runtime: #0969da;
  --castellan-substrate: #8250df;
  --castellan-gate: #1a7f37;

  --castellan-bg: #f7f8fa;
  --castellan-surface: #eef1f5;
  --castellan-surface-raised: #ffffff;
  --castellan-code-bg: #ebf0f5;
  --castellan-text: #111827;
  --castellan-muted: #5b6b7c;
  --castellan-border: #d5dde7;
  --castellan-link: #0d9488;
  --castellan-link-hover: #0f766e;
  --castellan-shadow: 0 1px 2px color-mix(in srgb, var(--castellan-text) 4%, transparent),
    0 20px 48px color-mix(in srgb, var(--castellan-text) 5%, transparent);
  --castellan-hero-bg: radial-gradient(ellipse 80% 60% at 20% 0%, rgba(20, 184, 166, 0.14), transparent 55%),
    radial-gradient(ellipse 60% 50% at 90% 10%, rgba(245, 158, 11, 0.1), transparent 50%),
    linear-gradient(180deg, #f0fdfa 0%, #f7f8fa 70%);

  --castellan-font-sans: "IBM Plex Sans", system-ui, -apple-system, BlinkMacSystemFont,
    "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --castellan-font-mono: "JetBrains Mono", ui-monospace, SFMono-Regular, Menlo,
    Consolas, "Liberation Mono", monospace;
  --castellan-line-height: 1.72;
  --castellan-body-size: 1.15rem;

  --castellan-space-1: 0.25rem;
  --castellan-space-2: 0.5rem;
  --castellan-space-3: 0.75rem;
  --castellan-space-4: 1rem;
  --castellan-space-5: 1.25rem;
  --castellan-space-6: 1.5rem;
  --castellan-space-8: 2rem;
  --castellan-space-10: 2.5rem;
  --castellan-space-12: 3rem;
  --castellan-space-16: 4rem;
  /* Fill main pane up to a premium readable cap (not a middle-third ribbon). */
  --castellan-content-max: min(100%, 64rem);

  --castellan-admonition-note: var(--castellan-coordination);
  --castellan-admonition-warning: #b45309;
  --castellan-admonition-honest: var(--castellan-evolve);

  --bg: var(--castellan-bg);
  --fg: var(--castellan-text);
  --sidebar-bg: var(--castellan-surface);
  --sidebar-fg: var(--castellan-muted);
  --sidebar-active: var(--castellan-coordination);
  --links: var(--castellan-link);
  --inline-code-color: var(--castellan-evolve-bright);
  --searchbar-border-color: var(--castellan-border);
  --table-border-color: var(--castellan-border);
  --theme-popup-border: var(--castellan-border);
  --icons: var(--castellan-muted);
  --icons-hover: var(--castellan-text);
  --mono-font: var(--castellan-font-mono);

  --sidebar-target-width: 17rem;
  --sidebar-width: var(--sidebar-target-width);
  --sidebar-resize-indicator-width: 0px;
  --sidebar-resize-indicator-space: 0px;
  --content-max-width: var(--castellan-content-max);
  --page-padding: 2rem;
  --copy-button-filter: none;
  --copy-button-filter-hover: none;
}

@media (prefers-color-scheme: dark) {
  :root {
    --castellan-coordination: #2dd4bf;
    --castellan-coordination-bright: #5eead4;
    --castellan-evolve: #fbbf24;
    --castellan-evolve-bright: #fcd34d;
    --castellan-runtime: #58a6ff;
    --castellan-substrate: #a371f7;
    --castellan-gate: #3fb950;

    --castellan-bg: #0a0c10;
    --castellan-surface: #11151c;
    --castellan-surface-raised: #171c26;
    --castellan-code-bg: #0e1218;
    --castellan-text: #f1f5f9;
    --castellan-muted: #94a3b8;
    --castellan-border: #252d3a;
    --castellan-link: #2dd4bf;
    --castellan-link-hover: #5eead4;
    --castellan-shadow: 0 1px 2px rgba(0, 0, 0, 0.4), 0 24px 56px rgba(0, 0, 0, 0.35);
    --castellan-hero-bg: radial-gradient(ellipse 80% 55% at 18% 0%, rgba(45, 212, 191, 0.12), transparent 55%),
      radial-gradient(ellipse 55% 45% at 92% 8%, rgba(251, 191, 36, 0.08), transparent 50%),
      linear-gradient(180deg, #0c1414 0%, #0a0c10 72%);
  }
}

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

html {
  max-width: 100%;
  overflow-x: hidden;
  font-size: 20px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  max-width: 100%;
  overflow-x: hidden;
  font-family: var(--castellan-font-sans);
  font-size: var(--castellan-body-size);
  line-height: var(--castellan-line-height);
  color: var(--castellan-text);
  background: var(--castellan-bg);
  letter-spacing: -0.011em;
}

img,
svg,
video,
canvas,
iframe {
  max-width: 100%;
}

.content {
  min-width: 0;
  padding-left: 0;
  padding-right: 0;
}

.content main {
  width: 100%;
  max-width: var(--castellan-content-max);
  min-width: 0;
  margin-inline: 0;
  padding: 0 var(--castellan-space-10) var(--castellan-space-16);
}

.content h1 {
  margin: 0 0 var(--castellan-space-6);
  color: var(--castellan-text);
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.035em;
  line-height: 1.1;
}

.content h2 {
  margin: var(--castellan-space-16) 0 var(--castellan-space-5);
  padding-bottom: 0.5em;
  border-bottom: 1px solid var(--castellan-border);
  color: var(--castellan-text);
  font-size: 1.65rem;
  font-weight: 650;
  letter-spacing: -0.025em;
  line-height: 1.2;
}

.content h3 {
  margin: var(--castellan-space-10) 0 var(--castellan-space-3);
  color: var(--castellan-text);
  font-size: 1.3rem;
  font-weight: 650;
  letter-spacing: -0.015em;
  line-height: 1.3;
}

.content h4 {
  margin: var(--castellan-space-8) 0 var(--castellan-space-2);
  color: var(--castellan-text);
  font-size: 1.1rem;
  font-weight: 650;
}

.content p,
.content li {
  color: var(--castellan-text);
}

.content p {
  margin: var(--castellan-space-4) 0;
}

.content li + li {
  margin-top: var(--castellan-space-2);
}

.content a {
  color: var(--castellan-link);
  font-weight: 520;
  text-decoration: none;
  text-underline-offset: 3px;
}

.content a:hover,
.content a:focus-visible {
  color: var(--castellan-link-hover);
  text-decoration: underline;
}

.content h1 a.header,
.content h2 a.header,
.content h3 a.header,
.content h4 a.header,
.content h5 a.header,
.content h6 a.header {
  color: inherit;
  opacity: 1;
  font-weight: inherit;
  text-decoration: none;
}

.content h1 a.header:hover,
.content h2 a.header:hover,
.content h3 a.header:hover,
.content h4 a.header:hover,
.content h5 a.header:hover,
.content h6 a.header:hover,
.content h1 a.header:focus-visible,
.content h2 a.header:focus-visible,
.content h3 a.header:focus-visible,
.content h4 a.header:focus-visible {
  color: inherit;
  opacity: 1;
  text-decoration: none;
}

.sidebar {
  max-width: min(var(--sidebar-target-width), 86vw);
  border-right: 1px solid var(--castellan-border);
  background: var(--castellan-bg);
  font-size: 1.075rem;
}

.sidebar-resize-handle {
  display: none !important;
  pointer-events: none !important;
}

.sidebar-scrollbox {
  padding: var(--castellan-space-6) var(--castellan-space-3) var(--castellan-space-12);
  overflow-x: hidden;
}

.sidebar .sidebar-title {
  padding: var(--castellan-space-2) var(--castellan-space-4) var(--castellan-space-6);
  color: var(--castellan-text);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.chapter li.chapter-item {
  margin: 0.05rem 0;
}

.chapter li.chapter-item a {
  display: block;
  min-width: 0;
  padding: 0.45rem 0.8rem;
  border-left: none;
  border-radius: 8px;
  color: var(--castellan-muted);
  font-size: 1.075rem;
  font-weight: 450;
  line-height: 1.4;
  overflow-wrap: anywhere;
  transition: color 0.1s ease, background 0.1s ease;
}

.chapter li.chapter-item a:hover {
  color: var(--castellan-text);
  background: color-mix(in srgb, var(--castellan-text) 5%, transparent);
}

.chapter li.chapter-item a.active {
  color: var(--castellan-coordination);
  background: color-mix(in srgb, var(--castellan-coordination) 12%, transparent);
  font-weight: 600;
}

.chapter li.chapter-item .section {
  margin-left: 0.5rem;
}

.chapter li.chapter-item .section a {
  padding-top: 0.34rem;
  padding-bottom: 0.34rem;
  font-size: 1rem;
}

.chapter li.part-title {
  padding: 1.6rem 0.75rem 0.35rem;
  color: var(--castellan-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.1em;
  opacity: 0.85;
  text-transform: uppercase;
}

.content code {
  padding: 0.17em 0.42em;
  border: 1px solid var(--castellan-border);
  border-radius: 7px;
  background: var(--castellan-code-bg);
  color: var(--castellan-evolve-bright);
  font-family: var(--castellan-font-mono);
  font-size: 0.9em;
}

.content pre {
  position: relative;
  max-width: 100%;
  margin: var(--castellan-space-6) 0;
  padding: 0;
  overflow: hidden;
  border: 1px solid var(--castellan-border);
  border-radius: 12px;
  background: var(--castellan-code-bg);
  box-shadow: none;
  line-height: 1.65;
}

.content pre > code {
  display: block;
  min-width: 0;
  padding: 1.15rem 1.25rem;
  overflow-x: auto;
  border: none;
  background: transparent;
  color: var(--castellan-text);
  font-size: 0.96rem;
}

pre > .buttons {
  position: absolute;
  top: 0.55rem;
  right: 0.55rem;
  z-index: 2;
}

pre > .buttons button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.35rem;
  height: 2.35rem;
  margin: 0;
  padding: 0;
  border: 1px solid var(--castellan-border);
  border-radius: 9px;
  background: var(--castellan-surface-raised);
  color: var(--castellan-muted);
  opacity: 0.94;
  transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease,
    transform 0.1s ease;
}

pre > .buttons button:hover,
pre > .buttons button:focus-visible {
  border-color: var(--castellan-coordination);
  background: color-mix(in srgb, var(--castellan-coordination) 10%, var(--castellan-surface-raised));
  color: var(--castellan-coordination);
  opacity: 1;
  outline: none;
  transform: translateY(-1px);
}

pre > .buttons button.clip-button::before {
  content: url('data:image/svg+xml,<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="%2394a3b8"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');
  line-height: 0;
}

pre > .buttons button.clip-button:hover::before,
pre > .buttons button.clip-button:focus-visible::before {
  content: url('data:image/svg+xml,<svg width="18" height="18" viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg" fill="%232dd4bf"><path d="M16 1H4c-1.1 0-2 .9-2 2v14h2V3h12V1zm3 4H8c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h11c1.1 0 2-.9 2-2V7c0-1.1-.9-2-2-2zm0 16H8V7h11v14z"/></svg>');
}

.content table {
  width: max-content;
  min-width: 100%;
  border-collapse: collapse;
  font-size: 0.98rem;
}

.content table tr:nth-child(even) {
  background: var(--castellan-surface);
}

.content table th,
.content table td {
  padding: 0.78em 1em;
  border: 1px solid var(--castellan-border);
  vertical-align: top;
}

.content table th {
  background: var(--castellan-surface);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.01em;
}

/* Product chrome: Auto / Light / Dark only — hide Rust book theme zoo + Print. */
#mdbook-theme-rust,
#mdbook-theme-navy,
#mdbook-theme-ayu {
  display: none !important;
}

a[href$="print.html"],
a[title="Print this book"],
#print-button {
  display: none !important;
}

.menu-title {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.02em;
  color: var(--castellan-muted);
  opacity: 0.9;
}

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

.searchbox input {
  padding: 0.5rem 0.7rem;
  border-radius: 10px;
  font-size: 1rem;
}

@media (min-width: 1440px) {
  :root {
    --castellan-body-size: 1.175rem;
    --castellan-content-max: min(100%, 68rem);
  }
}

@media (max-width: 1080px) {
  :root {
    --castellan-content-max: 100%;
  }

  .content main {
    padding-left: var(--castellan-space-8);
    padding-right: var(--castellan-space-8);
  }
}

@media (max-width: 768px) {
  html {
    font-size: 18px;
  }

  :root {
    --castellan-body-size: 1.1rem;
  }

  .content main {
    padding: 0 var(--castellan-space-5) var(--castellan-space-12);
  }

  .content h1 {
    font-size: 2rem;
  }

  .content h2 {
    margin-top: var(--castellan-space-12);
    font-size: 1.55rem;
  }

  .content h3 {
    font-size: 1.28rem;
  }

  .chapter li.chapter-item a {
    padding: 0.52rem 0.85rem;
    font-size: 1.05rem;
  }

  .content pre > code {
    padding: 1rem;
    font-size: 0.95rem;
  }

  pre > .buttons button {
    width: 2.5rem;
    height: 2.5rem;
  }
}
