/* ==========================================================================
   The Em Dash Conspiracy
   Set as a printed report: one white sheet on a grey desk, serif throughout,
   hard rules, no rounded corners. Colour appears only in the data marks, and
   only when the reader asks for it by highlighting a community.
   ========================================================================== */

:root {
  color-scheme: light;

  --desk:       #e8e8e8;
  --surface:    #ffffff;   /* the sheet, and the chart surface */
  --fill:       #f2f2f2;   /* table headers, callout boxes, pressed controls */
  --fill-soft:  #fafafa;

  --ink:        #000000;
  --ink-2:      #333333;
  --ink-3:      #555555;

  --rule:       #000000;   /* structural rules */
  --rule-soft:  #999999;
  --hair:       #cccccc;
  --sheet-edge: #bbbbbb;

  --grid:       #d9d9d9;   /* chart gridlines */
  --axis:       #000000;   /* chart baselines */
  --band-outer: rgba(0, 0, 0, 0.055);
  --band-inner: rgba(0, 0, 0, 0.125);
  --month-mark: rgba(0, 0, 0, 0.055);

  --accent:     #111111;   /* the single series in the ranking plate */

  /* Validated categorical slots, used only for reader chosen communities. */
  --s1: #2a78d6;
  --s2: #eb6834;
  --s3: #1baf7a;
  --s4: #eda100;
  --s5: #e87ba4;
  --s6: #008300;
  --s7: #4a3aa7;
  --s8: #e34948;

  --serif: "Times New Roman", Times, "Liberation Serif", Georgia, serif;
  --mono: "Courier New", Courier, "Liberation Mono", monospace;
}

/* ==========================================================================
   Base
   ========================================================================== */

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

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  padding: 2rem 0.75rem 4rem;
  background: var(--desk);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 16px;
  line-height: 1.45;
}

.page {
  max-width: 62rem;
  margin: 0 auto;
  padding: 2.5rem 3.5rem 3rem;
  background: var(--surface);
  border: 1px solid var(--sheet-edge);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.18);
}

h1, h2, h3 { margin: 0; font-weight: bold; line-height: 1.25; }
p { margin: 0 0 0.7rem; }
p:last-child { margin-bottom: 0; }

a { color: var(--ink); }
a:hover { text-decoration-thickness: 2px; }

code, .mono { font-family: var(--mono); font-size: 0.82em; }

button, input { font: inherit; color: inherit; }

:focus-visible { outline: 2px solid var(--ink); outline-offset: 2px; }

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

.skip {
  position: absolute;
  left: -9999px;
  top: 0;
  z-index: 60;
  background: var(--surface);
  border: 1px solid var(--rule);
  padding: 0.5rem 1rem;
}
.skip:focus { left: 0.75rem; top: 0.75rem; }

/* ==========================================================================
   Letterhead, title block, docket
   ========================================================================== */

.letterhead {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1.5rem;
  padding-bottom: 0.4rem;
  margin-bottom: 2.25rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.8rem;
  color: var(--ink-3);
}

.letterhead .imprint {
  display: inline-flex;
  align-items: baseline;
  gap: 0.6rem;
}
.letterhead .mark {
  font-size: 1.25rem;
  line-height: 1;
  color: var(--ink);
}
.letterhead .org {
  font-size: 0.8rem;
  font-variant: small-caps;
  letter-spacing: 0.1em;
  color: var(--ink);
}

.letterhead .file { text-align: right; line-height: 1.35; }

.title-block { text-align: center; margin: 4.5rem 0 0; }

.title-block h1 {
  font-size: 2.55rem;
  letter-spacing: 0.005em;
  margin-bottom: 0;
}

.title-block .subtitle {
  max-width: 38rem;
  margin: 1.05rem auto 0;
  font-size: 1.08rem;
  color: var(--ink-2);
}

