/* ===========================================================================
   THE GROUND THE APP SITS ON - colour, navigation, layout, tables
   ===========================================================================

   The CEMA blue is the brand, so it does the load bearing: the masthead is a
   solid plate of it and the opening band runs from it into the deep navy. Once
   past the opening, everything is white, because the maps and the bars are the
   point of the page and they need the quietest ground there is.

   Orange is never decoration. It marks one thing at a time - the tab you are
   on, the section you are reading, the value being pointed at.

   There is deliberately no grey text. Secondary copy is a deep slate blue,
   which reads as quieter without reading as switched off. Grey survives only
   in hairlines.
   =========================================================================== */

:root {
  /* ---- CEMA primaries ---- */
  --blue: #AA6340;
  --blue-050: #FBF6F2;
  --blue-100: #F3E3D9;
  --blue-200: #E3C6B4;
  --blue-300: #CB9877;
  --blue-600: #8A4F33;
  --blue-800: #6E402A;

  --orange: #E7A83E;
  --orange-050: #FDF7EC;
  --orange-100: #F3D9A6;
  --orange-300: #EFC172;
  --orange-600: #B87F22;

  /* ---- the rest of the palette, for chart series only ---- */
  --navy: #4A2A1C;
  --navy-900: #2A170E;
  --teal: #6B7A4B;
  --yellow: #D9B44A;
  --green: #7A8450;
  --purple: #7A4A5C;
  --pink: #A6392C;

  /* ---- ink. no greys. ---- */
  --ink: #221C13;
  --ink-soft: #635A46;
  --ink-faint: #8A7F66;

  /* ---- ground and lines ---- */
  --paper: #FFFFFF;
  --paper-tint: #FAF6EE;
  --rule: #E1D8BD;
  --rule-strong: #CDBF9A;

  /* ---- measure and rhythm ---- */
  --shell: 1980px;
  --gutter: clamp(16px, 2.2vw, 40px);
  --rail-width: 250px;
  --header-h: 112px;
  /* the tab bar wraps, so the offset an anchor has to clear is measured at
     runtime by script.js and written back here */
  --pinned: 176px;
  --stack: clamp(76px, 6vh, 108px);

  --radius: 14px;
  --radius-sm: 9px;
  --shadow-sm: 0 2px 10px rgba(12, 17, 22, 0.05);
  --shadow-md: 0 16px 38px rgba(12, 17, 22, 0.10);
}

* { box-sizing: border-box; }
html { scroll-behavior: smooth; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  /* clip rather than hidden: hidden makes the body a scroll container, and a
     sticky element nested inside one stops sticking */
  overflow-x: clip;
}

/* A hidden navset panel that still took up room was why the page scrolled far
   past the end of its content. Belt and braces: not displayed, and no height
   to contribute even if something else tries to show it. */
.tab-content > .tab-pane:not(.active) {
  display: none !important;
  height: 0 !important;
  overflow: hidden !important;
}

/* A hidden navset still prints its own list of panes. bslib hides it through
   Bootstrap, but there are 62 of these across the app and if that rule ever
   fails to reach them the page gains a column of empty bullets and several
   hundred pixels of height that belong to nothing. */
.nav.nav-hidden, ul.nav-hidden { display: none !important; }

[id] { scroll-margin-top: var(--pinned); }

p { margin: 0 0 1em; }
a { color: var(--blue-600); text-decoration-thickness: 1px; text-underline-offset: 3px; }
a:hover { color: var(--orange-600); }

.eyebrow { color: var(--blue-600); display: block; margin-bottom: 10px; }
/* No artificial measure on any of the running text. A cap of 64 characters put
   a break in the middle of a one-line caption while there was half a screen of
   white space beside it; text now wraps when it actually runs out of room. */
.lead { color: var(--ink-soft); max-width: none; }
.text-small { color: var(--ink-soft); }
.text-tiny { color: var(--ink-faint); }

.shell { max-width: var(--shell); margin: 0 auto; padding: 0 var(--gutter); }

/* ---------------------------------------------------------------------------
   THE MASTHEAD - a solid plate of the brand blue, pinned
   ------------------------------------------------------------------------- */

.app-header {
  position: sticky;
  top: 0;
  z-index: 60;
  height: var(--header-h);
  background: var(--blue);
  border-bottom: 1px solid rgba(255, 255, 255, 0.25);
}

.app-header__inner {
  max-width: var(--shell);
  margin: 0 auto;
  padding: 0 var(--gutter);
  height: 100%;
  display: flex;
  align-items: center;
  gap: 18px;
}

/* The two official marks were drawn for white paper, so each keeps a white
   plate of its own rather than being knocked out onto the blue. */
.brand { display: flex; align-items: center; gap: 13px; min-width: 0; }
.brand-plate {
  background: #fff;
  border-radius: 9px;
  padding: 7px 13px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.12);
}
/* The KNBS mark is the survey's own and the masthead is its header, so it is
   given the room to be read rather than being tucked in as a favicon. The
   masthead's height follows it; everything pinned below reads that height from
   the same variable, so nothing has to be adjusted twice. */
.brand-mark { height: 72px; width: auto; display: block; }
.brand-mark--small { height: 60px; }

.brand-name {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: 23px;
  letter-spacing: var(--tracking-tight);
  line-height: 1.08;
  color: #fff;
  white-space: nowrap;
}
/* The full survey name is four times the length of the old one, so it runs on
   one line beside the mark rather than stacking a subtitle under it, and it
   gives way on a narrow screen instead of forcing the masthead wide. */
.brand-name--long {
  font-size: clamp(17px, 1.5vw, 25px);
  line-height: 1.15;
  white-space: normal;
}
.brand-name--long .brand-name__years {
  display: inline;
  font-family: var(--font-display);
  font-size: inherit;
  font-weight: inherit;
  letter-spacing: inherit;
  text-transform: none;
  color: #FFDCBB;
}

.brand-name span {
  display: block;
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-medium);
  letter-spacing: 0.05em;
  color: rgba(255, 255, 255, 0.85);
}

.header-spacer { flex: 1 1 auto; }

/* The link to the final report. On launch day the report is what most readers
   came for, so the link is a solid button wherever it appears, never an
   outline: white on the brown masthead, gold in the opening band, each the
   strongest contrast its background allows. */
.report-link {
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-weight: var(--weight-bold);
  text-decoration: none;
  white-space: nowrap;
  transition: background 0.15s ease, color 0.15s ease, transform 0.15s ease;
}
.report-link__icon { display: inline-flex; }
.report-link__icon svg { width: 1.35em; height: 1.35em; stroke-width: 2; }
.report-link__text { display: inline-flex; flex-direction: column; line-height: 1.2; }
.report-link__kind {
  font-weight: var(--weight-bold);
  letter-spacing: 0.06em;
  border-radius: 6px;
  padding: 3px 8px;
}

