@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/inter-400.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/inter-500.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("../fonts/inter-600.woff2") format("woff2");
}
@font-face {
  font-family: "Inter";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("../fonts/inter-700.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-400.woff2") format("woff2");
}
@font-face {
  font-family: "JetBrains Mono";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("../fonts/jetbrains-mono-500.woff2") format("woff2");
}

:root {
  --bg: #0a0a0f;
  --bg-raised: #12131a;
  --bg-inline: #1a1b24;
  --border: #22232e;
  --border-soft: #1a1b24;
  --text: #e8e8ef;
  --text-dim: #8a8b99;
  --text-faint: #5a5b68;
  --accent: #7c6cff;
  --accent-glow: rgba(124, 108, 255, 0.25);
  --accent-2: #00d9c4;

  --type-audio: #7c6cff;
  --type-control: #00d9c4;
  --type-midi: #ff6ca8;
  --type-gate: #ffb86c;
  --type-voct: #a6e22e;
  --type-data: #88aaff;
  --type-image: #ff8a3d;
  --type-spectral: #c792ea;
  --type-sink: #6a6b78;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  scroll-padding-top: 5rem;
}

body.docs {
  background: var(--bg);
  color: var(--text);
  font-family: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
  min-height: 100vh;
}

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

.docs-header {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  background: rgba(10, 10, 15, 0.85);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  text-decoration: none;
}

.logo-mark {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: grid;
  place-items: center;
  font-weight: 700;
  color: #0a0a0f;
  font-size: 0.9rem;
}

.docs-nav {
  display: flex;
  gap: 1.5rem;
}

.nav-link {
  color: var(--text-dim);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s ease;
}

.nav-link:hover {
  color: var(--text);
}

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

.docs-layout {
  display: grid;
  grid-template-columns: 260px 1fr;
  max-width: 1400px;
  margin: 0 auto;
  gap: 2rem;
  padding: 2rem 1.5rem 4rem;
}

.docs-sidebar {
  position: sticky;
  top: 5rem;
  align-self: start;
  max-height: calc(100vh - 6rem);
  overflow-y: auto;
  padding-right: 0.5rem;
  font-size: 0.9rem;
}

.docs-sidebar::-webkit-scrollbar {
  width: 6px;
}
.docs-sidebar::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.docs-main {
  min-width: 0;
}

.docs-intro {
  margin-bottom: 3rem;
}

.docs-intro h1 {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.75rem;
  background: linear-gradient(180deg, #ffffff 0%, #a8a8b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.docs-intro p {
  color: var(--text-dim);
  font-size: 1.05rem;
  max-width: 720px;
}

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

.sidebar-search {
  margin-bottom: 1.25rem;
}

.sidebar-search input {
  width: 100%;
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.55rem 0.75rem;
  color: var(--text);
  font: inherit;
  font-size: 0.9rem;
  outline: none;
  transition: border-color 0.15s ease;
}

.sidebar-search input:focus {
  border-color: var(--accent);
}

.sidebar-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  color: var(--text-faint);
  margin-top: 0.5rem;
  padding-left: 0.2rem;
}

.toc {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.toc a {
  color: var(--text-dim);
  text-decoration: none;
  padding: 0.35rem 0.6rem;
  border-radius: 4px;
  transition: background 0.15s ease, color 0.15s ease;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
}

.toc a:hover {
  color: var(--text);
  background: var(--bg-raised);
}

.toc-count {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
}

.toc-h1 { font-weight: 600; color: var(--text); margin-top: 0.75rem; }
.toc-h2 { font-weight: 500; }
.toc-h3 { padding-left: 1.2rem; font-size: 0.85rem; }

/* ── Node cards ─────────────────────────────────────────────── */

.category {
  margin-bottom: 3rem;
}

.category-title {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85rem;
  font-weight: 500;
  color: var(--accent-2);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
}

.node {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.5rem;
  margin-bottom: 1rem;
  scroll-margin-top: 5rem;
  overflow: hidden;
}

.node-preview {
  float: right;
  width: 220px;
  max-width: 100%;
  margin: 0 0 1rem 1.5rem;
  height: auto;
  display: block;
}

@media (max-width: 720px) {
  .node-preview {
    float: none;
    margin: 0 auto 1rem;
  }
}

.node-title {
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 0.35rem;
}

.node-title a {
  color: var(--text);
  text-decoration: none;
}

.node-title a:hover {
  color: var(--accent);
}

.node-desc {
  color: var(--text-dim);
  font-size: 0.95rem;
  margin-bottom: 0.85rem;
}

.node-help {
  color: var(--text-dim);
  font-size: 0.9rem;
  line-height: 1.65;
  margin-top: 0.5rem;
}

.section-label {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--accent);
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-top: 1.25rem;
  margin-bottom: 0.5rem;
}

