/* The public exchange.
 *
 * Hand-written, using only tokens from `tokens.css` — which is generated
 * from `design/tokens.json` and must not be edited. No literal colour
 * appears below; a hex value here would be a value nobody can change from
 * the design source, which is the whole point of the token system.
 *
 * The design team's prototypes carry these styles inline. They are lifted
 * into classes here because 30 screens of repeated inline style is not
 * maintainable, and because a class can be themed, overridden at a
 * breakpoint, and read.
 *
 * Breakpoints are the four named ones only: 599, 600, 1023, 1024, 1439,
 * 1440. `manage.py build_tokens` fails the build on any other width.
 */

/* ── Page scaffolding ───────────────────────────────────────────────── */

body {
  margin: 0;
  background: var(--surface);
  color: var(--ink);
  font-family: var(--f-ui);
  font-size: var(--fs-ui);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

.x-wrap { max-width: 1280px; margin: 0 auto; padding: 0 var(--s-6); }

/* Visible the moment it is focused: a skip link that only appears on hover
   is a skip link that keyboard users cannot reach. */
.x-skip {
  position: absolute; left: -9999px; top: 0; z-index: var(--z-toast);
  background: var(--ink); color: var(--surface);
  padding: var(--s-3) var(--s-4); border-radius: 0 0 var(--r-md) 0;
}
.x-skip:focus { left: 0; }

:focus-visible {
  outline: 2px solid var(--focus);
  outline-offset: 2px;
  border-radius: var(--r-xs);
}

a { color: var(--signal); }
.x-muted { color: var(--ink-3); }
.x-num { font-family: var(--f-num); font-variant-numeric: tabular-nums; }

/* ── Header ─────────────────────────────────────────────────────────── */

.x-head { position: sticky; top: 0; z-index: var(--z-nav); background: var(--surface); }
.x-head__bar { border-bottom: 1px solid var(--line); }
.x-head__inner {
  padding-top: var(--s-3); padding-bottom: var(--s-3);
  display: flex; flex-wrap: wrap; align-items: center;
  justify-content: space-between; gap: var(--s-3);
}

.x-lockup { display: flex; align-items: center; gap: 10px; text-decoration: none; color: var(--ink); }
.x-glyph {
  width: 24px; height: 24px; border-radius: 25%;
  background: var(--ink); position: relative; flex: none;
}
.x-glyph > span {
  position: absolute; left: 50%; top: 50%;
  width: 29.17%; height: 29.17%;
  border-radius: 21%; background: var(--signal-fill);
}
.x-lockup__text { display: flex; flex-direction: column; line-height: 1.1; }
.x-lockup__name { font-weight: 600; font-size: 17px; letter-spacing: -0.015em; }
.x-lockup__endorse { font-size: 11px; color: var(--ink-3); }

.x-nav { display: flex; gap: var(--s-1); font-size: 15px; }
.x-nav a {
  padding: var(--s-2) var(--s-3); border-radius: var(--r-md);
  color: var(--ink); text-decoration: none;
}
.x-nav a:hover { background: var(--surface-sunken); }
.x-nav a[aria-current] { font-weight: 600; }

.x-head__actions { display: flex; align-items: center; gap: var(--s-2); }

/* The navigation is the first thing to go on a narrow screen: the lockup
   and the sign-in both still work, and the sections are reachable from the
   page itself. */
@media (max-width: 599px) { .x-nav { display: none; } }

/* ── Buttons ────────────────────────────────────────────────────────── */

.x-btn {
  display: inline-flex; align-items: center; justify-content: center;
  min-height: 48px; padding: 0 var(--s-5);
  border-radius: var(--r-md); font-weight: 500; font-size: 15px;
  text-decoration: none; cursor: pointer; border: 1px solid transparent;
}
.x-btn--solid { background: var(--ink); color: var(--surface); font-weight: 600; }
/* --line-input, not --line: this is a control boundary, and WCAG 1.4.11
   wants at least 3:1 for one. */
.x-btn--ghost { border-color: var(--line-input); color: var(--ink); }
.x-btn--ghost:hover { background: var(--surface-sunken); }

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

.x-section {
  padding: var(--s-16) 0;
  border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: var(--s-8);
}
.x-section--hero { gap: var(--s-12); }

.x-h1 {
  font-size: clamp(34px, 5vw, 56px);
  letter-spacing: -0.03em; font-weight: 600;
  line-height: 1.05; margin: 0; text-wrap: balance;
}
.x-h2 {
  font-size: clamp(28px, 3.4vw, 36px);
  letter-spacing: -0.02em; font-weight: 600; margin: 0; text-wrap: balance;
}
.x-lead { margin: 0; color: var(--ink-2); font-size: 18px; max-width: 40em; text-wrap: pretty; }
.x-section__head {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: baseline; gap: var(--s-3);
}
.x-actions { display: flex; flex-wrap: wrap; gap: var(--s-3); }

/* A term the vocabulary defines, marked where it first appears. Dotted
   rather than solid so it does not read as a link to somewhere else. */
.x-term { border-bottom: 1.5px dotted var(--line-strong); }

/* ── The ledger feed ────────────────────────────────────────────────── */

.x-panel {
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface-raised); overflow: hidden;
}
.x-panel__head {
  padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--line);
  display: flex; flex-wrap: wrap; justify-content: space-between;
  align-items: center; gap: var(--s-2); font-weight: 600;
}
.x-panel__foot {
  padding: var(--s-3) var(--s-5);
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: var(--s-2); font-size: 14px;
}

