/* Charts and infographics (src/charts.js, public/js/charts-core.js).
   The poster keeps its own navy and teal in every colour story. Its colours are set here, once for light and once for
   dark; everything below uses them. --viz-1 … --viz-6 were checked with the dataviz palette validator against --viz-bg
   in both modes (lightness, chroma, colour-blind and normal-vision separation, 3:1 contrast). Check again if you change
   them. --viz-on-* is the text drawn on top of each one. */
:root {
  --viz-bg: #FFFFFF; --viz-page: #F4F7FA; --viz-ink: #1D2B40; --viz-ink-2: #4B5A70; --viz-line: #DCE3EC; --viz-zero: #8290A5;
  --viz-head: #252D49; --viz-pill: #25384E; --viz-on-dark: #FFFFFF; --viz-edge: #5AA3B2; --viz-link: #0B6E75;
  --viz-1: #3460B4; --viz-2: #0F9488; --viz-3: #C96F22; --viz-4: #7B55C7; --viz-5: #C9487C; --viz-6: #5B8C2A; --viz-quiet: #A9B4C4;
  --viz-on-1: #FFFFFF; --viz-on-2: #0B1526; --viz-on-3: #0B1526; --viz-on-4: #FFFFFF; --viz-on-5: #0B1526; --viz-on-6: #0B1526; --viz-on-quiet: #0B1526;
}
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --viz-bg: #1B2438; --viz-page: #141B2B; --viz-ink: #EEF3FA; --viz-ink-2: #B4C0D2; --viz-line: #34415A; --viz-zero: #7F8DA6;
    --viz-head: #0E1424; --viz-pill: #2C4A66; --viz-edge: #4E93A3; --viz-link: #7FD3DA;
    --viz-1: #5C86E6; --viz-2: #12A596; --viz-3: #CC7A30; --viz-4: #9673DA; --viz-5: #D45C8A; --viz-6: #6C9A38; --viz-quiet: #66748E;
    --viz-on-1: #0B1526; --viz-on-4: #0B1526; --viz-on-quiet: #FFFFFF;
  }
}
:root[data-theme="dark"] {
  --viz-bg: #1B2438; --viz-page: #141B2B; --viz-ink: #EEF3FA; --viz-ink-2: #B4C0D2; --viz-line: #34415A; --viz-zero: #7F8DA6;
  --viz-head: #0E1424; --viz-pill: #2C4A66; --viz-edge: #4E93A3; --viz-link: #7FD3DA;
  --viz-1: #5C86E6; --viz-2: #12A596; --viz-3: #CC7A30; --viz-4: #9673DA; --viz-5: #D45C8A; --viz-6: #6C9A38; --viz-quiet: #66748E;
  --viz-on-1: #0B1526; --viz-on-4: #0B1526; --viz-on-quiet: #FFFFFF;
}

