/* Fonts are served from this site (assets/fonts/, SIL Open Font License),
   so the page still makes no requests to other sites. */
@font-face {
  font-family: "Inter";
  src: url("assets/fonts/inter.woff2") format("woff2");
  font-weight: 100 900;
  font-style: normal;
  font-display: swap;
}
@font-face {
  font-family: "JetBrains Mono";
  src: url("assets/fonts/jetbrains-mono.woff2") format("woff2");
  font-weight: 100 800;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #fbfbfd;
  --bg-alt: #f4f3f9;
  --card: #ffffff;
  --bar: #f6f5fa;
  --surface: #f2f1f7;
  --border: #e0ddea;
  --border-soft: #ebe9f2;
  --text: #1b1a22;
  --muted: #55526a;
  --accent: #5b34c4;
  --accent-strong: #6d43d9;
  --accent-tint: rgba(109, 67, 217, 0.1);
  --on-accent: #ffffff;
  --inline-code-bg: rgba(91, 52, 196, 0.08);
  --inline-code-text: #4a2aa8;
  --grid-dot: rgba(91, 52, 196, 0.2);
  --glow: rgba(109, 67, 217, 0.1);
  --shadow: 0 1px 2px rgba(20, 16, 40, 0.04), 0 14px 36px -14px rgba(20, 16, 40, 0.16);
  --ok: #1f9d55;
  --error: #d93d35;
  --warning: #b7791f;
  /* Code blocks are dark in both themes. */
  --code-bg: #1b1a24;
  --code-bar: #23222e;
  --code-line: #33313f;
  --code-text: #ecebf3;
  --code-muted: #a8a5b8;
  --code-accent: #b9a2ff;
  --radius: 10px;
  --radius-large: 14px;
  --wrap: 68rem;
  --sans: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #111018;
    --bg-alt: #15141e;
    --card: #1a1924;
    --bar: #17161f;
    --surface: #1a1924;
    --border: #2c2a3a;
    --border-soft: #22202d;
    --text: #ecebf3;
    --muted: #b0adc0;
    --accent: #b9a2ff;
    --accent-strong: #6d43d9;
    --accent-tint: rgba(185, 162, 255, 0.12);
    --inline-code-bg: rgba(185, 162, 255, 0.12);
    --inline-code-text: #d6c9ff;
    --grid-dot: rgba(185, 162, 255, 0.16);
    --glow: rgba(109, 67, 217, 0.2);
    --shadow: 0 14px 36px -14px rgba(0, 0, 0, 0.7);
    --ok: #4ade80;
    --error: #ff8a80;
    --warning: #f0b660;
    --code-bg: #0b0a10;
    --code-bar: #1a1924;
    --code-line: #2a2837;
  }
}

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

html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 16px/1.65 var(--sans);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  -webkit-text-size-adjust: 100%;
}

a {
  color: var(--accent);
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
  transition: color 0.15s, text-decoration-color 0.15s;
}
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; border-radius: 4px; }

code { font-family: var(--mono); font-size: 0.9em; }
/* JetBrains Mono joins pairs like -> and -- into single symbols by default.
   Commands and source must show the characters people actually type. */
/* The font shorthand resets this, so rules that set font in one line (the
   editor, panel titles) repeat it after their shorthand. */
code, pre, textarea {
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
}
:not(pre) > code {
  padding: 0.12em 0.38em;
  background: var(--inline-code-bg);
  color: var(--inline-code-text);
  border-radius: 5px;
  font-size: 0.86em;
}
a > code { color: inherit; }

h1, h2, h3 { line-height: 1.15; }
h2 {
  margin: 0 0 0.6rem;
  font-size: clamp(1.6rem, 3vw, 2.1rem);
  font-weight: 700;
  letter-spacing: -0.025em;
}
h3 { margin: 0 0 0.35rem; font-size: 1.05rem; font-weight: 650; letter-spacing: -0.01em; }

.wrap { max-width: var(--wrap); margin: 0 auto; padding: 0 1.25rem; }

.skip-link {
  position: absolute;
  left: 0.5rem;
  top: -3rem;
  padding: 0.5rem 0.75rem;
  background: var(--accent-strong);
  color: var(--on-accent);
  border-radius: 6px;
  z-index: 40;
}
.skip-link:focus { top: 0.5rem; }

