/* Swarmplane visual system.
 *
 * Technical-editorial restyle of MkDocs Material: typography-first, flat
 * chrome, one muted copper accent, both schemes designed deliberately.
 * Diagram colors go through Material's --md-mermaid-* variables only —
 * Mermaid renders into a closed shadow root that page CSS cannot reach
 * (see ADR-0002, "Known issue").
 */

@import url("https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&display=swap");

/* ------------------------------------------------------------------ */
/* Color tokens                                                        */
/* ------------------------------------------------------------------ */

/* Dark: desaturated near-black surfaces, warm gray text, copper accent. */
[data-md-color-scheme="slate"] {
  --sp-bg: #0e1116;
  --sp-surface: #161b22;
  --sp-line: #262c35;
  --sp-ink: #d6d9de;
  --sp-ink-muted: #9aa3ad;
  --sp-accent: #d9915b;

  --md-default-bg-color: var(--sp-bg);
  --md-default-fg-color: var(--sp-ink);
  --md-default-fg-color--light: var(--sp-ink);
  --md-default-fg-color--lighter: var(--sp-ink-muted);
  /* Low-alpha, matching stock semantics: Material uses --lightest for subtle
     fills (e.g. Mermaid cluster backgrounds) — a solid value here turns
     diagram clusters into heavy gray panels. */
  --md-default-fg-color--lightest: rgba(214, 217, 222, 0.06);

  --md-primary-fg-color: var(--sp-bg);
  --md-primary-fg-color--light: var(--sp-surface);
  --md-primary-fg-color--dark: var(--sp-bg);
  --md-primary-bg-color: var(--sp-ink);
  --md-primary-bg-color--light: var(--sp-ink-muted);

  --md-accent-fg-color: var(--sp-accent);
  --md-accent-fg-color--transparent: rgba(217, 145, 91, 0.12);
  --md-accent-bg-color: var(--sp-bg);
  --md-accent-bg-color--light: var(--sp-bg);

  --md-typeset-a-color: var(--sp-accent);
  --md-code-bg-color: var(--sp-surface);
  --md-code-fg-color: #c9d1d9;

  --md-footer-bg-color: var(--sp-bg);
  --md-footer-bg-color--dark: var(--sp-bg);
  --md-footer-fg-color: var(--sp-ink);
  --md-footer-fg-color--light: var(--sp-ink-muted);
  --md-footer-fg-color--lighter: #566069;

  --md-mermaid-font-family: "Inter", sans-serif;
  --md-mermaid-node-bg-color: var(--sp-surface);
  /* Node border must carry more contrast than the edge: Material feeds these to
     `.node rect{stroke}` and `.edgePath .path{stroke}`, so equal values give
     boxes and arrows identical weight and the diagram reads flat. Separate them
     by strengthening the border, never by weakening the edge — --edge-color also
     drives `.edgeLabel p{color}`, which is label text. 5.5:1 vs 4.1:1 on --sp-bg. */
  --md-mermaid-node-fg-color: #828c97;
  --md-mermaid-edge-color: #6d7681;
  --md-mermaid-label-bg-color: transparent;
  --md-mermaid-label-fg-color: var(--sp-ink);
}

