:root {
  --ink: #16202b;
  --muted: #5b6b7f;
  --rule: #e2e7ec;
  --ground: #ffffff;
  --panel: #f7f8fa;
  --accent: #1b4965;
  --warn-bg: #fdf6e7;
  --warn-rule: #e8d9ae;
  color-scheme: light;
}

* {
  box-sizing: border-box;
}

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

body {
  margin: 0;
  background: var(--ground);
  color: var(--ink);
  font: 16px/1.55 ui-sans-serif, system-ui, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

a {
  color: var(--accent);
}

.wrap {
  max-width: 860px;
  margin: 0 auto;
  padding: 0 20px 72px;
}

header.site {
  border-bottom: 1px solid var(--rule);
  margin-bottom: 32px;
}

header.site .wrap {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding-block: 18px;
}

header.site a.brand {
  font-weight: 650;
  font-size: 18px;
  text-decoration: none;
  color: var(--ink);
}

nav.locales a {
  font-size: 14px;
  text-decoration: none;
  padding: 2px 6px;
}

nav.locales a[aria-current="true"] {
  font-weight: 650;
  text-decoration: underline;
}

h1 {
  font-size: 30px;
  line-height: 1.2;
  margin: 0 0 8px;
}

h2 {
  font-size: 19px;
  margin: 40px 0 12px;
}

p.lede {
  color: var(--muted);
  margin-top: 0;
}

.meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 18px;
  font-size: 14px;
  color: var(--muted);
  margin: 0 0 24px;
  padding: 0;
  list-style: none;
}

.chart {
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 16px 16px 8px;
  margin-bottom: 8px;
  overflow-x: auto;
}

.tick {
  font-size: 11px;
  fill: var(--muted);
}

.series-label {
  font-size: 11.5px;
}

.note {
  background: var(--warn-bg);
  border: 1px solid var(--warn-rule);
  border-radius: 6px;
  padding: 12px 14px;
  font-size: 14.5px;
}

/* Domains on the front page. Each one is a box you open, so the eight of them fit on a screen
   and a reader can see what else exists before deciding where to look. */
details.domain {
  border: 1px solid var(--rule);
  border-radius: 6px;
  margin: 8px 0;
}

details.domain > summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 16px;
  cursor: pointer;
  font-size: 17px;
  font-weight: 600;
  border-radius: 6px;
  list-style: none;
}

/* Safari still draws its own triangle without this. */
details.domain > summary::-webkit-details-marker {
  display: none;
}

details.domain > summary:hover {
  background: var(--panel);
}

details.domain > summary::before {
  content: "+";
  color: var(--muted);
  font-weight: 400;
  width: 1em;
  flex: none;
}

details.domain[open] > summary::before {
  content: "−";
}

details.domain[open] > summary {
  border-bottom: 1px solid var(--rule);
  border-radius: 6px 6px 0 0;
}

.domain-name {
  flex: 1;
}