table.docket {
  border-collapse: collapse;
  margin: 4rem 0 2rem;
  font-size: 0.82rem;
}
table.docket td { padding: 0.12rem 0; vertical-align: top; }
table.docket td:first-child {
  font-weight: bold;
  padding-right: 1.75rem;
  white-space: nowrap;
}

/* ==========================================================================
   Sections
   ========================================================================== */

section { margin-bottom: 2.25rem; }

h2 {
  font-size: 1.12rem;
  margin: 0 0 0.7rem;
  padding-bottom: 0.25rem;
  border-bottom: 1px solid var(--rule);
}

h2 .num { margin-right: 0.5rem; }

.section-note {
  font-size: 0.9rem;
  color: var(--ink-2);
  margin-bottom: 0.9rem;
}

/* ==========================================================================
   Principal finding
   ========================================================================== */

.finding {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.4rem 1.6rem;
  border: 2px solid var(--rule);
  padding: 1rem 1.3rem 1.1rem;
  margin-bottom: 1.2rem;
}

.finding .label {
  flex: 0 0 100%;
  font-size: 0.74rem;
  font-weight: bold;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-3);
  margin-bottom: 0.35rem;
}

.finding .value {
  font-size: 3.1rem;
  line-height: 1;
  font-weight: bold;
}

.finding .statement {
  flex: 1 1 22rem;
  margin: 0;
  font-size: 1rem;
}

/* ==========================================================================
   Tables
   ========================================================================== */

table.ledger {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.94rem;
}
table.ledger caption {
  caption-side: bottom;
  text-align: left;
  font-size: 0.84rem;
  color: var(--ink-3);
  padding-top: 0.45rem;
}
table.ledger th,
table.ledger td {
  border: 1px solid var(--rule);
  padding: 0.4rem 0.7rem;
  vertical-align: top;
}
table.ledger th {
  background: var(--fill);
  text-align: left;
  font-weight: bold;
}
table.ledger td.figure-cell {
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
table.ledger td.remark { color: var(--ink-3); font-size: 0.88rem; }

/* the chart table views */
.table-wrap {
  max-height: 30rem;
  overflow: auto;
  border: 1px solid var(--rule);
}

.table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

.table-wrap thead th {
  position: sticky;
  top: 0;
  z-index: 1;
  background: var(--fill);
  padding: 0.4rem 0.65rem;
  text-align: right;
  font-size: 0.8rem;
  font-weight: bold;
  white-space: nowrap;
  border: 1px solid var(--rule);
}
.table-wrap thead th:first-child { text-align: left; }

.table-wrap tbody td,
.table-wrap tbody th {
  padding: 0.34rem 0.65rem;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  border: 1px solid var(--hair);
  border-top: 0;
}
.table-wrap tbody th {
  text-align: left;
  font-weight: bold;
  font-variant-numeric: normal;
  background: var(--fill-soft);
}
.table-wrap tbody td:first-child {
  text-align: left;
  font-variant-numeric: normal;
}
.table-wrap tbody tr:hover td,
.table-wrap tbody tr:hover th { background: var(--fill); }
.table-wrap tbody tr.row-strong td,
.table-wrap tbody tr.row-strong th { font-weight: bold; }

.swatch-inline {
  display: inline-block;
  width: 9px;
  height: 9px;
  margin-right: 0.4rem;
  border: 1px solid var(--ink);
  vertical-align: baseline;
}

.table-note {
  font-size: 0.84rem;
  color: var(--ink-3);
  margin: 0.45rem 0 0;
}

/* ==========================================================================
   Selection form
   ========================================================================== */

fieldset.selection {
  border: 1px solid var(--rule);
  padding: 0.9rem 1.15rem 1.05rem;
  margin: 0 0 2.25rem;
}

fieldset.selection legend {
  padding: 0 0.45rem;
  font-weight: bold;
  font-size: 0.94rem;
}

.field { margin-bottom: 0.9rem; }
.field:last-child { margin-bottom: 0; }

.field-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.2rem 0.7rem;
  margin-bottom: 0.45rem;
}

