/* FreshContext — shared design system.
 *
 * One stylesheet for every page. Before this, each page carried its own <style>
 * block: 247 distinct selectors across seven pages, only 14 of them shared by
 * five or more. That is why the site read as three different products.
 *
 * Two rules govern what is here:
 *   1. Monospace means something — an endpoint, a signature, a key id, a
 *      protocol state, a machine-readable field. It is not a decorative accent.
 *   2. A card is for a thing you might act on. Facts in a series are rows in a
 *      table, separated by a hairline. Most of what used to be a card is a row.
 *
 * No external fonts, so style-src and font-src can both be 'self'.
 */

/* ── tokens ───────────────────────────────────────────────────────────────── */
:root {
  --paper: #f7f2e6;
  --panel: #fffaf0;
  --graphite: #12140f;
  --graphite-soft: #1c1f19;

  --ink: #17140f;
  --muted: #6a6559;
  --ink-invert: #f4efe2;
  --muted-invert: #a8a293;

  --line: #e2d9c6;
  --line-strong: #cbbda2;
  --line-invert: rgba(244, 239, 226, 0.15);

  --green: #0f6e55;
  --green-deep: #0b5744;
  --green-wash: rgba(15, 110, 85, 0.08);
  --green-lift: #4bb894;
  --gold: #7d6220;        /* 5.16:1 on paper — #9c7a2c was 3.59 and failed AA */
  --gold-deep: #6f571c;   /* 5.58:1 on the gold tint below, where --gold is 4.69 */
  --gold-wash: rgba(125, 98, 32, 0.09);
  --gold-lift: #c8a84b;   /* 8.09:1 on --graphite, for gold inside a code block */
  --red: #a6423a;

  --sans: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  --mono: ui-monospace, SFMono-Regular, Menlo, Consolas, "Liberation Mono", monospace;

  --r: 6px;
  --wrap: 1120px;
  --gut: 24px;
}

/* ── reset ────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

img, svg { max-width: 100%; height: auto; }

/* ── type scale ───────────────────────────────────────────────────────────── */
h1, h2, h3, h4 { margin: 0 0 0.5em; font-weight: 600; line-height: 1.15; letter-spacing: -0.018em; text-wrap: balance; }
h1 { font-size: clamp(34px, 5.2vw, 54px); letter-spacing: -0.028em; }
h2 { font-size: clamp(25px, 3.1vw, 34px); }
h3 { font-size: 17px; letter-spacing: -0.008em; }
h4 { font-size: 15px; }

p { margin: 0 0 1em; }
p:last-child { margin-bottom: 0; }

.lede { font-size: clamp(17px, 1.5vw, 19px); color: var(--muted); max-width: 62ch; }
.sub { color: var(--muted); }
.small { font-size: 13.5px; }

/* An eyebrow labels a section. It is the one decorative use of uppercase, and
 * it is not monospace — mono is reserved for machine-readable things. */
.eyebrow {
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.13em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 14px;
}

a { color: var(--green-deep); text-underline-offset: 2px; text-decoration-thickness: 1px; }
a:hover { color: var(--green); }
a:focus-visible, button:focus-visible, summary:focus-visible {
  outline: 2px solid var(--green);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 100;
  background: var(--ink); color: var(--paper);
  padding: 10px 16px; border-radius: 0 0 var(--r) 0;
}
.skip-link:focus { left: 0; }

/* ── layout ───────────────────────────────────────────────────────────────── */
.wrap { max-width: var(--wrap); margin: 0 auto; padding-inline: var(--gut); }

.band { padding-block: clamp(52px, 7vw, 88px); border-top: 1px solid var(--line); }
.band:first-of-type { border-top: 0; }
.band--tint { background: var(--panel); }
.band--dark {
  background: var(--graphite);
  color: var(--ink-invert);
  border-top-color: transparent;
}
.band--dark h1, .band--dark h2, .band--dark h3 { color: var(--ink-invert); }
.band--dark .lede, .band--dark .sub, .band--dark .eyebrow { color: var(--muted-invert); }
.band--dark a { color: var(--green-lift); }

/* Section head: title left, standfirst right. Replaces the pattern where every
 * section restated itself in a card. */
.head { display: grid; grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr); gap: 12px 48px; align-items: end; margin-bottom: 32px; }
.head > :last-child { padding-bottom: 4px; }
@media (max-width: 860px) { .head { grid-template-columns: 1fr; gap: 8px; } }

.cols { display: grid; gap: 20px; }
.cols--2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.cols--3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
@media (max-width: 860px) { .cols--2, .cols--3 { grid-template-columns: 1fr; } }

/* ── rows: the default way to present a series of facts ───────────────────── */
.rows { border-top: 1px solid var(--line); }
.row {
  display: grid;
  grid-template-columns: 200px minmax(0, 1fr);
  gap: 4px 32px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}
.row > h3 { margin: 0; }
.row > p { color: var(--muted); font-size: 15px; }
.band--dark .rows, .band--dark .row { border-color: var(--line-invert); }
@media (max-width: 720px) { .row { grid-template-columns: 1fr; gap: 6px; } }

