/* ============================================================
   diagrams.css — FROZEN. Verbatim extract of the diagram rules from the
   pre-redesign custom.css (git 91b8c47), in original order. Do not edit.
   Keep it a separate stylesheet: its Inter @import must stay the first
   statement of its own file (concatenated after other rules it is
   silently dropped and the diagrams' text metrics change).
   diagram-freeze.css (loaded last) pins everything the diagrams inherit.
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&display=swap');

/* Effective token values at 91b8c47 (custom.css :root v1 + v2 merged).
   Diagram rules and the .t-* prose spans read these. --c-bg-soft is
   deliberately NOT defined (swarm .zone-footer relies on it). */
:root {
  --p-font-body: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif;
  --p-font-code: "SF Mono", Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --p-ink: #111; --p-body: #2a2a2a; --p-text: #0d0f12; --p-text-strong: #000;
  --p-muted: #636363; --p-muted-soft: #6b7079; --p-faint: #929292; --p-rule: #e2e2e2;
  --p-bg: #fff; --p-bg-soft: #fafafa; --p-bg-figure: #f9f9f9; --p-code-link: #2a2a2a;
  --c-bg: #fff; --c-bg-figure: #fafafa; --c-bg-code: #fafafa;
  --c-border: #e2e2e2; --c-border-soft: #e2e2e2; --c-text-strong: #111;
  --c-list: #2a2a2a; --c-muted: #636363; --c-muted-soft: #929292;
  --c-link: #0969da; --c-link-bg: #f0f7ff; --c-warn: #bf8700; --c-ok: #1a7f37;
  --c-discovery: #1a7f37; --c-compute: #005cc5; --c-coord: #6f42c1; --c-failure: #d73a49;
  --c-state: #71757e; --c-backward: #bf8700;
  --radius: 4px; --radius-soft: 4px; --radius-card: 8px;
}

/* --- custom.css L365-439 --- */
/* Numbered figures — <figure class="agora-figure"> wraps each diagram and
   provides the soft-gray surface from docs-site (figure-container).        */
.md-content article { counter-reset: agora-fig; }
.md-typeset figure.agora-figure {
  counter-increment: agora-fig;
  margin: 2rem 0;
  background: var(--p-bg-figure);
  border-top: 1px solid var(--c-border-soft);
  border-bottom: 1px solid var(--c-border-soft);
  padding: 24px 0 18px;
  width: 100%;
  overflow-x: auto;
}

/* Wide architecture diagrams (.swarm-fig has min-width: 1100px) stay
   inside the article column and scroll horizontally within the figure
   frame, so they never spill into the navigation or table-of-contents
   columns.                                                           */
@media (min-width: 1220px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    width: 100%;
    max-width: 100%;
    margin-right: 0;
    overflow-x: auto;
  }
  .md-typeset figure.agora-figure .swarm-fig {
    padding: 0;
    margin: 0;
  }
}
.md-typeset figure.agora-figure figcaption {
  font-size: 13px;       /* smaller than diagram body (max 16 px) and prose (17 px) */
  line-height: 1.5;
  color: var(--p-muted);
  margin: 14px auto 0;
  padding: 0 24px;
  max-width: 800px;
  text-align: center;
  font-style: italic;
  font-family: -apple-system, system-ui, "Helvetica Neue", Arial, sans-serif;
}
/* Inline colour cues in figcaptions — match the arrow colour for the
   referenced flow so the legend in the caption reads like the diagram. */
.md-typeset figure.agora-figure figcaption .fig-forward {
  color: var(--c-link); font-weight: 600; font-style: normal;
}
.md-typeset figure.agora-figure figcaption .fig-backward {
  color: var(--c-warn); font-weight: 600; font-style: normal;
}
.md-typeset figure.agora-figure figcaption .fig-discovery {
  color: var(--c-ok); font-weight: 600; font-style: normal;
}
.md-typeset figure.agora-figure figcaption::before {
  content: "Figure " counter(agora-fig) ". ";
  font-weight: 600;
  color: var(--p-text-strong);
  font-style: normal;
}

/* Diagrams use the same sans-serif stack as the rest of the docs. Inter
   falls back to the platform sans if the import fails or is blocked. */