.report-link--header {
  background: #FFFFFF;
  color: var(--blue-800);
  border-radius: 999px;
  padding: 12px 18px 12px 16px;
  box-shadow: 0 3px 12px rgba(0, 0, 0, 0.22);
}
.report-link--header .report-link__kind { background: var(--blue); color: #FFFFFF; }
.report-link--header:hover,
.report-link--header:focus-visible { background: var(--orange); color: var(--navy-900); transform: translateY(-1px); }
.report-link--header:hover .report-link__kind { background: var(--navy-900); color: #FFFFFF; }

.hero-report { margin: 0 0 28px; }
.report-link--hero {
  background: var(--orange);
  color: var(--navy-900);
  border-radius: var(--radius);
  padding: 18px 26px 18px 22px;
  gap: 16px;
  white-space: normal;
  box-shadow: 0 6px 22px rgba(0, 0, 0, 0.22);
}
.report-link--hero .report-link__sub { font-weight: var(--weight-medium); color: var(--navy-900); }
.report-link--hero .report-link__kind { background: var(--navy-900); color: #FFFFFF; }
.report-link--hero:hover,
.report-link--hero:focus-visible { background: #FFFFFF; color: var(--blue-800); transform: translateY(-1px); }
.report-link--hero:hover .report-link__sub { color: var(--blue-800); }

.report-link--footer { color: #FFFFFF; text-decoration: underline; text-underline-offset: 3px; }
.report-link--footer .report-link__kind { background: #FFFFFF; color: var(--cema-orange); }

/* ---------------------------------------------------------------------------
   THE CHAPTER BAR, pinned under the masthead
   ---------------------------------------------------------------------------
   Fourteen tabs will not fit across a laptop. They wrap onto a second line
   rather than scrolling sideways, because a tab that has scrolled off the end
   is a chapter the reader never learns exists.
   ------------------------------------------------------------------------- */

/* The tabs sit on the same blue as the masthead above them and the opening
   band below, so the page reads as one blue block and then white, rather than
   as blue, white, blue, white down the screen. */
.chapter-bar {
  position: sticky;
  top: var(--header-h);
  z-index: 55;
  background: var(--blue);
  border-bottom: 5px solid var(--orange);
}

.chapter-bar__inner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 3px 5px;
  padding-top: 9px;
  padding-bottom: 9px;
}

.chapter-bar__label {
  font-family: var(--font-body);
  font-size: 12px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.72);
  padding: 0 14px 0 2px;
  margin-right: 2px;
  border-right: 1px solid rgba(255, 255, 255, 0.3);
  align-self: stretch;
  display: flex;
  align-items: center;
}

/* the one tab that is not a chapter is set apart from the numbered run */
.chapter-tab--aside {
  margin-left: 10px;
  padding-left: 21px;
  border-left: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.chapter-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  padding: 10px 21px 12px;
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  border-radius: var(--radius-sm);
  transition: color 140ms ease, background 140ms ease;
}
.chapter-tab:hover { color: #fff; background: rgba(255, 255, 255, 0.18); }

.chapter-tab::after {
  content: "";
  position: absolute;
  left: 21px; right: 21px; bottom: 3px;
  height: 3px;
  border-radius: 3px;
  background: transparent;
  transition: background 160ms ease;
}
/* the tab you are on is the one piece of white in the blue block */
.chapter-tab.is-active {
  color: var(--ink);
  font-weight: var(--weight-bold);
  background: var(--paper);
  box-shadow: 0 2px 8px rgba(2, 15, 29, 0.18);
}
.chapter-tab.is-active::after { background: var(--orange); }

.chapter-tab__no {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-semibold);
  color: rgba(255, 255, 255, 0.72);
  margin-right: 8px;
  font-variant-numeric: tabular-nums;
}
.chapter-tab.is-active .chapter-tab__no { color: var(--orange-600); }

/* ---------------------------------------------------------------------------
   THE OPENING BAND
   ---------------------------------------------------------------------------
   The one part of the app that is not on white. It carries the title, the one
   paragraph that says what this is, the way in, and the cover of the report
   itself, which is a better picture of the survey than any chart could be.
   ------------------------------------------------------------------------- */

/* The opening band is a solid plate of the brand blue, as tall as the report
   cover standing beside it. Solid rather than graded: the colour is the mark,
   and a gradient reads as a decoration of it. */
/* No overflow clipping here. The search results hang out of the bottom of this
   band, and hiding the overflow cut the list down to the one row that happened
   to fit inside the brown. The wash below is kept inside the band by its own
   geometry instead. */
.hero {
  background: var(--blue);
  color: #fff;
  position: relative;
  margin-top: -1px;
}
/* The orange rule closes the whole blue block - masthead, band and tabs - so it
   sits under the tabs rather than between the band and them. */
/* a wash of white at the top right, so a plate this large is not perfectly
   flat behind the cover */
.hero::before {
  content: "";
  position: absolute;
  inset: 0 0 0 auto;
  width: 54%;
  background: radial-gradient(120% 140% at 82% 12%, rgba(255, 255, 255, 0.16), transparent 70%);
  pointer-events: none;
}

/* One column, and no minimum height. The band was two columns tall enough to
   hold the report cover beside the words; with the cover gone that left a title,
   a search box and two thirds of a screen of empty blue. It is now as tall as
   what is in it. */
.hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 0;
  align-items: start;
  position: relative;
  z-index: 1;
  min-height: 0;
  padding: clamp(20px, 2.2vh, 30px) 0 clamp(22px, 2.4vh, 32px);
}
.hero-copy { min-width: 0; }

.hero .eyebrow { color: rgba(255, 255, 255, 0.88); }
/* The headline had a column and a half to itself and was breaking at a third
   of it, leaving a field of blue between the words and the cover. */
.page-title { margin: 0 0 14px; max-width: none; color: #fff; }
.page-title em { font-style: normal; color: #FFDCBB; }
.hero-lead {
  color: rgba(255, 255, 255, 0.94);
  max-width: 72ch;
  font-family: var(--font-display);
  font-size: var(--size-lead);
  line-height: 1.5;
  margin-bottom: 32px;
}

/* the cover of the report, standing as tall as the plate it sits on */
.hero-cover { min-width: 0; display: flex; justify-content: center; align-items: center; }
.hero-cover img {
  width: 100%;
  max-width: 460px;
  height: auto;
  display: block;
  border-radius: 4px;
  box-shadow: 0 30px 70px rgba(2, 15, 29, 0.42), 0 0 0 1px rgba(255, 255, 255, 0.3);
  transform: rotate(-2.2deg);
  transition: transform 420ms ease;
}
.hero-cover img:hover { transform: rotate(0deg) scale(1.02); }

/* ---- the way in ---- */

.hero-search { max-width: 860px; }
.hero-search__label {
  display: block;
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  color: rgba(255, 255, 255, 0.92);
  margin-bottom: 10px;
}
.hero-search .shiny-input-container { width: 100%; margin: 0; }
.hero-search .selectize-input {
  border: 0 !important;
  border-radius: 999px !important;
  padding: 15px 22px 15px 52px !important;
  background: #fff !important;
  box-shadow: 0 10px 30px rgba(2, 15, 29, 0.28) !important;
  font-size: var(--size-input) !important;
  color: var(--ink) !important;
  min-height: 0 !important;
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%231A88B8' stroke-width='2.1' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E") !important;
  background-repeat: no-repeat !important;
  background-position: 20px center !important;
  background-size: 20px 20px !important;
}
.hero-search .selectize-input.focus { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.45) !important; }
.hero-search .selectize-input input { font-size: var(--size-input) !important; }

.hero-hint {
  margin: 12px 0 0;
  font-size: var(--size-tiny);
  color: rgba(255, 255, 255, 0.78);
}
.hero-hint b { color: #fff; font-weight: var(--weight-semibold); }

/* the dropdown, shared by the hero box and any other search in the app */
.selectize-dropdown {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius);
  box-shadow: var(--shadow-md);
  font-size: var(--size-small);
  overflow: hidden;
  color: var(--ink);
}
.selectize-dropdown .optgroup-header {
  font-size: 12px; font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--blue-600); padding: 12px 18px 5px; background: var(--paper);
}
.selectize-dropdown .option { padding: 10px 18px; color: var(--ink); }
.selectize-dropdown .active { background: var(--blue-050); color: var(--ink); }
/* nothing matched: say so in words rather than showing an empty white box */
.selectize-dropdown .no-results {
  padding: 16px 18px;
  color: var(--ink-soft);
  font-size: var(--size-small);
  line-height: 1.5;
}
.selectize-dropdown .no-results b { color: var(--ink); }
.selectize-dropdown .no-results span { display: block; color: var(--ink-faint); font-size: var(--size-tiny); margin-top: 5px; }

/* ---------------------------------------------------------------------------
   KENYA AT A GLANCE
   ------------------------------------------------------------------------- */

.section-head { padding: clamp(46px, 6vh, 84px) 0 clamp(22px, 3vh, 34px); }
.section-head h2 { margin: 0 0 12px; }

.highlight-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(272px, 1fr));
  gap: clamp(12px, 1.1vw, 18px);
}

.hl {
  appearance: none;
  text-align: left;
  cursor: pointer;
  display: flex;
  gap: 16px;
  align-items: flex-start;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  padding: 20px 20px 18px;
  transition: transform 170ms ease, box-shadow 170ms ease, border-color 170ms ease;
}
.hl:hover { transform: translateY(-3px); border-color: var(--blue-300); box-shadow: var(--shadow-md); }

.hl__icon { width: 32px; height: 32px; flex: 0 0 32px; color: var(--blue); margin-top: 5px; }
.hl__icon svg { width: 100%; height: 100%; display: block; }
.hl:hover .hl__icon { color: var(--orange); }

.hl__body { min-width: 0; }
.hl__value {
  font-family: var(--font-display);
  font-weight: var(--weight-bold);
  font-size: clamp(32px, 2.7vw, 44px);
  line-height: 1.05;
  letter-spacing: var(--tracking-tight);
  color: var(--ink);
  margin: 0 0 4px;
  font-variant-numeric: tabular-nums lining-nums;
}
.hl__value small {
  font-size: 0.42em; font-family: var(--font-body);
  font-weight: var(--weight-semibold); color: var(--ink-faint); margin-left: 3px;
}
.hl__label { display: block; font-weight: var(--weight-semibold); color: var(--ink); font-size: var(--size-small); line-height: 1.3; }
.hl__note { display: block; color: var(--ink-faint); font-size: var(--size-tiny); margin-bottom: 9px; }

.hl__move { display: inline-flex; align-items: center; gap: 6px; font-size: var(--size-tiny); font-weight: var(--weight-medium); color: var(--ink-faint); line-height: 1.35; }
.hl__arrow { font-size: 15px; font-weight: var(--weight-bold); }
/* whether a move is welcome depends on the indicator, which is why the
   direction is named in the registry rather than guessed from the sign */
.hl__move--good { color: var(--green); }
.hl__move--bad { color: var(--orange-600); }
.hl__move--flat { color: var(--ink-faint); }

/* ---------------------------------------------------------------------------
   THE CHAPTER CARDS
   ------------------------------------------------------------------------- */

.chapter-index {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(318px, 1fr));
  gap: clamp(14px, 1.2vw, 22px);
}

.chapter-entry {
  position: relative;
  display: flex;
  flex-direction: column;
  width: 100%;
  text-align: left;
  appearance: none;
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  background: var(--paper);
  padding: 28px 26px 20px;
  cursor: pointer;
  overflow: hidden;
  transition: transform 180ms ease, box-shadow 180ms ease, border-color 180ms ease;
}
.chapter-entry::before {
  content: "";
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  background: var(--blue-100);
  transform: scaleX(0.16);
  transform-origin: left;
  transition: transform 280ms ease, background 200ms ease;
}
.chapter-entry:hover { transform: translateY(-4px); border-color: var(--blue-300); box-shadow: var(--shadow-md); }
.chapter-entry:hover::before { transform: scaleX(1); background: var(--orange); }

.chapter-entry__no {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: var(--weight-bold);
  color: var(--orange);
  background: var(--orange-050);
  border-radius: 50%;
  width: 36px; height: 36px;
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 15px;
  font-variant-numeric: tabular-nums;
  transition: background 200ms ease, color 200ms ease;
}
.chapter-entry:hover .chapter-entry__no { background: var(--orange); color: #fff; }

.chapter-entry__name {
  font-family: var(--font-display);
  font-size: 23px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-tight);
  line-height: 1.18;
  color: var(--ink);
  display: block;
  margin-bottom: 9px;
}
.chapter-entry__blurb { color: var(--ink-soft); font-size: var(--size-small); line-height: 1.5; margin: 0 0 18px; flex: 1 1 auto; }
.chapter-entry__go {
  display: flex; justify-content: space-between; align-items: center;
  padding-top: 13px; border-top: 1px solid var(--rule);
  color: var(--ink-faint); font-size: var(--size-tiny); font-weight: var(--weight-semibold);
}
.chapter-entry__arrow { font-size: 19px; color: var(--blue-600); transition: transform 200ms ease, color 200ms ease; }
.chapter-entry:hover .chapter-entry__arrow { transform: translateX(5px); color: var(--orange); }

.reading-note { padding: clamp(36px, 4.5vh, 64px) 0 clamp(28px, 3.5vh, 46px); }
.reading-note p { max-width: none; margin: 0; }

/* ---------------------------------------------------------------------------
   A CHAPTER
   ------------------------------------------------------------------------- */

/* padding-block, not the shorthand: .shell sets the side gutter and a shorthand
   here silently zeroed it, which is why the chapter title sat flush against the
   left edge of the window while everything under it was inset. */
/* Tightened. The chapter opened with two thirds of a screen of title and white
   space, so the first chart was below the fold on a laptop. */
.chapter-head { padding-block: clamp(22px, 2.6vh, 34px) clamp(8px, 1vh, 14px); }
.chapter-title { margin: 0 0 10px; max-width: none; }

.chapter-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: clamp(26px, 2.6vw, 54px);
  align-items: start;
  padding-bottom: clamp(56px, 7vh, 108px);
}

/* ---- the rail ---- */

.rail {
  position: sticky;
  top: calc(var(--pinned) - 24px);
  max-height: calc(100vh - var(--pinned) - 20px);
  overflow-y: auto;
  padding-right: 8px;
  scrollbar-width: thin;
}

/* filtering one chapter, which is a different job from searching all thirteen */
.rail-filter { position: relative; margin-bottom: 16px; }
.rail-filter input {
  width: 100%;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 9px 14px 9px 36px;
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  color: var(--ink);
  background: var(--paper);
  background-image: url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%234B7188' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 13px center;
  background-size: 15px 15px;
}
.rail-filter input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
/* Shown only when a filter has actually excluded everything. It used to be in
   the page at all times, announcing that nothing matched before anything had
   been typed. */