/* ── the poster ── */
.ig { max-width: 1080px; margin-inline: auto; background: var(--viz-page); color: var(--viz-ink); border-radius: var(--radius-lg); overflow: clip; box-shadow: var(--shadow-glass); }
.ig__head { display: flex; align-items: center; gap: clamp(20px, 5vw, 64px); padding: clamp(28px, 5vw, 56px) clamp(20px, 5vw, 60px); background: var(--viz-head); }
.ig__head::after { content: ''; flex: 1; min-width: 32px; height: 5px; background: var(--viz-on-dark); }
.ig__head h2 { margin: 0; color: var(--viz-on-dark); font: 700 clamp(1.7rem, 4.6vw, 3.1rem)/1.1 var(--font-body); letter-spacing: 0; text-transform: uppercase; }
.ig__parts { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 44px clamp(16px, 2.4vw, 28px); padding: 48px clamp(14px, 3vw, 36px) clamp(24px, 3vw, 36px); }
.ig__part { position: relative; display: flex; flex-direction: column; gap: 20px; min-width: 0; padding: 40px clamp(16px, 2.4vw, 28px) clamp(18px, 2.4vw, 28px); background: var(--viz-bg); border: 3px solid var(--viz-edge); border-radius: 22px; }
.ig__part--wide { grid-column: 1 / -1; }
.ig__label { position: absolute; top: 0; left: 50%; translate: -50% -50%; margin: 0; padding: 7px 28px; background: var(--viz-pill); color: var(--viz-on-dark); border-radius: var(--radius-pill); font-weight: 700; line-height: 1.3; white-space: nowrap; }
.ig__text { text-align: center; max-width: 62ch; margin-inline: auto; }
.ig__text h3 { margin: 0 0 .4em; color: var(--viz-ink); font: 700 clamp(1.25rem, 2.1vw, 1.55rem)/1.25 var(--font-body); letter-spacing: 0; text-wrap: balance; }
.ig__text p { margin: 0 0 .8em; color: var(--viz-ink); }
.ig__text p:last-child { margin: 0; }
.ig__charts { display: grid; gap: 20px; align-content: start; }
/* cards side by side start their charts on the same line, and switching views never moves the buttons */
.ig__part:not(.ig__part--wide) { display: grid; grid-row: span 2; grid-template-rows: subgrid; }
.ig__part--wide.has-charts { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.15fr); align-items: center; gap: clamp(20px, 3vw, 40px); }
.ig__foot { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px 28px; padding: 16px clamp(20px, 4vw, 44px); background: var(--viz-pill); color: var(--viz-on-dark); font-size: .92rem; font-weight: 600; }
.ig__foot p { margin: 0; }
.ig__foot a { color: inherit; }
.ig__src { display: flex; flex-wrap: wrap; gap: 4px 18px; }
.ig__site { display: flex; align-items: center; gap: 12px; }
.ig__emblem { width: 42px; height: 42px; fill: none; stroke: currentColor; stroke-width: 2.6; stroke-linecap: round; flex: none; }
.ig__emblem circle { fill: currentColor; stroke: none; }
.ig :focus-visible, .viz :focus-visible { outline-color: var(--viz-link); }

/* words that pick out a value (pressable once charts.js runs) */
.viz-link[role="button"] { color: var(--viz-link); font-weight: 600; text-decoration: underline dotted; text-underline-offset: 4px; cursor: pointer; border-radius: 4px; }
.viz-link[aria-pressed="true"] { background: color-mix(in srgb, var(--viz-link) 16%, transparent); text-decoration-style: solid; }

/* ── one chart ── */
.viz { position: relative; margin: 0; min-width: 0; padding: clamp(14px, 2vw, 20px); background: var(--viz-bg); color: var(--viz-ink); border-radius: 14px; font-size: .95rem; line-height: 1.45; container-type: inline-size; }
.ig .viz { padding: 18px 0 0; border-top: 1px solid var(--viz-line); border-radius: 0; }
.ig__part--wide .viz { padding: 0; border-top: 0; }
.viz__head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 10px 16px; margin-bottom: 16px; }
.viz__head > div:first-child { flex: 1 1 200px; min-width: 0; }
.viz__title { margin: 0; color: var(--viz-ink); font: 650 1.08rem/1.3 var(--font-body); letter-spacing: 0; text-wrap: balance; }
.viz__sum { margin: 4px 0 0; color: var(--viz-ink-2); }
.viz__views { display: flex; gap: 2px; padding: 3px; border: 1px solid var(--viz-line); border-radius: 12px; background: var(--viz-page); }
.viz__views[hidden] { display: none; }
.viz__views button { display: grid; place-items: center; width: 38px; height: 36px; padding: 0; border: 0; border-radius: 9px; background: none; color: var(--viz-ink-2); cursor: pointer; }
.viz__views button:hover { color: var(--viz-ink); }
.viz__views button[aria-pressed="true"] { background: var(--viz-pill); color: var(--viz-on-dark); }
.viz__views svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.viz-val { font-weight: 650; color: var(--viz-ink); white-space: nowrap; pointer-events: none; }
.viz-mark { cursor: pointer; transition: opacity .2s, filter .2s, transform .2s; }
.viz-mark:focus-visible { border-radius: 4px; }
.viz-mark:is(:hover, :focus-visible) { filter: brightness(1.1); }
.viz.is-picking .viz-mark:not(.is-on) { opacity: .28; }

