/* Region maps (/regions…). Builds on app.css and pathways.css. The map uses
   one sequential blue ramp: darker = higher value, never good or bad. Light
   steps come from the validated dataviz ramp; dark mode runs the same ramp
   the other way so low values recede into the dark surface. */

:root {
  --q0: #86b6ef; --q1: #5598e7; --q2: #2a78d6; --q3: #1c5cab; --q4: #0d366b;
  --qn: #e9e6df; --map-line: #fff; --map-cur: #ff6a45;
}
@media (prefers-color-scheme: dark) {
  :root { --q0: #184f95; --q1: #256abf; --q2: #3987e5; --q3: #6da7ec; --q4: #cde2fb; --qn: #2a2f48; --map-line: #0d1020; }
}
.rhero { padding-bottom: 72px; }
.rhero h1 { max-width: 15em; }
.rlocal { margin: -10px 0 14px; color: rgba(255,255,255,.6); font-size: .95rem; }
.rpage .pwsec:first-child { margin-top: 48px; }

/* ---------- Map ---------- */
.rmap { display: block; width: 100%; height: auto; overflow: visible; }
.rmap path { fill: var(--qn); stroke: var(--map-line); stroke-width: 1.2; stroke-linejoin: round; vector-effect: non-scaling-stroke; transition: fill .35s, opacity .25s; }
.rmap .rg[data-q="0"] path { fill: var(--q0); } .rmap .rg[data-q="1"] path { fill: var(--q1); } .rmap .rg[data-q="2"] path { fill: var(--q2); }
.rmap .rg[data-q="3"] path { fill: var(--q3); } .rmap .rg[data-q="4"] path { fill: var(--q4); }
.rmap .rg[data-q="-1"] path { fill: var(--qn); }
.rmap .rg { cursor: pointer; outline: none; }
.rmap .rg:hover path, .rmap .rg.hot path { stroke: var(--ink); stroke-width: 2.2; }
.rmap .rg:focus-visible path { stroke: var(--map-cur); stroke-width: 3; }
.rmap .rg.out path { opacity: .18; }
.rmap.small path { stroke-width: .8; }
.rmap .rg.cur path { fill: var(--map-cur) !important; }
.rmap .rg:hover, .rmap .rg:focus-visible, .rmap .rg.hot { filter: drop-shadow(0 2px 6px rgba(0,0,0,.25)); }

.rmapwrap { display: grid; grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 28px; align-items: start; margin-top: 18px; }
@media (max-width: 860px) { .rmapwrap { grid-template-columns: 1fr; gap: 18px; } }
.rfig { position: relative; margin: 0; background: var(--surface); border: 1px solid var(--line); border-radius: 24px; padding: 18px; box-shadow: var(--shadow); }
.rfig .rmap { max-height: 72vh; }
.rtip { position: absolute; z-index: 5; pointer-events: none; min-width: 200px; max-width: 280px; background: var(--ink); color: var(--bg); border-radius: 14px; padding: 12px 14px; font-size: .86rem; line-height: 1.4; box-shadow: 0 12px 30px rgba(0,0,0,.25); }
.rtip b { display: block; font-size: .98rem; margin-bottom: 6px; }
.rtip dl { display: grid; grid-template-columns: 1fr auto; gap: 3px 14px; margin: 0; }
.rtip dt { opacity: .75; } .rtip dd { margin: 0; font-weight: 700; text-align: end; font-variant-numeric: tabular-nums; }
.rtip dt.on, .rtip dt.on + dd { opacity: 1; color: #9ec5f4; }
@media (prefers-color-scheme: dark) { .rtip dt.on, .rtip dt.on + dd { color: #184f95; } }
.rtip .hint { display: block; margin-top: 8px; opacity: .6; font-size: .78rem; }

.rseg a { flex: 1 1 180px; }
.rside { display: grid; gap: 14px; }
.rlegend { background: var(--surface); border: 1px solid var(--line); border-radius: 18px; padding: 14px 16px; }
.rlegend .lt { display: block; font-size: .78rem; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--ink-soft); margin-bottom: 10px; }
.rlegend .sw { display: grid; gap: 6px; font-size: .88rem; font-variant-numeric: tabular-nums; }
.rlegend .sw span { display: flex; align-items: center; gap: 10px; }
.rlegend i { width: 28px; height: 14px; border-radius: 4px; flex: none; }
.rlegend .q0 { background: var(--q0); } .rlegend .q1 { background: var(--q1); } .rlegend .q2 { background: var(--q2); }
.rlegend .q3 { background: var(--q3); } .rlegend .q4 { background: var(--q4); } .rlegend .qn { background: var(--qn); border: 1px dashed var(--line-strong); }
.rnote { background: var(--blue-soft); border-radius: 18px; padding: 14px 16px; font-size: .92rem; }
.rnote p { margin: 0 0 8px; } .rnote p:last-child { margin: 0; }
.tag { display: inline-block; font-size: .72rem; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; background: var(--surface); color: var(--blue); padding: 2px 8px; border-radius: 999px; margin-inline-end: 4px; }
.tag.soft { color: var(--coral-deep); }
.rlg[hidden], .rnote[hidden] { display: none; }

/* ---------- Table ---------- */
.rfilter { margin: 0 0 12px; background: var(--surface); border: 1px solid var(--line); border-radius: 16px; padding: 12px 16px; }
.rfilter summary { cursor: pointer; font-weight: 600; }
.rfs { display: grid; gap: 10px; margin-top: 12px; }
.rf { display: grid; grid-template-columns: minmax(0, 1fr) 110px 110px; gap: 8px; align-items: center; font-size: .9rem; }
.rf small { color: var(--ink-soft); }
.rf label { margin: 0; }
.rf input { padding: 8px 10px; font-size: .92rem; }
@media (max-width: 520px) { .rf { grid-template-columns: 1fr 1fr; } .rf > span { grid-column: 1 / -1; } }
.rfs .linkbtn { justify-self: start; font-size: .9rem; }
.rcount { min-height: 1.4em; margin: 0 0 6px; color: var(--ink-soft); font-size: .88rem; }
.rtable { overflow-x: auto; background: var(--surface); border: 1px solid var(--line); border-radius: 20px; }
.rtable table { width: 100%; border-collapse: collapse; font-size: .92rem; font-variant-numeric: tabular-nums; }
.rtable th, .rtable td { padding: 10px 14px; text-align: start; border-bottom: 1px solid var(--line); white-space: nowrap; }
.rtable tbody tr:last-child > * { border-bottom: 0; }
.rtable thead th { font-size: .8rem; color: var(--ink-soft); vertical-align: bottom; white-space: normal; min-width: 120px; }
.rtable thead th:first-child { min-width: 0; }
.rtable thead button { all: unset; cursor: pointer; font-weight: 700; display: block; line-height: 1.3; }
.rtable thead button:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; border-radius: 4px; }
.rtable thead button::after { content: " ↕"; opacity: .35; }
.rtable thead th[aria-sort="descending"] button::after { content: " ↓"; opacity: 1; }
.rtable thead th[aria-sort="ascending"] button::after { content: " ↑"; opacity: 1; }
.rtable thead small { display: block; font-weight: 400; }
.rtable tbody th { font-weight: 600; }
.rtable tbody th a { color: var(--ink); text-decoration: none; }
.rtable tbody th a:hover { color: var(--blue); text-decoration: underline; }
.rtable tbody th small { color: var(--ink-soft); font-weight: 400; }
.rtable td .num { display: inline-block; min-width: 3.6em; }
.rtable td .bar { display: inline-block; vertical-align: middle; height: 8px; width: calc(var(--w) * .6); max-width: 60px; border-radius: 0 4px 4px 0; background: var(--q2); opacity: .25; margin-inline-start: 6px; }
.rtable td.on .bar { opacity: 1; }
.rtable td.on { font-weight: 700; }
.rtable tfoot th, .rtable tfoot td { border-top: 2px solid var(--line-strong); border-bottom: 0; color: var(--ink-soft); font-weight: 600; }
.rtable tr.out { display: none; }
.rtable tr.hot { background: var(--blue-soft); }
.na { color: var(--ink-soft); }

/* ---------- Explanations ---------- */
.rnoscore { border-inline-start: 4px solid var(--coral); background: var(--coral-soft); border-radius: 0 16px 16px 0; padding: 14px 18px; margin: 0 0 18px; }
.rnoscore p { margin: 0; }
.rhow { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 14px; }
.rhow > div { background: var(--surface); border: 1px solid var(--line); border-radius: 20px; padding: 18px 20px; }
.rhow h3 { margin: 0 0 4px; font-size: 1.06rem; }
.rhow p { margin: 8px 0 0; font-size: .93rem; }
.rmeta { color: var(--ink-soft); font-size: .84rem !important; }
.not { color: var(--ink-soft); }
.not::before { content: "Doesn't say: "; font-weight: 700; color: var(--coral-deep); }
.rgap { margin: 18px 0 0; padding: 14px 18px; border-radius: 16px; background: var(--surface); border: 1px dashed var(--line-strong); color: var(--ink-soft); font-size: .93rem; }
.rhelp { background: var(--mint-soft); border-radius: 22px; padding: 22px 24px; }
.rhelp h2 { font-size: 1.5rem; margin: 0 0 10px; }
.rhelp ul { margin: 0; padding-inline-start: 20px; }
.rhelp li { margin-bottom: 6px; }
.rhelp a { display: inline-flex; gap: 5px; align-items: center; }
.rhelp svg { width: 12px; height: 12px; }
.tline { margin-top: 14px; }

/* ---------- Region page ---------- */
.rmini { margin: 0; justify-self: center; width: 100%; max-width: 380px; }
.rmini .rmap path { fill: rgba(255,255,255,.14); stroke: rgba(255,255,255,.35); }
.rmini .rmap .rg:hover path { stroke: #fff; }
.rmini .rmap .rg.cur path { fill: var(--coral) !important; stroke: #fff; }
.rmini .rmap .rg[data-q] path { fill: rgba(255,255,255,.14); }
.rcards { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.rcardstat { background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px 20px; box-shadow: var(--shadow); }
.rcardstat p { margin: 0; }
.rcardstat .lbl { font-size: .74rem; font-weight: 700; letter-spacing: .08em; text-transform: uppercase; color: var(--ink-soft); }
.rcardstat .big { font-family: var(--serif); font-size: 2.6rem; line-height: 1.05; margin-top: 8px; letter-spacing: -.02em; }
.rcardstat .u { color: var(--ink-soft); font-size: .84rem; }
.rcardstat .cmp { margin-top: 10px; font-size: .9rem; }
.rcardstat .grp { margin-top: 6px; font-size: .84rem; color: var(--coral-deep); }
.rcardstat .when { margin-top: 10px; font-size: .82rem; color: var(--ink-soft); }
.rcardstat details { margin-top: 10px; font-size: .88rem; }
.rcardstat summary { cursor: pointer; color: var(--blue); font-weight: 600; }
.rcardstat details p { margin-top: 8px; }
.rstats .rnoscore { margin-top: 18px; }

/* ---------- Overview ---------- */
.rcountries { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 18px; }
.rcountry { position: relative; display: grid; grid-template-columns: 1fr auto; gap: 10px 0; text-decoration: none; color: var(--ink); background: var(--surface); border: 1px solid var(--line); border-radius: 22px; padding: 18px; transition: transform .25s, box-shadow .25s, border-color .25s; }
.rcountry:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: var(--line-strong); }
.rcmap { grid-column: 1 / -1; display: grid; place-items: center; height: 190px; background: var(--bg); border-radius: 16px; padding: 12px; }
.rcmap .rmap { max-height: 166px; width: auto; max-width: 100%; }
.rctext b { display: flex; align-items: center; gap: 8px; font-size: 1.1rem; }
.rctext small { display: block; color: var(--ink-soft); font-size: .84rem; margin-top: 4px; }
.rcountry .cc { width: 28px; height: 22px; border-radius: 7px; font-size: .6rem; box-shadow: none; }
.rcountry .go { align-self: end; color: var(--coral-deep); font-size: 1.2rem; transition: transform .2s; }
.rcountry:hover .go { transform: translateX(4px); }
.how3 strong { display: block; color: var(--ink); margin-bottom: 4px; }

@media (prefers-reduced-motion: reduce) { .rmap path, .rcountry { transition: none; } }
@media (forced-colors: active) { .rmap path { stroke: CanvasText; } .rmap .rg:focus-visible path { stroke: Highlight; } }

/* ---------- layers (community / hate crime / recorded crime) ---------- */
.rlayers { display: flex; flex-wrap: wrap; gap: 8px; margin: 0 0 10px; }
.rlayers a { text-decoration: none; color: var(--ink); font-weight: 700; font-size: .92rem; padding: 9px 16px; border-radius: 999px; border: 1px solid var(--line-strong); background: var(--bg); transition: background .2s, color .2s; }
.rlayers a:hover { background: var(--surface); }
.rlayers a.on { background: var(--blue); border-color: var(--blue); color: #fff; }
.rlayers a:focus-visible, .rseg a:focus-visible { outline: 2px solid var(--coral); outline-offset: 2px; }
.rseg a[hidden] { display: none; }
.rcaveat { margin: 12px 0; padding: 12px 16px; border-radius: 14px; border: 1px dashed var(--line-strong); background: var(--surface); font-size: .9rem; color: var(--ink-soft); }
.rcaveat b { color: var(--ink); }
.rcaveat[hidden] { display: none; }
.rlayerh { margin: 28px 0 10px; font-size: 1.15rem; }
.rstats .rlayerh:first-child { margin-top: 0; }
.rtip dt.lh { grid-column: 1 / -1; margin-top: 6px; padding-top: 6px; border-top: 1px solid rgba(255,255,255,.18); opacity: .6; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; }
.rtip dt.lh:first-of-type { margin-top: 0; padding-top: 0; border-top: 0; }
.rtip dd.lh { display: none; }
.rtable thead .rlh { text-align: start; font-size: .72rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); border-bottom: 2px solid var(--line-strong); padding-bottom: 6px; min-width: 0; }
.rtable thead tr:first-child td { border-bottom: 0; }
.rcardstat.own { border-style: dashed; }

/* ---------- region comparison ---------- */
.rvs { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; margin: 0 0 14px; }
.rvs label { font-weight: 700; }
.rvs select { font: inherit; padding: 10px 14px; border-radius: 12px; border: 1px solid var(--line-strong); background: var(--bg); color: var(--ink); max-width: 100%; }
.rvs .btn { padding: 10px 20px; }
.rcmp th[scope="row"] { white-space: normal; min-width: 180px; }
.rcmp small { display: block; font-weight: 400; font-size: .76rem; color: var(--ink-soft); }
.rcmp td { white-space: normal; }
.rcmp tr.rlrow th { background: var(--blue-soft); font-size: .76rem; letter-spacing: .04em; text-transform: uppercase; color: var(--ink-soft); padding-block: 6px; }
.rcmp thead th a { color: inherit; }
.rcmp .ownv { color: var(--ink-soft); }
@media (max-width: 560px) { .rcmp table { font-size: .84rem; } .rcmp th[scope="row"], .rcmp thead th { min-width: 0; } .rcmp th[scope="row"] { width: 38%; } .rcmp th, .rcmp td { padding: 8px; } .rcmp small { font-size: .7rem; } .rtable th, .rtable td { padding: 8px 10px; } }
@media (prefers-color-scheme: dark) { .rtip dt.lh { border-top-color: rgba(0,0,0,.18); } }
@media (forced-colors: active) { .rlayers a.on { outline: 2px solid CanvasText; } }
@media (prefers-reduced-motion: reduce) { .rlayers a { transition: none; } }
/* The tooltip lists every layer, so keep it compact. */
.rtip { max-width: 340px; font-size: .8rem; line-height: 1.3; padding: 10px 12px; }
.rtip dl { gap: 2px 12px; }
.rtip dt.lh { margin-top: 4px; padding-top: 4px; }

/* ---------- district drill-downs ---------- */
.rdrill { margin: 26px 0 0; }
.rdrill h3 { font-size: 1.1rem; margin: 0 0 4px; }
.rdrill .sub { margin: 0 0 12px; }
.rdrill .rseg { margin-bottom: 12px; }
.rdtable { margin-top: 12px; }
.rdtable summary { cursor: pointer; font-weight: 700; padding: 6px 0; }
.rdtable .rtable { margin-top: 8px; max-height: 520px; overflow: auto; }
.rtable td small.cnt { display: block; font-size: .72rem; color: var(--ink-soft); font-weight: 400; }
.rtable tr:target { background: var(--blue-soft); }
.rsister { margin: 22px 0 0; font-size: .92rem; color: var(--ink-soft); }

/* ---------- people from my country ---------- */
.rlayers a.rjump { border-style: dashed; color: var(--ink-soft); }
.rlayers a.rjump:hover { color: var(--ink); }
.rorigin-pick { margin-bottom: 4px; }
#origin .rdrill { margin-top: 8px; }
.rtop { display: grid; grid-template-columns: repeat(auto-fill, minmax(190px, 1fr)); gap: 6px 18px; padding-inline-start: 1.3em; margin: 6px 0 14px; }
.rtop li span { color: var(--ink-soft); font-variant-numeric: tabular-nums; margin-inline-start: 6px; }
.rpop { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 10px; margin: 4px 0 0; color: rgba(255,255,255,.85); }
.rpop > span { font-size: .82rem; font-weight: 600; text-transform: uppercase; letter-spacing: .04em; color: #ffd8cb; }
.rpop b { font-size: 1.6rem; font-weight: 800; color: #fff; font-variant-numeric: tabular-nums; }
.rpop small { color: rgba(255,255,255,.6); }
.rpop .src { color: inherit; }
.rpoptable td.n { text-align: right; font-variant-numeric: tabular-nums; }
.rpoptable td:first-child { color: var(--muted, #888); width: 2.5em; }