/* ── Performance: two series, side by side ──────────────────────────────
   These three classes were used by `exchange/_performance.html` from the
   day it was written and defined nowhere, so the panel rendered as a column
   of unstyled prose: no padding, no divider, and the two series stacked
   with nothing to say they are separate. "Two series, never merged" was
   the one thing the panel had to show and the only thing it did not.

   A divider rather than two cards. They are one comparison — the benchmark
   is the reference and Actual is measured against it — and boxing them
   separately would say they are unrelated. */
.x-perf {
  display: grid; grid-template-columns: 1fr;
  gap: var(--s-5); padding: var(--s-5);
}
@media (min-width: 1024px) {
  .x-perf { grid-template-columns: 1fr 1fr; gap: var(--s-6); }
  /* The rule sits between the columns on a wide screen and above the
     second one when they stack, so the separation survives either way. */
  .x-perf__col + .x-perf__col {
    border-left: 1px solid var(--line); padding-left: var(--s-6);
  }
}
@media (max-width: 1023px) {
  .x-perf__col + .x-perf__col {
    border-top: 1px solid var(--line); padding-top: var(--s-5);
  }
}
.x-perf__col { min-width: 0; display: flex; flex-direction: column; gap: var(--s-3); }
.x-perf__h {
  margin: 0; font-size: 15px; font-weight: 600; letter-spacing: 0.01em;
}
.x-perf__col p { margin: 0; }
.x-perf__col .x-kv { margin-top: var(--s-2); }

/* The curve. Sized in CSS rather than on the element so the canvas cannot
   disagree with its container, which is what makes a chart look stretched. */
.x-perf__chart { width: 100%; height: 140px; display: block; }
.x-perf__legend {
  display: flex; flex-wrap: wrap; gap: var(--s-4);
  font-size: 12px; color: var(--ink-3); font-family: var(--f-num);
}
.x-perf__sw {
  display: inline-block; width: 14px; height: 2px;
  margin-right: 6px; vertical-align: middle;
}
/* Actual is drawn dashed and its key says so, because for most of the
   benchmark it is a series that has not started yet — a solid swatch beside
   an empty line would promise data that is not there. */
.x-perf__sw--dashed {
  height: 0; border-top: 2px dashed currentColor; background: none !important;
}
.x-perf__figure {
  margin: 0; padding: 0 var(--s-5) var(--s-5);
  display: flex; flex-direction: column; gap: var(--s-3);
}

