/* Each project has one colour, shared by the diagram and its section. */
:root {
  color-scheme: dark;
  --bg: #0a1426;
  --surface: #101e36;
  --ink: #e8eefb;
  --muted: #a3b3cf;
  --line: #26385a;
  --core: #5ba8ff;
  --sync: #3fd8d0;
  --interop: #b49cff;
  --core-tint: #12294a;
  --sync-tint: #0d2f3d;
  --interop-tint: #241f4d;
  --sans: "Source Sans 3", system-ui, sans-serif;
  --display: "Bricolage Grotesque", var(--sans);
  --mono: "JetBrains Mono", ui-monospace, monospace;
}

/* Dark is the default. Light applies when the system asks for it, unless the
   header toggle has saved a choice; the two blocks below must stay in sync. */
@media (prefers-color-scheme: light) {
  :root:not([data-theme="dark"]) {
    color-scheme: light;
    --bg: #f5f8fd;
    --surface: #ffffff;
    --ink: #0f1f3d;
    --muted: #4a5b78;
    --line: #d3ddec;
    --core: #1a62c4;
    --sync: #0a7078;
    --interop: #6242c9;
    --core-tint: #e3eefc;
    --sync-tint: #dff4f5;
    --interop-tint: #ece7fc;
  }
}

:root[data-theme="light"] {
  color-scheme: light;
  --bg: #f5f8fd;
  --surface: #ffffff;
  --ink: #0f1f3d;
  --muted: #4a5b78;
  --line: #d3ddec;
  --core: #1a62c4;
  --sync: #0a7078;
  --interop: #6242c9;
  --core-tint: #e3eefc;
  --sync-tint: #dff4f5;
  --interop-tint: #ece7fc;
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; scroll-padding-top: 1.5rem; -webkit-text-size-adjust: 100%; }
@media (prefers-reduced-motion: reduce) { html { scroll-behavior: auto; } }

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font: 400 1.125rem/1.6 var(--sans);
}

.wrap { width: min(100%, 68rem); margin-inline: auto; padding-inline: clamp(1rem, 4vw, 2rem); }

a { color: inherit; text-underline-offset: 0.18em; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; border-radius: 2px; }

code { font: 400 0.86em var(--mono); overflow-wrap: anywhere; }

.sr-only {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap;
}
.skip { position: absolute; left: -999px; }
.skip:focus { left: 1rem; top: 1rem; background: var(--surface); padding: 0.5rem 0.75rem; z-index: 1; }

/* Header */
.site-header {
  display: flex; flex-wrap: wrap; align-items: center;
  gap: 0.25rem 1.25rem; padding-block: 1.5rem;
}
.name { font: 700 1.2rem var(--display); text-decoration: none; margin-right: auto; }
.theme-toggle {
  padding: 0.3rem 0.7rem; cursor: pointer;
  font: 400 0.9375rem var(--sans); color: var(--muted);
  background: transparent; border: 1px solid var(--line); border-radius: 6px;
}
.theme-toggle:hover { color: var(--ink); border-color: var(--muted); }
.theme-toggle[hidden] { display: none; }
@media (max-width: 480px) {
  .site-header nav { order: 1; width: 100%; }
}
.site-header nav { display: flex; gap: 1.25rem; font-size: 1rem; }
.site-header nav a { text-decoration: none; color: var(--muted); padding-block: 0.25rem; }
.site-header nav a:hover { color: var(--ink); text-decoration: underline; }

/* Hero */
.hero { padding-block: clamp(2.5rem, 8vw, 5.5rem) 2.5rem; }
.eyebrow, .kicker, .meta, .r-where, figcaption {
  font: 400 0.8125rem/1.5 var(--mono); color: var(--muted);
}
.eyebrow { margin: 0 0 1.25rem; }
h1, h2, h3 { font-family: var(--display); line-height: 1.08; text-wrap: balance; }
h1 {
  margin: 0; max-width: 19em; font-weight: 700; letter-spacing: -0.02em;
  font-size: clamp(2.25rem, 6.2vw, 4.25rem);
}
.lede { max-width: 39em; margin: 1.75rem 0 0; font-size: clamp(1.15rem, 2vw, 1.3rem); line-height: 1.5; color: var(--muted); }