/* Properties table */

.props {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.props thead {
  background: var(--bg-inline);
}

.props th {
  text-align: left;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-faint);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--border);
}

.props td {
  padding: 0.5rem 0.75rem;
  color: var(--text-dim);
  vertical-align: top;
  border-bottom: 1px solid var(--border-soft);
}

.props tr:last-child td {
  border-bottom: none;
}

.props code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85em;
  color: var(--text);
  background: transparent;
  padding: 0;
}

.prop-group {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-left: 0.4rem;
}

/* Ports */

.ports {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 0.5rem;
}

@media (max-width: 720px) {
  .ports {
    grid-template-columns: 1fr;
  }
  .docs-layout {
    grid-template-columns: 1fr;
  }
  .docs-sidebar {
    position: static;
    max-height: none;
  }
}

.port-group .section-label {
  margin-top: 0.25rem;
}

.port {
  font-size: 0.85rem;
  padding: 0.35rem 0;
  color: var(--text-dim);
  line-height: 1.5;
}

.port-name {
  font-family: "JetBrains Mono", monospace;
  color: var(--text);
  font-size: 0.8rem;
}

.port-type {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  padding: 0.1rem 0.4rem;
  border-radius: 3px;
  background: var(--bg-inline);
  color: var(--text);
  margin-left: 0.25rem;
}

.port-type.type-audio { color: var(--type-audio); }
.port-type.type-control { color: var(--type-control); }
.port-type.type-midi { color: var(--type-midi); }
.port-type.type-gate { color: var(--type-gate); }
.port-type.type-voct { color: var(--type-voct); }
.port-type.type-data { color: var(--type-data); }
.port-type.type-image { color: var(--type-image); }
.port-type.type-spectral { color: var(--type-spectral); }
.port-type.type-sink { color: var(--type-sink); }

.port-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.7rem;
  color: var(--text-faint);
  margin-left: 0.25rem;
}

/* ── Prose (scripting guide) ────────────────────────────────── */

.prose {
  max-width: 820px;
  font-size: 0.95rem;
  line-height: 1.7;
}

.prose h1 {
  font-size: 2.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin: 1rem 0 1rem;
  background: linear-gradient(180deg, #ffffff 0%, #a8a8b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.prose h2 {
  font-size: 1.6rem;
  font-weight: 600;
  letter-spacing: -0.015em;
  margin: 2.5rem 0 1rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid var(--border);
  scroll-margin-top: 5rem;
}

.prose h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 2rem 0 0.75rem;
  scroll-margin-top: 5rem;
}

.prose h4 {
  font-size: 1rem;
  font-weight: 600;
  margin: 1.5rem 0 0.5rem;
  color: var(--text);
}

.prose p {
  color: var(--text-dim);
  margin: 0.75rem 0;
}

.prose strong {
  color: var(--text);
  font-weight: 600;
}

.prose em {
  color: var(--text);
}

.prose a {
  color: var(--accent);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.prose a:hover {
  border-bottom-color: var(--accent);
}

.prose ul,
.prose ol {
  margin: 0.75rem 0;
  padding-left: 1.5rem;
  color: var(--text-dim);
}

.prose li {
  margin: 0.3rem 0;
}

.prose code {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.85em;
  background: var(--bg-inline);
  color: var(--text);
  padding: 0.15rem 0.4rem;
  border-radius: 3px;
}

.prose pre {
  background: var(--bg-raised);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem 1.1rem;
  overflow-x: auto;
  margin: 1rem 0;
  font-size: 0.85rem;
  line-height: 1.6;
}

.prose pre code {
  background: transparent;
  padding: 0;
  font-size: inherit;
  color: var(--text);
}

/* Syntax highlighting palette - applies to any highlighted code block
   (rhai, rust, bash). Mirrors libs/platform-bevy/src/renderers/rhai_highlight.rs
   so docs match the in-editor console and script editor exactly. */
.prose pre.code code {
  color: rgb(171, 178, 191);
}
.hl-kw { color: rgb(198, 120, 221); }
.hl-bi { color: rgb(97, 175, 239); }
.hl-str { color: rgb(152, 195, 121); }
.hl-num { color: rgb(209, 154, 102); }
.hl-com { color: rgb(92, 99, 112); font-style: italic; }

.prose blockquote {
  border-left: 2px solid var(--accent);
  padding: 0.2rem 0 0.2rem 1rem;
  margin: 1rem 0;
  color: var(--text-dim);
  font-style: italic;
}

.prose table {
  width: 100%;
  border-collapse: collapse;
  margin: 1rem 0;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  overflow: hidden;
}

.prose th {
  text-align: left;
  padding: 0.5rem 0.75rem;
  background: var(--bg-inline);
  color: var(--text);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
}

.prose td {
  padding: 0.5rem 0.75rem;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border-soft);
}