.md-typeset .swarm-fig,
.md-typeset .agora-hero,
.md-typeset .ssn-fig,
.md-typeset .ipc-fig {
  font-family: 'Inter', -apple-system, system-ui, 'Helvetica Neue', Arial, sans-serif;
}

/* Semantic term highlighting (Goodfire-style) */
.t-discovery { color: var(--c-discovery); font-weight: 500; }
.t-compute   { color: var(--c-compute);   font-weight: 500; }
.t-coord     { color: var(--c-coord);     font-weight: 500; }
.t-failure   { color: var(--c-failure);   font-weight: 500; }
.t-state     { color: var(--c-state);     font-weight: 500; }
.t-backward  { color: var(--c-backward);  font-weight: 500; }
/* --- custom.css L601-740 --- */
/* ── Architecture / pipeline-zone diagram ─────────────────── */
.swarm-fig {
  width: fit-content; min-width: 1100px; max-width: 1400px;
  margin: 0 auto; padding: 0 24px;
}
.swarm-fig .fig-header { margin-bottom: 14px; }
.swarm-fig .fig-header h2 { font-size: 22px; margin: 0 0 4px; }
.swarm-fig .fig-header .fig-subtitle { font-size: 13px; color: var(--c-muted); }
.swarm-fig .architecture {
  display: flex; gap: 0; align-items: stretch; min-height: 380px;
}
.swarm-fig .zone {
  display: flex; flex-direction: column;
  border: 1px solid var(--c-border); background: var(--c-bg);
  overflow: hidden;
}
.swarm-fig .zone-header { padding: 10px 14px 8px; border-bottom: 1px solid var(--c-border-soft); }
.swarm-fig .zone-number {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1.5px; color: var(--c-muted-soft); margin-bottom: 2px;
}
.swarm-fig .zone-title { font-size: 16px; font-weight: 700; color: var(--c-text-strong); margin-bottom: 3px; }
.swarm-fig .zone-desc { font-size: 11px; color: var(--c-muted); line-height: 1.4; }
.swarm-fig .zone-body { flex: 1; padding: 10px 12px; display: flex; flex-direction: column; gap: 6px; }
.swarm-fig .seed-zone { flex: 0 0 200px; border-radius: var(--radius-card) 0 0 var(--radius-card); }
.swarm-fig .pipeline-zone { flex: 1; min-width: 500px; }
.swarm-fig .trainer-zone { flex: 0 0 220px; border-radius: 0 var(--radius-card) var(--radius-card) 0; }

.swarm-fig .stage-grid { display: flex; gap: 5px; flex: 1; }
.swarm-fig .pipeline-stage {
  flex: 1; background: var(--c-bg-figure);
  border: 1px solid var(--c-border); border-radius: var(--radius);
  padding: 7px; display: flex; flex-direction: column; gap: 3px;
}
.swarm-fig .pipeline-stage.head, .swarm-fig .pipeline-stage.tail {
  border-color: var(--c-link); background: var(--c-link-bg);
}
.swarm-fig .stage-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--c-muted-soft);
}
.swarm-fig .stage-name { font-size: 13px; font-weight: 700; color: var(--c-list); }
.swarm-fig .stage-detail { font-size: 11px; color: var(--c-muted); line-height: 1.4; }
.swarm-fig .worker-node {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 6px 8px; margin-top: 4px;
}
.swarm-fig .worker-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; color: var(--p-muted-soft);
}
.swarm-fig .worker-gpu  { font-size: 11px; font-weight: 600; color: var(--p-text); }
.swarm-fig .worker-info { font-size: 11px; color: var(--c-muted-soft); }

.swarm-fig .ar-bar {
  margin-top: auto; padding: 5px 8px;
  background: var(--c-link-bg); border: 1px solid #d0e0f0;
  border-radius: var(--radius-soft); text-align: center;
}
.swarm-fig .ar-label {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--c-link);
}
.swarm-fig .ar-detail { font-size: 11px; color: var(--c-muted); }

