/* FlashRouter v2 — design tokens + components. Token-first; no magic hex in pages.
   Foundation: near-black charcoal. Text: warm off-white. One accent: electric blue for Base / on-chain status.
   XRPL accent is scoped to .xrpl sections only. */
:root {
  --bg: #0b0d10;
  --bg-2: #101317;
  --surface: #14181e;
  --surface-2: #1a2027;
  --border: #232a33;
  --border-2: #313a46;
  --text: #f2efe9;
  --muted: #a39f97;
  --muted-2: #8e8b84;
  --accent: #3b82f6;
  --accent-2: #60a5fa;
  --accent-ink: #0b0d10;
  --xrpl: #2dd4bf;
  --xrpl-2: #5eead4;
  --ok: #4ade80;
  --warn: #f5b942;
  --bad: #f87171;
  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1120px;
  --font: Inter, ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

/* Light theme. Same token names; values audited with tools/contrast-audit.py (AA 4.5:1 on every text pairing). */
:root[data-theme="light"] {
  --bg: #f5f2ec;
  --bg-2: #ece8e0;
  --surface: #ffffff;
  --surface-2: #f5f2ec;
  --border: #d9d3c8;
  --border-2: #bfb8ab;
  --text: #14181e;
  --muted: #55524b;
  --muted-2: #6b675f;
  --accent: #1d4ed8;
  --accent-2: #1e40af;
  --accent-ink: #ffffff;
  --xrpl: #0f766e;
  --xrpl-2: #0d5f59;
  --ok: #166534;
  --warn: #92400e;
  --bad: #b91c1c;
}
:root { color-scheme: dark; }
:root[data-theme="light"] { color-scheme: light; }
* { box-sizing: border-box; }
html { scroll-behavior: smooth; }
body { margin: 0; background: var(--bg); color: var(--text); font-family: var(--font); line-height: 1.6; font-size: 16px; -webkit-font-smoothing: antialiased; }
a { color: var(--accent-2); text-decoration: none; }
a:hover { text-decoration: underline; }
code, pre { font-family: var(--mono); font-size: 0.9em; }
pre { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 1rem; overflow-x: auto; line-height: 1.5; }
code:not(pre code) { background: var(--bg-2); padding: 0.1em 0.35em; border-radius: 4px; border: 1px solid var(--border); }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.6em; font-weight: 650; letter-spacing: -0.015em; }
h1 { font-size: clamp(2.2rem, 1.4rem + 3vw, 3.8rem); }
h2 { font-size: clamp(1.5rem, 1.2rem + 1.2vw, 2.1rem); }
h3 { font-size: 1.1rem; }
p { margin: 0 0 1em; }
.muted { color: var(--muted); }
.small { font-size: 0.86rem; }
.mono { font-family: var(--mono); font-size: 0.86em; }
.kicker { color: var(--accent-2); letter-spacing: 0.14em; text-transform: uppercase; font-size: 0.72rem; font-weight: 650; margin: 0 0 0.75rem; }
.wrap { max-width: var(--maxw); margin: 0 auto; padding: 0 1.25rem; }
.section { padding: 4.25rem 0; border-top: 1px solid var(--border); }
.section.tight { padding: 2.5rem 0; }