.prose tr:last-child td {
  border-bottom: none;
}

.prose hr {
  border: 0;
  border-top: 1px solid var(--border);
  margin: 2rem 0;
}

/* ── Blog ───────────────────────────────────────────────────── */

.blog-post,
.blog-index {
  max-width: 920px;
  margin: 0 auto;
  padding: 3rem 1.5rem 6rem;
  position: relative;
  z-index: 1;
}

/* Canvas-style dot grid on blog pages to echo the editor canvas. */
body.docs.has-bg {
  background-image: radial-gradient(
    circle,
    rgba(255, 255, 255, 0.035) 1px,
    transparent 1px
  );
  background-size: 28px 28px;
}

/* Soft accent glow behind blog pages - borrowed from the landing so
   writing doesn't feel like a bare doc. */
body.docs.has-bg::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    radial-gradient(
      ellipse 60% 40% at 50% -5%,
      rgba(124, 108, 255, 0.1) 0%,
      transparent 60%
    ),
    radial-gradient(
      ellipse 50% 40% at 95% 100%,
      rgba(0, 217, 196, 0.07) 0%,
      transparent 60%
    );
  pointer-events: none;
  z-index: 0;
}

/* ── Node-framed section + ports + connector overlay ────────── */

.blog-post {
  /* Allow connector overlay to position absolutely against the main. */
  position: relative;
}

.blog-post article {
  position: relative;
  z-index: 1;
}

.node-card {
  --node-title-bg: #262834;
  --node-body-bg: rgba(48, 50, 62, 0.4);
  --node-border: #3e404e;
  --port-dot-size: 10px;
  /* Input sits 1.65rem from the TOP of the card (title-bar y).
     Output mirrors that from the BOTTOM for visual symmetry. */
  --port-in-y: 1.65rem;
  --port-out-y: 1.65rem;

  position: relative;
  background: var(--node-body-bg);
  border: 1px solid var(--node-border);
  border-radius: 8px;
  box-shadow:
    0 1px 2px rgba(0, 0, 0, 0.4),
    0 10px 30px -20px rgba(0, 0, 0, 0.6);
  margin: 0 0 100px;
  padding: 0;
}

.node-card:last-of-type {
  margin-bottom: 0;
}

.node-card > header {
  background: var(--node-title-bg);
  padding: 0.9rem 1.25rem;
  border-radius: 7px 7px 0 0;
  position: relative;
}

.node-card > header::after {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  bottom: -1px;
  height: 2px;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  opacity: 0.7;
}

.node-card > header h2 {
  margin: 0;
  padding: 0;
  font-size: 1.25rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  /* Override the generic blog h2 bar-on-left treatment. */
  border: none;
  background: none;
}

.node-card > header h2::before {
  display: none;
}

.node-card > .node-body {
  padding: 1.5rem 1.75rem 1.75rem;
}

.node-card > .node-body > *:first-child { margin-top: 0; }
.node-card > .node-body > *:last-child { margin-bottom: 0; }