.swarm-fig .seed-item, .swarm-fig .trainer-item {
  background: var(--c-bg-figure); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 7px; flex: 1;
}
.swarm-fig .seed-name, .swarm-fig .trainer-name {
  font-size: 12px; font-weight: 600; color: var(--c-list);
}
.swarm-fig .seed-desc, .swarm-fig .trainer-desc {
  font-size: 11px; color: var(--c-muted); line-height: 1.4; margin-top: 3px;
}
.swarm-fig .trainer-tag {
  display: inline-block; font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  padding: 2px 5px; border-radius: var(--radius-soft); margin-top: 3px;
}
.swarm-fig .tag-cpu { background: var(--c-link-bg); color: var(--c-link); }

.swarm-fig .arrow-col {
  width: 80px; flex-shrink: 0;
  display: flex; flex-direction: column; justify-content: center;
  align-items: center; gap: 8px; padding: 12px 0;
}
.swarm-fig .data-flow {
  display: flex; flex-direction: column; align-items: center;
  gap: 3px; width: 100%;
}
.swarm-fig .flow-direction {
  font-size: 10px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 1px; color: var(--p-muted-soft);
}
.swarm-fig .flow-arrow-line { width: 100%; height: 2px; position: relative; }
.swarm-fig .flow-arrow-line .line { width: 100%; height: 2px; }
.swarm-fig .flow-arrow-line .head-right {
  position: absolute; right: -1px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.swarm-fig .flow-arrow-line .head-left {
  position: absolute; left: -1px; top: 50%; transform: translateY(-50%);
  width: 0; height: 0; border-top: 4px solid transparent; border-bottom: 4px solid transparent;
}
.swarm-fig .flow-payload {
  background: var(--c-bg); border: 1px solid var(--c-border);
  border-radius: var(--radius); padding: 4px 6px;
  width: 100%; text-align: center;
}
.swarm-fig .payload-what { font-size: 11px; font-weight: 600; color: var(--c-list); line-height: 1.3; }
.swarm-fig .payload-size { font-size: 10px; color: var(--c-muted-soft); margin-top: 2px; }

.swarm-fig .flow-forward .line { background: var(--c-link); }
.swarm-fig .flow-forward .head-right { border-left: 6px solid var(--c-link); }
/* Mirrored direction: same blue, points LEFT. Used where data-going-INTO-
   compute travels right-to-left in the layout (e.g. IPC: Trainer → Workers). */
.swarm-fig .flow-forward .head-left { border-right: 6px solid var(--c-link); }
.swarm-fig .flow-backward .line { background: var(--c-warn); }
.swarm-fig .flow-backward .head-left { border-right: 6px solid var(--c-warn); }
/* Mirrored direction: same yellow, points RIGHT. Used where data-coming-OUT-
   of-compute travels left-to-right in the layout (e.g. IPC: Workers → Trainer). */
.swarm-fig .flow-backward .head-right { border-left: 6px solid var(--c-warn); }
.swarm-fig .flow-discovery .line { background: var(--c-ok); }
.swarm-fig .flow-discovery .head-right { border-left: 6px solid var(--c-ok); }

.swarm-fig .zone-footer {
  padding: 5px 10px; border-top: 1px solid var(--c-border-soft);
  background: var(--c-bg-soft);
}
.swarm-fig .security-badge { display: flex; align-items: flex-start; gap: 5px; }
.swarm-fig .badge-dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--c-ok);
  flex-shrink: 0;
  /* Align to the visual center of the FIRST text line, not the bounding-box
     center — keeps the dot lined up even when text wraps to two lines. */
  margin-top: 0.4em;
}
.swarm-fig .badge-text { font-size: 11px; color: var(--c-muted); }
.swarm-fig .badge-text strong { color: var(--c-list); }
/* --- custom.css L818-836 --- */
/* ── Subspace Networks compression diagram ───────────────── */
.ssn-fig {
  margin: 24px 0; padding: 18px 16px;
  background: var(--c-bg-figure); border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-card);
}
.ssn-fig svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }

