/* Order Flow — documentation.
   Same committed dark world as index.html: a trading terminal does not have a light mode.
   Every colour is painted explicitly so nothing inherits from the viewer's ground.
   Serif carries narrative, monospace carries anything mechanical or numeric. */

:root {
  --ground: #0b0e14;
  --surface: #131822;
  --surface-2: #1a212e;
  --line: #252e3d;
  --line-soft: #1c2432;
  --ink: #dde3ec;
  --muted: #7c8798;
  --retail: #35d07f;
  --maker: #ff5c5c;
  --flow: #ffb020;

  --serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Times New Roman", serif;
  --sans: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, "SF Mono", SFMono-Regular, Menlo, Consolas, monospace;

  --measure: 70ch;
  --gutter: 24px;

  color-scheme: dark;
}

* { box-sizing: border-box; }

html {
  -webkit-text-size-adjust: 100%;
  scroll-behavior: smooth;
  scroll-padding-top: 84px;
}

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
}

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 17px;
  line-height: 1.68;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Testnet banner ─────────────────────────────────────────────── */

.testnet {
  position: sticky;
  top: 0;
  z-index: 40;
  background: #1c1206;
  border-bottom: 1px solid #4a3208;
  color: var(--flow);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.07em;
  line-height: 1.5;
  padding: 9px var(--gutter);
  text-align: center;
  font-variant-numeric: tabular-nums;
}
.testnet b { color: #ffd98a; font-weight: 600; }
.testnet .warn { color: var(--maker); }
.testnet .sep { color: #4a3208; padding: 0 10px; }
@media (max-width: 760px) {
  .testnet { font-size: 10.5px; letter-spacing: 0.04em; text-align: left; }
  .testnet .sep { display: none; }
  .testnet .seg { display: block; }
}

/* ── Shell ──────────────────────────────────────────────────────── */

.shell {
  max-width: 1180px;
  margin: 0 auto;
  padding: 0 var(--gutter) 120px;
  display: grid;
  grid-template-columns: 1fr;
  gap: 56px;
}

@media (min-width: 1060px) {
  .shell {
    grid-template-columns: 214px minmax(0, 1fr);
    align-items: start;
    gap: 72px;
  }
}

main { min-width: 0; }

/* ── Table of contents ──────────────────────────────────────────── */

.toc {
  font-family: var(--mono);
  font-size: 12px;
  line-height: 1.5;
  border-top: 1px solid var(--line);
  padding-top: 20px;
  margin-top: 8px;
}
.toc h2 {
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
  border: 0;
  padding: 0;
}
.toc ol {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  counter-reset: toc;
}
.toc li { counter-increment: toc; }
.toc a {
  color: var(--muted);
  text-decoration: none;
  border: 0;
  display: block;
  padding-left: 26px;
  position: relative;
}
.toc a::before {
  content: counter(toc, decimal-leading-zero);
  position: absolute;
  left: 0;
  color: var(--line);
}
.toc a:hover { color: var(--ink); }
.toc a:hover::before { color: var(--flow); }
.toc a:focus-visible { outline: 2px solid var(--flow); outline-offset: 3px; }

@media (min-width: 1060px) {
  .toc {
    position: sticky;
    top: 76px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
  }
}
@media (max-width: 1059px) {
  .toc { order: -1; margin-top: 44px; }
  .toc ol {
    flex-direction: row;
    flex-wrap: wrap;
    gap: 8px 22px;
  }
}

/* ── Masthead ───────────────────────────────────────────────────── */

.masthead { padding: 72px 0 0; }

.eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--flow);
  margin: 0 0 18px;
}

h1 {
  font-family: var(--sans);
  font-size: clamp(40px, 8vw, 68px);
  font-weight: 800;
  letter-spacing: -0.04em;
  line-height: 0.98;
  margin: 0;
  text-wrap: balance;
}
h1 .slash { color: var(--flow); }

.standfirst {
  font-family: var(--serif);
  font-size: clamp(19px, 2.4vw, 23px);
  line-height: 1.5;
  color: var(--muted);
  margin: 24px 0 0;
  max-width: 44ch;
  text-wrap: pretty;
}