/* header */
.site-header { position: sticky; top: 0; z-index: 20; background: color-mix(in srgb, var(--bg) 88%, transparent); backdrop-filter: blur(8px); border-bottom: 1px solid var(--border); }
.site-header .wrap { display: flex; align-items: center; justify-content: space-between; height: 64px; gap: 1rem; }
.brand { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; color: var(--text); }
.brand:hover { text-decoration: none; }
.brand .mark { width: 24px; height: 24px; border-radius: 6px; background: var(--accent); display: inline-block; position: relative; }
.brand .mark::after { content: ""; position: absolute; left: 7px; top: 5px; width: 10px; height: 14px; border-left: 3px solid var(--accent-ink); border-bottom: 3px solid var(--accent-ink); transform: skewX(-18deg); }
.nav { display: flex; gap: 1.4rem; align-items: center; }
.nav a { color: var(--muted); font-size: 0.93rem; }
.nav a:hover, .nav a[aria-current="page"] { color: var(--text); text-decoration: none; }
.nav .cta { color: var(--accent-ink); background: var(--accent); padding: 0.45rem 0.9rem; border-radius: var(--radius-sm); font-weight: 650; }
.nav .cta:hover { background: var(--accent-2); }
.nav-toggle { display: none; background: none; border: 1px solid var(--border-2); color: var(--text); border-radius: var(--radius-sm); padding: 0.4rem 0.6rem; }
@media (max-width: 800px) {
  .nav { display: none; position: absolute; top: 64px; left: 0; right: 0; flex-direction: column; align-items: stretch; gap: 0; background: var(--bg-2); border-bottom: 1px solid var(--border); padding: 0.5rem 1.25rem 1rem; }
  .nav.open { display: flex; }
  .nav a { padding: 0.65rem 0; }
  .nav .cta { margin-top: 0.5rem; text-align: center; }
  .nav-toggle { display: inline-block; }
}

/* hero */
.hero { padding: 5rem 0 3rem; }
.hero h1 { max-width: 18ch; }
.hero .lede { font-size: 1.12rem; color: var(--muted); max-width: 62ch; }
.hero-actions { display: flex; gap: 0.75rem; flex-wrap: wrap; margin-top: 1.5rem; }

/* buttons */
.btn { display: inline-block; padding: 0.7rem 1.15rem; border-radius: var(--radius-sm); font-weight: 650; border: 1px solid var(--border-2); color: var(--text); background: var(--surface); cursor: pointer; font-family: inherit; font-size: 0.95rem; }
.btn:hover { border-color: var(--accent); text-decoration: none; }
.btn.primary { background: var(--accent); color: var(--accent-ink); border-color: var(--accent); }
.btn.primary:hover { background: var(--accent-2); border-color: var(--accent-2); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; }

/* grids + cards */
.grid { display: grid; gap: 1.1rem; }
.grid.cols-3 { grid-template-columns: repeat(3, 1fr); }
.grid.cols-2 { grid-template-columns: repeat(2, 1fr); }
@media (max-width: 860px) { .grid.cols-3, .grid.cols-2 { grid-template-columns: 1fr; } }
.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.card h3 { margin-top: 0; }
.card.product { display: flex; flex-direction: column; }
.card.product .foot { margin-top: auto; padding-top: 0.75rem; display: flex; gap: 1rem; flex-wrap: wrap; }