.rail-empty {
  display: none;
  padding: 14px 12px;
  color: var(--ink-soft);
  font-size: var(--size-tiny);
  line-height: 1.5;
  background: var(--blue-050);
  border-radius: var(--radius-sm);
}
.rail.is-empty .rail-empty { display: block; }
/* A theme with nothing left in it steps aside whole, heading and all, which is
   one class rather than two elements being juggled on every keystroke. */
.rail-group.is-hidden { display: none; }

/* A theme is a chapter's section heading and the one you are in has to be
   unmistakable, so it takes a filled plate rather than a change of colour. */
.rail-theme {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  letter-spacing: 0;
  color: var(--ink-soft);
  padding: 9px 12px;
  margin: 12px 0 4px;
  line-height: 1.3;
  display: block;
  width: 100%;
  text-align: left;
  border: 0;
  background: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: color 140ms ease, background 140ms ease;
}
.rail-theme:first-child { margin-top: 0; }
.rail-theme:hover { color: var(--ink); background: var(--blue-050); }
.rail-theme.is-active { color: #fff; background: var(--blue-600); }

.rail-links { border-left: 2px solid var(--rule); margin-left: 12px; }
.rail-links:not(.is-open) { display: none; }

.rail-link {
  display: block;
  padding: 8px 10px 8px 14px;
  margin-left: -2px;
  border-left: 2px solid transparent;
  color: var(--ink-soft);
  text-decoration: none;
  line-height: 1.35;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: color 130ms ease, border-color 130ms ease, background 130ms ease;
}
.rail-link:hover { color: var(--ink); background: var(--blue-050); }
/* the section being read: orange spine, bold, and a tinted plate */
.rail-link.is-active {
  color: var(--orange-600);
  font-weight: var(--weight-semibold);
  border-left-color: var(--orange);
  background: var(--orange-050);
}
.rail-link.is-hidden { display: none; }
/* one pathological title - table 2.7 arrived with a whole paragraph where its
   name should be - must not be allowed to fill the rail */
.rail-link {
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.rail-link.is-hidden { display: none; }

/* ---- the stream ---- */

.area-stream { min-width: 0; }
.area-stream > .area:first-child { padding-top: 2px; }
.area { padding-bottom: var(--stack); scroll-margin-top: var(--pinned); }

.theme-open { padding: 4px 0 clamp(22px, 2.6vh, 34px); scroll-margin-top: var(--pinned); }
.theme-title { margin: 0; color: var(--ink); }
.theme-open .rule { height: 3px; width: 72px; background: var(--orange); border-radius: 3px; margin-bottom: 18px; display: block; }

.area__no {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--blue-600);
  display: block;
  margin-bottom: 8px;
}
.area-title { margin: 0 0 8px; max-width: none; }
.area__lead { color: var(--ink-soft); max-width: none; font-size: var(--size-small); line-height: 1.5; margin: 0 0 10px; }

/* Who the figures are about, said once above the row rather than four times
   inside it. */
.stats-note {
  color: var(--ink-soft);
  font-weight: var(--weight-medium);
  margin: 22px 0 0;
}
.stats-note + .area-stats { margin-top: 12px; }

/* Four figures, four tiles. They are the one place a card earns its keep, so
   they are given room, a tinted disc for the icon, a hairline of blue along
   the top and a quiet line at the foot that says which way the figure moved.
   The first tile in every set takes the orange, because one thing at a time. */
.area-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(232px, 1fr));
  gap: 18px;
  margin: 26px 0 32px;
}
.stat {
  position: relative;
  /* one or two figures should not be stretched across the page to fill a row
     built for four */
  max-width: 520px;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: 16px;
  padding: 24px 24px 22px;
  display: flex;
  align-items: stretch;
  gap: 16px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(12, 17, 22, 0.04);
  transition: box-shadow 0.18s ease, transform 0.18s ease, border-color 0.18s ease;
}
.stat::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 4px;
  background: var(--blue);
}
.stat--accent::before { background: var(--orange); }
.stat:hover {
  transform: translateY(-2px);
  border-color: var(--blue-200);
  box-shadow: 0 10px 24px rgba(13, 70, 94, 0.09);
}
.stat__icon {
  flex: 0 0 auto;
  align-self: flex-start;
  width: 46px;
  height: 46px;
  margin-top: 4px;
  border-radius: 14px;
  display: grid;
  place-items: center;
  color: var(--blue-600);
  background: var(--blue-050);
  border: 1px solid var(--blue-100);
}
.stat__icon svg { width: 23px; height: 23px; display: block; }
.stat--accent .stat__icon {
  color: var(--orange-600);
  background: var(--orange-050);
  border-color: var(--orange-100);
}
.stat__body { min-width: 0; flex: 1 1 auto; display: flex; flex-direction: column; gap: 4px; }
.stat-value {
  color: var(--ink);
  margin: 0;
  line-height: 1.05;
  letter-spacing: -0.015em;
}
.stat-value small {
  font-size: 0.42em;
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  color: var(--ink-faint);
  margin-left: 5px;
  letter-spacing: 0;
}
.stat-label { color: var(--ink-soft); font-weight: var(--weight-semibold); line-height: 1.35; margin-bottom: 10px; }
.stat-note {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  align-self: flex-start;
  margin-top: auto;
  padding: 5px 12px 5px 9px;
  border-radius: 999px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  color: var(--ink-faint);
  line-height: 1.25;
}
.stat-note__arrow { font-weight: var(--weight-bold); line-height: 1; }
.stat-note--up { background: var(--blue-050); border-color: var(--blue-100); color: var(--blue-800); }
.stat-note--down { background: var(--orange-050); border-color: var(--orange-100); color: var(--orange-600); }
.stat-note--flat, .stat-note--none { background: var(--paper-tint); border-color: var(--rule); color: var(--ink-soft); }

/* ---- the pickers ---- */

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px 26px;
  align-items: flex-end;
  padding: 16px 0 20px;
  border-top: 1px solid var(--rule);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 28px;
}
/* A picker is as wide as it needs to be. Stretching one select across the page
   makes a control that governs a single chart look like the page's own header,
   and the words inside it end up marooned at the far left. */
.controls .shiny-input-container {
  margin-bottom: 0;
  flex: 0 1 auto;
  width: auto;
  min-width: 240px;
  max-width: 440px;
}
.controls .shiny-input-container > .form-control,
.controls .shiny-input-container > .selectize-control { width: 100%; }
.controls .shiny-input-container > label {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
  margin-bottom: 6px;
  display: block;
  line-height: 1.3;
}
.controls .form-select, .controls .form-control, .controls select {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--ink);
  background-color: var(--paper);
  /* left to itself a select sizes to its longest option, and on a phone the
     longest indicator name is wider than the screen */
  width: 100% !important;
  max-width: 100%;
  text-overflow: ellipsis;
}
.controls .form-select:focus, .controls .form-control:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }

/* A map wants the whole width. A bar chart does not: a bar running thirteen
   hundred pixels for a value of ninety per cent is a thin line across the page,
   so bar charts stop short of it and sit left. */
.plot { min-width: 0; margin-bottom: clamp(26px, 3vh, 46px); }
.plot .highchart { width: 100% !important; }
.plot--bars { max-width: 1240px; }

/* ---------------------------------------------------------------------------
   TABLES, set the way the report sets them
   ------------------------------------------------------------------------- */

.table-block { margin-top: 10px; }
.table-block__head {
  display: flex; justify-content: space-between; align-items: center;
  gap: 18px; flex-wrap: wrap; padding-bottom: 12px;
}
.table-block__title {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  font-size: var(--size-small);
  color: var(--ink);
}
.table-block__tools { display: flex; gap: 11px; align-items: center; flex-wrap: wrap; }
.table-block__head .shiny-input-container { width: auto; margin: 0; }
.table-block__head .radio-inline, .table-block__head .form-check-inline { margin-right: 14px; }
.table-block__head .form-check-label, .table-block__head label {
  font-size: var(--size-tiny); color: var(--ink-soft); font-weight: var(--weight-medium);
}
.table-block__head .form-check-input:checked { background-color: var(--orange); border-color: var(--orange); }

.dl-btn {
  appearance: none;
  border: 1px solid var(--rule-strong);
  background: var(--paper);
  color: var(--ink-soft);
  border-radius: 999px;
  padding: 8px 17px;
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  text-decoration: none;
  transition: all 150ms ease;
  white-space: nowrap;
}
.dl-btn:hover { border-color: var(--orange); color: var(--orange-600); background: var(--orange-050); }

/* Sized to its own contents rather than stretched across the page: table 8.1
   has two columns and filling the full width with them reads as a mistake. A
   table wider than the column gets a scroll of its own instead. */
table.dataTable {
  border-collapse: collapse !important;
  width: auto !important;
  max-width: 100%;
}
.dataTables_wrapper { width: 100%; }
table.dataTable thead th {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  color: var(--ink);
  background: var(--paper);
  border-top: 2px solid var(--ink);
  border-bottom: 1px solid var(--ink);
  padding: 11px 14px;
  vertical-align: bottom;
}
table.dataTable tbody td { border: 0; border-bottom: 1px solid var(--rule); padding: 9px 14px; color: var(--ink); }
table.dataTable tbody tr:last-child td { border-bottom: 2px solid var(--ink); }
table.dataTable tbody tr:hover td { background: var(--blue-050); }
table.dataTable td.num, table.dataTable th.num { text-align: right; }
table.dataTable tbody tr.grouprow td {
  font-weight: var(--weight-semibold); font-style: italic;
  color: var(--blue-800); background: var(--blue-050);
}

/* The box sat hard against its label, stretched itself wide, and took the
   browser's own focus ring rather than the one the rest of the app uses. */
.dataTables_wrapper .dataTables_filter { float: none; text-align: right; margin: 0 0 14px; }
.dataTables_wrapper .dataTables_filter label {
  display: inline-flex; align-items: center; gap: 10px; margin: 0;
  font-weight: var(--weight-medium);
}
.dataTables_wrapper .dataTables_filter input {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 8px 16px;
  margin: 0;
  width: 280px;
  max-width: 100%;
  font-size: var(--size-tiny);
  color: var(--ink);
  background: var(--paper);
}
.dataTables_wrapper .dataTables_filter input:focus,
.dataTables_wrapper .dataTables_length select:focus {
  outline: 0;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px var(--blue-100);
}
.dataTables_wrapper .dataTables_length { margin-bottom: 6px; }
.dataTables_wrapper .dataTables_length select {
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 5px 9px;
  margin: 0 6px;
}
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_length,
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_paginate { color: var(--ink-soft) !important; font-size: var(--size-tiny); }
.dataTables_wrapper .paginate_button.current {
  background: var(--blue) !important; border-color: var(--blue) !important;
  color: #fff !important; border-radius: var(--radius-sm);
}

.footnotes { margin-top: 16px; padding-top: 13px; border-top: 1px solid var(--rule); }
.footnotes p { margin: 0 0 5px; color: var(--ink-faint); font-size: var(--size-tiny); line-height: 1.5; }

