/* The Datum identity, for a page rather than an email.
 *
 * The email's constraints came from what mail clients can render. A browser lifts most of
 * them -- real CSS, flexbox, media queries -- so what carries over is the part that was
 * never technical: the palette, the two typefaces, the rules as hairlines, figures at 500
 * weight with tabular numerals, and the accent used ONCE per screen and never to carry
 * information on its own.
 */
:root {
  --ink:       #1A1A18;
  --paper:     #EFEDE7;
  --sheet:     #FFFFFF;
  --slate:     #6E6A61;
  --benchmark: #7A2E22;   /* the accent. ONE use per screen. */
  --rule:      #D9D5CC;
  --measure:   66ch;
  --inset:     24px;   /* the one inset every box uses */
}

* { box-sizing: border-box; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font: 400 16px/1.6 "IBM Plex Sans", -apple-system, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--ink); text-decoration-color: var(--rule); text-underline-offset: 3px; }
a:hover { text-decoration-color: var(--ink); }

.wrap { max-width: 940px; margin: 0 auto; padding: 0 24px; }
/* ONE INSET FOR EVERY BOX. A .sheet padded 32px and a .card padded 18px put their text on
 * two different vertical lines, so nothing down the page lines up with anything else -- the
 * boxes shared their edges and their contents did not. The box sizes still differ; the inset
 * does not. */
.sheet { background: var(--sheet); border: 1px solid var(--rule); padding: var(--inset); }

/* Masthead. The region suffix is the accent's single use. */
.masthead { padding: 28px 0 20px; border-bottom: 1px solid var(--rule); margin-bottom: 32px; }
.masthead h1 { margin: 0; font: 500 26px/1.2 "Libre Caslon Text", Georgia, "Times New Roman", serif; letter-spacing: -0.01em; }
.masthead h1 a { text-decoration: none; }
.masthead .suffix { color: var(--benchmark); }
.masthead nav { margin-top: 10px; font-size: 14px; color: var(--slate); display: flex; gap: 18px; }

h2 { font: 500 21px/1.3 "Libre Caslon Text", Georgia, serif; margin: 34px 0 12px; }
h3 { font: 500 17px/1.35 "Libre Caslon Text", Georgia, serif; margin: 24px 0 8px; }
p  { max-width: var(--measure); }

/* Figures. Tabular lining numerals, 500 weight, never bolder. */
.figure { font: 500 30px/1.1 "IBM Plex Sans", sans-serif; font-variant-numeric: tabular-nums lining-nums; }
.figure-sm { font: 500 20px/1.2 "IBM Plex Sans", sans-serif; font-variant-numeric: tabular-nums lining-nums; }
.change { font-size: 14px; color: var(--slate); font-variant-numeric: tabular-nums; }

/* The source line is mandatory under every figure and quiet by design: present for whoever
 * needs it, invisible to whoever does not. */
.source { font-size: 12px; line-height: 1.5; color: var(--slate); margin-top: 6px; }
.source a { color: var(--slate); }

/* A derived figure must say so. This is the one place the site admits a number is ours by
 * arithmetic rather than the producer's, and it is never allowed to be silent. */
.derived { font-size: 12px; color: var(--slate); border-left: 2px solid var(--rule); padding-left: 8px; }

/* CARDS GROW TO FILL THE ROW, whatever there are of them.
 *
 * Two attempts failed for the same underlying reason: the layout depended on the number of
 * items. `auto-fit, minmax(260px, 1fr)` left an empty third track, and a fixed
 * `repeat(3, 1fr)` left two cards filling two thirds -- in both cases the full-width box above
 * looked like it overflowed when in fact the cards were short.
 *
 * Flex with `flex: 1 1 <basis>` has no such dependency: items share the row in whatever number
 * they arrive, wrapping only when the basis no longer fits. One card fills the row, two share
 * it, five wrap onto two rows and still reach both edges. Every white box on the site ends at
 * the same two edges for any count. */
.grid, .cols-2, .cols-3 { display: flex; flex-wrap: wrap; gap: 20px; margin-bottom: 20px; }
.grid > *, .cols-2 > *, .cols-3 > * { flex: 1 1 260px; margin: 0; min-width: 0; }
.cols-2 > * { flex-basis: 340px; }

@media (max-width: 560px) {
  .grid > *, .cols-2 > *, .cols-3 > * { flex-basis: 100%; }
}
.card { background: var(--sheet); border: 1px solid var(--rule); padding: var(--inset); }
.card h3 { margin-top: 0; }

.kicker { font-size: 12px; letter-spacing: 0.08em; text-transform: uppercase; color: var(--slate); }
.standfirst { font: 400 19px/1.5 "Libre Caslon Text", Georgia, serif; max-width: var(--measure); }

table { border-collapse: collapse; width: 100%; font-size: 14px; }
th, td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--rule); vertical-align: top; }
th { font-weight: 500; color: var(--slate); font-size: 12px; text-transform: uppercase; letter-spacing: 0.06em; }
td.num { text-align: right; font-variant-numeric: tabular-nums lining-nums; }

.muted { color: var(--slate); }
.note { font-size: 14px; color: var(--slate); max-width: var(--measure); }

/* Wide things scroll inside their own box. The page body never scrolls sideways. */
.scroll-x { overflow-x: auto; }

footer { margin: 56px 0 40px; padding-top: 20px; border-top: 1px solid var(--rule);
         font-size: 13px; color: var(--slate); }