/* status pills */
.status { display: inline-flex; align-items: center; gap: 0.4rem; font-family: var(--mono); font-size: 0.76rem; letter-spacing: 0.04em; padding: 0.18rem 0.55rem; border-radius: 999px; border: 1px solid var(--border-2); background: var(--bg-2); color: var(--muted); white-space: nowrap; }
.status::before { content: ""; width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status.real { color: var(--ok); border-color: rgba(74, 222, 128, 0.35); }
.status.demo { color: var(--accent-2); border-color: rgba(96, 165, 250, 0.35); }
.status.skeleton { color: var(--warn); border-color: rgba(245, 185, 66, 0.35); }
.status.absent { color: var(--bad); border-color: rgba(248, 113, 113, 0.35); }
.status.dev { color: var(--muted-2); border-color: var(--border); }

/* evidence strip + cards */
.evidence { display: grid; grid-template-columns: repeat(4, 1fr); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; background: var(--surface); }
@media (max-width: 960px) { .evidence { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 520px) { .evidence { grid-template-columns: 1fr; } }
.ev { padding: 0.9rem 1rem; border-right: 1px solid var(--border); border-bottom: 1px solid var(--border); display: grid; gap: 0.2rem; min-width: 0; }
.ev .k { color: var(--muted-2); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; }
.ev .v { font-size: 0.92rem; word-break: break-all; }
.ev .v[data-state="live"] { color: var(--accent-2); }
.ev .v[data-state="stale"] { color: var(--warn); }
.ev .v[data-state="dev"] { color: var(--muted); }

/* tables */
.table-wrap { overflow-x: auto; border: 1px solid var(--border); border-radius: var(--radius); }
table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
th, td { text-align: left; padding: 0.7rem 0.9rem; border-bottom: 1px solid var(--border); vertical-align: top; }
th { color: var(--muted); font-weight: 600; font-size: 0.78rem; letter-spacing: 0.06em; text-transform: uppercase; background: var(--bg-2); }
tr:last-child td { border-bottom: 0; }
td.mono { font-family: var(--mono); font-size: 0.84rem; word-break: break-all; }

/* steps */
.steps { counter-reset: step; display: grid; gap: 1rem; }
.step { display: grid; grid-template-columns: 2.4rem 1fr; gap: 0.9rem; align-items: start; }
.step::before { counter-increment: step; content: counter(step); width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center; background: var(--surface-2); border: 1px solid var(--border-2); color: var(--accent-2); font-weight: 700; font-family: var(--mono); }
.step h3 { margin-bottom: 0.25rem; }
.step p { margin-bottom: 0.25rem; color: var(--muted); }

/* callouts */
.callout { border-left: 3px solid var(--accent); background: var(--bg-2); padding: 1rem 1.2rem; border-radius: 0 var(--radius-sm) var(--radius-sm) 0; margin: 1.25rem 0; }
.callout.warn { border-left-color: var(--warn); }
.callout.bad { border-left-color: var(--bad); }
.callout p:last-child { margin-bottom: 0; }

/* forms + tools */
form.stack { display: grid; gap: 0.9rem; }
label { display: grid; gap: 0.3rem; font-size: 0.9rem; color: var(--muted); }
input, select, textarea { width: 100%; padding: 0.65rem 0.8rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--bg-2); color: var(--text); font-family: inherit; font-size: 0.95rem; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: var(--accent); }
textarea { min-height: 110px; resize: vertical; }
.hp { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.form-note { font-size: 0.85rem; color: var(--muted-2); }
.result { margin-top: 1rem; padding: 1rem; border-radius: var(--radius-sm); border: 1px solid var(--border-2); background: var(--bg-2); font-family: var(--mono); font-size: 0.85rem; white-space: pre-wrap; word-break: break-word; min-height: 3rem; }
.result[data-state="ok"] { border-color: rgba(74, 222, 128, 0.5); }
.result[data-state="bad"] { border-color: rgba(248, 113, 113, 0.5); }
.result[data-state="warn"] { border-color: rgba(245, 185, 66, 0.5); }
.tool { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.4rem; }
.tool .row { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; }
@media (max-width: 760px) { .tool .row { grid-template-columns: 1fr; } }
.out { display: grid; grid-template-columns: repeat(3, 1fr); gap: 0.9rem; margin-top: 1rem; }
@media (max-width: 760px) { .out { grid-template-columns: 1fr; } }
.out .o { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.8rem 0.9rem; }
.out .o .k { color: var(--muted-2); font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; display: block; margin-bottom: 0.2rem; }
.out .o .v { font-size: 1.25rem; font-weight: 650; font-family: var(--mono); }
.source { margin-top: 0.9rem; font-size: 0.8rem; color: var(--muted-2); font-family: var(--mono); line-height: 1.5; }
.source b { color: var(--muted); font-weight: 600; }

/* diagrams */
.diagram { width: 100%; height: auto; display: block; margin: 0.5rem 0 0; }
.diagram text { font-family: var(--font); font-size: 13px; fill: var(--text); }
.diagram .lbl { fill: var(--muted); font-size: 11.5px; }
.diagram .box { fill: var(--surface-2); stroke: var(--border-2); stroke-width: 1; rx: 6; }
.diagram .box.client { stroke: var(--accent); }
.diagram .arrow { stroke: var(--muted); stroke-width: 1.4; fill: none; marker-end: url(#arr); }
.diagram .arrow.back { stroke: var(--accent-2); }
.diagram .mark { fill: var(--muted); }

/* XRPL-scoped accent */
.xrpl .kicker, .xrpl .step::before, .xrpl a { color: var(--xrpl-2); }
.xrpl .callout { border-left-color: var(--xrpl); }
.xrpl .btn.primary { background: var(--xrpl); border-color: var(--xrpl); color: var(--accent-ink); }
.xrpl .btn.primary:hover { background: var(--xrpl-2); border-color: var(--xrpl-2); }
.xrpl .status.real { color: var(--xrpl-2); border-color: rgba(45, 212, 191, 0.35); }
.xrpl .diagram .box.client { stroke: var(--xrpl); }
.xrpl .diagram .arrow.back { stroke: var(--xrpl-2); }
.netbadge { display: inline-block; font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0.08em; text-transform: uppercase; padding: 0.2rem 0.6rem; border-radius: 4px; border: 1px solid var(--border-2); color: var(--muted); }
.netbadge.testnet { color: var(--warn); border-color: rgba(245, 185, 66, 0.5); }
.netbadge.mainnet { color: var(--xrpl-2); border-color: rgba(45, 212, 191, 0.5); }

/* footer */
.site-footer { border-top: 1px solid var(--border); padding: 2.5rem 0 3rem; color: var(--muted); font-size: 0.88rem; }
.site-footer .cols { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 1.5rem; margin-bottom: 1.75rem; }
@media (max-width: 860px) { .site-footer .cols { grid-template-columns: 1fr 1fr; } }
.site-footer h4 { margin: 0 0 0.5rem; color: var(--text); font-size: 0.85rem; letter-spacing: 0.06em; text-transform: uppercase; }
.site-footer ul { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.35rem; }
.site-footer a { color: var(--muted); }
.site-footer a:hover { color: var(--text); }
.perimeter { color: var(--muted); border-top: 1px solid var(--border); padding-top: 1.25rem; }
.perimeter strong { color: var(--text); }

/* prose pages */
.prose { max-width: 76ch; }
.prose h2 { margin-top: 2.2rem; }
.prose ul, .prose ol { padding-left: 1.3rem; }
.prose li { margin-bottom: 0.35rem; }
.toc { display: flex; flex-wrap: wrap; gap: 0.5rem 1.2rem; margin: 0 0 2rem; font-size: 0.9rem; }

/* ---- contrast layer (generated assets in site/assets, see tools/gen-assets.py) ---- */
.hero { position: relative; overflow: hidden; background: var(--bg) url("assets/hero-field.svg") center top / cover no-repeat; }
.hero::after { content: ""; position: absolute; inset: 0; pointer-events: none; background: linear-gradient(180deg, color-mix(in srgb, var(--bg) 15%, transparent) 0%, color-mix(in srgb, var(--bg) 55%, transparent) 60%, var(--bg) 100%); }
:root[data-theme="light"] .hero { background-image: url("assets/hero-field-light.svg"); }
:root[data-theme="light"] .section.alt { background-image: url("assets/grid-light.svg"); }
.hero .wrap { position: relative; z-index: 1; }
.section.alt { background: var(--bg-2) url("assets/grid.svg") center / 48px 48px repeat; }
.section.alt .card, .section.alt .tool, .section.alt .evidence { background: var(--surface); }

/* paper band: an off-white section for the evidence table so the page has one hard tonal break */
.band-light { --bg: #f2efe9; --bg-2: #e9e5dd; --surface: #ffffff; --surface-2: #f5f2ec; --border: #d9d3c8; --border-2: #c4bcae;
  --text: #14181e; --muted: #55524b; --muted-2: #6b675f; --accent: #1d4ed8; --accent-2: #1e40af; --accent-ink: #ffffff;
  background: var(--bg); color: var(--text); border-top: 1px solid var(--border); border-bottom: 1px solid var(--border); }
/* in light mode the band inverts so the page keeps one hard tonal break */
:root[data-theme="light"] .band-light { --bg: #14181e; --bg-2: #1a2027; --surface: #1f2631; --surface-2: #262e3a; --border: #313a46; --border-2: #46505e;
  --text: #f2efe9; --muted: #b3afa7; --muted-2: #9a968e; --accent: #60a5fa; --accent-2: #93c5fd; --accent-ink: #0b0d10; }
:root[data-theme="light"] .band-light .status.real { color: #4ade80; border-color: rgba(74,222,128,.4); }
:root[data-theme="light"] .band-light .status.demo { color: #93c5fd; border-color: rgba(147,197,253,.4); }
:root[data-theme="light"] .band-light .status.skeleton { color: #f5b942; border-color: rgba(245,185,66,.4); }
:root[data-theme="light"] .band-light .status.absent { color: #f87171; border-color: rgba(248,113,113,.4); }
.band-light a { color: var(--accent); }
.band-light .kicker { color: var(--accent); }
.band-light .status { background: var(--surface); }
.band-light .status.real { color: #15803d; border-color: rgba(21,128,61,.4); }
.band-light .status.demo { color: var(--accent); border-color: rgba(29,78,216,.35); }
.band-light .status.skeleton { color: #b45309; border-color: rgba(180,83,9,.4); }
.band-light .status.absent { color: #b91c1c; border-color: rgba(185,28,28,.4); }
.band-light th { background: var(--bg-2); }
.band-light code:not(pre code) { background: var(--bg-2); border-color: var(--border); }

/* cards: accent hairline + hover lift */
.card, .tool { position: relative; transition: border-color .15s ease, transform .15s ease; }
.card::before { content: ""; position: absolute; left: 0; right: 0; top: 0; height: 2px; border-radius: var(--radius) var(--radius) 0 0; background: linear-gradient(90deg, var(--accent), transparent 70%); opacity: .8; }
.card.xrpl::before { background: linear-gradient(90deg, var(--xrpl), transparent 70%); }
.card:hover { border-color: var(--border-2); transform: translateY(-1px); }
.band-light .card::before { opacity: 1; }

/* evidence strip: stronger frame */
.evidence { box-shadow: 0 0 0 1px rgba(96,165,250,.08), 0 20px 50px -30px rgba(59,130,246,.35); }

/* data figure */
.figure { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem 1.1rem 0.6rem; }
.figure svg { width: 100%; height: auto; display: block; }
.figure figcaption { font-size: 0.82rem; color: var(--muted-2); margin-top: 0.4rem; font-family: var(--mono); line-height: 1.5; }
.figure figcaption b { color: var(--muted); font-weight: 600; }

/* section headings get a short accent rule */
.section > .wrap > .kicker::before { content: ""; display: inline-block; width: 18px; height: 2px; background: currentColor; margin-right: .5rem; vertical-align: middle; opacity: .8; }

/* ---- docs ---- */
.docnav { list-style: none; padding: 0; margin: 0; display: grid; gap: 0.2rem; position: sticky; top: 80px; }
.docnav a { display: block; padding: 0.35rem 0.6rem; border-radius: var(--radius-sm); color: var(--muted); font-size: 0.9rem; border-left: 2px solid transparent; }
.docnav a:hover { color: var(--text); background: var(--bg-2); text-decoration: none; }
.docnav a[aria-current="page"] { color: var(--text); border-left-color: var(--accent); }
.docbody h1 { font-size: clamp(1.8rem, 1.3rem + 1.6vw, 2.6rem); }
.docbody h2 { margin-top: 2rem; padding-top: 0.4rem; border-top: 1px solid var(--border); }
.docbody table { font-size: 0.88rem; }
.docbody pre { font-size: 0.82rem; }
.card.doc h3 a { color: var(--text); }
@media (max-width: 860px) { .docnav { position: static; grid-template-columns: 1fr 1fr; } .grid[style*="220px"] { grid-template-columns: 1fr !important; } }

/* theme toggle */
.theme-toggle { background: none; border: 1px solid var(--border-2); color: var(--muted); border-radius: var(--radius-sm); padding: 0.35rem 0.65rem; font-family: inherit; font-size: 0.8rem; cursor: pointer; }
.theme-toggle:hover { color: var(--text); border-color: var(--accent); }
.img-light { display: none !important; }
:root[data-theme="light"] .img-light { display: block !important; }
:root[data-theme="light"] .img-dark { display: none !important; }
.site-header .wrap { gap: 0.75rem; }
.site-header .theme-toggle { margin-left: auto; }
.site-header .nav { margin-left: 0; }
@media (min-width: 801px) { .site-header .theme-toggle { order: 3; margin-left: 0.25rem; } .site-header .nav { margin-left: auto; } }
