/* ==========================================================================
   The chart library's marks (web/js/chart/). One set of ch- classes, semantic
   tokens only, so both themes and the PDF follow. A mark's colour comes from
   its data-role (parts.js, ROLES): --c fills it, --s strokes it.
   The tip (.chart-tip, tip.js) is styled in app.css.
   ========================================================================== */

/* ---- Roles ------------------------------------------------------------- */
:where([class^="ch-"], [class*=" ch-"])[data-role="area"]   { --c: var(--bar-1); --s: var(--area-1); }
:where([class^="ch-"], [class*=" ch-"])[data-role="target"] { --c: var(--bar-2); --s: var(--area-2); }
:where([class^="ch-"], [class*=" ch-"])[data-role="extra"]  { --c: var(--bar-3); --s: var(--area-3); }
:where([class^="ch-"], [class*=" ch-"])[data-role="past"]   { --c: var(--past); --s: var(--past-line, var(--past)); }
:where([class^="ch-"], [class*=" ch-"])[data-role="future"] { --c: var(--area-1); --s: var(--area-1); }
:where([class^="ch-"], [class*=" ch-"])[data-role="line"]   { --c: var(--baseline); --s: var(--baseline); }

/* Flat fills (the consistency pass, 26 November 2026): the fade classes stay on the marks but draw nothing */
.ch-fade-h, .ch-fade-v { -webkit-mask-image: none; mask-image: none; }

/* Projected: a pale fill and a dashed outline in the place's colour, so it never reads as a census count */
:is(.ch-bar__fill, .ch-col__fill, .ch-swatch--bar)[data-role="future"] {
  background: var(--projected-fill); outline: 1.5px dashed var(--area-1); outline-offset: -1.5px;
}

/* Printed values: projected ones in Electric, earlier censuses quieter */
.ch-val { font-size: 13px; font-weight: 500; color: var(--text); white-space: nowrap; text-align: right; }
.ch-val[data-role="past"] { font-weight: 400; color: var(--text-2); }
.ch-val[data-role="future"], .ch-col__val[data-role="future"] { font-weight: 400; color: var(--accent-text); }
.ch-val.is-none, .ch-col__val.is-none { font-weight: 400; font-style: normal; color: var(--muted); }

/* ---- Key --------------------------------------------------------------- */
.ch-key { display: flex; flex-wrap: wrap; gap: 6px 14px; font-size: 12.5px; color: var(--text-2); }
.ch-key > span { display: inline-flex; align-items: center; gap: 6px; }
.ch-swatch { display: inline-block; flex: none; }
.ch-swatch--bar { width: 14px; height: 10px; border-radius: 0 3px 3px 0; background: var(--c); }
.ch-swatch--bar[data-role="line"] { width: 2px; height: 14px; border-radius: 0; }
.ch-swatch--stroke { width: 18px; height: 2.5px; border-radius: 2px; background: var(--s); }
.ch-swatch--dash { width: 18px; height: 0; border-top: 2px dashed var(--s); }
.ch-swatch--dot { width: 11px; height: 11px; border-radius: 50%; background: var(--s); }
.ch-swatch--ring { width: 11px; height: 11px; border-radius: 50%; background: var(--card); box-shadow: inset 0 0 0 2px var(--s); }

/* ---- Bars -------------------------------------------------------------- */
.ch-bars { display: flex; flex-direction: column; gap: 14px; }
.ch-row { display: flex; flex-direction: column; gap: 6px; }
.ch-row__head { display: flex; justify-content: space-between; align-items: baseline; gap: 12px; font-size: 13.5px; }
.ch-bar { position: relative; display: block; height: 10px; border-radius: 5px; background: var(--quiet); }
.ch-bar--thin { height: 8px; border-radius: 4px; }
.ch-bar__fill { position: absolute; left: 0; top: 0; bottom: 0; width: var(--w); min-width: 2px; background: var(--c); border-radius: 0 4px 4px 0; }
.ch-bar__line { position: absolute; top: -4px; bottom: -4px; left: var(--x); width: 2px; margin-left: -1px; background: var(--baseline); }
.ch-pair { display: grid; grid-template-columns: minmax(48px, max-content) minmax(0, 1fr) 64px; gap: 5px 10px; align-items: center; }
.ch-pair__name { max-width: 150px; font-size: 11.5px; line-height: 1.25; color: var(--text-2); }
.ch-pair .ch-val { font-size: 12px; }
.ch-pair .ch-caption { grid-column: 2 / -1; }
.ch-caption { display: flex; align-items: center; gap: 6px; font-size: 11.5px; color: var(--muted); }