.field-label { font-weight: bold; font-size: 0.94rem; }
.field-hint { font-size: 0.85rem; color: var(--ink-3); }

.field-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

.btn {
  padding: 0.18rem 0.6rem;
  background: var(--fill);
  border: 1px solid var(--rule);
  font-size: 0.86rem;
  cursor: pointer;
}
.btn:hover { background: var(--surface); }
.btn[aria-pressed="true"] {
  background: var(--ink);
  color: var(--surface);
}
.btn:disabled {
  color: var(--rule-soft);
  border-color: var(--rule-soft);
  background: var(--fill-soft);
  cursor: default;
}
.btn:disabled:hover { background: var(--fill-soft); }

/* search */
.picker { position: relative; width: min(22rem, 100%); }

.picker input {
  width: 100%;
  padding: 0.2rem 0.45rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  font-size: 0.88rem;
}
.picker input::placeholder { color: var(--rule-soft); font-style: italic; }

.picker-results {
  position: absolute;
  z-index: 20;
  top: calc(100% - 1px);
  left: 0;
  right: 0;
  max-height: 17rem;
  overflow-y: auto;
  margin: 0;
  padding: 0;
  list-style: none;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
}
.picker-results[hidden] { display: none; }

.picker-results button {
  display: flex;
  width: 100%;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.8rem;
  padding: 0.22rem 0.5rem;
  border: 0;
  border-bottom: 1px solid var(--hair);
  background: transparent;
  text-align: left;
  font-size: 0.86rem;
  cursor: pointer;
}
.picker-results li:last-child button { border-bottom: 0; }
.picker-results button:hover,
.picker-results button:focus-visible { background: var(--fill); }
.picker-results button[disabled] { color: var(--rule-soft); cursor: not-allowed; }
.picker-results button[disabled]:hover { background: transparent; }
.picker-results .meta { color: var(--ink-3); font-size: 0.8rem; font-variant-numeric: tabular-nums; }
.picker-results .none { padding: 0.4rem 0.5rem; color: var(--ink-3); font-size: 0.86rem; }

/* chosen communities */
.selected-chips {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.35rem;
  margin-top: 0.55rem;
  min-height: 1.6rem;
}

.token {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.1rem 0.15rem 0.1rem 0.4rem;
  border: 1px solid var(--rule);
  background: var(--surface);
  font-size: 0.86rem;
}

.token .swatch {
  flex: none;
  width: 9px;
  height: 9px;
  border: 1px solid var(--ink);
}

.token button {
  width: 1.15rem;
  height: 1.15rem;
  border: 0;
  background: transparent;
  color: var(--ink-3);
  line-height: 1;
  cursor: pointer;
}
.token button:hover { background: var(--ink); color: var(--surface); }

.empty-note { font-size: 0.86rem; color: var(--ink-3); font-style: italic; }

/* month radios */
.months {
  display: flex;
  flex-wrap: wrap;
  gap: 0.15rem 1.1rem;
}
.months label {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.92rem;
  cursor: pointer;
}
.months input { accent-color: var(--ink); margin: 0; }

/* ==========================================================================
   Figures
   ========================================================================== */

.figure-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.4rem 1rem;
  margin-bottom: 0.5rem;
}

.view-toggle {
  display: inline-flex;
  align-items: baseline;
  gap: 0.35rem;
  font-size: 0.84rem;
  color: var(--ink-3);
}
.view-toggle button {
  padding: 0.1rem 0.5rem;
  border: 1px solid var(--rule);
  background: var(--fill);
  font-size: 0.82rem;
  cursor: pointer;
}
.view-toggle button:hover { background: var(--surface); }
.view-toggle button[aria-pressed="true"] { background: var(--ink); color: var(--surface); }

.plate[hidden] { display: none; }

.plate {
  border: 1px solid var(--rule);
  padding: 0.7rem 0.8rem 0.4rem;
  background: var(--surface);
}