.domain-count {
  color: var(--muted);
  font-weight: 400;
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.domain-link {
  margin: 12px 16px 0;
}

details.domain > table.data {
  margin: 0 16px 16px;
  width: calc(100% - 32px);
}

/* Seats per group, drawn to scale against the chamber. The bar is an impression; the number
   beside it is the fact, which is why both are there. */
/* A top-level section box: slightly heavier than the ones nested inside it. */
details.domain.section > summary {
  font-size: 19px;
}

details.domain.section > p.note,
details.domain.section > details.domain,
details.domain.section > table.data {
  margin-left: 16px;
  margin-right: 16px;
}

details.domain.section > table.data {
  width: calc(100% - 32px);
  margin-bottom: 16px;
}

h4.chamber-title {
  margin: 14px 16px 0;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

ul.bars {
  list-style: none;
  margin: 0;
  padding: 12px 16px 16px;
}

ul.bars li {
  display: grid;
  grid-template-columns: 8.5em 1fr 3em 4em;
  align-items: center;
  gap: 10px;
  padding: 3px 0;
}

.bar-name {
  font-weight: 600;
  font-size: 14px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: var(--panel);
  border-radius: 3px;
  height: 15px;
}

.bar-fill {
  display: block;
  height: 100%;
  background: var(--accent, #2f4b7c);
  border-radius: 3px;
}

.bar-value {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
}

.bar-share {
  text-align: right;
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  color: var(--muted);
}

h2.map-title {
  margin: 18px 0 10px;
}

details.domain > nav.pills {
  padding: 12px 16px 16px;
}

details.domain > ul.facts {
  padding: 12px 16px 16px;
}

details.domain > h3.chart-title,
details.domain > div.chart {
  margin-left: 16px;
  margin-right: 16px;
}

details.domain > ul.cards {
  padding: 10px 16px 16px;
}

.cards {
  display: grid;
  gap: 2px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.cards a {
  display: block;
  padding: 12px 14px;
  text-decoration: none;
  color: inherit;
  border: 1px solid var(--rule);
  border-radius: 6px;
}

.cards a:hover {
  background: var(--panel);
}

.cards .name {
  font-weight: 600;
}

.cards .sub {
  font-size: 13.5px;
  color: var(--muted);
}

/* A table wider than the screen has to be reachable. Without this the hospital register
   measures 842px inside a 334px box with overflow visible, so on a phone the accreditation,
   the score and the expiry date are not merely cramped - they are clipped away, with nothing
   the reader can do about it. */
.scroll-x {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.scroll-x > table.data {
  min-width: 34em;
}

table.data {
  border-collapse: collapse;
  font-size: 14px;
  width: 100%;
}

table.data th,
table.data td {
  text-align: right;
  padding: 5px 10px;
  border-bottom: 1px solid var(--rule);
}

table.data th:first-child,
table.data td:first-child {
  text-align: left;
}

details.table summary {
  cursor: pointer;
  font-size: 14px;
  color: var(--muted);
  margin-bottom: 10px;
}

code.cite {
  display: block;
  background: var(--panel);
  border: 1px solid var(--rule);
  border-radius: 6px;
  padding: 10px 12px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
}

footer.site {
  border-top: 1px solid var(--rule);
  margin-top: 56px;
  padding-top: 18px;
  font-size: 13.5px;
  color: var(--muted);
}

.chart-controls {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 16px;
  margin-top: 10px;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.legend button,
.legend .legend-name {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font: inherit;
  font-size: 13.5px;
  line-height: 1.2;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--ground);
  color: var(--ink);
}

.legend button {
  cursor: pointer;
}

.legend button:hover {
  background: var(--panel);
}

.legend button.off {
  color: var(--muted);
  text-decoration: line-through;
}

.legend .swatch {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid;
}

.chart-hint {
  font-size: 12.5px;
  color: var(--muted);
}

.chart-hint .reset {
  font: inherit;
  padding: 4px 9px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--ground);
  color: var(--accent);
  cursor: pointer;
}

/* Chart */
.chart-figure {
  margin: 0;
}

.chart-scroll {
  overflow-x: auto;
}

.chart-svg {
  display: block;
  touch-action: pan-y;
  user-select: none;
  cursor: crosshair;
}

.chart-grid {
  stroke: var(--rule);
  stroke-width: 1;
}

.chart-tick {
  font-size: 11px;
  fill: var(--muted);
}

.chart-series-label {
  font-size: 11.5px;
}

.chart-selection {
  fill: var(--accent);
  opacity: 0.12;
}

.chart-crosshair {
  stroke: var(--muted);
  stroke-width: 1;
  stroke-dasharray: 3 3;
}

.chart-tooltip-box {
  fill: var(--ground);
  stroke: var(--rule);
  filter: drop-shadow(0 2px 6px rgb(22 32 43 / 0.12));
}

.chart-tooltip-title {
  font-size: 12px;
  font-weight: 650;
  fill: var(--ink);
}

.chart-tooltip-row {
  font-size: 11.5px;
  fill: var(--muted);
}

.chart-tooltip-value {
  font-size: 11.5px;
  font-weight: 600;
  fill: var(--ink);
}

/* County map */
.map-figure {
  margin: 0;
}

.map-head {
  margin-bottom: 8px;
}

.map-period {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--muted);
}

.map-period input[type="range"] {
  width: 220px;
  accent-color: var(--accent);
}

.map-period strong {
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

.map-canvas {
  overflow-x: auto;
}

.map-svg {
  display: block;
  width: 100%;
  max-width: 760px;
  height: auto;
}

.county,
.county-dot {
  stroke: var(--ground);
  stroke-width: 0.8;
  cursor: pointer;
}

.county-dot {
  stroke: #16202b;
  stroke-width: 1.4;
}

.county.hot,
.county-dot.hot {
  stroke: #16202b;
  stroke-width: 1.8;
}

.map-tooltip-box {
  fill: var(--ground);
  stroke: var(--rule);
  filter: drop-shadow(0 2px 6px rgb(22 32 43 / 0.14));
}

.map-tooltip-title {
  font-size: 12.5px;
  font-weight: 650;
  fill: var(--ink);
}

.map-tooltip-value {
  font-size: 11.5px;
  fill: var(--muted);
}

.map-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 14px;
  margin-top: 10px;
  font-size: 12px;
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.swatch-box {
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.swatch-box .swatch {
  width: 14px;
  height: 10px;
  border-radius: 2px;
  border: 1px solid rgb(22 32 43 / 0.12);
}

/* County pages */
nav.sections {
  margin-right: auto;
  padding-left: 22px;
}

nav.sections {
  display: flex;
  gap: 16px;
}

nav.sections a {
  font-size: 14.5px;
  text-decoration: none;
}

.county-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.county-grid a {
  display: flex;
  align-items: baseline;
  gap: 8px;
  padding: 9px 12px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}

.county-grid a:hover {
  background: var(--panel);
}

.county-grid .abbr {
  font-size: 11.5px;
  font-weight: 650;
  color: var(--muted);
  min-width: 20px;
}

.facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
  gap: 2px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.facts a {
  display: block;
  padding: 12px 14px;
  border: 1px solid var(--rule);
  border-radius: 6px;
  text-decoration: none;
  color: inherit;
}

.facts a:hover {
  background: var(--panel);
}

/* The unit sits with the figure, small and quiet. A headline number with no unit is the one
   thing a reader cannot resolve by looking harder at the page. */
.fact-unit {
  font-size: 13px;
  font-weight: 400;
  color: var(--muted);
  margin-left: 5px;
  white-space: nowrap;
}

/* Direction of travel into the latest period. Colour says which way, never whether it is good
   news - deaths rising and wages rising get the same green arrow. */
.trend {
  font-size: 0.62em;
  margin-left: 6px;
  vertical-align: 0.18em;
  font-weight: 400;
}

.trend.up {
  color: #1a7f45;
}

.trend.down {
  color: #b3261e;
}

.trend.flat {
  color: #1c63c4;
}

.facts-theme {
  font-size: 14px;
  font-weight: 600;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 26px 0 8px;
}

/* The latest national figure on a front-page card, kept beside the name rather than under it. */
.cards .card-value {
  float: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  margin-left: 12px;
}

.fact-name {
  display: block;
  font-size: 13px;
  color: var(--muted);
}

.fact-value {
  display: block;
  font-size: 23px;
  font-weight: 650;
  line-height: 1.25;
  font-variant-numeric: tabular-nums;
}

.fact-context {
  display: block;
  font-size: 12.5px;
  color: var(--muted);
}

h3.chart-title {
  font-size: 15px;
  margin: 22px 0 8px;
}

h3.chart-title a {
  text-decoration: none;
  color: inherit;
}

h3.chart-title a:hover {
  text-decoration: underline;
}

.map-svg a { cursor: pointer; }
.map-svg a:focus-visible .county,
.map-svg a:focus-visible .county-dot { stroke: #16202b; stroke-width: 2.2; outline: none; }

/* View toggle and tile grid */
.map-views {
  display: inline-flex;
  gap: 2px;
  margin-left: 14px;
}

.map-views button {
  font: inherit;
  font-size: 13px;
  padding: 3px 11px;
  border: 1px solid var(--rule);
  background: var(--ground);
  color: var(--muted);
  cursor: pointer;
}

.map-views button:first-child { border-radius: 999px 0 0 999px; }
.map-views button:last-child { border-radius: 0 999px 999px 0; }

.map-views button.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.tile-label {
  font-size: 13px;
  font-weight: 600;
}

nav.pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin: 0 0 18px;
}

nav.pills a {
  font-size: 13.5px;
  padding: 5px 12px;
  border: 1px solid var(--rule);
  border-radius: 999px;
  text-decoration: none;
  color: var(--ink);
}

nav.pills a:hover { background: var(--panel); }

nav.pills a.on {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

/* Search */
.search {
  position: relative;
  margin: 0 0 30px;
}

.search input {
  width: 100%;
  font: inherit;
  font-size: 16px;
  padding: 11px 14px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--ground);
  color: var(--ink);
}

.search input:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
}

.search-results {
  list-style: none;
  margin: 4px 0 0;
  padding: 4px;
  border: 1px solid var(--rule);
  border-radius: 8px;
  background: var(--ground);
  box-shadow: 0 6px 18px rgb(22 32 43 / 0.08);
}

.search-results a {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: baseline;
  padding: 8px 10px;
  border-radius: 5px;
  text-decoration: none;
  color: inherit;
}

.search-results a:hover {
  background: var(--panel);
}

.hit-kind {
  font-size: 12px;
  color: var(--muted);
}

.search-results .no-hit {
  padding: 8px 10px;
  font-size: 14px;
  color: var(--muted);
}

ul.updates {
  display: block;
  list-style: none;
  padding: 0;
}

ul.updates li {
  padding: 5px 0;
  border-bottom: 1px solid var(--rule);
}

ul.updates strong {
  display: inline-block;
  min-width: 100px;
  color: var(--ink);
  font-variant-numeric: tabular-nums;
}

/* Embedded view */
main.embed {
  max-width: 820px;
  margin: 0 auto;
  padding: 12px 14px 8px;
}

.embed-title {
  font-size: 17px;
  margin: 0 0 10px;
}

.embed-title a {
  text-decoration: none;
  color: var(--ink);
}

.embed-title a:hover {
  text-decoration: underline;
}

.embed-credit {
  margin: 8px 0 0;
  font-size: 12px;
  color: var(--muted);
}

footer.site .wrap {
  padding-block: 0 28px;
}

footer.site p {
  margin: 4px 0;
}

/* The hospital register. Names run long and the columns beside them are short, so the name takes
   whatever width is left and the table scrolls sideways on a phone rather than wrapping to shreds. */
table.hospitals {
  display: block;
  overflow-x: auto;
  margin-bottom: 28px;
}

table.hospitals th,
table.hospitals td {
  white-space: nowrap;
  vertical-align: top;
}

table.hospitals td:first-child {
  white-space: normal;
  min-width: 260px;
}

table.hospitals th,
table.hospitals td {
  text-align: left;
}

table.hospitals th.num,
table.hospitals td.num {
  text-align: right;
}

/* Event markers. Deliberately quiet: the line is there to be noticed when you are looking for it,
   not to compete with the data. The number sends the reader to the note under the chart. */
.chart-event {
  stroke: var(--rule);
  stroke-width: 1;
  stroke-dasharray: 2 4;
}

.chart-event-dot {
  fill: var(--ground);
  stroke: var(--muted);
  stroke-width: 1;
}

.chart-event-group:hover .chart-event-dot {
  fill: var(--muted);
}

.chart-event-mark {
  font-size: 9px;
  fill: var(--muted);
  font-weight: 600;
}

.chart-event-group:hover .chart-event-mark {
  fill: var(--ground);
}

/* Context: something that happened at the time but is not about this series. A bare line, no dot
   and no number, so the eye reads it as background rather than as one more thing to look up. */
.chart-event-context {
  stroke: var(--rule);
  stroke-width: 1;
  opacity: 0.45;
}

.chart-context-group:hover .chart-event-context {
  stroke: var(--muted);
  opacity: 1;
}

details.context {
  margin-top: 14px;
  border-top: 1px solid var(--rule);
  padding-top: 10px;
}

details.context > summary {
  cursor: pointer;
  color: var(--muted);
  font-size: 0.85rem;
}

details.context ul.events {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
}

/* The notes under a chart: numbered to match the markers, dense enough to scan. */
ol.events {
  list-style: none;
  padding: 0;
  margin: 10px 0 0;
  font-size: 14px;
  color: var(--muted);
}

ol.events li {
  display: grid;
  grid-template-columns: 22px 1fr;
  gap: 8px;
  margin-bottom: 6px;
  line-height: 1.45;
}

ol.events .mark {
  text-align: right;
  font-weight: 600;
}

ol.events .when {
  color: var(--ink);
  font-weight: 600;
}

/* "In short": the indicator explained for someone meeting it for the first time. */
.explainer {
  border-left: 3px solid var(--rule);
  padding: 2px 0 2px 14px;
  margin: 18px 0;
}

.explainer h2 {
  font-size: 13px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  margin: 0 0 6px;
}

.explainer p {
  margin: 0;
  max-width: 62ch;
}

/* The glossary: term and meaning, read top to bottom rather than scanned. */
dl.glossary {
  margin: 24px 0 0;
  max-width: 62ch;
}

dl.glossary dt {
  font-weight: 600;
  margin-top: 22px;
}

dl.glossary dd {
  margin: 4px 0 0;
  color: var(--muted);
  line-height: 1.55;
}