/* ---- Ranked list ------------------------------------------------------- */
.ch-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; }
.ch-list__item { display: grid; grid-template-columns: minmax(0, 1fr) minmax(64px, 38%) 52px; gap: 10px; align-items: center; padding: 5px 0; }
.ch-list__name { font-size: 13.5px; line-height: 1.3; min-width: 0; }

/* ---- Columns ----------------------------------------------------------- */
.ch-cols { container-type: inline-size; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: minmax(var(--plot-h, 170px), 1fr) auto; gap: 6px 8px; }
.ch-cols.has-values { padding-top: 18px; }
.ch-cols__axis { position: relative; min-width: 22px; font-size: 11.5px; color: var(--muted); }
.ch-cols__axis span { position: absolute; right: 0; bottom: var(--y); transform: translateY(50%); white-space: nowrap; }
.ch-cols__plot { position: relative; border-bottom: 1px solid var(--axis); }
.ch-cols__grid { position: absolute; left: 0; right: 0; bottom: var(--y); border-top: 1px solid var(--line); }
.ch-cols__bands { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; }
.ch-col { position: relative; display: flex; align-items: flex-end; justify-content: center; gap: 2px; padding: 0 2px; }
.ch-col.is-tip { background: color-mix(in srgb, var(--line) 60%, transparent); border-radius: 4px 4px 0 0; }
.ch-col__stack { position: relative; flex: 1; max-width: 56px; height: var(--h); min-height: 2px; }
.ch-col__stack.is-zero { height: 0; min-height: 0; }
.ch-col__fill { position: absolute; inset: 0; background: var(--c); border-radius: 3px 3px 0 0; }
.ch-col__val { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 3px; font-size: 11px; color: var(--text-2); white-space: nowrap; }
.ch-col__line { position: absolute; left: -2px; right: -2px; bottom: var(--x); height: 2px; margin-bottom: -1px; background: var(--baseline); pointer-events: none; }
.ch-cols__labels { grid-column: 2; display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); gap: 6px; font-size: 11.5px; color: var(--muted); text-align: center; }
.ch-cols__labels .is-short { display: none; }
@container (max-width: 420px) {
  .ch-cols__labels .is-long { display: none; }
  .ch-cols__labels .is-short { display: inline; }
}

/* ---- Lines ------------------------------------------------------------- */
.ch-lines { display: flex; flex-direction: column; gap: 8px; }
.ch-svg, .ch-spark { display: block; overflow: visible; }
.ch-svg :not(.ch-hit), .ch-spark :not(.ch-hit) { pointer-events: none; }   /* hover on the year columns */
.ch-grid { stroke: var(--line); stroke-width: 1; }
.ch-grid.is-zero { stroke: var(--axis); }
.ch-tick { font-family: var(--font-sans); font-size: 11.5px; fill: var(--muted); }
.ch-band { fill: var(--projected-band); }
.ch-band__label { font-family: var(--font-sans); font-size: 11px; fill: var(--muted); }
.ch-path { fill: none; stroke: var(--s); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; }
.ch-path[data-role="area"] { stroke-width: 2.5; }
.ch-path.is-ahead { stroke-dasharray: 3 4; }
.ch-dot { fill: var(--s); }
.ch-dot.is-ahead { fill: var(--card); stroke: var(--s); stroke-width: 1.5; }
.ch-end { font-family: var(--font-sans); font-size: 11.5px; font-weight: 600; fill: var(--text); }
.ch-end[data-role="line"] { font-weight: 400; fill: var(--text-2); }
.ch-end.is-ahead { color: var(--accent-text); }
.ch-gap { stroke: var(--text-2); stroke-width: 1.2; stroke-dasharray: 2 3; }
.ch-gap.is-strong { stroke: var(--text); stroke-width: 1.6; stroke-dasharray: none; }
.ch-gap__text { font-family: var(--font-sans); font-size: 10.5px; fill: var(--text-2); }
.ch-gap__text.is-strong { font-weight: 600; fill: var(--text); }
.ch-cross { fill: none; stroke: var(--text); stroke-width: 1.5; }
.ch-hit { fill: transparent; }
.ch-hit.is-tip { fill: var(--line); opacity: .6; }
.ch-spark { flex: none; }
.ch-spark .ch-path { stroke-width: 1.8; }
.ch-spark .ch-path.is-ahead { stroke-dasharray: 2.5 3; }
.ch-spark__zero { stroke: var(--line-strong); stroke-width: 1; }