/* columns and lines share a plot: scale on the left, labels underneath */
.viz-cols { --gutter: 4.2em; }
.viz-area { position: relative; height: 230px; margin: 1.6em 0 8px var(--gutter); }
.viz-grid span { position: absolute; left: 0; right: 0; border-top: 1px solid var(--viz-line); }
.viz-grid .is-zero { border-color: var(--viz-zero); }
.viz-grid i { position: absolute; right: 100%; top: 0; translate: -8px -50%; color: var(--viz-ink-2); font: 400 .8rem/1 var(--font-body); font-variant-numeric: tabular-nums; white-space: nowrap; }
.viz-cols__in, .viz-lines__in { position: absolute; inset: 0; }
.viz-cols__in { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); }
.viz-cols__g { display: flex; justify-content: center; gap: 2px; padding-inline: 6%; }
.viz-col { position: relative; flex: 0 1 44px; min-width: 3px; height: 100%; }
.viz-col__b { position: absolute; left: 0; right: 0; bottom: var(--from); height: var(--size); background: var(--c); border-radius: 4px 4px 0 0; transform-origin: bottom; }
.is-neg > .viz-col__b { border-radius: 0 0 4px 4px; transform-origin: top; }
.viz-col .viz-val { position: absolute; left: 50%; bottom: 100%; translate: -50% -2px; }
.viz-col.is-neg .viz-val { bottom: auto; top: 100%; translate: -50% 2px; }
.viz-x { display: grid; grid-template-columns: repeat(var(--n), minmax(0, 1fr)); margin-left: var(--gutter); color: var(--viz-ink-2); font-size: .85rem; line-height: 1.25; text-align: center; }
.viz-x span { padding-inline: 2px; overflow-wrap: anywhere; }
.viz-lines__in svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.viz-line { fill: none; stroke: var(--c); stroke-width: 2; stroke-linejoin: round; stroke-linecap: round; vector-effect: non-scaling-stroke; }
.viz-fill { fill: var(--c); opacity: .12; }
.viz-dot { position: absolute; width: 28px; height: 28px; margin: 0 0 -14px -14px; display: grid; place-items: center; }
.viz-dot::before { content: ''; width: 9px; height: 9px; border-radius: 50%; background: var(--c); box-shadow: 0 0 0 2px var(--viz-bg); }
.viz-dot .viz-val { position: absolute; bottom: 100%; translate: 0 6px; }

/* bars: name, bar, figure */
.viz-bars { display: grid; gap: 12px; }
.viz-bars__row { display: grid; grid-template-columns: minmax(0, 9.5em) minmax(0, 1fr); gap: 12px; align-items: center; }
.viz-bars__l { color: var(--viz-ink-2); text-align: right; line-height: 1.25; overflow-wrap: anywhere; }
.viz-bars__t { display: grid; gap: 2px; margin-right: 6.2em; border-left: 1px solid var(--viz-zero); }
.viz-bars__t:has(.is-neg) { border-left: 0; }
.viz-bar { position: relative; display: block; height: 24px; }
.viz-bar__b { position: absolute; inset-block: 0; left: var(--from); width: var(--size); background: var(--c); border-radius: 0 4px 4px 0; transform-origin: left; }
.is-neg > .viz-bar__b { border-radius: 4px 0 0 4px; transform-origin: right; }
.viz-bar .viz-val { position: absolute; left: calc(var(--from) + var(--size) + 8px); line-height: 24px; }