.chart { position: relative; width: 100%; }
.chart svg { display: block; width: 100%; height: auto; }
.chart:focus-visible { outline: 2px solid var(--ink); outline-offset: 3px; }

.chart-loading {
  display: grid;
  place-items: center;
  min-height: 15rem;
  color: var(--ink-3);
  font-style: italic;
}

.figure-caption {
  margin: 0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--ink-2);
}
.figure-caption b { color: var(--ink); }

/* chart internals */
.chart svg text { font-family: var(--serif); }
.tick-text { font-size: 11.5px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.axis-label { font-size: 11.5px; fill: var(--ink-3); }
.gridline { stroke: var(--grid); stroke-width: 1; shape-rendering: crispEdges; }
.baseline { stroke: var(--axis); stroke-width: 1; shape-rendering: crispEdges; }
.series-label { font-size: 11.5px; fill: var(--ink-2); }
.value-label { font-size: 12px; font-weight: bold; fill: var(--ink); font-variant-numeric: tabular-nums; }
.value-sub { font-size: 11px; fill: var(--ink-3); font-variant-numeric: tabular-nums; }
.cat-label { font-size: 12.5px; fill: var(--ink); }

/* legend */
.legend[hidden] { display: none; }

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem 1.2rem;
  margin-top: 0.65rem;
  padding-top: 0.55rem;
  border-top: 1px solid var(--hair);
  font-size: 0.82rem;
  color: var(--ink-2);
}

.legend-item { display: inline-flex; align-items: center; gap: 0.4rem; }
.legend-item .key { flex: none; width: 16px; height: 3px; }
.legend-item .key-thin { height: 1.5px; }
.legend-item .key-band { height: 11px; border: 1px solid var(--hair); }

/* tooltip */
.tip {
  position: fixed;
  z-index: 40;
  min-width: 11rem;
  max-width: 19rem;
  padding: 0.45rem 0.55rem;
  background: var(--surface);
  border: 1px solid var(--rule);
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.22);
  font-size: 0.86rem;
  pointer-events: none;
  opacity: 0;
}
.tip[data-open="true"] { opacity: 1; }

.tip-head {
  padding-bottom: 0.3rem;
  margin-bottom: 0.3rem;
  border-bottom: 1px solid var(--rule);
  font-size: 0.78rem;
  font-weight: bold;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--ink-3);
}

.tip-row {
  display: grid;
  grid-template-columns: 14px 1fr auto;
  align-items: center;
  gap: 0.45rem;
  padding-block: 0.06rem;
  font-size: 0.85rem;
}
.tip-row .key { width: 14px; height: 2.5px; }
.tip-row .name { color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tip-row .val { font-weight: bold; font-variant-numeric: tabular-nums; }
.tip-note { margin-top: 0.35rem; font-size: 0.78rem; color: var(--ink-3); }

/* ==========================================================================
   Notes and sources
   ========================================================================== */

ol.notes { margin: 0; padding-left: 1.4rem; font-size: 0.92rem; }
ol.notes li { margin-bottom: 0.5rem; }
ol.notes li:last-child { margin-bottom: 0; }

ul.sources { margin: 0; padding-left: 1.4rem; font-size: 0.92rem; }
ul.sources li { margin-bottom: 0.25rem; }

/* ==========================================================================
   Narrow sheets and print
   ========================================================================== */

@media (max-width: 780px) {
  body { padding: 1rem 0.5rem 2.5rem; }
  .page { padding: 1.5rem 1.1rem 2rem; }
  .title-block h1 { font-size: 1.5rem; }
  .finding .value { font-size: 2.4rem; }
  .letterhead { font-size: 0.74rem; }
}

@media print {
  body { background: var(--surface); padding: 0; }
  .page { max-width: none; border: 0; box-shadow: none; padding: 0; }
  fieldset.selection, .view-toggle { display: none; }
  .plate { break-inside: avoid; }
}
