/* Data-flow section: the network-traffic map. Loaded by index.html (next to
   styles.css) and by data-flow.html (next to concept.css). The two sheets share
   --ink/--muted/--faint/--line/--paper/--accent and the font tokens; anything
   else is resolved with a fallback so the section renders identically on both.

   No JavaScript. The mode radios and opt-in checkboxes sit ahead of the figure
   inside .df-lab, and general-sibling selectors show or hide SVG groups. The
   public docs host serves a CSP with no script-src and style-src 'self', so
   this file is the only place any of that can live. */

.dataflow {
  --df-surface: var(--surface, var(--lift, var(--paper)));
  --df-deep: var(--paper-deep, var(--wash, var(--paper)));
  --df-accent-soft: var(--accent-soft, var(--accent-wash, transparent));
  --df-warn: #b8412e;
  --df-good: #3f8f63;
  border-top: 1px solid var(--line);
  background: var(--df-deep);
  padding: clamp(66px, 9vw, 116px) 0;
  color: var(--ink);
  font-family: var(--sans);
}
@media (prefers-color-scheme: dark) {
  .dataflow { --df-warn: #ff8a7a; --df-good: #6fc294; }
}
:root[data-theme="dark"] .dataflow { --df-warn: #ff8a7a; --df-good: #6fc294; }
:root[data-theme="light"] .dataflow { --df-warn: #b8412e; --df-good: #3f8f63; }

.dataflow .container { width: min(100% - 48px, 1120px); margin: 0 auto; }

/* Intro. Mirrors .section-intro from styles.css so the concept.css shell
   renders the same heading. */
.dataflow .eyebrow {
  margin: 0 0 17px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .13em;
  line-height: 1.35;
  text-transform: uppercase;
}
.dataflow-intro { max-width: 720px; }
.dataflow-intro h2 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(38px, 4.2vw, 60px);
  font-weight: 400;
  letter-spacing: -.05em;
  line-height: .98;
  text-wrap: balance;
}
.dataflow .line-soft { color: var(--muted); }
.dataflow-intro > p:last-child {
  max-width: 60ch;
  margin: 26px 0 0;
  color: var(--muted);
  font-size: 17px;
  line-height: 1.55;
  text-wrap: pretty;
}
.dataflow-intro em { color: var(--ink); font-style: italic; }

/* Lab: controls, headline, figure */
.df-lab { margin-top: clamp(34px, 5vw, 56px); }
.df-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

.df-controls {
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(0, 4fr);
  gap: 18px 28px;
  align-items: start;
}
.df-control-group { display: flex; flex-wrap: wrap; gap: 8px; }
.df-control-title {
  flex-basis: 100%;
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
}
.df-controls label {
  display: inline-grid;
  gap: 1px;
  padding: 9px 16px 10px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--df-surface);
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  transition: color .16s ease, background .16s ease, border-color .16s ease;
}
.df-controls label strong { color: var(--ink); font-size: 13px; font-weight: 600; line-height: 1.25; }
.df-controls label span { font-size: 11.5px; line-height: 1.3; }
.df-controls label:hover { border-color: var(--faint); }

/* Mode: the selected one goes solid ink. Opt-ins: a checked one gets the
   accent wash, so on and off read differently from a radio choice. */
#df-mode-device:checked ~ .df-controls label[for="df-mode-device"],
#df-mode-local:checked ~ .df-controls label[for="df-mode-local"],
#df-mode-hosted:checked ~ .df-controls label[for="df-mode-hosted"] {
  background: var(--ink);
  border-color: var(--ink);
  color: var(--paper);
}
#df-mode-device:checked ~ .df-controls label[for="df-mode-device"] strong,
#df-mode-local:checked ~ .df-controls label[for="df-mode-local"] strong,
#df-mode-hosted:checked ~ .df-controls label[for="df-mode-hosted"] strong { color: var(--paper); }

#df-opt-mcp:checked ~ .df-controls label[for="df-opt-mcp"],
#df-opt-remote:checked ~ .df-controls label[for="df-opt-remote"],
#df-opt-sync:checked ~ .df-controls label[for="df-opt-sync"] {
  background: var(--df-accent-soft);
  border-color: var(--accent);
}
#df-opt-fast:checked ~ .df-controls label[for="df-opt-fast"] {
  border-color: var(--df-warn);
  box-shadow: inset 0 0 0 1px var(--df-warn);
}
#df-opt-fast:checked ~ .df-controls label[for="df-opt-fast"] strong { color: var(--df-warn); }