/* ── table ────────────────────────────────────────────────────────────────── */
.tablewrap { overflow-x: auto; border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); }
/* min-width so a multi-column table scrolls inside its wrapper on a phone
 * rather than crushing three columns into 110px each. The wrapper scrolls;
 * the page never does. */
table { width: 100%; border-collapse: collapse; font-size: 14.5px; }
/* Only tables inside a scroll wrapper get a min-width: it makes them scroll on a
 * phone instead of crushing three columns into 110px each. Applying it to every
 * table instead pushed the page itself sideways on /spec and the demo, which the
 * mobile-overflow check caught. */
.tablewrap table { min-width: 560px; }
th, td { text-align: left; padding: 13px 16px; border-bottom: 1px solid var(--line); vertical-align: top; }
thead th {
  font-size: 11.5px; font-weight: 600; letter-spacing: 0.09em; text-transform: uppercase;
  color: var(--muted); background: transparent; white-space: nowrap;
}
tbody tr:last-child td { border-bottom: 0; }
td strong { font-weight: 600; }
.band--dark .tablewrap { background: var(--graphite-soft); border-color: var(--line-invert); }
.band--dark th, .band--dark td { border-color: var(--line-invert); }

/* ── state: the only chip that survives, and it means one thing ───────────── */
.state {
  display: inline-block;
  font-family: var(--mono);
  font-size: 11px; letter-spacing: 0.04em;
  padding: 2px 7px; border-radius: 3px; white-space: nowrap;
  border: 1px solid transparent;
}
.state--live { color: var(--green-deep); background: var(--green-wash); border-color: rgba(15, 110, 85, 0.22); }
.state--seam { color: var(--gold-deep); background: var(--gold-wash); border-color: rgba(125, 98, 32, 0.26); }
.state--open { color: var(--muted); background: rgba(106, 101, 89, 0.08); border-color: var(--line-strong); }
.band--dark .state--live { color: var(--green-lift); background: rgba(75, 184, 148, 0.12); border-color: rgba(75, 184, 148, 0.3); }
.band--dark .state--open { color: var(--muted-invert); background: rgba(244, 239, 226, 0.06); border-color: var(--line-invert); }

/* ── card: kept, but only where a thing is actionable ─────────────────────── */
.card {
  border: 1px solid var(--line);
  border-radius: var(--r);
  background: var(--panel);
  padding: 22px;
}
.card > :last-child { margin-bottom: 0; }
.card p { color: var(--muted); font-size: 15px; }
.band--dark .card { background: var(--graphite-soft); border-color: var(--line-invert); }

