/*
 * Creditcrest Research — choropleth maps (src/research/svg-map.js).
 *
 * The site allows no script and no inline style (site/_headers), so a map's
 * layers are switched here: every area's <path> carries one class per layer
 * (l{layer}{s|d}{swatch} or l{layer}n), and a class is coloured only while
 * that layer's radio button (class rs-l{layer}) is checked. :has() is in
 * Safari from 15.4, Chrome from 105 and Firefox from 121; without it, layer 1
 * shows and its legend with it.
 *
 * The scheme is fixed — eight layers, seven swatches per palette — so this
 * file is written once; tests/svg-map.js checks it covers every class
 * src/research/svg-map.js can write.
 *
 * Palettes are ColorBrewer's YlGnBu (sequential) and RdBu (diverging), both
 * safe for the common forms of colour blindness; in dark mode, the same hues
 * run from dark (low, or near the middle) to light (high, or far from it).
 * No data is a plain light grey.
 */

:root {
  --rs-s0: #ffffcc; --rs-s1: #c7e9b4; --rs-s2: #7fcdbb; --rs-s3: #41b6c4; --rs-s4: #1d91c0; --rs-s5: #225ea8; --rs-s6: #0c2c84;
  --rs-d0: #b2182b; --rs-d1: #ef8a62; --rs-d2: #fddbc7; --rs-d3: #f7f7f7; --rs-d4: #d1e5f0; --rs-d5: #67a9cf; --rs-d6: #2166ac;
  --rs-na: #d5d9e0;
  --rs-edge: rgba(7, 13, 36, .2);
  --rs-outline: #070D24;
  --rs-hover: #070D24;
}
:root[data-theme="dark"] {
  --rs-s0: #1b2a5c; --rs-s1: #1f4e8f; --rs-s2: #2a7fb8; --rs-s3: #41b6c4; --rs-s4: #7fcdbb; --rs-s5: #c7e9b4; --rs-s6: #ffffcc;
  --rs-d0: #f4a582; --rs-d1: #c4554a; --rs-d2: #6e3a40; --rs-d3: #3b4256; --rs-d4: #2d5a80; --rs-d5: #4f9ad0; --rs-d6: #a6d4ef;
  --rs-na: #4b5163;
  --rs-edge: rgba(7, 13, 36, .55);
  --rs-outline: #B4C3E3;
  --rs-hover: #FFFFFF;
}