/* ---- Dots -------------------------------------------------------------- */
.ch-dots-wrap { container-type: inline-size; display: flex; flex-direction: column; gap: 8px; }
.ch-dots { display: grid; grid-template-columns: minmax(72px, min(34%, 230px)) minmax(120px, 1fr) 64px; gap: 4px 10px; align-items: center; }
@container (max-width: 460px) {     /* a narrow card: the axis names its ends only */
  .ch-dots__axis span:not(:first-child):not(:last-child) { display: none; }
}
.ch-dots__axis { position: relative; height: 18px; }
.ch-dots__axis span { position: absolute; top: 0; left: var(--x); transform: translateX(-50%); font-size: 11px; color: var(--muted); white-space: nowrap; }
.ch-dots__label { padding: 3px 0; font-size: 12.5px; line-height: 1.25; }
.ch-dots__track { position: relative; align-self: stretch; min-height: 22px; }
.ch-dots__grid { position: absolute; top: 0; bottom: 0; left: var(--x); border-left: 1px dashed var(--line); }
.ch-dots__grid:first-child { border-left: 1px solid var(--axis); }
.ch-dots__link { position: absolute; top: 50%; left: var(--a); width: calc(var(--b) - var(--a)); height: 2px; margin-top: -1px; background: var(--line-strong); }
.ch-dots__dot { position: absolute; top: 50%; left: var(--x); width: 11px; height: 11px; margin: -5.5px 0 0 -5.5px; border-radius: 50%; background: var(--s); }
.ch-dots__dot.is-them { background: var(--card); box-shadow: inset 0 0 0 2px var(--s); }
.ch-dots__diff { font-size: 12px; text-align: right; color: var(--muted); white-space: nowrap; }
.ch-dots__diff.is-none { font-size: 11.5px; }
.ch-dots__diff.is-strong { font-weight: 600; }
.ch-dots__diff.is-strong.is-up { color: var(--area-1-text, var(--area-1)); }
.ch-dots__diff.is-strong.is-down { color: var(--area-2); }

/* ---- Parts of a whole (stack, stackColumns) ----------------------------
   Parts in a fixed order, --stack-1 … 5, then the neutral rest; --p fills a
   part, --p-ink is the text printed on it. */
/* --stack-1 … 5, their inks and --stack-other are in tokens.css */
.ch-part[data-part="1"] { --p: var(--stack-1); --p-ink: var(--stack-1-ink, var(--ink-900)); }
.ch-part[data-part="2"] { --p: var(--stack-2); --p-ink: var(--stack-2-ink, var(--ink-900)); }
.ch-part[data-part="3"] { --p: var(--stack-3); --p-ink: var(--stack-3-ink, var(--ink-900)); }
.ch-part[data-part="4"] { --p: var(--stack-4); --p-ink: var(--stack-4-ink, var(--ink-900)); }
.ch-part[data-part="5"] { --p: var(--stack-5); --p-ink: var(--stack-5-ink, var(--ink-900)); }
.ch-part[data-part="other"] { --p: var(--stack-other, var(--line-strong)); --p-ink: var(--text); }
.ch-swatch.ch-part { background: var(--p); }
.ch-stack .ch-part { transition: opacity .12s; }
.ch-stack.has-on .ch-part:not(.is-on) { opacity: .3; }