/* ── buttons ──────────────────────────────────────────────────────────────── */
.actions { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; }
.btn {
  display: inline-flex; align-items: center; gap: 8px;
  font: inherit; font-size: 15px; font-weight: 500;
  padding: 10px 18px; border-radius: var(--r);
  border: 1px solid var(--ink); background: var(--ink); color: var(--paper);
  text-decoration: none; cursor: pointer;
  transition: background .14s ease, border-color .14s ease, color .14s ease;
}
.btn:hover { background: #000; color: var(--paper); }
.btn--ghost { background: transparent; color: var(--ink); border-color: var(--line-strong); }
.btn--ghost:hover { background: transparent; border-color: var(--ink); color: var(--ink); }
/* The quietest of the three: a tertiary action that still sits on the button
 * baseline so a row of mixed weights lines up. */
.btn--text { background: transparent; border-color: transparent; color: var(--muted); padding-inline: 6px; }
.btn--text:hover { background: transparent; color: var(--ink); }
.band--dark .btn { background: var(--ink-invert); border-color: var(--ink-invert); color: var(--graphite); }
.band--dark .btn:hover { background: #fff; color: var(--graphite); }
.band--dark .btn--ghost { background: transparent; color: var(--ink-invert); border-color: var(--line-invert); }
.band--dark .btn--ghost:hover { border-color: var(--ink-invert); color: var(--ink-invert); }

/* ── code and machine-readable text ───────────────────────────────────────── */
code, kbd, samp { font-family: var(--mono); font-size: 0.9em; }
:not(pre) > code {
  background: var(--green-wash);
  color: var(--green-deep);
  padding: 1px 5px;
  border-radius: 3px;
  overflow-wrap: anywhere;
}
.band--dark :not(pre) > code { background: rgba(75, 184, 148, 0.13); color: var(--green-lift); }

pre {
  margin: 0;
  font-family: var(--mono); font-size: 13px; line-height: 1.65;
  background: var(--graphite); color: var(--ink-invert);
  border-radius: var(--r); padding: 15px 17px;
  overflow-x: auto;
}
pre code { background: none; color: inherit; padding: 0; }

/* A labelled command block with a copy affordance. */
.cmd { border: 1px solid var(--line); border-radius: var(--r); overflow: hidden; background: var(--graphite); }
.cmd-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 8px 10px 8px 15px; border-bottom: 1px solid var(--line-invert); }
.cmd-bar span { font-family: var(--mono); font-size: 11.5px; color: var(--muted-invert); letter-spacing: 0.04em; }
.cmd pre { border-radius: 0; }
.copy {
  font: inherit; font-size: 12px; font-family: var(--mono);
  padding: 4px 10px; border-radius: 4px; cursor: pointer;
  background: transparent; color: var(--muted-invert);
  border: 1px solid var(--line-invert);
}
.copy:hover { color: var(--ink-invert); border-color: var(--ink-invert); }

/* ── definition list used for record anatomy ──────────────────────────────── */
.spec { border: 1px solid var(--line); border-radius: var(--r); background: var(--panel); overflow: hidden; }
.spec-hd { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 16px; border-bottom: 1px solid var(--line); }
.spec-hd b { font-size: 12px; font-weight: 600; letter-spacing: 0.08em; text-transform: uppercase; color: var(--muted); }
.spec dl { margin: 0; }
.spec div { display: grid; grid-template-columns: 168px minmax(0, 1fr); gap: 6px 16px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.spec div:last-child { border-bottom: 0; }
.spec dt { font-family: var(--mono); font-size: 12.5px; color: var(--muted); overflow-wrap: anywhere; }
.spec dd { margin: 0; font-family: var(--mono); font-size: 12.5px; overflow-wrap: anywhere; }
.band--dark .spec { background: var(--graphite-soft); border-color: var(--line-invert); }
.band--dark .spec-hd, .band--dark .spec div { border-color: var(--line-invert); }
.band--dark .spec-hd b, .band--dark .spec dt { color: var(--muted-invert); }
@media (max-width: 560px) { .spec div { grid-template-columns: 1fr; gap: 2px; } }

/* ── note ─────────────────────────────────────────────────────────────────── */
.note {
  border: 1px solid var(--line);
  border-left: 2px solid var(--green);
  border-radius: var(--r);
  background: var(--panel);
  padding: 15px 18px;
  font-size: 14.5px;
  color: var(--muted);
}
.note strong { color: var(--ink); font-weight: 600; }
.band--dark .note { background: var(--graphite-soft); border-color: var(--line-invert); border-left-color: var(--green-lift); }
.band--dark .note strong { color: var(--ink-invert); }

/* ── nav ──────────────────────────────────────────────────────────────────── */
.nav { border-bottom: 1px solid var(--line); background: var(--paper); position: sticky; top: 0; z-index: 20; }
.nav-inner { max-width: var(--wrap); margin: 0 auto; padding: 12px var(--gut); display: flex; align-items: center; justify-content: space-between; gap: 20px; flex-wrap: wrap; }
.brand { display: inline-flex; align-items: center; gap: 9px; font-weight: 600; color: var(--ink); text-decoration: none; font-size: 15px; }
.brand-mark {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 5px;
  background: var(--graphite); color: var(--ink-invert);
  font-family: var(--mono); font-size: 10.5px; letter-spacing: 0.02em;
}
.nav-links { display: flex; flex-wrap: wrap; gap: 4px 18px; align-items: center; }
.nav-links a { color: var(--muted); text-decoration: none; font-size: 14.5px; }
.nav-links a:hover, .nav-links a[aria-current="page"] { color: var(--ink); }
.nav-links a[aria-current="page"] { font-weight: 500; }

/* ── footer ───────────────────────────────────────────────────────────────── */
.footer { border-top: 1px solid var(--line); background: var(--panel); padding-block: 40px; }
.footer-inner { display: flex; flex-wrap: wrap; gap: 24px 48px; align-items: flex-start; justify-content: space-between; }
.footer b { display: block; font-size: 15px; }
.footer .sub { font-size: 14px; max-width: 34ch; }
.footer nav { display: flex; flex-wrap: wrap; gap: 8px 22px; }
.footer nav a { color: var(--muted); text-decoration: none; font-size: 14px; }
.footer nav a:hover { color: var(--ink); }
.footer-legal { margin-top: 26px; padding-top: 18px; border-top: 1px solid var(--line); font-size: 13px; color: var(--muted); }

/* ── prose pages (privacy, accessibility, spec body) ──────────────────────── */
.prose { max-width: 72ch; }
.prose h2 { margin-top: 2em; font-size: clamp(21px, 2.4vw, 26px); }
.prose h3 { margin-top: 1.6em; font-size: 16px; }
.prose ul, .prose ol { margin: 0 0 1em; padding-left: 1.25em; }
.prose li { margin-bottom: 0.4em; }
.prose li::marker { color: var(--muted); }

/* ── utilities ────────────────────────────────────────────────────────────── */
/* Spacing utilities exist so no page needs a style="" attribute. Inline style
 * attributes are governed by style-src, so a single one of them would force
 * 'unsafe-inline' back into the CSP for the whole site. */
.mt-s { margin-top: 18px; }
.mt-m { margin-top: 22px; }
.mt-l { margin-top: 28px; }
.flush-top { border-top: 0; }
.stack > * + * { margin-top: 16px; }
.stack-lg > * + * { margin-top: 32px; }
.mono { font-family: var(--mono); }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute; width: 1px; height: 1px;
  margin: -1px; padding: 0; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}