/* ---------- layout ---------- */
.rs-map { margin: 0 0 28px; max-width: 100%; }
.rs-map-layers { border: 0; margin: 0 0 10px; padding: 0; display: flex; flex-wrap: wrap; gap: 6px 18px; }
.rs-map-layers legend { padding: 0; margin: 0 0 6px; font-size: 13px; font-weight: 600; letter-spacing: .04em; text-transform: uppercase; color: var(--muted, #53617D); }
.rs-map-layers label { display: inline-flex; align-items: center; gap: 8px; min-height: 32px; font-size: 15px; color: var(--text, #333E5B); cursor: pointer; }
.rs-map-layers input { width: 18px; height: 18px; margin: 0; accent-color: var(--cobalt, #2457FF); cursor: pointer; }
.rs-map-layers input:focus-visible { outline: 3px solid var(--cobalt, #2457FF); outline-offset: 3px; }
:root[data-theme="dark"] .rs-map-layers input:focus-visible { outline-color: var(--ice, #79DFFF); }

.rs-lgs { margin: 0 0 10px; }
.rs-lg { display: none; }
.rs-lg-title { margin: 0 0 6px; font-size: 14px; font-weight: 600; color: var(--text, #333E5B); }
.rs-lg ul { list-style: none; margin: 0; padding: 0; display: flex; flex-wrap: wrap; gap: 4px 14px; }
.rs-lg li { display: inline-flex; align-items: center; gap: 6px; font-size: 13px; line-height: 1.3; color: var(--text, #333E5B); }
.rs-sw { display: inline-block; width: 14px; height: 14px; border-radius: 3px; border: 1px solid var(--rs-edge); flex: none; }

.rs-map-svg, .rs-inset-svg { display: block; width: 100%; height: auto; }
.rs-insets { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; margin-top: 12px; }
.rs-inset { margin: 0; }
.rs-inset-svg { border: 1px solid var(--line, #DEE5F3); border-radius: 6px; }
.rs-inset-label { margin: 4px 0 0; font-size: 13px; color: var(--muted, #53617D); }
.rs-map figcaption { margin-top: 8px; font-size: 13px; color: var(--muted, #53617D); }

/* ---------- areas ---------- */
.rs-areas path { fill: var(--rs-na); fill-rule: evenodd; stroke: var(--rs-edge); stroke-width: .5px; vector-effect: non-scaling-stroke; stroke-linejoin: round; }
.rs-areas path:hover { stroke: var(--rs-hover); stroke-width: 1.5px; }
.rs-ste { fill: none; stroke: var(--rs-outline); stroke-width: 1px; vector-effect: non-scaling-stroke; stroke-linejoin: round; pointer-events: none; }

/* ---------- swatches ---------- */
.rs-s0 { background: var(--rs-s0); }
.rs-s1 { background: var(--rs-s1); }
.rs-s2 { background: var(--rs-s2); }
.rs-s3 { background: var(--rs-s3); }
.rs-s4 { background: var(--rs-s4); }
.rs-s5 { background: var(--rs-s5); }
.rs-s6 { background: var(--rs-s6); }
.rs-d0 { background: var(--rs-d0); }
.rs-d1 { background: var(--rs-d1); }
.rs-d2 { background: var(--rs-d2); }
.rs-d3 { background: var(--rs-d3); }
.rs-d4 { background: var(--rs-d4); }
.rs-d5 { background: var(--rs-d5); }
.rs-d6 { background: var(--rs-d6); }
.rs-n { background: var(--rs-na); }

/* ---------- layer 1 by default, for browsers without :has() ---------- */
.rs-lg1 { display: block; }
.rs-areas .l1s0 { fill: var(--rs-s0); }
.rs-areas .l1s1 { fill: var(--rs-s1); }
.rs-areas .l1s2 { fill: var(--rs-s2); }
.rs-areas .l1s3 { fill: var(--rs-s3); }
.rs-areas .l1s4 { fill: var(--rs-s4); }
.rs-areas .l1s5 { fill: var(--rs-s5); }
.rs-areas .l1s6 { fill: var(--rs-s6); }
.rs-areas .l1d0 { fill: var(--rs-d0); }
.rs-areas .l1d1 { fill: var(--rs-d1); }
.rs-areas .l1d2 { fill: var(--rs-d2); }
.rs-areas .l1d3 { fill: var(--rs-d3); }
.rs-areas .l1d4 { fill: var(--rs-d4); }
.rs-areas .l1d5 { fill: var(--rs-d5); }
.rs-areas .l1d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-map-layers input:checked:not(.rs-l1)) .rs-lg1 { display: none; }

/* ---------- each layer, while its radio is checked ---------- */

/* layer 1 */
.rs-map:has(.rs-l1:checked) .rs-lg1 { display: block; }
.rs-map:has(.rs-l1:checked) .l1s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l1:checked) .l1s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l1:checked) .l1s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l1:checked) .l1s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l1:checked) .l1s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l1:checked) .l1s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l1:checked) .l1s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l1:checked) .l1d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l1:checked) .l1d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l1:checked) .l1d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l1:checked) .l1d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l1:checked) .l1d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l1:checked) .l1d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l1:checked) .l1d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l1:checked) .l1n { fill: var(--rs-na); }

/* layer 2 */
.rs-map:has(.rs-l2:checked) .rs-lg2 { display: block; }
.rs-map:has(.rs-l2:checked) .l2s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l2:checked) .l2s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l2:checked) .l2s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l2:checked) .l2s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l2:checked) .l2s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l2:checked) .l2s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l2:checked) .l2s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l2:checked) .l2d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l2:checked) .l2d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l2:checked) .l2d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l2:checked) .l2d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l2:checked) .l2d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l2:checked) .l2d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l2:checked) .l2d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l2:checked) .l2n { fill: var(--rs-na); }