@media (max-width: 640px) {
  :root { --inset: 16px; }
  .wrap { padding: 0 16px; }
  .sheet { padding: 16px; }
  .figure { font-size: 25px; }
}

/* A subject card is a destination, so the whole box is the link rather than a word inside it. */
a.card.subject { text-decoration: none; display: block; }
a.card.subject:hover { border-color: var(--ink); }

/* A sortable header is a control and has to look like one, but quietly: the arrow appears
 * only on the column actually in use. */
th.sortable { cursor: pointer; user-select: none; }
th.sortable:hover { color: var(--ink); }
th.sortable[aria-sort]::after { content: " \2191"; }
th.sortable[aria-sort="descending"]::after { content: " \2193"; }

td.overdue { color: var(--benchmark); }

/* Expandable subject groups. <details> rather than JavaScript: it opens with scripting off,
 * it is keyboard-navigable and screen-reader-announced for free, and the browser remembers
 * nothing we then have to un-remember. */
details.group { background: var(--sheet); border: 1px solid var(--rule); margin-bottom: 12px; }
details.group > summary {
  cursor: pointer; padding: 14px var(--inset); display: flex; justify-content: space-between;
  align-items: baseline; gap: 12px; list-style: none;
}
details.group > summary::-webkit-details-marker { display: none; }
details.group > summary::after { content: "+"; color: var(--slate); font-size: 18px; }
details.group[open] > summary::after { content: "\2013"; }
details.group > summary:hover .group-name { text-decoration: underline; }
.group-name { font: 500 17px/1.3 "Libre Caslon Text", Georgia, serif; }
.group-count { color: var(--slate); font-size: 13px; font-variant-numeric: tabular-nums; }
.group-body { padding: 0 var(--inset) 6px; }

/* One measure inside a group: name and figure on a line, then its chart, then its source. */
.measure { border-top: 1px solid var(--rule); padding: 16px 0; }
.measure-head { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; }
.measure-name { font-weight: 500; text-decoration-color: var(--rule); }
.chart { margin: 10px 0 6px; }
.chart figcaption { margin-top: 2px; }

@media (max-width: 640px) {
  .group-body { padding: 0 16px 6px; }
  .measure-head { flex-direction: column; gap: 2px; }
}

details.group.nested { border: 0; border-top: 1px solid var(--rule); margin: 0; background: none; }
details.group.nested > summary { padding: 12px 0; }
details.group.nested .group-name { font-size: 15px; color: var(--slate); }
details.group.nested .group-body { padding: 0 0 8px; }

.sheet.correction { border-left: 3px solid var(--benchmark); }

/* Hover on a chart: the point under the cursor lights up. The tooltip itself is the SVG
 * <title>, which the browser renders and a screen reader announces -- no JavaScript, so it
 * behaves the same everywhere the rest of the page does. */
.chart .pt circle { transition: opacity .08s linear; pointer-events: none; }
.chart .pt:hover circle { opacity: 1; }
.chart .pt rect { cursor: crosshair; }

/* The locator runs the full width under the area name, where a reader looks first and where
 * it is big enough to actually place somewhere. At 240px in the corner it was decoration. */
#area-map { width: 100%; height: 260px; margin-bottom: 20px;
            border: 1px solid var(--rule); background: var(--sheet); }
#area-map .leaflet-control-attribution { font-size: 10px; }
@media (max-width: 640px) { #area-map { height: 200px; } }

/* The basemap is context, not content: desaturated and held back so the area outline in the
 * accent colour is the only thing that reads as information. */
#area-map .leaflet-tile-pane, #map .leaflet-tile-pane {
  filter: grayscale(1) contrast(0.92) brightness(1.06) opacity(0.72);
}

/* Breadcrumbs. A horizontal list with a separator drawn in CSS, so the markup is an ordered
   list a screen reader can announce rather than a string of text with slashes in it. */
.crumbs { margin: 0 0 18px; font-size: 13px; color: var(--slate); }
.crumbs ol { list-style: none; margin: 0; padding: 0; }
.crumbs li { display: inline; }
.crumbs li + li::before { content: "\203A"; margin: 0 7px; color: var(--rule); }
.crumbs a { color: var(--slate); }
.crumbs a:hover { color: var(--ink); }
.crumbs [aria-current] { color: var(--ink); }

/* Question and answer. The question is set in the serif at body size -- it is a heading in
   the document outline, not a section rule, so it must not compete with one. */
.qa { margin: 0 0 16px; }
.qa h4 { font: 500 16px/1.4 "Libre Caslon Text", Georgia, serif; margin: 0 0 4px;
         max-width: var(--measure); }
.qa p { margin: 0; }

/* A percentile set beneath its combined chart: the latest value at each point of the
   distribution. Tabular numerals so the column reads as a distribution rather than as five
   unrelated figures, and the same slate rule the rest of the page uses. */
table.pctl { border-collapse: collapse; margin: 6px 0 2px; font-variant-numeric: tabular-nums; }
table.pctl th { font-size: 12px; font-weight: 400; color: #6E6A61; text-align: right;
                padding: 2px 0 2px 18px; white-space: nowrap; }
table.pctl td { font-size: 15px; text-align: right; padding: 0 0 2px 18px;
                border-top: 1px solid #D9D5CC; white-space: nowrap; }
table.pctl th:first-child, table.pctl td:first-child { padding-left: 0; }