#df-mode-device:focus-visible ~ .df-controls label[for="df-mode-device"],
#df-mode-local:focus-visible ~ .df-controls label[for="df-mode-local"],
#df-mode-hosted:focus-visible ~ .df-controls label[for="df-mode-hosted"],
#df-opt-mcp:focus-visible ~ .df-controls label[for="df-opt-mcp"],
#df-opt-remote:focus-visible ~ .df-controls label[for="df-opt-remote"],
#df-opt-sync:focus-visible ~ .df-controls label[for="df-opt-sync"],
#df-opt-fast:focus-visible ~ .df-controls label[for="df-opt-fast"] { outline: 2px solid var(--accent); outline-offset: 3px; }

/* One honest sentence per mode. */
.df-headline {
  max-width: 68ch;
  margin: 26px 0 0;
  font-family: var(--serif);
  font-size: clamp(19px, 2vw, 24px);
  line-height: 1.35;
  letter-spacing: -.015em;
  text-wrap: pretty;
}
.df-headline span { display: none; }
#df-mode-device:checked ~ .df-headline .df-headline-device,
#df-mode-local:checked ~ .df-headline .df-headline-local,
#df-mode-hosted:checked ~ .df-headline .df-headline-hosted { display: inline; }
/* Opt-ins that change what leaves override the plan sentence, the way the
   in-app headline does: a relay on the on-device plan, and audio egress. */
#df-mode-device:checked ~ #df-opt-remote:checked ~ .df-headline .df-headline-device { display: none; }
#df-mode-device:checked ~ #df-opt-remote:checked ~ .df-headline .df-headline-device-remote { display: inline; }
#df-opt-fast:checked ~ .df-headline .df-headline-device,
#df-opt-fast:checked ~ .df-headline .df-headline-local,
#df-opt-fast:checked ~ .df-headline .df-headline-hosted,
#df-opt-fast:checked ~ .df-headline .df-headline-device-remote { display: none; }
#df-opt-fast:checked ~ .df-headline .df-headline-fast { display: inline; color: var(--df-warn); }

/* Figure */
.df-figure {
  margin: 22px 0 0;
  padding: clamp(14px, 2vw, 24px);
  border: 1px solid var(--line);
  border-radius: 24px 24px 10px 24px;
  background: var(--df-surface);
  overflow-x: auto;
  color: var(--ink);
}
.df-figure svg {
  display: block;
  width: 100%;
  min-width: 760px;
  height: auto;
  font-family: var(--sans);
}
.df-figure-mcp svg { min-width: 900px; }
.df-figure figcaption {
  max-width: 78ch;
  margin: 14px 4px 0;
  color: var(--muted);
  font-size: 13.5px;
  line-height: 1.5;
}

/* SVG vocabulary. Strokes and text in currentColor; a literal hue only where
   it carries meaning: accent for a transcript-text path, warn for audio. */
.df-mac { fill: var(--df-deep); stroke: var(--line); stroke-width: 1; }
.df-mac-row { fill: var(--df-deep); }
.df-region { font-family: var(--serif); font-size: 20px; letter-spacing: -.02em; fill: currentColor; }
.df-region-sub, .df-row-sub { font-size: 11.5px; fill: var(--muted); }
.df-row-title { font-family: var(--serif); font-size: 18px; letter-spacing: -.02em; fill: currentColor; }
.df-node rect { fill: var(--df-surface); stroke: var(--line); stroke-width: 1; }
.df-node-title { font-size: 13px; font-weight: 600; fill: currentColor; }
.df-node-sub { font-size: 11px; fill: var(--muted); }
.df-node-key rect { stroke: currentColor; stroke-width: 1.2; }
.df-node-muted rect { stroke-dasharray: 3 3; }
.df-node-muted .df-node-title { fill: var(--muted); }
.df-node-quiet rect { stroke-dasharray: 3 3; }
.df-node-cyrano rect { fill: var(--df-accent-soft); stroke: var(--accent); }
.df-node-warn rect { stroke: var(--df-warn); }
.df-node-warn .df-node-title { fill: var(--df-warn); }
.df-inner { stroke: var(--faint); stroke-width: 1.2; fill: none; }
.df-edge { stroke: currentColor; stroke-width: 1.5; fill: none; }
.df-edge-quiet { stroke: var(--faint); stroke-dasharray: 4 4; }
.df-edge-accent { stroke: var(--accent); stroke-width: 2.2; }
.df-edge-warn { stroke: var(--df-warn); stroke-width: 2.2; stroke-dasharray: 7 4; }
.df-fill-accent { fill: var(--accent); }
.df-fill-warn { fill: var(--df-warn); }
.df-edge-label { font-size: 11px; fill: var(--muted); }
.df-edge-label-accent { fill: var(--accent); font-weight: 600; }
.df-edge-label-warn { fill: var(--df-warn); font-weight: 600; }
.df-boundary { stroke: var(--faint); stroke-width: 1; stroke-dasharray: 2 5; }
.df-boundary-label { font-size: 10.5px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase; fill: var(--faint); }
.df-never { font-size: 11px; fill: var(--muted); }
.df-note { font-size: 11.5px; fill: var(--muted); font-style: italic; }