.ch-stack { display: flex; flex-direction: column; gap: 14px; }
/* a part's value inside it: from 16% of the bar, or 25% when the card is narrow (the key always has them all) */
@container (max-width: 380px) { .ch-stack__seg .is-mid { display: none; } }
.ch-stack__bars { container-type: inline-size; display: grid; grid-template-columns: minmax(48px, max-content) minmax(0, 1fr); gap: 8px 12px; align-items: center; }
.ch-stack__name { font-size: 12.5px; color: var(--text-2); white-space: nowrap; }
.ch-stack__bar { display: flex; gap: 2px; height: 24px; border-radius: 6px; overflow: hidden; }
.ch-stack__bar.is-past { opacity: .55; }       /* an earlier census: first, and muted */
.ch-stack__seg { flex: 0 1 var(--w); min-width: 2px; display: flex; align-items: center; padding-left: 6px; overflow: hidden;
  background: var(--p); color: var(--p-ink); font-size: 11px; font-weight: 600; white-space: nowrap; }
.ch-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.ch-scol { position: relative; align-self: end; justify-self: center; width: 100%; max-width: 64px; height: var(--h);
  display: flex; flex-direction: column-reverse; }
.ch-scol.is-none { height: 0; }
.ch-scol__seg { flex: none; height: var(--h); min-height: 2px; display: flex; align-items: center; justify-content: center; overflow: hidden;
  background: var(--p); color: var(--p-ink); border-top: 2px solid var(--card); font-size: 10.5px; font-weight: 600; }
.ch-scol__seg:first-of-type { border-radius: 0; }
.ch-scol__seg:last-child { border-radius: 3px 3px 0 0; }
.ch-scol__seg.is-ahead { background: color-mix(in srgb, var(--p) 18%, transparent);
  outline: 1.5px dashed var(--p); outline-offset: -1.5px; color: var(--text); }
.ch-scol__total { position: absolute; bottom: 100%; left: 50%; transform: translateX(-50%); padding-bottom: 3px; font-size: 11px; color: var(--text-2); white-space: nowrap; }
.ch-scol__total.is-ahead { color: var(--accent-text); }
.ch-scol.is-none .ch-scol__total { color: var(--muted); }

/* ---- Headline figures (kpi, kpiRow) ------------------------------------ */
.ch-kpis { display: flex; flex-direction: column; gap: 12px; }
.ch-kpis__tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(240px, 100%), 1fr)); gap: var(--gap); }
.ch-kpis__note { margin: 0; font-size: 12.5px; color: var(--text-2); }
.ch-kpi { display: flex; flex-direction: column; align-items: flex-start; gap: 8px; }
.ch-kpi__label { font-size: 14.5px; color: var(--text); }
.ch-kpi__row { align-self: stretch; display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; }
.ch-kpi__value { font-size: 32px; font-weight: 600; letter-spacing: -0.02em; line-height: 1.05; }
.ch-kpi__chg { padding: 4px 10px; border-radius: 999px; background: var(--line); font-size: 13px; font-weight: 500; color: var(--text); }
.ch-kpi__vs { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-2); }
.ch-kpi__caption { font-size: 12.5px; color: var(--muted); }
.ch-kpi__line { font-size: 13px; color: var(--text-2); }
.ch-kpi.is-accent { --text: var(--kpi-accent-text); --text-2: var(--kpi-accent-text-2); --muted: var(--kpi-accent-text-2);
  --line: var(--kpi-accent-line); --line-strong: var(--kpi-accent-line); --area-1: var(--kpi-accent-text); --baseline: var(--kpi-accent-text);
  --card: var(--kpi-accent); background: var(--kpi-accent); border-color: var(--kpi-accent); color: var(--text); }

/* ---- Spans of years (gantt) ------------------------------------------- */
.ch-gt { container-type: inline-size; display: grid; grid-template-columns: minmax(64px, max-content) minmax(0, 1fr) 52px;
  grid-template-rows: repeat(var(--rows), 34px) auto; column-gap: 12px; align-items: center; }
