/* Bankadr. Tokens first: a technical paper. White page, near-black ink, grey rules,
   one navy accent for links. Sans-serif throughout, square corners, no tinted panels. */
:root {
  --page: #ffffff;
  --panel: #f5f6f8;
  --ink: #15181c;
  --ink-muted: #59626e;
  --line: #d8dce2;
  --line-strong: #15181c;
  --accent: #1a4480;
  --focus: #2f6fd0;

  --font: "Helvetica Neue", Helvetica, "Segoe UI", Arial, system-ui, sans-serif;
  --mono: ui-monospace, "SF Mono", "Cascadia Mono", Menlo, Consolas, monospace;
  --step--1: 0.8125rem;
  --step-0: 1rem;
  --step-1: 1.125rem;
  --step-2: 1.4rem;
  --step-3: 1.9rem;
  --radius: 2px;
  --measure: 44rem;
}

@media (prefers-color-scheme: dark) {
  :root {
    --page: #111317;
    --panel: #1a1d23;
    --ink: #e5e7ea;
    --ink-muted: #9aa2ad;
    --line: #2c3139;
    --line-strong: #e5e7ea;
    --accent: #9dbcf2;
    --focus: #9dbcf2;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-padding-top: 1rem; }
body {
  margin: 0;
  background: var(--page);
  color: var(--ink);
  font: var(--step-0)/1.6 var(--font);
}
a { color: var(--accent); text-underline-offset: 3px; text-decoration-thickness: 1px; }
a:hover { text-decoration-thickness: 2px; }
:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

.skip { position: absolute; left: -999rem; }
.skip:focus { left: 1rem; top: 1rem; background: var(--page); padding: 0.5rem 0.75rem; z-index: 2; }

/* Masthead */
.mast { border-bottom: 2px solid var(--line-strong); }
.mast-in {
  max-width: 88rem; margin: 0 auto; padding: 0.9rem 1.25rem;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 0.25rem 1rem;
}
.brand {
  color: var(--ink); font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase;
  font-size: var(--step--1); text-decoration: none;
}
.tagline { margin: 0; color: var(--ink-muted); font-size: var(--step--1); }

/* Shell: pages | text | on this page */
.shell {
  max-width: 88rem; margin: 0 auto; padding: 0 1.25rem;
  display: grid; grid-template-columns: minmax(0, 1fr); gap: 0 2.5rem;
}
.side, .toc { display: none; }
.pages { margin: 1rem 0 0; border: 1px solid var(--line); border-radius: var(--radius); }
.pages summary { padding: 0.7rem 1rem; cursor: pointer; font-weight: 600; }
.pages nav { padding: 0 0.5rem 0.5rem; }

.side ol, .pages ol, .toc ol { list-style: none; margin: 0; padding: 0; }
.side a, .pages a {
  display: grid; grid-template-columns: 2.1rem 1fr; gap: 0.25rem; align-items: baseline;
  padding: 0.38rem 0.6rem; border-left: 2px solid transparent; color: var(--ink); text-decoration: none;
  font-size: 0.9rem; line-height: 1.35;
}
.side a:hover, .pages a:hover { background: var(--panel); }
.side a[aria-current], .pages a[aria-current] { border-left-color: var(--line-strong); background: var(--panel); font-weight: 600; }
.num { font: 400 var(--step--1)/1.35 var(--mono); color: var(--ink-muted); }

main { min-width: 0; padding: 1.5rem 0 3rem; }
article { max-width: var(--measure); margin: 0 auto; }

@media (min-width: 62rem) {
  .shell { grid-template-columns: 17rem minmax(0, 1fr); }
  .pages { display: none; }
  .side {
    display: block; position: sticky; top: 0; align-self: start;
    max-height: 100vh; overflow-y: auto; padding: 2rem 0;
  }
  main { padding-top: 2.5rem; }
}
@media (min-width: 84rem) {
  .shell { grid-template-columns: 17rem minmax(0, 1fr) 14rem; }
  .toc {
    display: block; position: sticky; top: 0; align-self: start;
    max-height: 100vh; overflow-y: auto; padding: 2.75rem 0 2rem; font-size: var(--step--1);
  }
  .toc-title { margin: 0 0 0.5rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-muted); }
  .toc li { border-left: 1px solid var(--line); }
  .toc a { display: block; padding: 0.3rem 0 0.3rem 0.8rem; color: var(--ink-muted); text-decoration: none; line-height: 1.35; }
  .toc a:hover { color: var(--ink); }
}

/* Text */
h1, h2, h3 { font-weight: 700; line-height: 1.25; }
h1 { font-size: var(--step-3); margin: 0 0 1.25rem; letter-spacing: -0.015em; }
h2 { font-size: var(--step-2); margin: 2.75rem 0 0.75rem; padding-top: 1rem; border-top: 1px solid var(--line-strong); letter-spacing: -0.01em; }
h3 { font-size: var(--step-1); margin: 1.9rem 0 0.5rem; }
.anchor { color: inherit; text-decoration: none; }
.anchor:hover::after { content: " #"; color: var(--ink-muted); }
p, ul, ol, .table-scroll, pre, figure, aside { margin: 0 0 1.1rem; }
article ul, article ol { padding-left: 1.4rem; }
article li { margin: 0.3rem 0; }
article li > ul, article li > ol { margin: 0.3rem 0 0.3rem; }
strong { font-weight: 700; }
code {
  font: 0.86em/1.4 var(--mono); background: var(--panel); padding: 0.1em 0.3em; border-radius: var(--radius);
  overflow-wrap: anywhere;
}
pre.code {
  background: var(--panel); color: var(--ink); padding: 0.9rem 1rem; border: 1px solid var(--line);
  border-radius: var(--radius); overflow-x: auto; font-size: 0.875rem; line-height: 1.5;
}
pre.code code { background: none; padding: 0; font-size: inherit; overflow-wrap: normal; }

/* Numbered references to the page's source list */
sup.fn { font-size: 0.72em; line-height: 0; margin-left: 0.1em; }
sup.fn a { text-decoration: none; }
ol.sources { font-size: 0.9rem; line-height: 1.45; overflow-wrap: anywhere; }
ol.sources li:target { background: var(--panel); }

/* Callouts: a note set off by rules; the summary is the page's abstract */
.callout { border-left: 3px solid var(--line-strong); padding: 0.1rem 0 0.1rem 1rem; }
.callout p { margin: 0; }
.callout.summary {
  border: 0; border-top: 1px solid var(--line-strong);
  padding: 0.9rem 0; font-size: var(--step-1); line-height: 1.55;
}

/* Tables scroll inside their own box; the page never scrolls sideways */
.table-scroll { overflow-x: auto; }
table { border-collapse: collapse; width: 100%; font-size: 0.9rem; line-height: 1.45; border-top: 1px solid var(--line-strong); border-bottom: 1px solid var(--line-strong); }
th, td { text-align: left; vertical-align: top; padding: 0.55rem 0.8rem 0.55rem 0; border-bottom: 1px solid var(--line); min-width: 7rem; }
th { font-weight: 700; white-space: nowrap; border-bottom: 1px solid var(--line-strong); }
tbody tr:last-child td { border-bottom: 0; }

/* Diagrams: committed pictures, one for each colour scheme */
.diagram {
  border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1rem; overflow-x: auto; text-align: center;
}
.diagram-link { display: inline-block; }
.diagram img { max-width: 100%; height: auto; vertical-align: middle; }
@media (max-width: 40rem) {
  /* On a phone a wide picture scaled to the screen is unreadable: keep it at a
     legible size and let its box scroll sideways. */
  .diagram.wide { text-align: left; }
  .diagram.wide img { width: 40rem; max-width: none; }
}
@media (min-width: 62rem) {
  /* Wide pictures may use the space beside the column. */
  .diagram { margin-left: -2rem; margin-right: -2rem; }
}

.pager { max-width: var(--measure); margin: 3rem auto 0; display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.pager a {
  display: block; padding: 0.8rem 1rem; border: 1px solid var(--line); border-radius: var(--radius);
  text-decoration: none; color: var(--ink); line-height: 1.35; font-weight: 600;
}
.pager a:hover { border-color: var(--line-strong); }
.pager span { display: block; font-size: var(--step--1); font-weight: 400; color: var(--ink-muted); margin-bottom: 0.15rem; }
.pager .next { text-align: right; }

.foot { border-top: 1px solid var(--line); margin-top: 2rem; }
.foot p { max-width: 88rem; margin: 0 auto; padding: 1.25rem; color: var(--ink-muted); font-size: var(--step--1); }

@media print {
  .mast, .side, .pages, .toc, .pager, .skip { display: none; }
  .shell { display: block; }
}