.port-dot {
  position: absolute;
  width: var(--port-dot-size);
  height: var(--port-dot-size);
  border-radius: 50%;
  z-index: 3;
  box-shadow: 0 0 0 2px var(--bg);
}
.port-dot.in {
  left: calc(var(--port-dot-size) / -2);
  top: calc(var(--port-in-y) - var(--port-dot-size) / 2);
}
.port-dot.out {
  right: calc(var(--port-dot-size) / -2);
  bottom: calc(var(--port-out-y) - var(--port-dot-size) / 2);
}
.port-dot.audio   { background: #00ffff; }
.port-dot.control { background: #00ff00; }
.port-dot.voct    { background: #0080ff; }
.port-dot.midi    { background: #ff0000; }
.port-dot.gate    { background: #ffff00; }

.connector-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: visible;
  z-index: 0;
}

.connector-overlay path {
  fill: none;
  stroke: var(--accent);
  stroke-width: 1.5;
  opacity: 0.6;
  stroke-linecap: round;
}

.connector-overlay path.glow {
  stroke: var(--accent);
  stroke-width: 6;
  opacity: 0.15;
  filter: blur(4px);
}

/* Terminal sink node (pull()). */
.sink-node > header > h2 {
  font-family: "JetBrains Mono", monospace;
  font-weight: 500;
  font-size: 1.1rem;
}
.sink-node > header > h2 code {
  background: transparent;
  padding: 0;
  color: var(--text);
}

.sink-body {
  padding: 2.25rem 1.75rem 2rem;
  text-align: center;
}
/* Specificity bump: `.prose p` (0,1,1) would otherwise override single-class
   rules below (0,1,0) and wipe out our `margin: 0 auto`, breaking centering. */
.sink-body .sink-line {
  font-family: "JetBrains Mono", monospace;
  font-size: 1.2rem;
  margin: 0 auto 0.6rem;
}
.sink-body .sink-line a {
  color: var(--text);
  border-bottom: 1px solid var(--accent);
}
.sink-body .sink-caption {
  font-size: 0.85rem;
  color: var(--text-faint);
  max-width: 440px;
  margin: 0 auto;
  line-height: 1.6;
}

/* Section breaks are carried by the node-card frames - hide every hr
   inside any blog page (including ones now nested inside node-body). */
.blog-post hr {
  display: none;
}

.blog-post .prose h2 {
  border-bottom: none;
  padding-bottom: 0;
  position: relative;
  padding-left: 1rem;
  margin-top: 4rem;
}
.blog-post .prose h2::before {
  content: "";
  position: absolute;
  left: 0;
  top: 0.35em;
  bottom: 0.25em;
  width: 3px;
  background: linear-gradient(180deg, var(--accent), var(--accent-2));
  border-radius: 2px;
}

/* Language badge on code blocks. Derived from the `code code-rust`,
   `code code-bash`, etc. classes the generator emits. */
.blog-post .prose pre.code {
  position: relative;
}
.blog-post .prose pre.code::before {
  position: absolute;
  top: 0.55rem;
  right: 0.75rem;
  font-family: "JetBrains Mono", monospace;
  font-size: 0.65rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint, #5a5b68);
  pointer-events: none;
}
.blog-post .prose pre.code-rhai::before { content: "rhai"; }
.blog-post .prose pre.code-rust::before { content: "rust"; }
.blog-post .prose pre.code-bash::before,
.blog-post .prose pre.code-sh::before,
.blog-post .prose pre.code-shell::before,
.blog-post .prose pre.code-console::before { content: "bash"; }

/* Dim the bottom of long prose blocks so scroll-to-continue reads as
   intentional. Subtle - 1-2% opacity at the edges. */
.blog-post .prose blockquote {
  background: linear-gradient(
    90deg,
    rgba(124, 108, 255, 0.06),
    transparent
  );
  padding: 1rem 1.2rem;
  margin: 1.5rem 0;
  border-left-width: 3px;
}

.blog-title {
  font-size: 2.5rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin: 0.5rem 0 0.5rem;
  background: linear-gradient(180deg, #ffffff 0%, #a8a8b8 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.blog-meta {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  color: var(--text-faint, #5a5b68);
  letter-spacing: 0.08em;
  margin: 0 0 2.5rem;
}

.blog-draft {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.15em;
  background: rgba(255, 180, 70, 0.15);
  border: 1px solid rgba(255, 180, 70, 0.4);
  color: #ffb446;
  padding: 0.5rem 0.9rem;
  border-radius: 6px;
  margin-bottom: 2rem;
  text-align: center;
}

.blog-list {
  list-style: none;
  padding: 0;
  margin: 2rem 0 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.blog-list li {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.5rem 1.25rem;
  align-items: baseline;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.blog-list li:last-child {
  border-bottom: none;
}

.blog-list-date {
  font-family: "JetBrains Mono", monospace;
  font-size: 0.8rem;
  color: var(--text-faint, #5a5b68);
  letter-spacing: 0.04em;
}

.blog-list-title {
  font-size: 1.15rem;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  border-bottom: 1px solid transparent;
  transition: border-color 0.15s ease;
}

.blog-list-title:hover {
  border-bottom-color: var(--accent);
}

.blog-list-summary {
  grid-column: 2;
  color: var(--text-dim);
  font-size: 0.95rem;
  line-height: 1.55;
}

.blog-empty {
  color: var(--text-dim);
  font-style: italic;
  margin-top: 2rem;
}

@media (max-width: 720px) {
  .blog-list li {
    grid-template-columns: 1fr;
  }
  .blog-list-summary {
    grid-column: 1;
  }
}