.ch-gt__label { grid-column: 1; font-size: 12.5px; font-weight: 500; line-height: 1.25; }
.ch-gt__grid, .ch-gt__track, .ch-gt__axis { grid-column: 2; position: relative; }
.ch-gt__grid { grid-row: 1 / -2; align-self: stretch; }
.ch-gt__grid span { position: absolute; top: 0; bottom: 0; left: var(--x); border-left: 1px dashed var(--line); }
.ch-gt__track { display: flex; flex-direction: column; justify-content: center; gap: 3px; align-self: stretch; }
.ch-gt__bar { position: relative; left: var(--a); width: calc(var(--b) - var(--a)); height: 14px; border-radius: 3px; background: var(--c); }
.ch-gt__bar.is-them { height: 6px; border-radius: 2px; }
.ch-gt__bar[data-role="future"] { height: 7px; }
.ch-gt__bar.is-open { border-left: 2px dashed var(--card); }
.ch-gt__vals { grid-column: 3; display: flex; flex-direction: column; align-items: flex-end; line-height: 1.2; }
.ch-gt__val { font-size: 12.5px; font-weight: 600; color: var(--area-1-text, var(--area-1)); }
.ch-gt__val.is-them { font-size: 11px; font-weight: 400; color: var(--muted); }
.ch-gt__val.is-them[data-role="future"] { color: var(--accent-text); }
.ch-gt__axis { grid-row: -2; height: 24px; }
.ch-gt__axis span { position: absolute; top: 6px; left: var(--x); transform: translateX(-50%); font-size: 11.5px; color: var(--muted); }
@container (max-width: 420px) { .ch-gt__axis .is-minor { display: none; } }

/* ---- Homes as a street (street) ---------------------------------------- */
.ch-street { display: flex; flex-direction: column; gap: 4px; }
.ch-street + .ch-street { margin-top: 10px; }
.ch-street__name { margin: 0; font-size: 14px; font-weight: 500; }
.ch-street__name[data-role="target"] { color: var(--area-2); }
.ch-street__name[data-role="past"], .ch-street__name[data-role="future"] { color: var(--text-2); }
.ch-street__scroll { overflow-x: auto; }
.ch-street__inner { min-width: 560px; }
.ch-street__draw { position: relative; }
.ch-street__svg { display: block; width: 100%; height: auto; overflow: visible; }
.ch-street__svg :not(.ch-hit) { pointer-events: none; }
.ch-street__wall { fill: var(--street-wall); }
.ch-street__roof { fill: var(--street-roof); }
.ch-street__semi { fill: var(--street-semi); }
.ch-street__flat[data-tone="1"] { fill: var(--street-flat-1); }
.ch-street__flat[data-tone="2"] { fill: var(--street-flat-2); }
.ch-street__flat[data-tone="3"] { fill: var(--street-flat-3); }
.ch-street__flat[data-tone="4"] { fill: var(--street-flat-4); }
.ch-street__window { fill: var(--card); opacity: .55; }
.ch-street__ground { stroke: var(--axis); stroke-width: 1.5; vector-effect: non-scaling-stroke; }
.ch-street .ch-hit.is-tip { fill: var(--line); opacity: .35; }
.ch-street__flag { position: absolute; right: calc(100% - var(--x)); top: var(--y); transform: translate(4px, calc(-100% - 4px));
  font-size: 11.5px; color: var(--text-2); white-space: nowrap; pointer-events: none; }
.ch-street__groups { position: relative; height: 40px; }
.ch-street__group { position: absolute; top: 4px; left: var(--x); width: var(--w); display: flex; flex-direction: column; align-items: center;
  padding-top: 6px; border-top: 1px solid var(--axis); font-size: 12.5px; line-height: 1.3; white-space: nowrap; }
.ch-street__group::before, .ch-street__group::after { content: ''; position: absolute; top: -4px; height: 7px; border-left: 1px solid var(--axis); }
.ch-street__group::before { left: 0; }
.ch-street__group::after { right: 0; }
.ch-street__group-name { font-weight: 500; }
.ch-street__group-v { font-weight: 600; color: var(--area-1-text, var(--area-1)); }
.ch-street__group-v[data-role="target"] { color: var(--area-2); }
.ch-street__group-v[data-role="past"], .ch-street__group-v[data-role="future"] { color: var(--muted); }