/* ---------------------------------------------------------------------------
   MOVING ON, AND THE FOOTER
   ------------------------------------------------------------------------- */

.next-strip {
  display: flex; justify-content: space-between; align-items: center;
  gap: 24px; flex-wrap: wrap;
  padding: 30px 0; border-top: 2px solid var(--ink); margin-top: 16px;
}
.next-strip__say { color: var(--ink-soft); max-width: 62ch; font-size: var(--size-small); }

.go-btn {
  appearance: none; border: 0; background: var(--ink); color: #fff;
  border-radius: 999px; padding: 14px 26px;
  font-family: var(--font-body); font-size: var(--size-button); font-weight: var(--weight-semibold);
  cursor: pointer; display: inline-flex; align-items: center; gap: 12px;
  transition: background 160ms ease, transform 160ms ease;
}
.go-btn:hover { background: var(--orange); transform: translateX(3px); }
.go-btn__arrow { font-size: 1.1em; }

/* The foot of the page is a band of CEMA orange rather than another sheet of
   paper, so the credit and the note about the survey read as one block and the
   page ends on something rather than trailing off. Everything inside it is set
   in white. */
.app-footer {
  border-top: none;
  /* The orange carried at nine tenths, so the band reads as a softer wash of
     the brand colour rather than a solid slab of it. */
  background: rgba(253, 117, 1, 0.9);
  color: #FFFFFF;
  padding: clamp(36px, 4.5vh, 58px) 0 38px;
}
.footer-grid {
  display: grid; grid-template-columns: minmax(230px, 1fr) minmax(0, 2fr);
  gap: clamp(28px, 3.5vw, 64px); align-items: start;
}
.footer-logo { height: 46px; width: auto; display: block; }
.footer-marks { display: flex; align-items: center; gap: 24px; margin-bottom: 16px; }
.app-footer p { color: #FFFFFF; }
.app-footer a { color: #FFFFFF; text-decoration: underline; }
/* The CEMA mark is drawn for a light ground, so it keeps one of its own. */
.footer-marks {
  background: #FFFFFF; border-radius: var(--radius-sm);
  padding: 10px 16px; width: max-content;
}
/* the way back to the top is a line in the footer rather than a disc floating
   over the page, which is one less thing sitting on top of the maps */
.footer-top {
  margin-top: 22px; padding-top: 16px; border-top: 1px solid rgba(255, 255, 255, 0.45);
  display: flex; justify-content: flex-end;
}
.footer-top button {
  appearance: none; border: 1px solid rgba(255, 255, 255, 0.7); background: transparent;
  color: #FFFFFF; border-radius: 999px; padding: 9px 20px;
  font-family: var(--font-body); font-size: var(--size-tiny); font-weight: var(--weight-semibold);
  cursor: pointer; transition: all 150ms ease;
}
.footer-top button:hover { background: #FFFFFF; color: var(--cema-orange); border-color: #FFFFFF; }

/* ---------------------------------------------------------------------------
   NARROWER SCREENS
   ------------------------------------------------------------------------- */

@media (max-width: 1320px) {
  :root { --rail-width: 224px; }
}

@media (max-width: 1120px) {
  .hero-grid { grid-template-columns: minmax(0, 1fr); }
  .hero-cover { display: none; }
  .hero-search { max-width: none; }
}

@media (max-width: 1040px) {
  .chapter-layout { grid-template-columns: minmax(0, 1fr); }
  .rail {
    position: static; max-height: none; overflow: visible;
    padding: 0 0 18px; margin-bottom: 26px;
    border-bottom: 1px solid var(--rule);
  }
  .rail-theme { margin: 10px 0 4px; }
  .rail-links { display: flex; flex-wrap: wrap; gap: 4px 8px; border-left: 0; margin-left: 0; }
  .rail-links:not(.is-open) { display: none; }
  .rail-link { border-left: 0; border-bottom: 2px solid transparent; padding: 5px 9px; margin-left: 0; border-radius: var(--radius-sm); }
  .rail-link.is-active { border-left: 0; border-bottom-color: var(--orange); }
}

@media (max-width: 820px) {
  :root { --header-h: 76px; --pinned: 24px; }
  /* Fourteen tabs wrap into seven rows on a phone, and seven rows pinned to the
     top of a small screen leaves almost nothing to read. On a narrow screen the
     navigation scrolls away with the page instead. */
  .app-header, .chapter-bar { position: static; }
  .brand-name { display: none; }
  .footer-grid { grid-template-columns: minmax(0, 1fr); }
  .controls .shiny-input-container { flex: 1 1 100%; min-width: 0; }
  .area-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 14px; }
  .stat { padding: 18px 18px 16px; gap: 13px; }
  .stat__icon { width: 40px; height: 40px; border-radius: 12px; }
  .stat__icon svg { width: 20px; height: 20px; }
}

@media (max-width: 560px) {
  .highlight-grid, .chapter-index { grid-template-columns: minmax(0, 1fr); }
  .brand-plate { padding: 4px 7px; gap: 8px; }
  .brand-mark { height: 44px; }
  .table-block__head { align-items: flex-start; }
}

/* Shiny's own furniture we do not want */
.shiny-output-error { color: var(--orange-600); font-size: var(--size-small); }
.shiny-output-error:before { content: "This chart could not be drawn. "; }
.recalculating { opacity: 0.35; transition: opacity 200ms ease; }

/* A picker that sits with the chart it governs needs less room around it than
   the row at the head of a section. */
.controls--tight {
  border-top: 0;
  padding-top: 0;
  padding-bottom: 14px;
  margin-bottom: 14px;
  max-width: 1060px;
}
.controls--tight .shiny-input-container { flex: 0 1 320px; min-width: 220px; }

/* the round picker, when it has to sit in a table's own header row */
.table-year .shiny-input-container { margin: 0; }
.table-year select, .table-year .form-select {
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  padding: 7px 14px;
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
  background-color: var(--paper);
}

/* The tabs live in the page twice and only one copy is ever shown: under the
   introduction on the opening page, at the top once you are inside a chapter.
   script.js marks the body with which page is showing. */
body.on-overview .chapter-bar--top { display: none; }
body:not(.on-overview) .chapter-bar--inline { display: none; }
/* placed below the opening band, it pins as the reader scrolls past it */
.chapter-bar--inline { border-top: 0; }

/* ---------------------------------------------------------------------------
   ONE COUNTY AT A TIME
   ------------------------------------------------------------------------- */

.county-head {
  display: grid;
  grid-template-columns: minmax(0, 1.1fr) minmax(0, 0.9fr);
  gap: clamp(28px, 3.5vw, 70px);
  align-items: center;
  padding: clamp(36px, 4.5vh, 62px) var(--gutter) clamp(26px, 3vh, 40px);
}
.county-head__copy { min-width: 0; }
.county-head__map { min-width: 0; }

.county-pick { max-width: 380px; margin-top: 22px; }
.county-pick .shiny-input-container { width: 100%; margin: 0; }
.county-pick label {
  font-family: var(--font-body);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
  margin-bottom: 6px;
  display: block;
}
.county-pick select, .county-pick .form-select {
  width: 100% !important;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  padding: 11px 15px;
  font-size: var(--size-input);
  color: var(--ink);
  background-color: var(--paper);
}
.county-pick select:focus { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }

@media (max-width: 1040px) {
  .county-head { grid-template-columns: minmax(0, 1fr); }
  .county-head__map { display: none; }
}

/* the two pickers that narrow a county's five hundred figures */
.county-filters { max-width: 760px; border-top: 1px solid var(--rule); padding-top: 16px; }
.county-filters .shiny-input-container { flex: 1 1 300px; min-width: 200px; }

/* ---------------------------------------------------------------------------
   THEMES OVER CHAPTERS
   The top row is six themes. Opening one drops its chapters into a second row
   underneath, in the same blue, so the two read as one block of navigation
   rather than as a bar with something stuck under it.
   ------------------------------------------------------------------------- */

.theme-tab {
  appearance: none;
  border: 0;
  background: transparent;
  color: #fff;
  font-family: var(--font-body);
  font-size: var(--size-nav-link);
  font-weight: var(--weight-semibold);
  padding: 10px 16px;
  border-radius: 999px;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.1;
  transition: background 0.15s ease, color 0.15s ease;
}
.theme-tab:hover { background: rgba(255, 255, 255, 0.16); }
.theme-tab.is-open {
  background: var(--paper);
  color: var(--blue-800);
  box-shadow: 0 2px 10px rgba(8, 30, 44, 0.18);
}

/* The chapters of the open theme. Every theme's row is in the page and all but
   one are hidden, so opening a theme is a class change and not a request. */
.chapter-bar__second { padding: 0; }
.chapter-bar__chapters {
  display: none;
  flex-wrap: wrap;
  gap: 4px 2px;
  align-items: center;
  padding: 8px 0 12px;
  border-top: 1px solid rgba(255, 255, 255, 0.28);
}
.chapter-bar__chapters.is-open { display: flex; }
.chapter-bar__chapters .chapter-tab { font-size: var(--size-rail-link); padding: 7px 13px; }

/* ---------------------------------------------------------------------------
   THE TOUR
   A dim over the page, a hole where the thing being talked about is, and a
   card beside it. Shown on a first visit and never again, and leaving counts
   as having seen it.
   ------------------------------------------------------------------------- */

/* The scrim is there to be clicked, not to be seen. The dimming is the hole's
   own enormous outer shadow, which is what leaves a clean bright window over
   the thing being pointed at. */
.tour-scrim {
  position: fixed;
  inset: 0;
  background: transparent;
  z-index: 4000;
}
.tour-hole {
  position: fixed;
  z-index: 4001;
  border-radius: 14px;
  pointer-events: none;
  box-shadow: 0 0 0 9999px rgba(8, 30, 44, 0.55), 0 0 0 3px var(--orange);
  transition: top 0.28s ease, left 0.28s ease, width 0.28s ease, height 0.28s ease;
}
.tour-card {
  position: fixed;
  z-index: 4002;
  background: var(--paper);
  border-radius: 16px;
  padding: 22px 22px 18px;
  box-shadow: 0 24px 60px rgba(8, 30, 44, 0.3);
  border: 1px solid var(--rule);
  animation: tour-in 0.25s ease;
}
.tour-card__step {
  margin: 0 0 8px;
  color: var(--blue-600);
  font-weight: var(--weight-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
}
.tour-card__title {
  margin: 0 0 8px;
  font-family: var(--font-display);
  color: var(--ink);
  line-height: 1.2;
}
.tour-card__body { margin: 0 0 18px; color: var(--ink-soft); line-height: 1.5; }
.tour-card__row { display: flex; align-items: center; gap: 10px; }
.tour-card__spacer { flex: 1 1 auto; }
.tour-card button {
  font-family: var(--font-body);
  border-radius: 999px;
  padding: 9px 18px;
  cursor: pointer;
  border: 1px solid transparent;
}
.tour-next { background: var(--blue); color: #fff; font-weight: var(--weight-semibold); }
.tour-next:hover { background: var(--blue-600); }
.tour-back { background: var(--paper); border-color: var(--rule-strong); color: var(--ink-soft); }
.tour-back:hover { border-color: var(--blue); color: var(--blue-800); }
.tour-skip { background: transparent; color: var(--ink-faint); padding-left: 0; }
.tour-skip:hover { color: var(--orange-600); text-decoration: underline; }
.tour-card button:focus-visible { outline: 3px solid var(--blue-200); outline-offset: 2px; }

/* Deliberately no scroll lock. The tour scrolls the page to each step, and a
   locked body would leave every step below the fold unreachable. */

@keyframes tour-in { from { opacity: 0; } to { opacity: 1; } }

@media (max-width: 620px) {
  .tour-card { left: 16px !important; right: 16px; width: auto !important; }
  .tour-card__row { flex-wrap: wrap; }
}

/* the way back in, for anyone who skipped it or wants it again. It sits at the
   other end of the footer rule from the button back to the top. */
.footer-top { justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.footer-top .tour-again { border-color: rgba(255, 255, 255, 0.7); color: #FFFFFF; }
.footer-top .tour-again:hover { background: #FFFFFF; color: var(--cema-orange); }

/* ==================================================================================
   THE THREE CROSS-CUTTING PAGES
   Counties, Compare and Trends are read differently from a chapter: a chapter is
   scrolled, these are steered. So the controls sit close to what they change and
   every chart is followed by the sentence that says what it shows, rather than
   leaving a reader to work out the finding from the picture on their own.
   ================================================================================== */

.cross .shell, .trends .shell { padding-block: 8px 56px; }

/* The reading beside a chart. Two weights: the finding, and the caution. */
.cross-read {
  display: flex; flex-direction: column; gap: 18px;
  align-self: start;
  padding: 22px 24px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
}
.cross-read__line {
  font-family: var(--font-display);
  font-size: var(--size-lead);
  line-height: 1.32;
  color: var(--ink);
  margin: 0;
}
.cross-read__fine {
  font-size: var(--size-small);
  line-height: 1.55;
  color: var(--ink-soft);
  margin: 0;
}
.cross-read__fine + .cross-read__fine { color: var(--ink-faint); }

/* The scatter and its reading, side by side on a wide screen and stacked on a
   narrow one. The chart keeps the room; the words are the column that gives way. */
.cross-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(280px, 380px);
  gap: 26px;
  align-items: start;
}
@media (max-width: 1100px) {
  .cross-grid { grid-template-columns: minmax(0, 1fr); }
}

/* The trends reading runs the full width, because the slope chart under it does. */
.trend-read {
  display: flex; flex-direction: column; gap: 12px;
  margin: 22px 0 6px;
  padding: 22px 24px;
  background: var(--paper-tint);
  border: 1px solid var(--rule);
  border-left: 4px solid var(--blue);
  border-radius: var(--radius);
}
.trend-read .cross-read__line { font-size: var(--size-lead); }

/* The line under a chart that says what the chart cannot: how wide the spread is,
   how many counties reported, what a rank is worth here. */
.figure-note {
  font-size: var(--size-small);
  line-height: 1.6;
  color: var(--ink-soft);
  max-width: 92ch;
  margin: 14px 0 26px;
}

/* A second button that is plainly secondary to the one beside it. */
.go-btn--quiet {
  background: transparent;
  color: var(--blue-600);
  border: 1px solid var(--rule-strong);
}
.go-btn--quiet:hover { border-color: var(--blue); color: var(--blue-800); }

/* The action that sits in a row of pickers lines up with them rather than with
   the labels above them. */
.controls__action { display: flex; align-items: flex-end; padding-bottom: 2px; }

/* ----------------------------------------------------------------------------------
   Trends, two charts abreast
   Kenya on the left and the groups inside it on the right, because the second chart
   answers the question the first one raises and scrolling between them loses that.
   Below about 1150px there is not enough width for two charts to be worth reading,
   so they stack.
   ---------------------------------------------------------------------------------- */
.trend-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 30px;
  align-items: start;
  margin-top: 8px;
}
.trend-grid__col { display: flex; flex-direction: column; min-width: 0; }
@media (max-width: 1150px) {
  .trend-grid { grid-template-columns: minmax(0, 1fr); gap: 12px; }
}

/* The movement, said once and said large, so nobody has to read two data labels
   off a chart and subtract them. */
.trend-read__big {
  font-family: var(--font-display);
  font-size: clamp(26px, 2.4vw, 38px);
  line-height: 1.12;
  font-weight: var(--weight-bold);
  color: var(--ink);
  margin: 0;
}
.trend-read--up { border-left-color: var(--blue); }
.trend-read--down { border-left-color: var(--orange); }
.trend-read--flat { border-left-color: var(--rule-strong); }

/* One line per group, in order of how far it moved. A list, because that is what
   it is: a short list of statements, not a paragraph pretending to be prose. */
.trend-list { list-style: none; margin: 0; padding: 0; display: flex;
              flex-direction: column; gap: 9px; }
.trend-list__item {
  font-size: var(--size-small);
  line-height: 1.5;
  color: var(--ink);
  padding-left: 20px;
  position: relative;
}
.trend-list__item::before {
  content: "";
  position: absolute; left: 0; top: 0.58em;
  width: 9px; height: 9px; border-radius: 50%;
}
.trend-list__item--up::before { background: var(--blue); }
.trend-list__item--down::before { background: var(--orange); }
.trend-list__item--flat::before { background: var(--rule-strong); }
.trend-list__item b { font-weight: var(--weight-semibold); }

/* A table that is not drawn until it is asked for needs a button that reads as a
   switch rather than as another download, which is why the download links now say
   the word download and this one does not. */
.dl-btn--toggle {
  background: var(--blue-050);
  border-color: var(--blue-200);
  color: var(--blue-800);
}
.dl-btn--toggle:hover { background: var(--blue-100); border-color: var(--blue); }

/* ==================================================================================
   THE CHAPTER'S OWN NAVIGATION, ACROSS THE TOP
   Two rows: which part of the chapter, then which topic in it. A side rail asked a
   reader to hold eight themes and twenty three topics in their eye at once, in a
   250 pixel column; this says the same thing in the order it is used and leaves the
   page its full width for the charts.
   ================================================================================== */

/* The base .rail rules made a sticky, scrolling column of it. This is a bar, so
   it takes none of that back: no sticky, no height cap, no inner scroller. */
.topic-bar {
  position: static;
  max-height: none;
  overflow: visible;
  padding-right: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 4px 0 26px;
  padding-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}
.topic-bar__row { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; }

/* Row one. The part of the chapter, in the blue that says navigation everywhere
   else on the page. */
.topic-bar .rail-theme {
  /* The side rail made these full-width blocks stacked down a column. In a row
     they size to their own text, so the resets have to be explicit. */
  display: inline-flex;
  align-items: center;
  width: auto;
  flex: 0 0 auto;
  text-align: center;
  margin: 0;
  padding: 9px 16px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  line-height: 1.2;
  cursor: pointer;
  white-space: nowrap;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.topic-bar .rail-theme:hover { border-color: var(--blue); color: var(--blue-800); }
.topic-bar .rail-theme.is-active {
  background: var(--blue);
  border-color: var(--blue);
  color: #fff;
}
.topic-bar .rail-theme.is-hidden { display: none; }

/* Row two. The topics inside the part. Orange, because it is a different kind of
   choice from the row above it and a reader should never have to work out which
   row they just clicked. The one being read is filled, not underlined: an
   underline on a row of eight is easy to miss and that was the whole complaint. */
.topic-bar .rail-links {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  border: 0;
  margin: 0;
  padding: 2px 0 0;
}
.topic-bar .rail-links:not(.is-open) { display: none; }
.topic-bar .rail-link {
  display: inline-flex;
  align-items: center;
  width: auto;
  flex: 0 0 auto;
  margin: 0;
  padding: 7px 14px;
  border: 1px solid var(--rule);
  border-left: 1px solid var(--rule);
  border-radius: 999px;
  background: var(--paper-tint);
  color: var(--ink-soft);
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-medium);
  line-height: 1.25;
  text-align: left;
  cursor: pointer;
  max-width: 42ch;
  white-space: normal;
  transition: background 120ms ease, color 120ms ease, border-color 120ms ease;
}
.topic-bar .rail-link:hover {
  border-color: var(--orange-300);
  background: var(--orange-050);
  color: var(--ink);
}
.topic-bar .rail-link.is-active {
  background: var(--orange);
  border-color: var(--orange);
  color: #fff;
  font-weight: var(--weight-semibold);
}
.topic-bar .rail-link.is-hidden { display: none; }

/* The chapter search sits at the end of the first row rather than above both. */
.topic-bar .rail-filter { margin: 0 0 0 auto; min-width: 210px; }
.topic-bar .rail-filter input { padding-block: 8px; }

/* One topic on the page at a time. */
.area-page { display: none; }
.area-page.is-on { display: block; }

/* The chapter's one-line caption. It is a caption for the chapter, not a
   paragraph about it, and a caption that wraps stops reading as one. */
.lead--one {
  max-width: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

@media (max-width: 900px) {
  /* Nowhere near enough width to keep a sentence on one line, so on a phone it
     wraps rather than being cut off at four words. */
  .lead--one { white-space: normal; overflow: visible; }
  .topic-bar .rail-filter { margin-left: 0; width: 100%; }
  .topic-bar .rail-link { max-width: 100%; }
}

/* ==================================================================================
   TIGHTENING THE TOP OF A PAGE, AND LETTING A SENTENCE BE A SENTENCE
   Two related complaints, one cause. Headings and captions were capped at a
   character count, so they broke early and left white space beside them, and the
   gaps between them were set for a page with much less on it. A reader opening a
   topic should see the chart, not the title of the chart.
   ================================================================================== */

/* No truncation anywhere in the running text. The earlier one-line caption cut
   itself off with an ellipsis; a caption that reaches the edge of the page now
   wraps, which is what a reader expects a sentence to do. */
.lead--one {
  max-width: none;
  white-space: normal;
  overflow: visible;
  text-overflow: clip;
  margin: 0;
}

.section-head .lead, .chapter-head .lead { margin-top: 0; }
.topic-bar { margin: 10px 0 16px; padding-bottom: 12px; }
.area__no { margin-bottom: 2px; }
.area .area-stats { margin-top: 14px; }
.area .controls { margin-block: 10px; }
.figure-note { max-width: none; }
.next-strip__say { max-width: none; }

/* The pickers read as part of the same row of controls as the sub-tabs above
   them, so they are set in the same face at the same size. A select styled by
   the browser sits at 13px in a different family and looks like a form dropped
   into a page rather than part of it. */
.controls select,
.controls .form-select,
.controls select.form-control,
.county-pick select,
.table-block__head select {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-medium);
  color: var(--ink);
  line-height: 1.25;
  border-radius: 999px;
  padding: 8px 34px 8px 14px;
  border: 1px solid var(--rule-strong);
  background-color: var(--paper);
}
.controls select:focus, .controls .form-select:focus {
  outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100);
}
.controls label, .county-pick label {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
  margin-bottom: 5px;
}

/* ==================================================================================
   THE SEARCH BOX ON A PAGE WITH NO SERVER
   Shiny's version of this box is a selectize widget. Without Shiny there is no
   selectize, and the same markup arrives as a bare dropdown of a hundred and eighty
   entries carrying a placeholder promising a search. So the static build renders a
   real field and these are its clothes.
   ================================================================================== */

.site-search { position: relative; }
.site-search__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-medium);
  color: var(--ink);
  padding: 14px 18px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper);
}
.site-search__input::placeholder { color: var(--ink-faint); font-weight: var(--weight-regular); }
.site-search__input:focus {
  outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100);
}