/* layer 3 */
.rs-map:has(.rs-l3:checked) .rs-lg3 { display: block; }
.rs-map:has(.rs-l3:checked) .l3s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l3:checked) .l3s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l3:checked) .l3s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l3:checked) .l3s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l3:checked) .l3s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l3:checked) .l3s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l3:checked) .l3s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l3:checked) .l3d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l3:checked) .l3d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l3:checked) .l3d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l3:checked) .l3d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l3:checked) .l3d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l3:checked) .l3d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l3:checked) .l3d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l3:checked) .l3n { fill: var(--rs-na); }

/* layer 4 */
.rs-map:has(.rs-l4:checked) .rs-lg4 { display: block; }
.rs-map:has(.rs-l4:checked) .l4s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l4:checked) .l4s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l4:checked) .l4s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l4:checked) .l4s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l4:checked) .l4s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l4:checked) .l4s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l4:checked) .l4s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l4:checked) .l4d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l4:checked) .l4d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l4:checked) .l4d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l4:checked) .l4d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l4:checked) .l4d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l4:checked) .l4d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l4:checked) .l4d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l4:checked) .l4n { fill: var(--rs-na); }

/* layer 5 */
.rs-map:has(.rs-l5:checked) .rs-lg5 { display: block; }
.rs-map:has(.rs-l5:checked) .l5s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l5:checked) .l5s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l5:checked) .l5s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l5:checked) .l5s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l5:checked) .l5s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l5:checked) .l5s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l5:checked) .l5s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l5:checked) .l5d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l5:checked) .l5d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l5:checked) .l5d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l5:checked) .l5d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l5:checked) .l5d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l5:checked) .l5d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l5:checked) .l5d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l5:checked) .l5n { fill: var(--rs-na); }

/* layer 6 */
.rs-map:has(.rs-l6:checked) .rs-lg6 { display: block; }
.rs-map:has(.rs-l6:checked) .l6s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l6:checked) .l6s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l6:checked) .l6s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l6:checked) .l6s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l6:checked) .l6s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l6:checked) .l6s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l6:checked) .l6s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l6:checked) .l6d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l6:checked) .l6d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l6:checked) .l6d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l6:checked) .l6d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l6:checked) .l6d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l6:checked) .l6d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l6:checked) .l6d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l6:checked) .l6n { fill: var(--rs-na); }

/* layer 7 */
.rs-map:has(.rs-l7:checked) .rs-lg7 { display: block; }
.rs-map:has(.rs-l7:checked) .l7s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l7:checked) .l7s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l7:checked) .l7s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l7:checked) .l7s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l7:checked) .l7s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l7:checked) .l7s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l7:checked) .l7s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l7:checked) .l7d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l7:checked) .l7d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l7:checked) .l7d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l7:checked) .l7d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l7:checked) .l7d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l7:checked) .l7d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l7:checked) .l7d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l7:checked) .l7n { fill: var(--rs-na); }

/* layer 8 */
.rs-map:has(.rs-l8:checked) .rs-lg8 { display: block; }
.rs-map:has(.rs-l8:checked) .l8s0 { fill: var(--rs-s0); }
.rs-map:has(.rs-l8:checked) .l8s1 { fill: var(--rs-s1); }
.rs-map:has(.rs-l8:checked) .l8s2 { fill: var(--rs-s2); }
.rs-map:has(.rs-l8:checked) .l8s3 { fill: var(--rs-s3); }
.rs-map:has(.rs-l8:checked) .l8s4 { fill: var(--rs-s4); }
.rs-map:has(.rs-l8:checked) .l8s5 { fill: var(--rs-s5); }
.rs-map:has(.rs-l8:checked) .l8s6 { fill: var(--rs-s6); }
.rs-map:has(.rs-l8:checked) .l8d0 { fill: var(--rs-d0); }
.rs-map:has(.rs-l8:checked) .l8d1 { fill: var(--rs-d1); }
.rs-map:has(.rs-l8:checked) .l8d2 { fill: var(--rs-d2); }
.rs-map:has(.rs-l8:checked) .l8d3 { fill: var(--rs-d3); }
.rs-map:has(.rs-l8:checked) .l8d4 { fill: var(--rs-d4); }
.rs-map:has(.rs-l8:checked) .l8d5 { fill: var(--rs-d5); }
.rs-map:has(.rs-l8:checked) .l8d6 { fill: var(--rs-d6); }
.rs-map:has(.rs-l8:checked) .l8n { fill: var(--rs-na); }