/* ── Inter-process communication sequence diagram ────────── */
.ipc-fig {
  margin: 24px 0; padding: 18px 16px;
  background: var(--c-bg-figure); border: 1px solid var(--c-border-soft);
  border-radius: var(--radius-card);
}
.ipc-fig svg { display: block; margin: 0 auto; max-width: 100%; height: auto; }
.ssn-fig .ssn-caption {
  text-align: center; font-size: 12.5px; color: var(--c-muted);
  margin-top: 10px;
}
/* --- custom.css L869-895 --- */
/* ── Responsive ───────────────────────────────────────────── */
@media (max-width: 1100px) {
  .swarm-fig {
    min-width: 0; width: 100%; padding: 0;
  }
  .swarm-fig .architecture {
    flex-direction: column; min-height: 0;
  }
  .swarm-fig .seed-zone, .swarm-fig .pipeline-zone, .swarm-fig .trainer-zone {
    flex: 1 1 auto; min-width: 0; border-radius: 0;
  }
  .swarm-fig .seed-zone { border-radius: var(--radius-card) var(--radius-card) 0 0; }
  .swarm-fig .trainer-zone { border-radius: 0 0 var(--radius-card) var(--radius-card); }
  .swarm-fig .arrow-col {
    width: 100%; flex-direction: row; padding: 8px 12px; gap: 12px;
  }
  .swarm-fig .stage-grid { flex-wrap: wrap; }
  .swarm-fig .pipeline-stage { flex: 1 1 45%; min-width: 200px; }
}

@media (max-width: 700px) {
  .agora-hero { flex-direction: column; }
  .agora-hero .hero-zone + .hero-zone { border-left: none; border-top: 1px solid var(--c-border); }
  .agora-hero .hero-arrow {
    flex: 0 0 24px; height: 24px; transform: rotate(90deg);
  }
}
/* --- custom.css L1597-1888 --- */
/* Figures and existing HTML diagrams. */
.md-content article {
  counter-reset: agora-fig;
}

.md-typeset figure {
  margin: 28px 0;
}

.md-typeset figure.agora-figure {
  box-sizing: border-box;
  width: 100%;
  max-width: 100%;
  margin: 32px 0;
  padding: 18px;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-inline: contain;
  background: var(--p-bg-soft);
  border: 1px solid var(--p-rule);
  border-radius: 8px;
  box-shadow: none;
}

.md-typeset figure.agora-figure:has(.swarm-fig) {
  --p-swarm-zoom: 1;
  overflow-x: hidden;
  overflow-y: visible;
}

@media (min-width: 1220px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    width: min(1280px, calc(100vw - ((100vw - 1080px) / 2 + 237px) - 32px));
    max-width: none;
    margin-right: 0;
  }

  .md-typeset figure.agora-figure .swarm-fig {
    margin: 0;
    padding: 0;
  }
}

@media (max-width: 760px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.47;
    margin-left: -20px;
    margin-right: -20px;
    width: calc(100% + 40px);
    max-width: none;
  }
}

@media (min-width: 761px) and (max-width: 900px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.58;
  }
}

@media (min-width: 901px) and (max-width: 1219px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.68;
  }
}

@media (min-width: 1220px) and (max-width: 1399px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.68;
  }
}

@media (min-width: 1400px) and (max-width: 1599px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.78;
  }
}

@media (min-width: 1600px) and (max-width: 1799px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.86;
  }
}

@media (min-width: 1800px) and (max-width: 1919px) {
  .md-typeset figure.agora-figure:has(.swarm-fig) {
    --p-swarm-zoom: 0.94;
  }
}

.md-typeset figure.agora-figure > .swarm-fig {
  width: max-content;
  min-width: 1220px;
  max-width: none;
  zoom: var(--p-swarm-zoom);
}

.md-typeset figure.agora-figure > .swarm-fig .architecture {
  display: flex;
  flex-direction: row;
  align-items: stretch;
  min-height: 380px;
}

.md-typeset figure.agora-figure > .swarm-fig .seed-zone {
  flex: 0 0 200px;
  border-radius: var(--radius-card) 0 0 var(--radius-card);
}

.md-typeset figure.agora-figure > .swarm-fig .pipeline-zone {
  flex: 1 1 auto;
  min-width: 640px;
}

.md-typeset figure.agora-figure > .swarm-fig .trainer-zone {
  flex: 0 0 220px;
  border-radius: 0 var(--radius-card) var(--radius-card) 0;
}

.md-typeset figure.agora-figure > .swarm-fig .arrow-col {
  flex: 0 0 80px;
  width: auto;
  height: auto;
  transform: none;
}

.md-typeset figure.agora-figure > .swarm-fig .stage-grid {
  display: flex;
  flex-wrap: nowrap;
}