.site-search__list {
  position: absolute;
  z-index: 70;
  left: 0; right: 0; top: calc(100% + 7px);
  margin: 0; padding: 6px;
  list-style: none;
  max-height: 58vh; overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 18px 44px rgba(12, 17, 22, 0.16);
}
.site-search__list[hidden] { display: none; }
.site-search__hit {
  display: flex; flex-direction: column; gap: 2px;
  width: 100%; text-align: left;
  padding: 9px 13px;
  border: 0; border-radius: var(--radius-sm);
  background: none; cursor: pointer;
}
.site-search__hit:hover, .site-search__hit.is-on { background: var(--blue-050); }
.site-search__title {
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-semibold);
  color: var(--ink);
}
.site-search__where { font-size: var(--size-tiny); color: var(--blue-800); }
.site-search__miss { padding: 11px 13px; font-size: var(--size-small); color: var(--ink); }
.site-search__miss b { font-weight: var(--weight-semibold); }

/* The search now finds indicators as well as tables. Each hit says which it is
   in a small tag above its name, the words typed are picked out in gold, and a
   line at the top of the list says how many matched. */
.site-search__count {
  padding: 8px 13px 6px;
  font-weight: var(--weight-semibold);
  color: var(--blue-800);
  border-bottom: 1px solid var(--rule);
  margin-bottom: 4px;
}
.site-search__kind {
  align-self: flex-start;
  font-weight: var(--weight-bold);
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--blue-800);
  background: var(--blue-050);
  border: 1px solid var(--blue-200);
  border-radius: 5px;
  padding: 1px 7px;
  margin-bottom: 2px;
}
.site-search__hit--t .site-search__kind { color: var(--navy-900); background: var(--orange-050); border-color: var(--orange-100); }
.site-search__title mark { background: var(--orange-100); color: var(--navy-900); border-radius: 3px; padding: 0 1px; }