.x-entry {
  display: grid; grid-template-columns: 24px minmax(0, 1fr) auto;
  gap: 2px var(--s-3); padding: var(--s-4) var(--s-5);
  border-bottom: 1px solid var(--line);
  text-decoration: none; color: var(--ink);
}
.x-entry:hover { background: var(--surface-sunken); }
.x-entry__glyph { color: var(--ink-2); text-align: center; }
.x-entry__body { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.x-entry__meta { font-size: 13px; color: var(--ink-2); }
.x-entry__meta strong { font-weight: 600; }
.x-entry__title { font-weight: 500; text-wrap: pretty; }
.x-entry__hash { font-family: var(--f-num); font-size: 12px; color: var(--ink-3); }
.x-entry__seq { font-family: var(--f-num); font-size: 13px; color: var(--ink-3); }

/* A superseded entry stays visible and is marked — never hidden. The same
   rule the desk already applies to a stale approval. */
.x-flag {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-family: var(--f-num); font-size: 11px;
  border-radius: var(--r-xs); padding: 1px 6px;
}
.x-flag--superseded { background: var(--warn-wash); color: var(--warn); }
.x-flag--correction { background: var(--signal-wash); color: var(--signal); }
.x-flag--ok { background: color-mix(in oklch, var(--pos) 14%, transparent); color: var(--pos); }
.x-flag--bad { background: color-mix(in oklch, var(--neg) 14%, transparent); color: var(--neg); }

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

.x-grid {
  display: grid; gap: var(--s-4);
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 360px), 1fr));
}

.x-card {
  border: 1px solid var(--line-strong); border-radius: var(--r-xl);
  background: var(--surface-raised); padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-4);
  text-decoration: none; color: var(--ink);
}
a.x-card:hover { border-color: var(--ink); }
.x-card__top { display: flex; justify-content: space-between; align-items: center; gap: var(--s-2); }
.x-ticker {
  font-family: var(--f-num); font-weight: 500;
  background: var(--ink); color: var(--surface);
  border-radius: var(--r-sm); padding: 2px var(--s-2); font-size: 13px;
}
.x-card__name { font-size: 22px; font-weight: 600; letter-spacing: -0.01em; }
.x-card__summary { color: var(--ink-2); font-size: 15px; text-wrap: pretty; }
.x-figures {
  display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: var(--s-3); border-top: 1px solid var(--line); padding-top: var(--s-4);
}
.x-figure { display: flex; flex-direction: column; gap: 2px; }
.x-figure__label { font-size: 12px; color: var(--ink-3); }
.x-figure__value { font-family: var(--f-num); font-size: 17px; }
/* Absent, not invented. A figure with no record behind it shows a dash and
   is dimmed, never estimated. */
.x-figure__value--none { color: var(--ink-3); }

/* ── The six-things grid ────────────────────────────────────────────── */