/* ---- Diverging bars ---------------------------------------------------- */
.ch-div { display: grid; grid-template-columns: minmax(90px, max-content) minmax(0, 1fr) 64px; gap: 12px 10px; align-items: center; }
.ch-div__ends { display: flex; justify-content: space-between; gap: 6px; font-size: 10.5px; color: var(--muted); white-space: nowrap; }
.ch-div__label { font-size: 12.5px; }
.ch-div__track { position: relative; height: 14px; }
.ch-div__track::before { content: ''; position: absolute; left: 50%; top: -4px; bottom: -4px; border-left: 1px solid var(--axis); }
.ch-div__bar { position: absolute; left: 50%; top: 0; bottom: 0; width: var(--w); min-width: 2px; background: var(--bar-1); border-radius: 0 3px 3px 0; }
.ch-div__bar.is-below { left: auto; right: 50%; border-radius: 3px 0 0 3px; }
.ch-div__val { font-size: 12px; text-align: right; white-space: nowrap; }

/* ---- Chart cards (card.js): the house anatomy --------------------------
   title · subtitle · sentence · key · chart · note · foot, Show data top right.
   Cards in a row are the same height: lines and columns grow into the spare
   height, the rest sit at the top, and the footer sits on the bottom edge. */
.ch-card { display: flex; flex-direction: column; gap: 12px; min-width: 0; }
.ch-card.is-wide, .ch-kpis { grid-column: 1 / -1; }          /* across the whole grid */
.ch-card__head { display: grid; grid-template-columns: minmax(0, 1fr) auto; align-items: start; gap: 2px 12px; }
.ch-card__tools { grid-row: 1; grid-column: 2; display: flex; gap: 6px; margin-top: -4px; }   /* on the title's line only */
.ch-card__title a { color: inherit; }
.ch-card__title a:hover { color: var(--link-hover); }
.ch-card__subtitle { grid-column: 1 / -1; }
.ch-card__title { margin: 0; font-size: 15px; font-weight: 400; line-height: 1.4; }
.ch-card__subtitle { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--muted); }   /* 12.5: one line in Onest at phone width */
.ch-card__data, .ch-card__tools > .btn-icon { flex: none; width: 30px; height: 30px; display: grid; place-items: center; padding: 0; border: 1px solid var(--line);
  border-radius: 8px; background: transparent; color: var(--text-2); }
.ch-card__data:hover { color: var(--text); border-color: var(--line-strong); }
.ch-card__data[aria-pressed="true"] { background: var(--line); color: var(--text); }
.ch-card__sentence { margin: 0; font-size: 14px; line-height: 1.45; min-height: 2.9em; }      /* two lines kept, so charts line up */
.ch-card__chart { min-width: 0; }
.ch-card__chart.is-fill { flex: 1; display: flex; flex-direction: column; min-height: 240px; position: relative; }
.ch-card__chart.is-fill > .ch-cols, .ch-card__chart.is-fill > .ch-stack { flex: 1; }
.ch-card__chart.is-fill > .ch-stack > .ch-cols { flex: 1; }
.ch-fill { position: absolute; inset: 0; }                                   /* a chart drawn at the card's size (fit) */
.ch-card.is-data .ch-card__chart, .ch-card.is-data .ch-card__key { display: none; }
.ch-card__table { overflow-x: auto; }
.ch-card__note { margin: 0; font-size: 12.5px; line-height: 1.4; color: var(--text-2); }
.ch-card__foot { margin: auto 0 0; padding-top: 2px; font-size: 12.5px; color: var(--muted); white-space: normal; }

.ch-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ch-table th, .ch-table td { padding: 6px 0 6px 12px; border-bottom: 1px solid var(--line); text-align: right; white-space: nowrap; }
.ch-table th:first-child { padding-left: 0; text-align: left; font-weight: 400; white-space: normal; }
.ch-table thead th { font-size: 11.5px; font-weight: 500; color: var(--muted); }
.ch-table td { font-weight: 500; }