/* Light: warm off-white paper, near-black ink, darkened copper accent. */
[data-md-color-scheme="default"] {
  --sp-bg: #faf9f7;
  --sp-surface: #f1efeb;
  --sp-line: #e2ded7;
  --sp-ink: #1d232b;
  --sp-ink-muted: #5d6672;
  /* Darker than the dark-scheme accent: #b05f2c only reaches ~4.4:1 on this
     background; this hits ~5.2:1. */
  --sp-accent: #a2561f;

  --md-default-bg-color: var(--sp-bg);
  --md-default-fg-color: var(--sp-ink);
  --md-default-fg-color--light: var(--sp-ink);
  --md-default-fg-color--lighter: var(--sp-ink-muted);
  --md-default-fg-color--lightest: rgba(29, 35, 43, 0.05);

  --md-primary-fg-color: var(--sp-bg);
  --md-primary-fg-color--light: var(--sp-surface);
  --md-primary-fg-color--dark: var(--sp-bg);
  --md-primary-bg-color: var(--sp-ink);
  --md-primary-bg-color--light: var(--sp-ink-muted);

  --md-accent-fg-color: var(--sp-accent);
  --md-accent-fg-color--transparent: rgba(162, 86, 31, 0.1);
  --md-accent-bg-color: var(--sp-bg);
  --md-accent-bg-color--light: var(--sp-bg);

  --md-typeset-a-color: var(--sp-accent);
  --md-code-bg-color: var(--sp-surface);
  --md-code-fg-color: #24292f;

  --md-footer-bg-color: var(--sp-bg);
  --md-footer-bg-color--dark: var(--sp-bg);
  --md-footer-fg-color: var(--sp-ink);
  --md-footer-fg-color--light: var(--sp-ink-muted);
  --md-footer-fg-color--lighter: #9aa0a8;

  --md-mermaid-font-family: "Inter", sans-serif;
  --md-mermaid-node-bg-color: var(--sp-surface);
  /* See the slate block: border outranks edge, never the reverse. 5.2:1 vs 3.6:1. */
  --md-mermaid-node-fg-color: #6f685c;
  --md-mermaid-edge-color: #8a8377;
  --md-mermaid-label-bg-color: transparent;
  --md-mermaid-label-fg-color: var(--sp-ink);
}

/* ------------------------------------------------------------------ */
/* Header: flat, hairline-bordered — no colored band                   */
/* ------------------------------------------------------------------ */

.md-header {
  background-color: var(--md-default-bg-color);
  color: var(--md-default-fg-color);
  box-shadow: none;
  border-bottom: 1px solid var(--sp-line);
}

.md-header__title {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.md-search__form {
  background-color: transparent;
  border: 1px solid var(--sp-line);
  border-radius: 0.2rem;
}

.md-search__form:hover {
  background-color: var(--sp-surface);
}

.md-search__input::placeholder,
.md-search__icon {
  color: var(--sp-ink-muted);
}

[data-md-toggle="search"]:checked ~ .md-header .md-search__form {
  background-color: var(--sp-surface);
  border-color: var(--sp-line);
}

/* Source (GitHub) chip in the header */
.md-source {
  color: var(--sp-ink-muted);
}

/* ------------------------------------------------------------------ */
/* Typography                                                          */
/* ------------------------------------------------------------------ */

.md-typeset {
  line-height: 1.65;
}

.md-typeset h1,
.md-typeset h2,
.md-typeset h3,
.md-typeset h4 {
  font-family: "Space Grotesk", "Inter", sans-serif;
  color: var(--md-default-fg-color);
}

.md-typeset h1 {
  font-size: 2.1em;
  font-weight: 700;
  letter-spacing: -0.02em;
  margin-bottom: 0.8em;
}

.md-typeset h2 {
  font-size: 1.45em;
  font-weight: 600;
  letter-spacing: -0.015em;
}

.md-typeset h3 {
  font-size: 1.15em;
  font-weight: 600;
  letter-spacing: -0.01em;
}

/* Heading permalink anchors: quiet until hover */
.md-typeset .headerlink {
  color: var(--sp-line);
}

.md-typeset .headerlink:hover,
.md-typeset :target > .headerlink {
  color: var(--sp-accent);
}

/* Links: accent color, understated underline that firms up on hover */
.md-typeset a {
  text-decoration: underline;
  text-decoration-color: color-mix(in srgb, var(--sp-accent) 40%, transparent);
  text-underline-offset: 0.15em;
}

.md-typeset a:hover {
  text-decoration-color: var(--sp-accent);
}

/* ------------------------------------------------------------------ */
/* Code                                                                */
/* ------------------------------------------------------------------ */

.md-typeset code {
  border-radius: 3px;
  font-size: 0.82em;
}

/* Code blocks are evidence here, not decoration — keep them a notch
   larger than Material's habit so SQL and Python stay comfortable. */
.md-typeset pre > code {
  font-size: 0.85em;
  line-height: 1.6;
}

.md-typeset .highlight {
  border: 1px solid var(--sp-line);
  border-radius: 0.2rem;
}

/* ------------------------------------------------------------------ */
/* Navigation and TOC                                                  */
/* ------------------------------------------------------------------ */

/* Section labels: small caps, letterspaced */
.md-nav__item--section > .md-nav__link {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sp-ink-muted);
}