.x-model {
  display: grid; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 260px), 1fr));
}
.x-model > div {
  background: var(--surface-raised); padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.x-model__n { font-family: var(--f-num); font-size: 13px; color: var(--ink-3); }
.x-model__name { font-weight: 600; font-size: 20px; }
.x-model > div span:last-child { color: var(--ink-2); text-wrap: pretty; }

/* ── Listing tabs ───────────────────────────────────────────────────── */

.x-tabs {
  display: flex; gap: var(--s-1); flex-wrap: wrap;
  border-bottom: 1px solid var(--line);
}
.x-tabs a {
  padding: var(--s-3) var(--s-4); text-decoration: none; color: var(--ink-2);
  border-bottom: 2px solid transparent; margin-bottom: -1px;
}
.x-tabs a:hover { color: var(--ink); }
.x-tabs a[aria-current] {
  color: var(--ink); font-weight: 600; border-bottom-color: var(--signal);
}

/* ── Verification ───────────────────────────────────────────────────── */

.x-verify {
  display: flex; flex-direction: column; gap: var(--s-4);
  border: 1px solid var(--line); border-radius: var(--r-xl);
  background: var(--surface-sunken); padding: var(--s-6);
}
.x-kv { display: grid; gap: var(--s-2) var(--s-4); grid-template-columns: max-content minmax(0, 1fr); }
.x-kv dt { color: var(--ink-3); font-size: 14px; }
.x-kv dd { margin: 0; font-family: var(--f-num); font-size: 13px; word-break: break-all; }

/* Wide content scrolls inside its own container: the page body must never
   scroll sideways. */
.x-pre {
  margin: 0; overflow-x: auto;
  font-family: var(--f-num); font-size: 13px; line-height: 1.6;
  background: var(--surface); color: var(--ink-2);
  border: 1px solid var(--line); border-radius: var(--r-md);
  padding: var(--s-4);
}

@media (max-width: 599px) {
  .x-kv { grid-template-columns: minmax(0, 1fr); gap: var(--s-1); }
  .x-figures { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .x-entry { grid-template-columns: 20px minmax(0, 1fr); }
  .x-entry__seq { grid-column: 2; }
}

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

.x-foot { padding: var(--s-8) 0; }
.x-foot__inner {
  display: flex; flex-wrap: wrap; justify-content: space-between;
  gap: var(--s-3); font-size: 14px; color: var(--ink-3);
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }
}

/* ── Prose and long-form sections ───────────────────────────────────── */

/* Running text near 65 characters: the measure that stays readable. */
.x-prose { display: flex; flex-direction: column; gap: var(--s-3); max-width: 42em; }

/* ── Numbered steps ─────────────────────────────────────────────────── */

/* Numbered because these *are* a sequence — a thing happens, it is written
   down, chained, then pinned. The numbering carries information; it is not
   a decorative device. */
.x-steps {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 1px; background: var(--line);
  border: 1px solid var(--line); border-radius: var(--r-xl); overflow: hidden;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
}
.x-steps li {
  background: var(--surface-raised); padding: var(--s-6);
  display: flex; flex-direction: column; gap: var(--s-2);
}
.x-steps__n { font-family: var(--f-num); font-size: 13px; color: var(--ink-3); }
.x-steps__t { font-weight: 600; font-size: 19px; }
.x-steps__b { color: var(--ink-2); text-wrap: pretty; }

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

/* Wide content scrolls inside its own container, so the page body never
   scrolls sideways. */
.x-table-wrap { overflow-x: auto; }
.x-table { border-collapse: collapse; width: 100%; min-width: 32rem; }
.x-table caption { text-align: left; padding-bottom: var(--s-3); font-size: 14px; }
.x-table th, .x-table td {
  text-align: left; padding: var(--s-3) var(--s-4);
  border-bottom: 1px solid var(--line); vertical-align: top;
}
.x-table thead th {
  font-size: 13px; color: var(--ink-3); font-weight: 500;
  border-bottom-color: var(--line-strong);
}
.x-table tbody th { font-weight: 600; white-space: nowrap; }
.x-table td { color: var(--ink-2); }

/* ── Key/value lists ────────────────────────────────────────────────── */

/* The wide variant is for prose values — a registered office, a director's
   name — rather than the hashes `.x-kv` was built for, so it does not force
   monospace or break words mid-letter. */
.x-kv--wide { max-width: 44rem; }
.x-kv--wide dd { font-family: var(--f-ui); font-size: var(--fs-ui); word-break: normal; }

/* ── Plain lists ────────────────────────────────────────────────────── */

.x-list { margin: 0; padding-left: var(--s-5); display: flex; flex-direction: column; gap: var(--s-2); }
.x-list li { color: var(--ink-2); }
.x-list a { font-weight: 500; }

/* ── Sections that end a page ───────────────────────────────────────── */

/* A section carries a rule beneath it to separate it from the next one.
   The last section on a page has nothing to separate from, so the rule is
   a line hanging above the footer. */
.x-section--last { border-bottom: 0; }
.x-section--flush { padding-top: 0; }

/* ── One-off section and heading variants ───────────────────────────── */

/* Named rather than written inline: the handoff's position is that CSS
   lives in a stylesheet, and an inline style cannot be themed, overridden
   at a breakpoint, or found by the token validator. */
.x-h1--page { font-size: clamp(28px, 4vw, 42px); }
.x-h2--card { font-size: 19px; }
.x-card--tight { gap: var(--s-2); }
.x-panel__head a,
.x-panel__head .x-muted { font-weight: 400; font-size: 14px; }
.x-hero__col { display: flex; flex-direction: column; gap: var(--s-5); max-width: 48rem; }
.x-stack { display: flex; flex-direction: column; gap: var(--s-2); }
.x-stack--4 { gap: var(--s-1); }
.x-empty { padding: var(--s-6); color: var(--ink-3); }
.x-figures--flush { border-top: 0; padding-top: 0; }
.x-figures--wide { grid-template-columns: repeat(auto-fit, minmax(min(100%, 160px), 1fr)); padding: var(--s-5); }
.x-kv--pad { padding: var(--s-5); }
.x-verify__row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--s-3); }
.x-verify__note { margin: 0; max-width: 44em; }
.x-measure { max-width: 40rem; }

.x-card__top--left { justify-content: flex-start; gap: var(--s-3); }

.x-small { font-size: 13px; }

/* ── Article body ───────────────────────────────────────────────────── */