/* ==================================================================================
   THE THREE THINGS A DHS MEASURES
   Health, nutrition and demographics, said as three bands rather than as one row of
   unlabelled numbers. The heading is the quiet kind: it names the band and gets out
   of the way, because the figures under it are what a reader came for.
   ================================================================================== */

.band-head {
  display: flex; align-items: baseline; gap: 14px;
  margin: 26px 0 12px;
}
.band-head::after {
  content: "";
  flex: 1 1 auto;
  height: 1px;
  background: var(--rule);
}
.band-title {
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue-600);
  margin: 0;
}
.highlight-grid + .band-head { margin-top: 34px; }

/* The ready-made comparisons. Quieter than the sub-tabs inside a chapter, because
   these are suggestions rather than the page's own navigation. */
.preset-row {
  display: flex; flex-wrap: wrap; align-items: center; gap: 8px;
  margin: 10px 0 4px;
}
.preset-row__label {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
  margin-right: 2px;
}
.preset {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-medium);
  color: var(--blue-800);
  background: var(--blue-050);
  border: 1px solid var(--blue-200);
  border-radius: 999px;
  padding: 7px 14px;
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease, color 120ms ease;
}
.preset:hover { background: var(--blue-100); border-color: var(--blue); }
.preset.is-on { background: var(--blue); border-color: var(--blue); color: #fff; }

/* ==================================================================================
   SEARCHABLE PICKERS
   The native select is still there, covered rather than replaced, so Shiny goes on
   reading it and the static site goes on hearing it. These are the clothes of the
   box in front of it.
   ================================================================================== */

.pick { position: relative; width: 100%; }
.pick__native {
  /* Present for the code that owns it, out of the way of the reader. Not
     display:none: a hidden form control is skipped by some bindings. */
  position: absolute;
  width: 1px; height: 1px;
  opacity: 0;
  pointer-events: none;
  clip: rect(0 0 0 0);
}
.pick__input {
  width: 100%;
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-medium);
  color: var(--ink);
  line-height: 1.25;
  padding: 8px 34px 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: 999px;
  background: var(--paper)
    /* the chevron, drawn rather than fetched */
    url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%232E4E60' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E")
    no-repeat right 12px center;
  background-size: 15px 15px;
  cursor: text;
}
.pick__input::placeholder { color: var(--ink); opacity: 1; }
.pick__input:focus {
  outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100);
}
.pick.is-open .pick__input { border-color: var(--blue); }

.pick__list {
  position: absolute;
  z-index: 50;
  left: 0; right: 0; top: calc(100% + 6px);
  margin: 0; padding: 6px;
  list-style: none;
  max-height: 46vh; overflow-y: auto;
  background: var(--paper);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(12, 17, 22, 0.16);
}
.pick__list[hidden] { display: none; }
.pick__group {
  padding: 9px 12px 4px;
  font-family: var(--font-body);
  font-size: 11.5px;
  font-weight: var(--weight-bold);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--ink-faint);
}
.pick__hit {
  display: block; width: 100%; text-align: left;
  padding: 8px 12px;
  border: 0; border-radius: var(--radius-sm);
  background: none; cursor: pointer;
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-medium);
  color: var(--ink);
  line-height: 1.35;
}
.pick__hit:hover, .pick__hit.is-on { background: var(--blue-050); }
.pick__hit.is-current { color: var(--blue-800); font-weight: var(--weight-semibold); }
.pick__miss { padding: 10px 12px; font-size: var(--size-tiny); color: var(--ink-soft); }

/* ==================================================================================
   THE STATIC SITE'S PICKERS
   Tom Select boxes (site_src/pickers.js), dressed to match the app's selectize
   boxes: a white field with a fine border and a caret, the list opening under
   it. Sizes are in sizes.css. Nothing here applies in the app, which has no
   .ts-wrapper.
   ================================================================================== */
.ts-wrapper { width: 100%; max-width: 100%; }
/* Without Shiny's own stylesheet a picker's container shrinks to its text, and
   the box with it: the caret sat on the last word. They take the column instead,
   up to the same 440px the app allows. */
/* The static site's own markup puts each picker in a .field that is a flex
   item sized to its text, so it is given a width: 440px for a table's pickers,
   up to 720px on the Analytics pages, whose measures have long names. */