.backlink {
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin: 30px 0 0;
}

/* ── Sections ───────────────────────────────────────────────────── */

section { padding-top: 76px; }

h2 {
  font-family: var(--mono);
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--flow);
  margin: 0 0 26px;
  padding-bottom: 10px;
  border-bottom: 1px solid var(--line);
}
h2.retail { color: var(--retail); }
h2.maker { color: var(--maker); }

h3 {
  font-family: var(--sans);
  font-size: clamp(22px, 3vw, 27px);
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin: 52px 0 14px;
  text-wrap: balance;
}
/* Only an h3 sitting directly under the section label loses its leading — an h3 that follows
   prose still needs the full gap above it. */
h2 + h3 { margin-top: 0; }
h3.retail { color: var(--retail); }
h3.maker { color: var(--maker); }
h3.flow { color: var(--flow); }

h4 {
  font-family: var(--mono);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--ink);
  margin: 34px 0 10px;
}

p { max-width: var(--measure); margin: 0 0 20px; }
p:last-child { margin-bottom: 0; }

.lede {
  font-size: 19.5px;
  line-height: 1.6;
  color: var(--ink);
}

.fable {
  font-family: var(--serif);
  font-size: 19px;
  line-height: 1.8;
}
.fable p { max-width: 60ch; margin: 0 0 24px; }
.fable p:last-child { margin-bottom: 0; }
.fable strong { color: var(--flow); font-weight: 400; font-style: italic; }
.fable .close { color: var(--muted); }

.note {
  font-size: 15px;
  color: var(--muted);
  max-width: var(--measure);
}

/* ── Lists ──────────────────────────────────────────────────────── */

ul.terms,
ul.plain {
  list-style: none;
  padding: 0;
  margin: 0 0 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
ul.terms li,
ul.plain li {
  padding-left: 26px;
  position: relative;
  max-width: var(--measure);
}
ul.terms li::before,
ul.plain li::before {
  content: "\25B8";
  position: absolute;
  left: 0;
  top: 1px;
  color: var(--flow);
  font-size: 13px;
}
ul.plain li::before { color: var(--line); }

ol.steps {
  list-style: none;
  counter-reset: step;
  padding: 0;
  margin: 24px 0;
  display: flex;
  flex-direction: column;
  gap: 20px;
}
ol.steps li {
  counter-increment: step;
  padding-left: 46px;
  position: relative;
  max-width: var(--measure);
}
ol.steps li::before {
  content: counter(step, decimal-leading-zero);
  position: absolute;
  left: 0;
  top: 1px;
  font-family: var(--mono);
  font-size: 12px;
  letter-spacing: 0.08em;
  color: var(--flow);
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 2px 7px;
  line-height: 1.4;
}
ol.steps b {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 600;
  color: var(--ink);
  display: block;
  letter-spacing: -0.01em;
}
ol.steps .body { color: var(--muted); font-size: 16px; }
ol.steps .body em { color: var(--ink); font-style: normal; }

/* ── Rules ──────────────────────────────────────────────────────── */

.rule {
  border: 0;
  border-top: 1px solid var(--line);
  margin: 64px 0 0;
}

/* ── Tables ─────────────────────────────────────────────────────── */

.scroller {
  overflow-x: auto;
  margin: 26px 0;
  border-top: 1px solid var(--line);
  -webkit-overflow-scrolling: touch;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-family: var(--mono);
  font-size: 13.5px;
  font-variant-numeric: tabular-nums;
  min-width: 560px;
}
thead th {
  text-align: left;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 10.5px;
  padding: 12px 18px 10px 0;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
  vertical-align: bottom;
}
td {
  padding: 14px 18px 14px 0;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: top;
  line-height: 1.6;
  color: var(--muted);
}
tbody tr:last-child td { border-bottom: 0; }
td.num { white-space: nowrap; color: var(--ink); }
td.act { color: var(--ink); white-space: nowrap; }
td.risk { color: var(--maker); }
td.safe { color: var(--retail); }
th.w-notes { width: 42%; }
/* The four-column defects table needs more room than the three-column action tables;
   below this it scrolls inside .scroller rather than crushing the last column. */
table.wide { min-width: 780px; }
table.wide th.w-notes { width: 40%; }
th.w-fix { width: 21%; }

/* ── Cards ──────────────────────────────────────────────────────── */

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 22px 24px;
  margin: 26px 0;
}
.card > :last-child { margin-bottom: 0; }
.card.warn { border-color: #542020; background: #16100f; }
.card.warn .card-label { color: var(--maker); }
.card-label {
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--flow);
  margin: 0 0 12px;
  max-width: none;
}
.card p { font-size: 16px; max-width: 66ch; }