/* Header: stays at the top while scrolling, over a frosted background. */
.site-header {
  position: sticky;
  top: 0;
  z-index: 30;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 82%, transparent);
  -webkit-backdrop-filter: saturate(140%) blur(10px);
  backdrop-filter: saturate(140%) blur(10px);
  border-bottom: 1px solid var(--border-soft);
}
.header-inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem 1.5rem;
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}
.brand {
  display: inline-flex;
  flex: none;
  align-items: center;
  gap: 0.55rem;
  color: var(--text);
  font-weight: 700;
  font-size: 1.08rem;
  letter-spacing: -0.01em;
  text-decoration: none;
}
.site-header nav ul {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.5rem;
  margin: 0;
  padding: 0;
  list-style: none;
  font-size: 0.93rem;
  font-weight: 500;
}
.site-header nav a { color: var(--muted); text-decoration: none; }
.site-header nav a:hover { color: var(--text); }
/* On phones the menu stays on one line beside the brand and scrolls sideways;
   the fade at its right edge hints that there is more. */
@media (max-width: 40rem) {
  .header-inner { flex-wrap: nowrap; gap: 1rem; }
  .site-header nav {
    min-width: 0;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-mask-image: linear-gradient(to right, #000 80%, transparent);
    mask-image: linear-gradient(to right, #000 80%, transparent);
  }
  .site-header nav::-webkit-scrollbar { display: none; }
  .site-header nav ul { flex-wrap: nowrap; gap: 1.1rem; padding-right: 1.5rem; white-space: nowrap; }
}

/* Anchor targets land below the sticky header. */
section[id] { scroll-margin-top: 4rem; }

/* Hero: a faint dot grid, like graph paper, fading out towards the text. */
.hero {
  position: relative;
  isolation: isolate;
  overflow: hidden;
  padding: 5.5rem 0 4.5rem;
}
.hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background-image: radial-gradient(var(--grid-dot) 1.2px, transparent 1.6px);
  background-size: 22px 22px;
  -webkit-mask-image: radial-gradient(ellipse 55% 80% at 80% 40%, #000 20%, transparent 72%);
  mask-image: radial-gradient(ellipse 55% 80% at 80% 40%, #000 20%, transparent 72%);
}
.hero::after {
  content: "";
  position: absolute;
  top: -14rem;
  right: -10rem;
  z-index: -1;
  width: 44rem;
  height: 44rem;
  background: radial-gradient(closest-side, var(--glow), transparent);
}
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0 0 1.25rem;
  padding: 0.22rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--muted);
  font-size: 0.84rem;
  font-weight: 500;
}
.badge::before {
  content: "";
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--accent-strong);
  box-shadow: 0 0 0 3px var(--accent-tint);
}
.hero h1 {
  margin: 0;
  max-width: 18ch;
  font-size: clamp(2.3rem, 6vw, 3.75rem);
  font-weight: 800;
  line-height: 1.05;
  letter-spacing: -0.035em;
}
.lead {
  max-width: 40rem;
  margin: 1.4rem 0 0;
  color: var(--muted);
  font-size: 1.15rem;
}
.actions { display: flex; flex-wrap: wrap; gap: 0.75rem; margin-top: 2rem; }
.button {
  display: inline-block;
  padding: 0.7rem 1.15rem;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.button:hover { border-color: var(--muted); }
.button-primary {
  background: var(--accent-strong);
  border-color: var(--accent-strong);
  color: var(--on-accent);
  box-shadow: 0 1px 2px rgba(20, 16, 40, 0.15), 0 6px 18px -6px rgba(109, 67, 217, 0.6);
}
.button-primary:hover {
  background: #5b34c4;
  border-color: #5b34c4;
  transform: translateY(-1px);
}

/* Sections: more air, and alternating background shades instead of
   dividing lines. */
.section { padding: 4.5rem 0; }
main > section:nth-of-type(even) {
  background: var(--bg-alt);
  border-block: 1px solid var(--border-soft);
}
.section-lead { max-width: 44rem; margin: 0 0 1.75rem; color: var(--muted); }
.label { margin: 1.1rem 0 0.45rem; font-size: 0.9rem; font-weight: 600; }
@media (max-width: 40rem) {
  .hero { padding: 3.5rem 0 3rem; }
  .section { padding: 3rem 0; }
}

/* Code blocks */
.code {
  position: relative;
  margin: 0 0 1rem;
  padding: 0.9rem 1rem;
  overflow-x: auto;
  background: var(--code-bg);
  color: var(--code-text);
  border-radius: var(--radius);
  font-size: 0.85rem;
  line-height: 1.6;
  tab-size: 2;
}
.code code { font-size: inherit; }
/* Colours for commands and config, matching the live editor's colours. */
.code-comment { color: var(--code-muted); font-style: italic; }
.code-prompt { color: var(--code-accent); user-select: none; }
.code-output { color: var(--code-muted); }
.code-command { color: #8fc7ff; }
.code-flag { color: #ffb86b; }
.code-string { color: #9fd98f; }
.code-operator { color: #7fd8e8; }
.code-key { color: #cbb8ff; }
/* A code block with a Copy button gets a thin top strip for the button, so
   the button never sits on top of the code. app.js adds the wrapper. */
.code-block {
  position: relative;
  margin: 0 0 1rem;
  padding-top: 2.3rem;
  background: var(--code-bg);
  border: 1px solid var(--code-line);
  border-radius: var(--radius);
  overflow: hidden;
}
.code-block::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 2.3rem;
  background: var(--code-bar);
  border-bottom: 1px solid var(--code-line);
}
.code-block > .code { margin: 0; border-radius: 0; }
.copy {
  position: absolute;
  top: 0.42rem;
  right: 0.5rem;
  padding: 0.18rem 0.6rem;
  border: 1px solid var(--code-line);
  border-radius: 6px;
  background: var(--code-bg);
  color: var(--code-muted);
  font: 600 0.75rem/1.4 var(--sans);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.copy:hover, .copy:focus-visible { color: var(--code-text); border-color: var(--code-muted); }

/* Live editor (example section): one window with the diagram on top at the
   full column width, the source below it, and a status bar. */
.live-editor {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  margin-bottom: 1rem;
  overflow: hidden;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius-large);
  box-shadow: var(--shadow);
}
.panel { margin: 0; min-width: 0; display: flex; flex-direction: column; }
.panel-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  min-height: 2.6rem;
  padding: 0.4rem 0.9rem;
  background: var(--bar);
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font: 500 0.8rem var(--mono);
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
}
/* The window's title bar: three dots, then its label. */
.diagram-panel .panel-title { justify-content: flex-start; gap: 0.85rem; }
.diagram-panel .panel-title::before {
  content: "";
  flex: none;
  width: 2.6rem;
  height: 0.65rem;
  background:
    radial-gradient(circle at 0.32rem 50%, var(--border) 0.3rem, transparent 0.32rem),
    radial-gradient(circle at 1.3rem 50%, var(--border) 0.3rem, transparent 0.32rem),
    radial-gradient(circle at 2.28rem 50%, var(--border) 0.3rem, transparent 0.32rem);
}
.diagram-panel + .panel .panel-title { border-top: 1px solid var(--border); }
.panel-button {
  padding: 0.15rem 0.6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--card);
  color: var(--muted);
  font: 600 0.75rem/1.4 var(--sans);
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s;
}
.panel-button:hover { color: var(--text); border-color: var(--muted); }

/* The editor is a transparent textarea over a highlighted copy of its text.
   Both must use identical font, padding and wrapping so the text lines up. */
/* Tall enough to show every line (1.28rem per line, plus padding and room for
   a horizontal scrollbar). editor.js keeps --editor-lines in step with the
   source; 18 is the example's line count. */
.editor {
  position: relative;
  height: clamp(8rem, calc(var(--editor-lines, 18) * 1.28rem + 2.55rem), 36rem);
  background: var(--code-bg);
  overflow: hidden;
}
.editor-highlight, .editor-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 0.9rem 1rem;
  border: 0;
  font: 0.8rem/1.6 var(--mono);
  font-variant-ligatures: none;
  font-feature-settings: "calt" 0, "liga" 0;
  letter-spacing: 0;
  tab-size: 2;
  white-space: pre;
  overflow: auto;
}
/* The highlighted copy only follows the textarea's scrolling (editor.js), so
   it shows no scrollbars of its own. */
.editor-highlight { color: var(--code-text); pointer-events: none; overflow: hidden; }
.editor-highlight code { font: inherit; font-variant-ligatures: inherit; font-feature-settings: inherit; }
.editor-input {
  width: 100%;
  height: 100%;
  resize: none;
  background: transparent;
  color: var(--code-text);
  caret-color: var(--code-text);
  outline: none;
}
.editor:focus-within { outline: 2px solid var(--accent); outline-offset: -2px; }
/* Only once the highlighter runs does the textarea text become see-through. */
.live-editor.is-live .editor-input { color: transparent; }
.live-editor.is-live .editor-input::selection { background: rgba(185, 162, 255, 0.35); color: transparent; }
.live-editor:not(.is-live) .editor-highlight { display: none; }

.token-comment { color: #8b88a0; font-style: italic; }
.token-string { color: #9fd98f; }
.token-name { color: #cbb8ff; font-weight: 600; }
.token-type { color: #8fc7ff; }
.token-keyword { color: #ffb86b; }
.token-arrow { color: #7fd8e8; }
.token-key { color: #b9a2ff; }
.token-number { color: #f5c26b; }
.line-error {
  background: rgba(248, 81, 73, 0.18);
  text-decoration: underline wavy #ff6b6b;
  text-decoration-skip-ink: none;
  text-underline-offset: 3px;
}

/* Status bar: a grey dot while loading, green when the source parses, red
   with the error otherwise. */
.editor-status {
  margin: 0;
  padding: 0.55rem 0.9rem 0.55rem 2.1rem;
  position: relative;
  background: var(--bar);
  border-top: 1px solid var(--border);
  color: var(--muted);
  font-size: 0.83rem;
  line-height: 1.55;
}
.editor-status::before {
  content: "";
  position: absolute;
  left: 0.95rem;
  top: 0.95rem;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--muted);
  opacity: 0.6;
}
.editor-status.is-ok::before { background: var(--ok); opacity: 1; }
.editor-status.is-error { color: var(--error); }
.editor-status.is-error::before { background: var(--error); opacity: 1; }
.editor-status .hint { display: block; color: var(--muted); }

/* The panel takes the diagram's own shape. Very tall diagrams are capped so
   they fit on screen; the space beside them takes the diagram's background
   colour (set by editor.js), so no box shows inside the panel. */
.diagram {
  position: relative;
  overflow: hidden;
  background: var(--surface);
}
.diagram img, .diagram svg { display: block; width: 100%; height: auto; max-height: 80vh; }
.diagram img { object-fit: contain; }
/* Touch screens keep normal scrolling over the diagram; dragging boxes is
   for mouse and pen. */
@media (pointer: fine) {
  .diagram svg { touch-action: none; }
}
.diagram.is-over-node { cursor: grab; }
.diagram.is-dragging { cursor: grabbing; }
/* Floats over the bottom of the diagram, so showing it never pushes the
   editor down while someone is typing. */
.diagram-panel { position: relative; }
.diagram-note {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  transform: translateX(-50%);
  width: max-content;
  max-width: calc(100% - 2rem);
  margin: 0;
  padding: 0.3rem 0.75rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--warning);
  font-size: 0.85rem;
  text-align: center;
  pointer-events: none;
}
.diagram-note[hidden] { display: none; }
.editor-footnote { margin: 0 0 1rem; color: var(--muted); font-size: 0.85rem; }

/* Feature cards, each with a small line icon. */
.features, .types, .notes { margin: 0; padding: 0; list-style: none; }
.features {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(12rem, 1fr));
  gap: 1rem;
}
.features li {
  padding: 1.15rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
}
.feature-icon {
  display: grid;
  place-items: center;
  width: 2.25rem;
  height: 2.25rem;
  margin-bottom: 0.85rem;
  border-radius: 9px;
  background: var(--accent-tint);
  color: var(--accent);
}
.feature-icon svg { width: 1.15rem; height: 1.15rem; }
.features p { margin: 0; color: var(--muted); font-size: 0.94rem; }
.features h3 code { padding: 0; background: none; color: var(--accent); font-size: 0.95em; }

.notes li { position: relative; padding-left: 1.1rem; margin: 0.4rem 0; color: var(--muted); }
.notes li::before { content: "–"; position: absolute; left: 0; }

/* Agents: one row per topic, the explanation on the left and its code on the
   right, so every code block starts at the same left edge and width. */
.agent-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem 3rem;
  padding: 1.75rem 0;
  border-top: 1px solid var(--border);
}
.agent-row:first-of-type { padding-top: 0.75rem; border-top: 0; }
.agent-row:last-of-type { padding-bottom: 0; }
@media (min-width: 52rem) {
  .agent-row { grid-template-columns: minmax(0, 2fr) minmax(0, 3fr); }
}
.agent-text h3 { margin-top: 0.15rem; }
.agent-text p { margin: 0.5rem 0 0; color: var(--muted); }
.agent-code .label:first-child { margin-top: 0; }
.agent-code .code-block:last-child,
.agent-code > .code:last-child { margin-bottom: 0; }

/* Diagram types. Each card is a button that loads its example into the live
   editor. The buttons start disabled and plain; editor.js enables them once
   the editor is running. */
.types {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(15rem, 1fr));
  gap: 0.7rem;
}
.type-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 0.8rem 2.2rem 0.85rem 1rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: inherit;
  font: inherit;
  text-align: left;
}
.type-card:disabled { cursor: default; }
.type-card code { padding: 0; background: none; color: var(--accent); font-weight: 600; font-size: 0.88em; }
.type-card span { color: var(--muted); font-size: 0.92rem; }
.type-card:enabled {
  cursor: pointer;
  transition: transform 0.15s, border-color 0.15s, box-shadow 0.15s, background-color 0.15s;
}
.type-card:enabled:hover,
.type-card:enabled:focus-visible {
  transform: translateY(-2px);
  border-color: color-mix(in srgb, var(--accent) 55%, var(--border));
  box-shadow: 0 12px 26px -16px rgba(109, 67, 217, 0.7);
}
/* An arrow in the corner on hover says "open this". */
.type-card:enabled::after {
  content: "";
  position: absolute;
  top: 0.85rem;
  right: 0.85rem;
  width: 0.95rem;
  height: 0.95rem;
  background: var(--accent);
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='black' stroke-width='2.4' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M7 17 17 7M8 7h9v9'/%3E%3C/svg%3E") center / contain no-repeat;
  opacity: 0;
  transform: translate(-3px, 3px);
  transition: opacity 0.15s, transform 0.15s;
}
.type-card:enabled:hover::after,
.type-card:enabled:focus-visible::after { opacity: 1; transform: none; }
/* The card whose example is in the editor: tinted, with a dot instead of the arrow. */
.type-card[aria-pressed="true"] {
  background: color-mix(in srgb, var(--accent) 9%, var(--card));
  border-color: var(--accent);
}
.type-card[aria-pressed="true"]::after {
  width: 0.5rem;
  height: 0.5rem;
  top: 1.05rem;
  right: 1.05rem;
  border-radius: 50%;
  -webkit-mask: none;
  mask: none;
  opacity: 1;
  transform: none;
  box-shadow: 0 0 0 3px var(--accent-tint);
}

/* A short pulse around the editor window when a card loads a new example,
   so the eye catches the change after scrolling up. */
.live-editor { scroll-margin-top: 5rem; }
.live-editor.is-switching { animation: editor-pulse 0.9s ease-out; }
@keyframes editor-pulse {
  from { box-shadow: 0 0 0 0 rgba(109, 67, 217, 0.55), var(--shadow); }
  to { box-shadow: 0 0 0 16px rgba(109, 67, 217, 0), var(--shadow); }
}

/* Footer */
.site-footer { border-top: 1px solid var(--border-soft); color: var(--muted); font-size: 0.9rem; }
.footer-inner {
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 0.5rem 2rem;
  padding-top: 1.75rem;
  padding-bottom: 2.25rem;
}
.footer-inner p { margin: 0; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; }
  .button-primary:hover,
  .type-card:enabled:hover,
  .type-card:enabled:focus-visible { transform: none; }
  .live-editor.is-switching { animation: none; }
}