.controls .field:has(.ts-wrapper) { flex: 0 1 440px; min-width: 260px; max-width: 100%; }
.cross .controls .field:has(.ts-wrapper) { flex-basis: 720px; }
.county-pick .field:has(.ts-wrapper) { width: 100%; }
.field:has(.ts-wrapper) > div { width: 100%; }
.controls .ts-wrapper, .county-pick .ts-wrapper { width: 100% !important; }
.ts-wrapper .ts-control { min-width: 0; }
.ts-wrapper.single .ts-control > .item { flex: 0 1 auto; min-width: 0; }
.ts-wrapper.single .ts-control > input { flex: 1 1 0; min-width: 0 !important; }
/* The search field at the top of an open list */
.ts-dropdown .dropdown-input-wrap { padding: 8px; border-bottom: 1px solid var(--rule); background: var(--paper); }
.ts-dropdown .dropdown-input {
  width: 100%; padding: 8px 12px 8px 36px;
  border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  color: var(--ink); background: var(--paper)
    url("data:image/svg+xml;charset=utf8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23AA6340' stroke-width='2.1' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M20 20l-4-4'/%3E%3C/svg%3E")
    no-repeat 11px center;
  background-size: 17px 17px;
}
.ts-dropdown .dropdown-input:focus { outline: 0; border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.ts-dropdown .dropdown-input::placeholder { color: var(--ink-soft); }
.ts-wrapper .ts-control {
  min-height: 44px;
  padding: 8px 40px 8px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  box-shadow: none;
  align-items: center;
  flex-wrap: nowrap;
  cursor: pointer;
}
.ts-wrapper .ts-control > .item {
  color: var(--ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 100%;
}
.ts-wrapper .ts-control > input { color: var(--ink); min-width: 4rem; }
.ts-wrapper .ts-control > input::placeholder { color: var(--ink-soft); }
/* the caret, as the app draws it */
.ts-wrapper.single .ts-control::after {
  content: ""; position: absolute; right: 16px; top: 50%; margin-top: -3px;
  border-style: solid; border-width: 6px 6px 0; border-color: var(--ink) transparent transparent;
}
.ts-wrapper.single.dropdown-active .ts-control::after {
  margin-top: -4px; border-width: 0 6px 6px; border-color: transparent transparent var(--ink);
}
.ts-wrapper.focus .ts-control { border-color: var(--blue); box-shadow: 0 0 0 3px var(--blue-100); }
.ts-wrapper.dropdown-active .ts-control { border-radius: var(--radius-sm) var(--radius-sm) 0 0; }
.ts-wrapper.single.input-active .ts-control { cursor: text; }

.ts-dropdown {
  z-index: 45;
  margin: 0;
  border: 1px solid var(--blue);
  border-top: 0;
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
  background: var(--paper);
  color: var(--ink);
  box-shadow: var(--shadow-md);
}
.ts-dropdown .ts-dropdown-content { max-height: min(50vh, 440px); }
.ts-dropdown .option { padding: 9px 14px; color: var(--ink); line-height: 1.35; }
.ts-dropdown .option.active { background: var(--blue-050); color: var(--ink); }
.ts-dropdown .option.selected { color: var(--blue-800); font-weight: var(--weight-semibold); }
.ts-dropdown .optgroup-header {
  padding: 11px 14px 4px;
  font-weight: var(--weight-bold); letter-spacing: var(--tracking-wide); text-transform: uppercase;
  color: var(--blue-600); background: var(--paper);
}
.ts-dropdown .no-results { padding: 12px 14px; color: var(--ink); }
.ts-dropdown .highlight { background: var(--orange-050); color: inherit; border-radius: 2px; }
/* The round picker in a table's header row stays compact. */
.table-year .ts-wrapper { width: auto; min-width: 140px; }
.table-year .ts-wrapper .ts-control { min-height: 38px; padding-block: 5px; }


/* ==================================================================================
   THE COUNTY PERFORMANCE MAP, AND THE PAGE THAT LEAVES THE SITE
   ================================================================================== */

/* Map and ranking side by side: the map says where, the ranking says how far
   apart, and neither says it alone. They stack below 1150px, where a map squeezed
   into half a phone is a smudge. */
.map-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 28px;
  align-items: start;
  margin-top: 8px;
}
@media (max-width: 1150px) { .map-grid { grid-template-columns: minmax(0, 1fr); } }

/* The one page that needs a connection says so while it waits, and says why if
   it cannot get one. */
.past-status {
  font-size: var(--size-small);
  color: var(--ink-soft);
  min-height: 1.4em;
  margin: 6px 0 10px;
}
.past-status--warn {
  color: var(--orange-600);
  background: var(--orange-050);
  border-left: 3px solid var(--orange);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
}
.past .field { display: flex; flex-direction: column; min-width: 240px; flex: 1 1 260px; }
.past .field label {
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
  margin-bottom: 5px;
}

/* Live DHS explorer.  It deliberately uses the dashboard's existing type,
   paper, rule, blue and orange tokens rather than importing the standalone
   prototype's visual system. */
.past-live-controls {
  position: sticky;
  top: var(--pinned);
  z-index: 50;
  isolation: isolate;
  display: grid;
  grid-template-columns: minmax(290px, 2fr) minmax(210px, 1fr) minmax(250px, 1.15fr) auto;
  gap: 16px;
  /* The indicator field has a second, confirmatory line containing its DHS ID.
     Keep the other controls aligned to its input, rather than its bottom edge. */
  align-items: start;
  padding: 14px 18px;
  margin: 24px 0 8px;
  background: rgba(250, 246, 238, .78);
  border: 1px solid var(--rule);
  border-radius: var(--radius);
  -webkit-backdrop-filter: blur(14px) saturate(92%);
  backdrop-filter: blur(14px) saturate(92%);
}
.past-live-controls::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: -8px -10px;
  border-radius: calc(var(--radius) + 8px);
  background: rgba(250, 246, 238, .48);
  -webkit-backdrop-filter: blur(10px) saturate(92%);
  backdrop-filter: blur(10px) saturate(92%);
  pointer-events: none;
}
.past-field { min-width: 0; position: relative; }
.past-field label, .past-field__label {
  display: block;
  margin: 0 0 6px;
  font-family: var(--font-body);
  font-size: var(--size-tiny);
  font-weight: var(--weight-semibold);
  color: var(--ink-soft);
}
.past-field .form-control { width: 100%; }
.past-field--id .form-control { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; }
.past-field--action { min-width: max-content; }
.past-fetch { min-height: 42px; color: var(--paper); background: var(--blue); border-color: var(--blue); }
.past-fetch:hover { color: var(--paper); background: var(--blue-800); border-color: var(--blue-800); }
.past-fetch:disabled { opacity: .65; cursor: wait; }
.past-selection { min-height: 1.3em; margin: 6px 0 0; color: var(--ink-faint); font-size: var(--size-tiny); }
.past-options {
  position: absolute; z-index: 50; top: calc(100% - 22px); left: 0; right: 0;
  max-height: 340px; overflow-y: auto; padding: 5px;
  background: var(--paper); border: 1px solid var(--rule-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
}
.past-option { display: block; width: 100%; padding: 9px 10px; border: 0; border-radius: 6px; text-align: left; background: transparent; color: var(--ink); cursor: pointer; }
.past-option:hover, .past-option:focus { background: var(--blue-050); outline: 0; }
.past-option__label { display: block; font-size: var(--size-tiny); font-weight: var(--weight-medium); line-height: 1.35; }
.past-option__meta { display: block; margin-top: 2px; color: var(--ink-faint); font-size: var(--size-tiny); }
.past-options__note { padding: 9px 10px; color: var(--ink-soft); font-size: var(--size-tiny); line-height: 1.45; }
.past-query { margin: 8px 0 4px; color: var(--ink-faint); font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 11px; line-height: 1.5; overflow-wrap: anywhere; }
.past-query b { color: var(--ink-soft); font-family: var(--font-body); }
.past-results { margin-top: 18px; }
.past-result-head { display: flex; justify-content: space-between; gap: 18px; align-items: flex-start; flex-wrap: wrap; margin: 26px 0 12px; }
.past-result-head h3 { margin: 0; font-family: var(--font-display); font-size: var(--size-section); color: var(--ink); }
.past-result-note { margin: 5px 0 0; color: var(--ink-soft); font-size: var(--size-small); }
.past-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 12px; margin: 16px 0 24px; }
.past-summary__item { padding: 16px; border: 1px solid var(--rule); border-radius: var(--radius-sm); background: var(--paper); }
.past-summary__label { display: block; color: var(--ink-faint); font-size: var(--size-tiny); font-weight: var(--weight-semibold); }
.past-summary__value { display: block; margin-top: 5px; color: var(--ink); font-family: var(--font-display); font-size: var(--size-lead); line-height: 1.1; }
.past-layout { display: grid; grid-template-columns: minmax(260px, .8fr) minmax(0, 1.5fr); gap: 22px; align-items: start; margin: 18px 0 28px; }
.past-map { min-height: 380px; }
.past-layout--national { align-items: stretch; }
.past-layout--national .past-map { min-height: 475px; }
.past-layout--geographic .past-map { min-height: 475px; }
.past-layout__data { min-width: 0; }
.past-layout__data .past-summary { margin: 0 0 18px; }
.past-map-frame { position: relative; }
.past-national-badge {
  position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);
  min-width: 116px; padding: 10px 14px; border: 1px solid var(--rule-strong);
  border-radius: var(--radius); background: color-mix(in srgb, var(--paper) 94%, transparent);
  box-shadow: var(--shadow-md); text-align: center; pointer-events: none;
}
.past-national-badge strong { display: block; color: var(--blue); font-family: var(--font-display); font-size: var(--size-subsection); line-height: 1.1; }
.past-national-badge span { display: block; margin-top: 4px; color: var(--ink-faint); font-size: var(--size-tiny); }
.past-map-note { margin: 7px 0 0; color: var(--ink-soft); font-size: var(--size-tiny); line-height: 1.45; }
.past-chart { min-height: 380px; }
.past-trends { margin: 24px 0; }
.past-trends__head { display: flex; align-items: end; gap: 16px; flex-wrap: wrap; margin-bottom: 10px; }
.past-trends__head .past-field { min-width: min(100%, 360px); flex: 1 1 300px; }
.past-tags { display: flex; flex-wrap: wrap; gap: 7px; margin: 8px 0 12px; }
.past-tag { display: inline-flex; gap: 6px; align-items: center; padding: 5px 8px 5px 10px; border: 1px solid var(--rule-strong); border-radius: 999px; background: var(--paper); color: var(--ink-soft); font-size: var(--size-tiny); }
.past-tag button { border: 0; padding: 0; background: transparent; color: inherit; cursor: pointer; font-size: 16px; line-height: 1; }
.past-table-wrap { overflow-x: auto; }
/* Report tables elsewhere may shrink to the width of their contents. The live
   DHS result is an explorer: its returned-records table should use the whole
   reading column beneath the map/chart composition. */
.past .table-block, .past .past-table-wrap, .past .past-table-wrap .dataTables_wrapper { width: 100%; }
.past .past-table-wrap table.dataTable { width: 100% !important; }
.past-raw-link { margin: 12px 0 0; font-size: var(--size-tiny); }
.past-raw-link a { color: var(--blue); font-weight: var(--weight-semibold); }
.past-empty { padding: 18px; border-left: 3px solid var(--orange); background: var(--orange-050); color: var(--ink-soft); border-radius: var(--radius-sm); }
/* Where an indicator is published. Shown in place of a result when there is
   nothing at the level asked for, and small under every result that did come
   back. One cell per Kenya survey, shaded by the finest level DHS published:
   counties darkest, then former provinces, then the country alone. */
.past-avail { margin: 22px 0; padding: 20px 22px; border: 1px solid var(--rule-strong); border-left: 4px solid var(--orange); border-radius: var(--radius-sm); background: var(--paper); }
.past-avail .eyebrow { display: block; margin-bottom: 4px; }
.past-avail__title { margin: 0 0 6px; font-family: var(--font-display); font-size: var(--size-section); color: var(--ink); }
.past-avail__text { margin: 0 0 14px; color: var(--ink-soft); max-width: 72ch; line-height: 1.55; }
.past-avail__lead { display: block; margin: 0 0 8px; color: var(--ink-soft); font-size: var(--size-tiny); font-weight: var(--weight-semibold); text-transform: uppercase; letter-spacing: .04em; }
.past-avail__strip { display: grid; grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)); gap: 6px; }
.past-avail__cell { display: flex; flex-direction: column; gap: 2px; padding: 8px 10px; border: 1px solid var(--rule); border-radius: var(--radius-sm); font-size: var(--size-tiny); line-height: 1.25; }
.past-avail__cell b { font-size: var(--size-small); }
.past-avail__cell--county { background: var(--blue); border-color: var(--blue); color: #fff; }
.past-avail__cell--province { background: var(--orange); border-color: var(--orange); color: var(--ink); }
.past-avail__cell--national { background: var(--blue-100); border-color: var(--blue-100); color: var(--ink); }
.past-avail__cell--none { background: transparent; border-style: dashed; color: var(--ink-faint); }
.past-avail__cell.is-here { box-shadow: 0 0 0 2px var(--paper), 0 0 0 4px var(--ink); }
.past-avail__actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 14px; }
.past-avail__actions:empty { display: none; }
.past-avail__note { margin: 12px 0 0; color: var(--ink-faint); font-size: var(--size-tiny); }
.past-avail--inline { margin: 0 0 18px; padding: 14px 16px; border-left-width: 1px; background: transparent; }
.past-avail--inline .past-avail__actions { margin-top: 10px; }
@media (max-width: 1100px) { .past-live-controls { grid-template-columns: repeat(2, minmax(0, 1fr)); } .past-field--action { min-width: 0; } }
@media (max-width: 760px) { .past-live-controls, .past-summary, .past-layout { grid-template-columns: minmax(0, 1fr); } .past-layout { gap: 12px; } .past-map, .past-chart { min-height: 320px; } }

/* ==================================================================================
   The dashboard assistant
   ==================================================================================
   A bubble in the corner and a panel above it. The panel is a column: a band at
   the top, the conversation in the middle taking whatever height is left, and the
   question box pinned at the bottom, so a long answer scrolls and the box stays
   where the reader put their hands. */