.md-nav__link {
  color: var(--md-default-fg-color--lighter);
}

.md-nav__link:hover {
  color: var(--sp-accent);
}

.md-nav__link--active,
.md-nav__link--active code {
  color: var(--sp-accent);
  font-weight: 600;
}

/* TOC: hairline rail */
.md-nav--secondary .md-nav__list {
  border-left: 1px solid var(--sp-line);
  padding-left: 0.6rem;
}

.md-nav--secondary .md-nav__title {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sp-ink-muted);
  box-shadow: none;
}

/* ------------------------------------------------------------------ */
/* Admonitions: left-border style instead of tinted boxes              */
/* ------------------------------------------------------------------ */

.md-typeset .admonition,
.md-typeset details {
  border-width: 0 0 0 3px;
  border-radius: 0 0.2rem 0.2rem 0;
  box-shadow: none;
  background-color: var(--sp-surface);
  font-size: 0.72rem;
}

.md-typeset .admonition-title,
.md-typeset summary {
  background-color: transparent !important;
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
}

/* ------------------------------------------------------------------ */
/* Tables                                                              */
/* ------------------------------------------------------------------ */

.md-typeset table:not([class]) {
  border: 1px solid var(--sp-line);
  border-radius: 0.2rem;
  box-shadow: none;
  font-size: 0.72rem;
}

.md-typeset table:not([class]) th {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  background-color: var(--sp-surface);
  color: var(--md-default-fg-color);
}

.md-typeset table:not([class]) td {
  border-top: 1px solid var(--sp-line);
}

/* ------------------------------------------------------------------ */
/* Footer                                                              */
/* ------------------------------------------------------------------ */

.md-footer {
  border-top: 1px solid var(--sp-line);
}

.md-footer-meta {
  background-color: var(--md-default-bg-color);
}

.md-footer__inner {
  padding-top: 0.8rem;
  padding-bottom: 0.8rem;
}

.md-footer__title {
  font-family: "Space Grotesk", "Inter", sans-serif;
}

/* ------------------------------------------------------------------ */
/* Landing page (docs/index.md only — .sp-* containers exist nowhere   */
/* else, so nothing here can leak into interior pages)                 */
/* ------------------------------------------------------------------ */

/* With the sidebars hidden, prose would run the full ~61rem grid — about
   150 characters a line. Cap every loose block at a readable measure and
   center it, so the leftover width splits evenly instead of piling up on
   the right; only the hero, diagram, and card grid may span the page.
   rem, not em: the strip and status run a smaller font than the body
   blocks, so an em cap gives each a different pixel width and a ragged
   column edge. 32rem is the old 40em at body size (0.8rem). */
.sp-landing > p,
.sp-landing > ol,
.sp-landing > .sp-status {
  max-width: 32rem;
  margin-inline: auto;
}

/* Material's own list rule out-specifies the group above for margin-left,
   which un-centers the ol; re-state the centering above its specificity. */
.md-typeset .sp-landing > ol {
  margin-inline: auto;
}

/* Headings center as text — a short line anchored to a centered column's
   left edge would read as accidentally indented. */
.md-typeset .sp-landing h2 {
  text-align: center;
}

/* A front door, not a docs page: no permalink ¶ on landing headings. */
.sp-landing .headerlink {
  display: none;
}

.sp-hero {
  padding: 2.6rem 0 1.2rem;
  text-align: center;
}