/* ── Address list ───────────────────────────────────────────────── */

.addr {
  font-family: var(--mono);
  font-size: 12.5px;
  display: flex;
  flex-direction: column;
  gap: 13px;
  margin: 0;
}
.addr > div {
  display: flex;
  gap: 8px 18px;
  flex-wrap: wrap;
  align-items: baseline;
}
.addr .role { color: var(--muted); min-width: 190px; }
.addr code { color: var(--ink); word-break: break-all; }
.addr a { border-bottom-color: var(--line); }

/* ── Live values ────────────────────────────────────────────────── */

.live {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  border-bottom: 1px dotted var(--line);
  cursor: help;
  white-space: nowrap;
}
.live[data-state="pending"] { color: var(--muted); opacity: 0.7; }
.live[data-state="failed"] { color: var(--maker); border-bottom-color: var(--maker); }

/* A compile-time constant of the deployed bytecode: real, but not in a readable slot.
   Marked differently from a live read so the two are never confused. */
.const {
  font-family: var(--mono);
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  border-bottom: 1px dashed var(--line);
  cursor: help;
  white-space: nowrap;
}

.provenance {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--muted);
  border-top: 1px solid var(--line);
  padding-top: 14px;
  margin-top: 26px;
  max-width: var(--measure);
}
.provenance .key {
  display: inline-block;
  border-bottom: 1px dotted var(--line);
  color: var(--ink);
  margin-right: 4px;
}
.provenance .key.c { border-bottom-style: dashed; }

/* ── Status readout ─────────────────────────────────────────────── */

/* Cells carry their own border rather than sitting on a 1px grid gap over a lit background.
   A partial last row then leaves ground behind it instead of an orphaned filled block. */
.readout {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 10px;
  margin: 26px 0;
}
.readout div {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 16px 18px;
}
.readout dt {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 7px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.readout dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 21px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
  color: var(--ink);
  line-height: 1.2;
}
.readout dd small {
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--muted);
  display: block;
  margin-top: 5px;
}
.readout dd[data-state="pending"] { color: var(--muted); opacity: 0.6; }
.readout dd[data-state="failed"] { color: var(--maker); font-size: 13px; }
.readout .r dd { color: var(--retail); }
.readout .m dd { color: var(--maker); }
.readout .f dd { color: var(--flow); }

.readout-bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-top: -8px;
}
button.recheck {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--flow);
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 2px;
  padding: 6px 13px;
  cursor: pointer;
}
button.recheck:hover:not(:disabled) { border-color: var(--flow); }
button.recheck:disabled { color: var(--muted); cursor: progress; }
button.recheck:focus-visible { outline: 2px solid var(--flow); outline-offset: 3px; }

/* ── Split panels ───────────────────────────────────────────────── */

.split {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  background: var(--line);
  border: 1px solid var(--line);
  border-radius: 3px;
  margin: 30px 0;
  overflow: hidden;
}
.split > div { background: var(--surface); padding: 22px; }
.split h4 {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  margin: 0 0 12px;
}
.split .r h4 { color: var(--retail); }
.split .m h4 { color: var(--maker); }
.split p { font-size: 15px; margin: 0; color: var(--muted); max-width: none; }
.split .big {
  font-family: var(--mono);
  font-size: 29px;
  color: var(--ink);
  display: block;
  margin-bottom: 8px;
  letter-spacing: -0.02em;
  font-variant-numeric: tabular-nums;
}
@media (max-width: 620px) {
  .split { grid-template-columns: 1fr; }
}