/* Conditional layers. Everything below is hidden until its mode or opt-in is
   on. The order matters: the last matching rule wins where two overlap. */
.df-figure .df-hosted,
.df-figure .df-local,
.df-figure .df-remote,
.df-figure .df-sync,
.df-figure .df-fast,
.df-figure .df-mcp,
.df-figure .df-analysis-remote { display: none; }

#df-mode-hosted:checked ~ .df-figure .df-hosted { display: inline; }
#df-mode-local:checked ~ .df-figure .df-local { display: inline; }
#df-mode-hosted:checked ~ .df-figure .df-analysis-remote,
#df-mode-local:checked ~ .df-figure .df-analysis-remote { display: inline; }
#df-mode-hosted:checked ~ .df-figure .df-analysis-device,
#df-mode-local:checked ~ .df-figure .df-analysis-device { display: none; }

#df-opt-mcp:checked ~ .df-figure .df-mcp { display: inline; }
#df-opt-remote:checked ~ .df-figure .df-remote { display: inline; }
#df-opt-sync:checked ~ .df-figure .df-sync { display: inline; }
#df-opt-fast:checked ~ .df-figure .df-fast { display: inline; }

/* In hosted mode the transcript already travels on the hosted path; the
   remote relay edge would draw the same route twice. */
#df-mode-hosted:checked ~ .df-figure .df-remote-relay { display: none; }

/* Sub-sections */
.df-mcp-section, .df-ledger-section { margin-top: clamp(54px, 7vw, 84px); }
.df-subintro { max-width: 720px; }
.df-subintro h3 {
  margin: 0;
  font-family: var(--serif);
  font-size: clamp(28px, 3vw, 38px);
  font-weight: 400;
  letter-spacing: -.035em;
  line-height: 1.05;
}
.df-subintro p { max-width: 60ch; margin: 14px 0 0; color: var(--muted); font-size: 16px; line-height: 1.55; }
.df-mcp-section .df-figure { margin-top: 24px; }

/* Ledger */
.dataflow .table-scroll { margin-top: 24px; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.df-ledger {
  width: 100%;
  min-width: 760px;
  border-collapse: collapse;
  font-size: 14px;
  line-height: 1.5;
}
.df-ledger thead th {
  padding: 0 14px 12px 0;
  border-bottom: 1px solid var(--ink);
  color: var(--faint);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: .1em;
  text-align: left;
  text-transform: uppercase;
}
.df-ledger td, .df-ledger tbody th { vertical-align: top; text-align: left; }
.df-ledger td { padding: 12px 18px 13px 0; border-bottom: 1px solid var(--line); color: var(--muted); }
.df-ledger td:first-child { width: 19%; color: var(--ink); font-weight: 600; }
.df-ledger td:nth-child(2) { width: 38%; }
.df-ledger td:nth-child(3) { width: 17%; }
.df-ledger td:last-child { padding-right: 0; }
.df-ledger-group th {
  padding: 34px 0 8px;
  border-bottom: 1px solid var(--line);
  font-family: var(--serif);
  font-size: 21px;
  font-weight: 400;
  letter-spacing: -.02em;
  color: var(--ink);
}
.df-ledger tbody:first-of-type .df-ledger-group:first-child th { padding-top: 22px; }

/* Verify */
.df-verify {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 1.1fr);
  gap: 8px 40px;
  margin-top: clamp(54px, 7vw, 84px);
  padding: clamp(24px, 3vw, 34px) clamp(24px, 3vw, 36px);
  border: 1px solid var(--line);
  border-radius: 24px 24px 10px 24px;
  background: var(--df-surface);
}
.df-verify h3 { grid-column: 1 / -1; margin: 0 0 6px; font-family: var(--serif); font-size: 26px; font-weight: 400; letter-spacing: -.03em; }
.df-verify p { margin: 0 0 12px; color: var(--muted); font-size: 15px; line-height: 1.55; }
.df-verify em { color: var(--ink); }
.df-verify pre {
  grid-column: 2;
  grid-row: 2 / span 2;
  align-self: start;
  margin: 0;
  padding: 16px 18px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--df-deep);
  overflow-x: auto;
}
.df-verify code { font-family: var(--mono); font-size: 13px; color: var(--ink); }
.df-verify-links { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 4px; }
.dataflow .text-link { color: var(--accent); font-size: 14px; font-weight: 700; text-decoration-thickness: 1px; }
.dataflow .text-link:hover { color: var(--ink); }

@media (max-width: 860px) {
  .df-controls { grid-template-columns: 1fr; }
  .df-verify { grid-template-columns: 1fr; }
  .df-verify pre { grid-column: 1; grid-row: auto; margin-bottom: 12px; }
}
@media (prefers-reduced-motion: reduce) {
  .df-controls label { transition: none; }
}