/* Must out-specify `.md-typeset h1` above; the landing h1 is the hero. */
.md-typeset .sp-hero h1 {
  font-size: clamp(1.9rem, 5vw, 2.6rem);
  font-weight: 700;
  letter-spacing: -0.025em;
  line-height: 1.15;
  max-width: 22em;
  margin: 0 auto 0.6em;
}

/* Hero lede: Inter, not Space Grotesk — a display face carrying running
   text reads effortful; the heading pays for the grotesk, the lede doesn't. */
.md-typeset .sp-lede {
  font-size: 0.95rem;
  font-weight: 400;
  color: var(--md-default-fg-color--lighter);
  max-width: 36em;
  margin: 0 auto 1.6em;
}

.sp-hero .md-button {
  margin: 0.15rem 0.25rem;
}

/* Buttons: Material derives .md-button colors from the primary tokens,
   which this theme remaps to background values — unstyled, the label
   would sit at background-on-background. Restyle from --sp-* directly.
   Primary uses --sp-bg as text on --sp-accent: each scheme's own pairing
   clears 4.5:1 (#0e1116 on #d9915b, #faf9f7 on #a2561f). */
.md-typeset .md-button {
  border: 1px solid var(--sp-line);
  border-radius: 0.2rem;
  color: var(--md-default-fg-color);
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-weight: 600;
  text-decoration: none;
}

.md-typeset .md-button:hover {
  background-color: var(--sp-surface);
  border-color: var(--sp-ink-muted);
  color: var(--md-default-fg-color);
}

.md-typeset .md-button--primary {
  background-color: var(--sp-accent);
  border-color: var(--sp-accent);
  color: var(--sp-bg);
}

.md-typeset .md-button--primary:hover {
  /* Mixing toward ink shifts the copper toward the scheme's text color —
     lighter in dark, darker in light — so hover reads in both. */
  background-color: color-mix(in srgb, var(--sp-accent) 82%, var(--sp-ink));
  border-color: transparent;
  color: var(--sp-bg);
}

/* Small-caps kicker, same voice as the sidebar section labels */
.md-typeset .sp-kicker {
  font-family: "Space Grotesk", "Inter", sans-serif;
  font-size: 0.62rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.09em;
  color: var(--sp-ink-muted);
  text-align: center;
  margin-bottom: 0;
}

.sp-graph {
  margin: 1.6rem auto 2.4rem;
  text-align: center;
}

.md-typeset .sp-caption {
  font-size: 0.68rem;
  color: var(--md-default-fg-color--lighter);
  max-width: 34em;
  margin: 0.4rem auto 0;
}

.sp-cards {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.6rem;
  margin: 1.2rem 0;
}

@media screen and (max-width: 44.9375em) {
  .sp-cards {
    grid-template-columns: 1fr;
  }
}

.sp-card {
  border: 1px solid var(--sp-line);
  border-radius: 0.2rem;
  background-color: var(--sp-surface);
  padding: 0.9rem 1rem;
  font-size: 0.72rem;
}

.md-typeset .sp-card h3 {
  font-size: 0.85rem;
  margin: 0 0 0.5em;
}

.sp-card > :last-child {
  margin-bottom: 0;
}

.md-typeset .sp-strip {
  border-top: 1px solid var(--sp-line);
  border-bottom: 1px solid var(--sp-line);
  padding: 0.9rem 0;
  /* auto, not 0: this shorthand out-specifies the shared column group's
     margin-inline, so it must re-state the centering itself. */
  margin: 2rem auto;
  font-size: 0.72rem;
  color: var(--md-default-fg-color--lighter);
}

/* Status: same left-border grammar as admonitions, accent because the
   no-promise disclosure is the one thing this page must not mute. */
.sp-status {
  border-left: 3px solid var(--sp-accent);
  border-radius: 0 0.2rem 0.2rem 0;
  background-color: var(--sp-surface);
  padding: 0.8rem 1rem;
  /* Width and centering come from the shared 32rem column cap above. */
  margin: 2rem auto 1rem;
  font-size: 0.72rem;
}

.sp-status > :last-child {
  margin-bottom: 0;
}