.chat-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 200;
  width: 60px; height: 60px; border-radius: 50%; border: none; cursor: pointer;
  background: var(--blue); color: var(--paper);
  box-shadow: 0 6px 20px rgba(34, 28, 19, .28);
  display: flex; align-items: center; justify-content: center;
  transition: transform .15s, box-shadow .15s, background .15s;
}
.chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 24px rgba(34, 28, 19, .34); }
.chat-fab.is-open { background: var(--blue-800); }
.chat-fab-dot {
  position: absolute; top: 5px; right: 5px; width: 11px; height: 11px;
  border-radius: 50%; background: var(--orange); border: 2px solid var(--paper);
}
.chat-panel {
  position: fixed; right: 22px; bottom: 96px; z-index: 200;
  width: 420px; max-width: calc(100vw - 32px);
  height: min(620px, calc(100vh - 150px));
  background: var(--paper); border: 1px solid var(--rule); border-radius: var(--radius);
  box-shadow: 0 16px 48px rgba(34, 28, 19, .3);
  display: flex; flex-direction: column; overflow: hidden;
}
.chat-panel[hidden] { display: none; }
.chat-head {
  background-image: linear-gradient(135deg, var(--navy), var(--navy-900));
  color: var(--paper); padding: 14px 18px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: space-between;
}
.chat-head-title {
  display: flex; align-items: center; gap: 9px;
  font-family: var(--font-display); font-size: var(--size-label);
  font-weight: var(--weight-semibold);
}
.chat-head-dot {
  width: 9px; height: 9px; border-radius: 50%; background: var(--orange);
  box-shadow: 0 0 0 3px rgba(231, 168, 62, .28); flex-shrink: 0;
}
.chat-close {
  background: none; border: none; color: var(--paper); opacity: .85;
  font-size: 26px; line-height: 1; cursor: pointer; padding: 0 3px;
}
.chat-close:hover { opacity: 1; }
.chat-body {
  flex: 1; overflow-y: auto; padding: 16px; background: var(--paper-tint);
  display: flex; flex-direction: column; gap: 11px;
}
.chat-msg {
  max-width: 90%; font-size: var(--size-small); line-height: 1.55;
  padding: 10px 14px; border-radius: 13px; word-wrap: break-word;
}
.chat-msg.bot {
  align-self: flex-start; background: var(--paper); border: 1px solid var(--rule);
  color: var(--ink); border-bottom-left-radius: 3px;
}
.chat-msg.user {
  align-self: flex-end; background: var(--blue); color: var(--paper);
  border-bottom-right-radius: 3px;
}
.chat-msg b { font-weight: var(--weight-bold); }
.chat-msg .cm-sub {
  display: block; margin-top: 5px; font-size: var(--size-tiny); color: var(--ink-faint);
}
.chat-chips { align-self: flex-start; max-width: 100%; display: flex; flex-wrap: wrap; gap: 7px; }
.chat-chip {
  font-family: var(--font-body); font-size: var(--size-tiny); text-align: left;
  background: var(--paper); border: 1px solid var(--rule-strong); color: var(--blue-800);
  border-radius: 999px; padding: 7px 13px; cursor: pointer;
  transition: background .15s, border-color .15s;
}
.chat-chip:hover { background: var(--blue-050); border-color: var(--blue); }
.chat-input-row {
  display: flex; align-items: center; gap: 9px; padding: 12px;
  border-top: 1px solid var(--rule); background: var(--paper); flex-shrink: 0;
}
.chat-input {
  flex: 1; border: 1px solid var(--rule); border-radius: 999px; padding: 10px 16px;
  font-family: var(--font-body); font-size: var(--size-small);
  background: var(--paper-tint); color: var(--ink); outline: none;
}
.chat-input:focus { border-color: var(--blue); }
.chat-send {
  width: 38px; height: 38px; border-radius: 50%; border: none;
  background: var(--blue); color: var(--paper); flex-shrink: 0; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.chat-send:hover { background: var(--blue-800); }
.chat-foot {
  margin: 0; padding: 0 14px 11px; background: var(--paper);
  font-size: var(--size-tiny); color: var(--ink-faint); flex-shrink: 0;
}
@media (max-width: 560px) {
  .chat-panel { right: 14px; left: 14px; width: auto; bottom: 86px; }
  .chat-fab { right: 14px; bottom: 14px; }
}

/* ==================================================================================
   The opening line, the band notes and the graphic inside a headline figure
   ==================================================================================

   CEMA's own colours, taken from the brand sheet, and used here and nowhere
   else. The page itself is KNBS saddle brown because the survey is theirs; the
   graphics are CEMA's because the reading of them is ours. */
:root {
  --cema-blue: #26AAE1;
  --cema-orange: #FD7501;
  --cema-navy: #084887;
  --cema-yellow: #EFCA08;
  --cema-green: #497048;
  --cema-teal: #006D77;
  --cema-purple: #8E44AC;
  --cema-pink: #EF2A7C;
}

/* What the survey is, for somebody who has never heard of it, with the three
   figures a reader will actually take away set out beside the words. */
/* The two counts take the width they need and the paragraph takes everything
   else, so the sentence runs long and shallow rather than sitting in a narrow
   column with a field of empty brown beside it. */
.hero-about {
  display: grid;
  grid-template-columns: minmax(0, 1fr) max-content;
  gap: clamp(18px, 2.2vw, 40px);
  align-items: start;
  margin: 0 0 24px;
}
.hero-sample {
  margin: 0;
  max-width: none;
  font-size: var(--size-base);
  line-height: 1.5;
  color: rgba(255, 255, 255, 0.94);
}
/* One column for the figures and one for what they are, so the words start at
   the same place whether the number beside them is two digits or six. */
.hero-facts {
  display: grid;
  grid-template-columns: max-content minmax(0, 1fr);
  align-items: baseline;
  gap: 14px 16px;
  padding-left: clamp(16px, 2vw, 28px);
  border-left: 2px solid rgba(255, 255, 255, 0.28);
}
.hero-fact { display: contents; }
.hero-fact__n {
  font-family: var(--font-display);
  font-size: var(--size-stat);
  font-weight: var(--weight-bold);
  line-height: 1;
  color: #FFFFFF;
  min-width: 3.6ch;
}
.hero-fact__what {
  font-size: var(--size-small);
  line-height: 1.35;
  color: rgba(255, 255, 255, 0.9);
}
@media (max-width: 1100px) {
  .hero-about { grid-template-columns: 1fr; gap: 22px; }
  .hero-facts {
    display: flex; flex-wrap: wrap; gap: 8px 32px;
    border-left: none; padding-left: 0;
    border-top: 2px solid rgba(255, 255, 255, 0.28); padding-top: 16px;
  }
  .hero-fact { display: flex; flex-direction: column; gap: 2px; }
}

/* One line under a band heading, saying what kind of figure is in it. Outcomes
   and services read alike and are not alike, and this is where that is said. */
.band-note {
  margin: -4px 0 16px;
  max-width: 92ch;
  font-size: var(--size-small);
  line-height: 1.5;
  color: var(--ink-soft);
}

/* With the standfirst gone, the eyebrow is the whole of this heading, and the
   space that was holding a paragraph up should not still be there. */
.overview .section-head:has(> .eyebrow:only-child) { margin-bottom: 2px; }

/* The rounds, drawn across the foot of the card. Teal where the survey has
   moved the welcome way, orange where it has not, blue where the question does
   not have a welcome direction. Which of those it is comes off the indicator
   rather than off the sign of the change, because mortality falling is good
   news and vaccination falling is not. */
.hl__spark {
  display: block;
  width: 100%;
  margin: 12px 0 -6px;
  overflow: visible;
}
.hl__spark-fill { fill: var(--spark); opacity: 0.16; }
.hl__spark-line { stroke: var(--spark); }
.hl__spark-axis { stroke: var(--rule); stroke-width: 1; }
.hl__spark-grid { stroke: var(--rule); stroke-width: 1; stroke-dasharray: 3 4; }
.hl__spark-tick {
  font-family: var(--font-body);
  font-size: 13px;
  font-weight: var(--weight-medium);
  fill: var(--ink-faint);
}
/* Every round the survey has, marked. The earlier ones are hollow so the
   current one is the only solid mark on the line. */
.hl__spark-was { fill: var(--paper); stroke: var(--spark); stroke-width: 2.2; }
.hl__spark-halo { fill: var(--spark); opacity: 0.22; }
.hl__spark-now { fill: var(--spark); }
.hl__spark-year {
  font-family: var(--font-body);
  font-size: 14px;
  font-weight: var(--weight-medium);
  fill: var(--ink-faint);
}
.hl__spark-year--now { font-weight: var(--weight-bold); fill: var(--spark); }
.hl__spark--good { --spark: var(--cema-teal); }
.hl__spark--bad { --spark: var(--cema-orange); }
.hl__spark--flat { --spark: var(--cema-blue); }

/* The arrow and the figure it came from, in the same colour as the line under
   them, so a card reads as one thing. */
.hl__move--good { color: var(--cema-teal); }
.hl__move--bad { color: var(--cema-orange); }
.hl__move--flat { color: var(--ink-faint); }
.hl__move { font-size: var(--size-small); font-weight: var(--weight-semibold); }
.hl__arrow { font-size: 1.15em; }

/* The results list has to sit over the sticky theme bar, and it cannot while
   the band it lives in is held at a lower layer than that bar. The band is
   lifted only for as long as there are results to show, so nothing overlaps
   the bar at any other moment. */
.hero-grid:has(.site-search__list:not([hidden])) { z-index: 70; }
/* In the app the box is selectize, and its list is attached to the page body
   rather than to the band (dropdownParent in survey_search), so it can sit
   over the sticky theme bar without lifting the band, whose text would then
   paint over the pinned header. Above the theme bar (55), below the header (60). */
body > .selectize-dropdown { z-index: 58 !important; }
/* Room for a dozen results rather than selectize's three and a half. */
body > .selectize-dropdown .selectize-dropdown-content { max-height: min(60vh, 560px); }

/* ==================================================================================
   The report's own summary of a chapter
   ================================================================================== */
.key-findings {
  margin: 0 auto 22px;
  padding: 20px 26px 22px;
  background: var(--blue-050);
  border-left: 4px solid var(--blue);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.key-findings__title {
  margin: 0 0 12px;
  font-family: var(--font-body);
  font-size: var(--size-small);
  font-weight: var(--weight-bold);
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--blue-600);
}
.key-findings__list { margin: 0; padding-left: 22px; }
.key-findings__list li {
  margin-bottom: 9px;
  font-size: var(--size-small);
  line-height: 1.55;
  color: var(--ink);
}
.key-findings__list li:last-child { margin-bottom: 0; }
.key-findings__list b { color: var(--blue-800); }

/* On a phone the masthead has room for the mark and the link and nothing else,
   so the link tightens rather than pushing the mark off the edge. */
@media (max-width: 768px) {
  .report-link--header { padding: 8px 12px; gap: 8px; }
  .report-link--header .report-link__kind { display: none; }
  .report-link--hero { padding: 14px 18px; gap: 12px; }
}

/* While the app carries a reader from the search to a table (script.js,
   kdhs-goto) the page is held out of sight, so the chapter's opening is never
   drawn before the jump, and it fades back in at the table. */
html.kdhs-landing .app-main { opacity: 0; }
html:not(.kdhs-landing) .app-main { transition: opacity 0.15s ease; }