.md-typeset figure.agora-figure > .swarm-fig .pipeline-stage {
  flex: 1 1 0;
  min-width: 0;
}

.md-typeset figure.agora-figure > .ssn-fig,
.md-typeset figure.agora-figure > .ipc-fig {
  min-width: min(760px, 100%);
}

.md-typeset figure.agora-figure figcaption,
.figure-caption,
.ssn-fig .ssn-caption,
.md-typeset figcaption {
  max-width: 680px;
  margin: 12px auto 0;
  padding: 0;
  color: var(--p-faint);
  font-family: var(--p-font-body);
  font-size: 13px;
  font-style: normal;
  line-height: 1.55;
  text-align: center;
}

.md-typeset figure.agora-figure figcaption::before {
  color: var(--p-ink);
  font-weight: 600;
}

.swarm-fig,
.md-typeset .swarm-fig,
.md-typeset .agora-hero,
.md-typeset .ssn-fig,
.md-typeset .ipc-fig,
.md-typeset .worker-fig,
.md-typeset .trainer-fig {
  font-family: var(--p-font-body);
}

.swarm-fig .zone,
.swarm-fig .worker-node,
.swarm-fig .flow-payload,
.agora-hero .hero-zone,
.ssn-fig,
.ipc-fig,
.worker-fig,
.worker-fig .wc-cell,
.trainer-fig {
  border-color: var(--p-rule);
}

.swarm-fig .zone,
.agora-hero .hero-zone {
  background: #fff;
}

.swarm-fig .pipeline-stage,
.swarm-fig .seed-item,
.swarm-fig .trainer-item,
.ssn-fig,
.ipc-fig,
.worker-fig,
.trainer-fig {
  background: #fff;
}

.swarm-fig .pipeline-stage.head,
.swarm-fig .pipeline-stage.tail,
.swarm-fig .ar-bar,
.agora-hero .hero-zone.compute,
.worker-fig .wc-cell,
.worker-fig .wc-cell.accent {
  background: #f3f3f3;
  border-color: var(--p-rule);
}

.swarm-fig .zone-title,
.swarm-fig .stage-name,
.swarm-fig .seed-name,
.swarm-fig .trainer-name,
.agora-hero .hero-zone .hero-title,
.worker-fig .worker-label,
.worker-fig .wc-name {
  color: var(--p-ink);
}

.swarm-fig .zone-desc,
.swarm-fig .stage-detail,
.swarm-fig .worker-info,
.swarm-fig .seed-desc,
.swarm-fig .trainer-desc,
.swarm-fig .payload-size,
.agora-hero .hero-zone .hero-desc,
.worker-fig .wc-desc {
  color: var(--p-muted);
}

.worker-fig {
  box-sizing: border-box;
  display: block;
  max-width: 880px;
  margin: 0 auto;
  padding: 18px 16px;
  border: 1px solid var(--p-rule);
  border-radius: 8px;
}

.worker-fig .worker-label {
  margin: 0 0 14px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.12em;
  line-height: 1.2;
  text-align: center;
  text-transform: uppercase;
}

.worker-fig .worker-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 0;
}

.worker-fig .wc-cell {
  box-sizing: border-box;
  flex: 1 1 calc(33.333% - 10px);
  min-width: 190px;
  margin: 0;
  padding: 10px 12px;
  border: 1px solid var(--p-rule);
  border-radius: 6px;
}

.worker-fig .wc-name {
  margin: 0 0 3px;
  font-size: 13px;
  font-weight: 600;
  line-height: 1.35;
}

.worker-fig .wc-desc {
  margin: 0;
  font-size: 11px;
  line-height: 1.45;
}

.trainer-fig {
  box-sizing: border-box;
  margin: 0 auto;
  padding: 18px 16px;
  border: 1px solid var(--p-rule);
  border-radius: 8px;
}

.trainer-fig svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}
/* --- custom.css L2018-2026 (was inside @media screen and (max-width: 700px)) --- */
@media screen and (max-width: 700px) {
  .md-typeset figure.agora-figure {
    margin-left: -20px;
    margin-right: -20px;
    width: calc(100% + 40px);
    border-left: 0;
    border-right: 0;
    border-radius: 0;
    padding: 18px 20px;
  }
}