/* ── Chain diagram ──────────────────────────────────────────────── */

.chain {
  font-family: var(--mono);
  font-size: 12.5px;
  line-height: 1.7;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 3px;
  padding: 22px 24px;
  margin: 26px 0;
  overflow-x: auto;
}
.chain pre {
  margin: 0;
  color: var(--muted);
  white-space: pre;
  font: inherit;
}
.chain .op { color: var(--flow); }
.chain .seq { color: var(--maker); }
.chain .out { color: var(--retail); }
/* Subordinate to the code, but still legible against --surface. */
.chain .cmt { color: #55617a; }

/* ── FAQ ────────────────────────────────────────────────────────── */

.faq {
  border-top: 1px solid var(--line);
  margin: 26px 0 0;
}
.faq details {
  border-bottom: 1px solid var(--line-soft);
}
.faq summary {
  cursor: pointer;
  list-style: none;
  padding: 18px 34px 18px 0;
  position: relative;
  font-family: var(--sans);
  font-size: 17px;
  font-weight: 600;
  color: var(--ink);
  letter-spacing: -0.01em;
}
.faq summary::-webkit-details-marker { display: none; }
.faq summary::after {
  content: "+";
  position: absolute;
  right: 4px;
  top: 16px;
  font-family: var(--mono);
  font-size: 17px;
  color: var(--flow);
}
.faq details[open] summary::after { content: "\2212"; }
.faq summary:focus-visible { outline: 2px solid var(--flow); outline-offset: 2px; }
.faq .answer { padding: 0 0 22px; }
.faq .answer p { font-size: 16.5px; color: var(--muted); }
.faq .answer p strong { color: var(--ink); font-weight: 600; }

/* ── Footer ─────────────────────────────────────────────────────── */

footer {
  margin-top: 88px;
  padding-top: 28px;
  border-top: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 11.5px;
  color: var(--muted);
  line-height: 1.95;
}
footer strong { color: var(--ink); font-weight: 600; }
footer .disclaim { color: var(--maker); }

/* ── Inline elements ────────────────────────────────────────────── */

a {
  color: var(--flow);
  text-decoration: none;
  border-bottom: 1px solid var(--line);
}
a:hover { border-bottom-color: var(--flow); }
a:focus-visible { outline: 2px solid var(--flow); outline-offset: 3px; }

code {
  font-family: var(--mono);
  font-size: 0.88em;
  color: var(--ink);
  background: var(--surface-2);
  border-radius: 2px;
  padding: 1px 5px;
}
/* Identifiers read better unbroken, but a 40-character function name cannot fit a phone.
   Below the narrow breakpoint they wrap rather than push the page sideways. */
p code, li code, td code { white-space: nowrap; }
@media (max-width: 640px) {
  p code, li code, td code { white-space: normal; overflow-wrap: anywhere; }
}

strong { color: var(--ink); font-weight: 600; }

abbr[title] { text-decoration: none; border-bottom: 1px dotted var(--line); cursor: help; }

.tag {
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  border: 1px solid currentColor;
  border-radius: 2px;
  padding: 1px 6px;
  vertical-align: 2px;
  white-space: nowrap;
}
.tag.risk { color: var(--maker); }
.tag.safe { color: var(--retail); }
.tag.flow { color: var(--flow); }

::selection { background: rgba(255, 176, 32, 0.28); color: #fff; }

/* Clipped rather than pushed off-canvas, so it never contributes to page width. */
.skip {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
}
.skip:focus {
  width: auto;
  height: auto;
  overflow: visible;
  clip-path: none;
  left: var(--gutter);
  top: 8px;
  z-index: 60;
  position: fixed;
  background: var(--surface);
  border: 1px solid var(--flow);
  color: var(--flow);
  padding: 10px 16px;
  font-family: var(--mono);
  font-size: 12px;
}

@media print {
  .testnet { position: static; }
  .toc, button.recheck { display: none; }
  body { background: #fff; color: #000; }
}
