/* Prose, and the chrome around it.

   Everything here is spacing, measure and rules. Not one colour, size or face is invented:
   they are the tokens from `frontend/src/design/styles.css`, which this file is always loaded
   after. A second palette in a second file is how two halves of a site stop matching, and the
   design project is the half that decides.

   The system is Swiss transport graphic: white paper, a black grotesk, heavy black rules,
   Verkehrsrot as signal and never as decoration, and nothing rounded. A long methodology page
   full of wide tables is the hardest thing that system has to carry, so the tables get most of
   the attention below. */

/* ---------------------------------------------------------------- chrome */

.bp-content { max-width: 74rem; margin: 0 auto; padding: 0 var(--s6) var(--s9); }

.bp-site-head {
  display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--s5) var(--s7);
  padding: var(--s6) 0 var(--s5);
}

/* Visible only once tabbed to. A page whose first interactive element is a nav of five links
   is a page a keyboard reader pays for on every visit. */
.bp-skip {
  position: absolute; left: -9999px;
  background: var(--paper); color: var(--ink); padding: var(--s3) var(--s5);
  border: 2px solid var(--accent);
}
.bp-skip:focus { left: var(--s6); top: var(--s3); z-index: 10; }

.bp-mark { text-decoration: none; color: var(--ink); }
.bp-mark__name {
  font-weight: 700; font-size: var(--t-h1); letter-spacing: -.028em; line-height: 1;
}
.bp-mark:hover .bp-mark__name { color: var(--accent-ink); }

.bp-nav { display: flex; flex-wrap: wrap; gap: var(--s5) var(--s6); margin-left: auto; }
.bp-nav a {
  color: var(--ink-2); text-decoration: none;
  font-size: var(--t-h3); font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
  padding-bottom: var(--s2); border-bottom: 2px solid transparent;
}
.bp-nav a:hover { color: var(--ink); border-bottom-color: var(--rule); }
/* The current page is marked with the rule, not with colour alone — red is disruption here and
   nowhere else. */
.bp-nav a[aria-current="page"] { color: var(--ink); border-bottom-color: var(--bar); }

.bp-site-foot {
  display: flex; flex-wrap: wrap; gap: var(--s5) var(--s7); align-items: baseline;
  padding-top: var(--s5); font-size: var(--t-sm); color: var(--ink-3);
}
.bp-site-foot__note { margin: 0; max-width: 46rem; }
.bp-langs { display: flex; gap: var(--s5); margin-left: auto; }
.bp-langs__current { color: var(--ink); font-weight: 700; }

/* ---------------------------------------------------------------- prose */

/* 34rem at 15px is roughly 68 characters: the measure a reader can return to the next line of
   without losing it. The tables below are allowed out of it, because a table is scanned and not
   read, and a five-column table squeezed to the text measure is unreadable in a different way. */
.bp-prose { max-width: 38rem; padding-top: var(--s7); }
.bp-prose__head h1 { font-size: var(--t-fig-l); line-height: 1.08; margin-bottom: var(--s5); }
.bp-prose__date { color: var(--ink-3); margin: 0 0 var(--s4); }
.bp-prose__lede { font-size: var(--t-fig-s); color: var(--ink-2); margin: var(--s5) 0 var(--s6); }
.bp-prose .bp-bar { margin: var(--s6) 0 var(--s7); }

.bp-draft {
  display: inline-block; margin: 0 0 var(--s5);
  background: var(--accent-soft); color: var(--accent-ink);
  border-left: 3px solid var(--accent);
  padding: var(--s3) var(--s5);
  font-size: var(--t-h3); font-weight: 700; letter-spacing: .09em; text-transform: uppercase;
}

/* Quieter than the draft banner and made of the same parts: a fact about the document, stated
   in the page's own voice, in the place a reader looks before the first paragraph. */
.bp-notice {
  margin: 0 0 var(--s6); padding: var(--s4) var(--s5);
  border-left: 3px solid var(--rule-strong); background: var(--surface-2);
  color: var(--ink-2); font-size: var(--t-sm);
}

.bp-prose h2 {
  font-size: var(--t-fig-m); margin: var(--s9) 0 var(--s5);
  padding-top: var(--s5); border-top: 3px solid var(--bar);
}
.bp-prose h3 { font-size: var(--t-fig-s); font-weight: 700; margin: var(--s8) 0 var(--s4); }
.bp-prose h4 { font-size: var(--t-body); font-weight: 700; margin: var(--s7) 0 var(--s4); }
.bp-prose p { margin: 0 0 var(--s6); }
.bp-prose ul, .bp-prose ol { margin: 0 0 var(--s6); padding-left: var(--s7); }
.bp-prose li { margin-bottom: var(--s4); }
.bp-prose li > ul, .bp-prose li > ol { margin-top: var(--s4); }

.bp-prose hr { height: 1px; background: var(--rule); border: 0; margin: var(--s8) 0; }

.bp-prose blockquote {
  margin: 0 0 var(--s6); padding-left: var(--s6);
  border-left: 3px solid var(--rule); color: var(--ink-2);
}