/* Editorial text, so it keeps a readable measure rather than running the
   full width of the wrapper. */
.x-article { max-width: 38em; color: var(--ink-2); }
.x-article p { margin: 0 0 var(--s-4); text-wrap: pretty; }

/* ── Clock labels ───────────────────────────────────────────────────── */

/* Every time carries which clock it is in. Quieter than the figure, but
   never hidden: this product keeps three clocks and they are never
   interchangeable. */
.x-clock { color: var(--ink-3); }

/* Visually hidden, still announced. Used for the clock's spoken expansion
   — `title` is not announced by most screen readers and is unreachable on
   touch (engineering answer D4). */
.x-sr {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip-path: inset(50%); white-space: nowrap; border: 0;
}

/* ── Components from the state matrix ───────────────────────────────── */
/* These are product components, not library decoration: the library page
   renders the same classes the product does, which is what stops a style
   guide drifting from the thing it documents. */

/* Buttons — the four variants in HANDOFF.md. Never pill: the old pill
   shape was part of the heritage-finance look the redesign removes. */
.x-btn--verify { background: var(--signal-fill); color: var(--on-signal); font-weight: 600; }
.x-btn--danger { border-color: var(--neg); color: var(--neg); }
.x-btn--danger:hover { background: color-mix(in oklch, var(--neg) 10%, transparent); }

/* Disabled: dashed border and a reason in text. Dashed rather than faded
   alone, because reduced contrast on its own is not a reliable signal. */
.x-btn:disabled,
.x-btn[aria-disabled="true"] {
  border-style: dashed; border-color: var(--line-input);
  background: transparent; color: var(--ink-3); cursor: not-allowed;
}

/* Fields. --line-input because a control boundary needs 3:1 (WCAG
   1.4.11) — this is the token that exists because the old border sat at
   1.79:1. */
.x-input {
  width: 100%; min-height: var(--row); padding: 0 var(--s-3);
  border: 1px solid var(--line-input); border-radius: var(--r-md);
  background: var(--surface-raised); color: var(--ink);
  font: inherit; font-size: var(--fs-ui);
}
.x-input:hover { border-color: var(--ink-3); }
.x-input--error { border-width: 1.5px; border-color: var(--neg); }

/* Freshness. The glyph differs per state as well as the colour, so the
   state survives a greyscale print and red-green blindness alike. */
.x-stamp {
  display: inline-flex; align-items: center; gap: var(--s-2);
  font-size: 13px; color: var(--ink-2);
}
.x-stamp::before { font-family: var(--f-num); }
.x-stamp--moving::before   { content: "●"; color: var(--pos); }
.x-stamp--silent::before   { content: "○"; color: var(--ink-3); }
.x-stamp--closed::before   { content: "■"; color: var(--ink-3); }
.x-stamp--retrying::before { content: "◌"; color: var(--warn); }
.x-stamp--fetching::before { content: "◌"; color: var(--ink-3); }

/* A signed figure carries its glyph and sign, never colour alone. */
.x-signed { display: inline-flex; align-items: baseline; gap: var(--s-1);
            font-family: var(--f-num); font-variant-numeric: tabular-nums; }
.x-signed--up     { color: var(--pos); }
.x-signed--down   { color: var(--neg); }
.x-signed--flat   { color: var(--ink-2); }
.x-signed--absent { color: var(--ink-3); }

/* Provenance. The solid/dashed difference carries meaning, so the border
   uses --line-input rather than the decorative --line (K14). */
.x-prov {
  font-family: var(--f-num); font-size: 11px; letter-spacing: 0.04em;
  padding: 1px 5px; border-radius: var(--r-xs);
  border: 1px solid var(--line-input); color: var(--ink-2);
}
.x-prov--der { border-style: dashed; font-style: italic; }

/* A lifecycle state, distinct from .x-flag which is a row condition. */
.x-status {
  display: inline-flex; align-items: center; gap: var(--s-1);
  font-size: 12px; padding: 1px 8px; border-radius: var(--r-round);
  border: 1px solid var(--line-input); color: var(--ink-2);
}
.x-status--ratified { border-style: solid; color: var(--pos); border-color: var(--pos); }
.x-status--proposed { border-style: dashed; }
.x-status--rejected { color: var(--neg); border-color: var(--neg); }
.x-status--retired  { text-decoration: line-through; color: var(--ink-3); }