/* pie and donut */
.viz-pie { display: grid; grid-template-columns: minmax(150px, 1fr) minmax(0, 1.1fr); align-items: center; gap: 20px; }
.viz-pie__c { position: relative; width: 100%; max-width: 250px; margin-inline: auto; }
.viz-pie svg { display: block; width: 100%; overflow: visible; }
.viz-slice { fill: var(--c); fill-rule: evenodd; stroke: var(--viz-bg); stroke-width: 2; stroke-linejoin: round; }
.viz-slice:is(:hover, :focus-visible, .is-on) { transform: translate(var(--dx), var(--dy)); }
.viz-slice:focus-visible { outline: none; stroke: var(--viz-link); stroke-width: 4; paint-order: stroke; }
.viz-pie__mid { position: absolute; inset: 24%; margin: 0; display: grid; place-content: center; text-align: center; pointer-events: none; line-height: 1.2; }
.viz-pie__mid b { font-size: 1.6rem; font-weight: 650; }
.viz-pie__mid span { color: var(--viz-ink-2); font-size: .85rem; }

.viz-split { display: flex; gap: 2px; margin-bottom: 14px; }
.viz-seg { flex: var(--size) 1 0; min-width: 4px; height: 28px; padding-inline: 8px; background: var(--c); border-radius: 4px; }
.viz-seg:not(:has(.viz-val)) { padding: 0; }
.viz-seg .viz-val { color: var(--on); line-height: 28px; }
@container (max-width: 420px) { .viz-seg { padding-inline: 4px; } .viz-seg .viz-val { font-size: .74rem; } }

.viz-people { margin-bottom: 14px; }
.viz-people svg { display: block; width: 100%; overflow: visible; }
.viz-crowd { fill: var(--c); }
.viz-crowd rect { fill: transparent; }
.viz-crowd:focus-visible { outline: none; stroke: var(--viz-link); stroke-width: .9; }
.viz-crowd:focus-visible rect { stroke: none; }
.viz-people__key { margin: 8px 0 0; color: var(--viz-ink-2); font-size: .85rem; }

.viz-nums { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 12px; }
.viz-num { display: grid; align-content: start; gap: 4px; padding: 14px 16px; border: 1px solid var(--viz-line); border-top: 4px solid var(--c); border-radius: 10px; }
.viz-num b { font-size: 1.9rem; font-weight: 650; line-height: 1.1; }
.viz-num span { color: var(--viz-ink-2); }

/* key */
.viz-key { display: flex; flex-wrap: wrap; gap: 2px 6px; margin: 12px 0 0; padding: 0; list-style: none; }
.viz-key__b { display: flex; align-items: center; gap: 9px; width: 100%; min-height: 36px; padding: 5px 9px; border: 0; border-radius: 9px; background: none; color: var(--viz-ink); font: inherit; text-align: left; }
.js-viz .viz-key__b { cursor: pointer; }
.js-viz .viz-key__b:is(:hover, [aria-pressed="true"]) { background: color-mix(in srgb, var(--viz-ink) 8%, transparent); }
.viz-key__b i { flex: none; width: 12px; height: 12px; border-radius: 3px; background: var(--c); }
.viz-key__b b { margin-left: auto; padding-left: 10px; font-weight: 650; text-align: right; }
.viz-pie .viz-key { display: grid; margin: 0; }
@container (max-width: 430px) {
  .viz-pie { grid-template-columns: minmax(0, 1fr); }
  .viz-bars__row { grid-template-columns: minmax(0, 1fr); gap: 3px; }
  .viz-bars__l { text-align: left; }
}

/* numbers, notes, CSV */
.viz__more { margin-top: 14px; color: var(--viz-ink-2); font-size: .9rem; }
.viz__more summary { width: fit-content; padding: 6px 0; cursor: pointer; color: var(--viz-link); font-weight: 600; }
.viz__more p { margin: 10px 0 0; }
.viz__scroll { overflow-x: auto; }
.viz-table { width: 100%; border-collapse: collapse; color: var(--viz-ink); }
.viz-table :is(th, td) { padding: 7px 8px; border-bottom: 1px solid var(--viz-line); text-align: right; font-weight: 400; font-variant-numeric: tabular-nums; }
.viz-table :is(th, td):first-child { padding-left: 0; text-align: left; }
.viz-table thead th { color: var(--viz-ink-2); font-weight: 600; }
.viz__csv { margin-top: 12px; padding: 8px 14px; border: 1px solid var(--viz-zero); border-radius: var(--radius-pill); background: none; color: var(--viz-ink); font: 600 .88rem/1.3 var(--font-body); cursor: pointer; }
.viz__csv:hover { background: color-mix(in srgb, var(--viz-ink) 8%, transparent); }
.viz__csv[hidden] { display: none; }