.bp-prose code {
  font-family: var(--font-mono); font-size: .88em;
  background: var(--surface-2); padding: 1px var(--s2);
}
.bp-prose pre {
  background: var(--surface-2); border-left: 3px solid var(--rule);
  padding: var(--s5); overflow-x: auto; margin: 0 0 var(--s6);
}
.bp-prose pre code { background: none; padding: 0; }

/* A heading you can link to. The anchor only appears on hover or focus, so it is available
   without being furniture. */
.bp-prose h2, .bp-prose h3 { scroll-margin-top: var(--s6); }

/* ---------------------------------------------------------------- tables */

/* `docs/` writes five- and six-column tables with a paragraph in the last cell. Two rules make
   them survive: they may exceed the text measure, and they scroll inside themselves rather than
   widening the page — a body that scrolls sideways on a phone is unusable and it is the failure
   this exact kind of document causes most often. */
.bp-prose table {
  border-collapse: collapse; width: 100%;
  font-size: var(--t-sm); line-height: 1.35;
}
/* `width` and not `max-width`. A block element's width is `auto`, which means "as wide as the
   parent's content box" — so a `max-width: 66rem` on a table inside a 38rem column caps a width
   it never reaches, and the four-column columns table renders at the text measure with three
   words per cell. Setting the width is what takes the table out of the column.
   `max-content` is the other obvious answer and is worse here: these cells hold sentences, so
   max-content is one very long line and the table becomes a horizontal scroller nobody can
   read. A fixed target width with wrapping cells is what a reference table wants. */
.bp-prose > table {
  display: block; overflow-x: auto;
  width: min(64rem, calc(100vw - 2 * var(--s6)));
  margin: 0 0 var(--s7);
}
.bp-prose th, .bp-prose td {
  border-bottom: 1px solid var(--rule); padding: var(--s3) var(--s5) var(--s3) 0;
  text-align: left; vertical-align: top;
}
.bp-prose thead th {
  border-bottom: 3px solid var(--bar);
  font-size: var(--t-h3); font-weight: 700; letter-spacing: .06em; text-transform: uppercase;
  white-space: nowrap;
}
/* Markdown's `---:` alignment, which the docs use for every count. */
.bp-prose th[style*="right"], .bp-prose td[style*="right"] {
  font-variant-numeric: tabular-nums lining-nums;
}
.bp-prose tbody tr:hover { background: var(--surface-2); }

/* ---------------------------------------------------------------- figures */

/* A number read from the cube at request time (`content::figure`). Tabular so that two of them
   in neighbouring sentences line up, and never coloured: a rate is not good news or bad news
   until someone says what it is being compared with. */
.bp-figure { font-variant-numeric: tabular-nums lining-nums; font-weight: 700; }
.bp-figure__note { font-weight: 400; color: var(--ink-2); }
/* Withheld and missing are different states and they look different. Withheld is a decision the
   system made and states plainly; missing is a deployment that cannot answer. Neither is a dash
   and neither is a greyed-out digit — `design/01-constraints.md` §3. */
.bp-figure--withheld { font-weight: 400; color: var(--ink-2); font-style: italic; }
.bp-figure--missing {
  font-weight: 400; color: var(--accent-ink);
  background: var(--accent-soft); padding: 0 var(--s2);
}

.bp-prose figure { margin: 0 0 var(--s7); max-width: min(48rem, 100%); }
.bp-prose img { max-width: 100%; height: auto; display: block; }
.bp-prose figcaption, .bp-prose p > img + em {
  font-size: var(--t-sm); color: var(--ink-3); margin-top: var(--s3);
}
/* A markdown image alone in a paragraph is the caption-less case; give it the same room. */
.bp-prose p:has(> img:only-child) { margin-bottom: var(--s7); }

/* ---------------------------------------------------------------- blog index */

.bp-index { list-style: none; margin: 0; padding: 0; max-width: 46rem; }
.bp-index__row {
  display: grid; grid-template-columns: 6.5rem 1fr; gap: var(--s6);
  padding: var(--s6) 0; border-bottom: 1px solid var(--rule); margin: 0;
}
.bp-index__date { color: var(--ink-3); padding-top: 3px; }
.bp-index__title {
  font-size: var(--t-fig-s); font-weight: 700; color: var(--ink);
  text-decoration: none; border-bottom: 2px solid var(--rule);
}
.bp-index__title:hover { border-bottom-color: var(--accent); color: var(--ink); }
.bp-index__summary { margin: var(--s4) 0 0; color: var(--ink-2); }
.bp-empty { color: var(--ink-2); }

@media (max-width: 34rem) {
  .bp-index__row { grid-template-columns: 1fr; gap: var(--s3); }
  .bp-nav { margin-left: 0; }
}

/* The methodology page is cited in print and in PDFs sent to operators. Give it a page that
   works: no chrome, black on white, and the tables unclipped. */
@media print {
  .bp-site-head, .bp-site-foot, .bp-skip, .bp-langs { display: none; }
  .bp-prose, .bp-content { max-width: none; padding: 0; }
  .bp-prose > table { overflow: visible; max-width: none; }
  .bp-prose a { color: inherit; }
}