/* Diagram: desktop SVG, phone list */
.map { padding-block: 1rem 3rem; }
.map-svg { display: block; width: 100%; height: auto; }
.map-svg a { text-decoration: none; }
.group.core { --c: var(--core); --t: var(--core-tint); }
.group.sync { --c: var(--sync); --t: var(--sync-tint); }
.group.interop { --c: var(--interop); --t: var(--interop-tint); }
.group-label { font: 500 13px var(--mono); fill: var(--c); }
.node rect { fill: var(--t); stroke: var(--c); stroke-width: 1.25; transition: stroke-width 0.15s; }
.group:hover .node rect, .group:focus-visible .node rect { stroke-width: 2.5; }
.node text { text-anchor: middle; fill: var(--ink); }
.node .t { font: 600 15px var(--sans); }
.node .s { font: 400 11.5px var(--mono); fill: var(--muted); }
.link { fill: none; stroke: var(--c); stroke-width: 1.5; }
.link.dashed { stroke-dasharray: 5 4; }
.edge { font: 400 11.5px var(--mono); fill: var(--muted); text-anchor: middle; }
.head.core path { fill: var(--core); }
.head.sync path { fill: var(--sync); }
.head.interop path { fill: var(--interop); }

.map-list { display: none; list-style: none; margin: 0; padding: 0; }
.map-list li { padding: 0.8rem 0 0.8rem 1rem; border-left: 3px solid var(--c); margin-bottom: 0.75rem; line-height: 1.4; }
.map-list a { display: block; margin-bottom: 0.15rem; color: var(--c); }
.map-list .core { --c: var(--core); }
.map-list .sync { --c: var(--sync); }
.map-list .interop { --c: var(--interop); }

@media (max-width: 760px) {
  .map-svg { display: none; }
  .map-list { display: block; }
}

/* Context */
.context p {
  max-width: 47em; margin: 0; padding-block: 1.5rem;
  border-block: 1px solid var(--line); color: var(--muted);
}
.context strong { color: var(--ink); }

/* Projects */
.project { padding-block: clamp(3.5rem, 8vw, 6rem) 0; }
.project.core { --c: var(--core); --t: var(--core-tint); }
.project.sync { --c: var(--sync); --t: var(--sync-tint); }
.project.interop { --c: var(--interop); --t: var(--interop-tint); }

.project-head { border-top: 4px solid var(--c); padding-top: 1rem; margin-bottom: 2rem; }
.kicker { margin: 0 0 1.5rem; color: var(--c); }
.project h2 { margin: 0; font-size: clamp(2rem, 5vw, 3.25rem); letter-spacing: -0.02em; }
.summary { max-width: 30em; margin: 0.75rem 0 0.75rem; font: 500 clamp(1.25rem, 2.6vw, 1.6rem)/1.3 var(--display); }
.meta { margin: 0; }
.project h3 { font-size: 1.35rem; margin: 2.75rem 0 1rem; }

.prose { max-width: 41em; }
.prose p { margin: 0 0 1rem; }

/* Table */
figure { margin: 2rem 0 0; }
figcaption { margin-bottom: 0.6rem; }
.table-scroll { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 8px; }
table { width: 100%; min-width: 44rem; border-collapse: collapse; font-size: 1rem; line-height: 1.4; }
th, td { padding: 0.75rem 1rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--line); }
th { font: 500 0.8125rem var(--mono); color: var(--muted); }
tbody tr:last-child td { border-bottom: 0; }
td code { color: var(--c); overflow-wrap: normal; }
td:first-child { white-space: nowrap; }

/* Work lists */
.work-list { list-style: none; margin: 0; padding: 0; max-width: 46em; }
.work-list li { padding: 0.9rem 0; border-top: 1px solid var(--line); }
.work-list li:last-child { border-bottom: 1px solid var(--line); }
.work-list strong { display: block; font-weight: 600; }

/* Code */
.code-figure pre {
  margin: 0; max-width: 46em; padding: 1rem 1.25rem; overflow-x: auto;
  background: var(--t); border-left: 3px solid var(--c); border-radius: 0 8px 8px 0;
  font-size: 0.95rem; line-height: 1.6;
}
.code-figure code { overflow-wrap: normal; white-space: pre; }
.c { color: var(--muted); }
.k { color: var(--c); font-weight: 500; }
.s, .n { color: inherit; }
.node .s { color: inherit; }

/* Reconcile */
.reconcile { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.75rem; max-width: 56rem; }
.reconcile > div { padding: 1rem 1.1rem; background: var(--t); border-radius: 8px; }
.reconcile p { margin: 0; }
.r-name { font: 500 1.15rem var(--mono); color: var(--c); margin: 0.2rem 0 0.4rem !important; }
.r-do { font-size: 1rem; line-height: 1.4; }
@media (max-width: 640px) { .reconcile { grid-template-columns: 1fr; } }

.note { max-width: 46em; margin: 1.5rem 0 0; color: var(--muted); font-size: 1rem; }

/* Footer */
.site-footer { margin-top: clamp(4rem, 9vw, 7rem); padding-block: 2.5rem 3rem; }
.foot-cta { margin: 0 0 1rem; padding-top: 1.5rem; border-top: 1px solid var(--line); font: 500 clamp(1.4rem, 3vw, 1.9rem)/1.2 var(--display); }
.fine { max-width: 46em; margin: 0; font-size: 0.9375rem; color: var(--muted); }