/* tooltip: one for the page, placed by charts.js */
.viz-tip { position: fixed; z-index: 60; left: 0; top: 0; max-width: min(260px, calc(100vw - 16px)); padding: 9px 12px; border-radius: 10px; background: var(--viz-ink); color: var(--viz-bg); font: 400 .88rem/1.4 var(--font-body); box-shadow: 0 8px 24px rgb(0 0 0 / .28); pointer-events: none; }
.viz-tip[hidden] { display: none; }
.viz-tip b { display: block; font-size: 1.05rem; font-weight: 650; }
.viz-tip__r { display: flex; align-items: center; gap: 8px; }
.viz-tip__r::before { content: ''; width: 12px; height: 3px; border-radius: 2px; background: var(--c); }
.viz-tip__r b { display: inline; font-size: inherit; }

/* drawn in when a chart scrolls into view, and when its view changes */
@media (prefers-reduced-motion: no-preference) {
  .viz.is-waiting .viz__plot { opacity: 0; }
  .viz.is-drawing .viz-col__b { animation: viz-up .7s cubic-bezier(.2, .8, .2, 1) backwards; }
  .viz.is-drawing .viz-bar__b { animation: viz-across .7s cubic-bezier(.2, .8, .2, 1) backwards; }
  .viz.is-drawing :is(.viz-slice, .viz-seg, .viz-crowd, .viz-num, .viz-dot, .viz-fill, .viz-val, .viz-line) { animation: viz-in .6s ease backwards; }
  .viz.is-drawing .viz-mark:nth-child(2), .viz.is-drawing :is(.viz-cols__g, .viz-bars__row):nth-child(2) :is(.viz-col__b, .viz-bar__b) { animation-delay: .12s; }
  .viz.is-drawing .viz-mark:nth-child(n + 3), .viz.is-drawing :is(.viz-cols__g, .viz-bars__row):nth-child(n + 3) :is(.viz-col__b, .viz-bar__b) { animation-delay: .24s; }
}
@keyframes viz-up { from { transform: scaleY(0); } }
@keyframes viz-across { from { transform: scaleX(0); } }
@keyframes viz-in { from { opacity: 0; } }
@media (prefers-reduced-motion: reduce) { .viz-mark { transition: none; } .viz-slice:is(:hover, :focus-visible, .is-on) { transform: none; } }

/* the small still picture on a project card */
.viz-tile, .viz-tile svg { display: block; width: 100%; height: 100%; }
.viz-tile__bg { fill: var(--viz-page); }
.viz-tile__band { fill: var(--viz-head); }
.viz-tile__grid { stroke: var(--viz-line); fill: none; }
.viz-tile__bar { fill: var(--viz-1); }

@media (max-width: 767px) {
  .ig__parts, .ig__part--wide.has-charts { grid-template-columns: minmax(0, 1fr); }
  .ig__part:not(.ig__part--wide) { grid-row: auto; grid-template-rows: auto; }
  .ig__part--wide .viz { padding-top: 18px; border-top: 1px solid var(--viz-line); }
  .viz__views button { width: 44px; height: 44px; }
  .viz-key__b { min-height: 44px; }
  .ig__foot { flex-direction: column; text-align: center; }
  .ig__src { justify-content: center; }
}
@media (forced-colors: active) {
  .viz-col__b, .viz-bar__b, .viz-seg, .viz-key__b i, .viz-dot::before, .viz-slice, .viz-crowd, .viz-tile { forced-color-adjust: none; }
}
@media print { .viz__views, .viz__csv { display: none; } .ig, .viz { print-color-adjust: exact; -webkit-print-color-adjust: exact; } }
