/* ==================================================================
   La criminalité au Luxembourg
   Palette: validated data-viz default (see README).
   Light values on bare :root; dark values under both the OS media
   query and the [data-theme] toggle so the toggle wins either way.
   ================================================================== */

:root {
  color-scheme: light;

  /* surfaces + ink */
  --surface-0: #f6f5f2;
  --surface-1: #fcfcfb;
  --surface-2: #efeeea;
  --border:    #dedcd5;
  --border-strong: #c6c3b9;

  --text-primary:   #16150f;
  --text-secondary: #52514a;
  --text-muted:     #76746a;

  /* categorical slots 1-3 (validated all-pairs, light) */
  --series-1: #2a78d6;  /* blue   */
  --series-2: #eb6834;  /* orange */
  --series-3: #1baf7a;  /* aqua   */

  /* diverging pair: blue <-> red, neutral gray midpoint */
  --div-neg: #2a78d6;
  --div-pos: #e34948;
  --div-mid: #e6e4dd;

  --accent: #2a78d6;
  --accent-ink: #ffffff;

  --grid: #e4e2db;
  --axis: #b8b5aa;

  --radius: 10px;
  --radius-sm: 6px;
  --maxw: 1120px;

  --font-sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
               "Helvetica Neue", Arial, sans-serif;
  --font-num: "SF Mono", ui-monospace, "JetBrains Mono", "Roboto Mono", Menlo,
              Consolas, monospace;

  --shadow: 0 1px 2px rgba(20, 18, 10, .05), 0 4px 14px rgba(20, 18, 10, .045);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --surface-0: #121211;
    --surface-1: #1a1a19;
    --surface-2: #232321;
    --border:    #323230;
    --border-strong: #474743;

    --text-primary:   #f4f3ee;
    --text-secondary: #c3c2b7;
    --text-muted:     #96958c;

    --series-1: #3987e5;
    --series-2: #d95926;
    --series-3: #199e70;

    --div-neg: #3987e5;
    --div-pos: #e66767;
    --div-mid: #383835;

    --accent: #3987e5;
    --accent-ink: #0b0b0b;

    --grid: #2b2b29;
    --axis: #55554f;

    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
  --surface-0: #121211;
  --surface-1: #1a1a19;
  --surface-2: #232321;
  --border:    #323230;
  --border-strong: #474743;

  --text-primary:   #f4f3ee;
  --text-secondary: #c3c2b7;
  --text-muted:     #96958c;

  --series-1: #3987e5;
  --series-2: #d95926;
  --series-3: #199e70;

  --div-neg: #3987e5;
  --div-pos: #e66767;
  --div-mid: #383835;

  --accent: #3987e5;
  --accent-ink: #0b0b0b;

  --grid: #2b2b29;
  --axis: #55554f;

  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 4px 16px rgba(0, 0, 0, .3);
}

/* ---------------- base ---------------- */

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}

body {
  margin: 0;
  background: var(--surface-0);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

img { max-width: 100%; }
[hidden] { display: none !important; }

.wrap {
  width: 100%;
  max-width: var(--maxw);
  margin-inline: auto;
  padding-inline: 20px;
}

.sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip-link {
  position: absolute; left: 12px; top: -60px;
  background: var(--accent); color: var(--accent-ink);
  padding: 10px 16px; border-radius: var(--radius-sm);
  z-index: 100; text-decoration: none; font-weight: 600;
  transition: top .15s ease;
}
.skip-link:focus { top: 12px; }

a { color: var(--accent); }
a:focus-visible, button:focus-visible, select:focus-visible,
th[role="button"]:focus-visible, [tabindex]:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-radius: 3px;
}

h1, h2, h3, h4 { line-height: 1.22; margin: 0 0 .5em; letter-spacing: -.015em; }
h1 { font-size: clamp(2rem, 5.2vw, 3.1rem); font-weight: 700; }
h2 { font-size: clamp(1.4rem, 3vw, 1.95rem); font-weight: 650; }
h3 { font-size: clamp(1.05rem, 2vw, 1.22rem); font-weight: 640; }

p { margin: 0 0 1rem; }

/* ---------------- header ---------------- */

.site-header {
  position: sticky; top: 0; z-index: 50;
  background: color-mix(in srgb, var(--surface-1) 88%, transparent);
  backdrop-filter: saturate(140%) blur(12px);
  border-bottom: 1px solid var(--border);
}

.header-inner {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px; padding-block: 12px;
}

.brand {
  display: flex; align-items: center; gap: 11px;
  text-decoration: none; color: inherit; min-width: 0;
}
.brand-mark {
  width: 10px; height: 30px; border-radius: 3px; flex: none;
  background: linear-gradient(180deg, var(--series-1) 0 34%, var(--div-pos) 34% 67%, var(--series-3) 67%);
}
.brand-text { display: flex; flex-direction: column; min-width: 0; }
.brand-text strong { font-size: 1rem; font-weight: 660; letter-spacing: -.01em; }
.brand-text small {
  font-size: .76rem; color: var(--text-muted); line-height: 1.3;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.header-controls { display: flex; align-items: center; gap: 8px; flex: none; }

#lang-select {
  font: inherit; font-size: .85rem;
  padding: 7px 10px; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong);
  background: var(--surface-1); color: var(--text-primary);
  cursor: pointer;
}

.icon-btn {
  display: grid; place-items: center;
  width: 36px; height: 36px; padding: 0;
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  background: var(--surface-1); color: var(--text-secondary); cursor: pointer;
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--axis); }
.icon-btn svg {
  width: 17px; height: 17px; fill: none; stroke: currentColor;
  stroke-width: 1.8; stroke-linecap: round;
}
.ico-moon { display: none; }
:root[data-theme="dark"] .ico-sun { display: none; }
:root[data-theme="dark"] .ico-moon { display: block; }
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .ico-sun { display: none; }
  :root:not([data-theme="light"]) .ico-moon { display: block; }
}

.site-nav { border-top: 1px solid var(--border); overflow-x: auto; scrollbar-width: none; }
.site-nav::-webkit-scrollbar { display: none; }
.nav-inner { display: flex; gap: 4px; padding-block: 0; white-space: nowrap; }
.site-nav a {
  display: inline-block; padding: 10px 12px;
  font-size: .84rem; font-weight: 520;
  color: var(--text-secondary); text-decoration: none;
  border-bottom: 2px solid transparent;
}
.site-nav a:hover { color: var(--text-primary); }
.site-nav a.is-active { color: var(--accent); border-bottom-color: var(--accent); }

/* ---------------- hero ---------------- */

.hero { padding-block: clamp(42px, 8vw, 78px) clamp(28px, 4vw, 44px); }
.eyebrow {
  font-size: .78rem; font-weight: 600; letter-spacing: .04em;
  text-transform: uppercase; color: var(--text-muted); margin-bottom: .9rem;
}
.hero .lead {
  font-size: clamp(1.02rem, 2.1vw, 1.2rem);
  color: var(--text-secondary); max-width: 62ch; margin-top: 1rem;
}
.hero .meta { font-size: .84rem; color: var(--text-muted); margin-top: 1.4rem; }

/* ---------------- bands ---------------- */

.band { padding-block: clamp(38px, 6vw, 62px); border-top: 1px solid var(--border); }
.band-quiet { background: var(--surface-1); }
.section-lead { color: var(--text-secondary); max-width: 72ch; }

.callout {
  margin-top: 1.6rem; padding: 15px 18px;
  background: var(--surface-2);
  border-left: 3px solid var(--accent);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  color: var(--text-secondary); font-size: .93rem; max-width: 78ch;
}

/* ---------------- read-first notes ---------------- */

.note-grid {
  display: grid; gap: 14px; margin-top: 1.8rem;
  grid-template-columns: repeat(auto-fit, minmax(255px, 1fr));
}
.note-card {
  background: var(--surface-0);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
}
.note-card h3 { font-size: .98rem; margin-bottom: .45em; }
.note-card p { font-size: .89rem; color: var(--text-secondary); margin: 0; }
.note-num {
  display: inline-grid; place-items: center;
  width: 24px; height: 24px; border-radius: 6px; margin-bottom: 12px;
  background: var(--accent); color: var(--accent-ink);
  font-size: .78rem; font-weight: 700; font-family: var(--font-num);
}

/* ---------------- KPI ---------------- */

.kpi-grid {
  display: grid; gap: 14px; margin-top: 1.8rem;
  grid-template-columns: repeat(auto-fit, minmax(215px, 1fr));
}
.kpi {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px; box-shadow: var(--shadow);
  display: flex; flex-direction: column; gap: 4px;
}
.band-quiet .kpi { background: var(--surface-0); }
.kpi-value {
  font-family: var(--font-num);
  font-size: clamp(1.75rem, 4vw, 2.3rem);
  font-weight: 660; letter-spacing: -.025em; line-height: 1.05;
}
.kpi-label { font-size: .92rem; font-weight: 600; }
.kpi-sub { font-size: .8rem; color: var(--text-muted); }
.kpi-delta {
  font-size: .79rem; font-family: var(--font-num);
  margin-top: 6px; display: inline-flex; align-items: center; gap: 5px;
}
.kpi-delta .dot { width: 7px; height: 7px; border-radius: 50%; flex: none; }
.delta-up   .dot { background: var(--div-pos); }
.delta-down .dot { background: var(--div-neg); }
.delta-flat .dot { background: var(--axis); }

.src-tag {
  margin-top: auto; padding-top: 10px;
  font-size: .72rem; color: var(--text-muted);
}
.src-tag a { color: var(--text-muted); text-decoration: underline; text-underline-offset: 2px; }
.src-tag a:hover { color: var(--accent); }

/* ---------------- filters ---------------- */

.filter-row { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 1.7rem; }
.filter-btn {
  font: inherit; font-size: .83rem; font-weight: 540;
  padding: 7px 13px; cursor: pointer;
  border: 1px solid var(--border-strong); border-radius: 999px;
  background: var(--surface-1); color: var(--text-secondary);
}
.band-quiet .filter-btn { background: var(--surface-0); }
.filter-btn:hover { color: var(--text-primary); border-color: var(--axis); }
.filter-btn[aria-pressed="true"] {
  background: var(--accent); border-color: var(--accent);
  color: var(--accent-ink);
}

/* ---------------- figures / charts ---------------- */

.figure {
  margin: 1.9rem 0 0;
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.band-quiet .figure { background: var(--surface-0); }
.fig-head {
  display: flex; flex-wrap: wrap; align-items: baseline;
  justify-content: space-between; gap: 10px; margin-bottom: 16px;
}
.fig-head h3 { margin: 0; }
.fig-sub { font-size: .85rem; color: var(--text-muted); margin: 0; flex-basis: 100%; }

.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .81rem; color: var(--text-secondary); }
.legend-item { display: inline-flex; align-items: center; gap: 6px; }
.legend-swatch { width: 11px; height: 11px; border-radius: 3px; flex: none; }

.chart-host { width: 100%; }
.chart-host svg { display: block; width: 100%; height: auto; overflow: visible; }

.axis-line { stroke: var(--axis); stroke-width: 1; }
.grid-line { stroke: var(--grid); stroke-width: 1; }
.tick-text { fill: var(--text-muted); font-size: 11px; font-family: var(--font-num); }
.cat-text  { fill: var(--text-secondary); font-size: 12.5px; }
.val-text  { fill: var(--text-primary); font-size: 11.5px; font-family: var(--font-num); font-weight: 600; }
.bar { transition: opacity .12s ease; }
.bar-hit { fill: transparent; cursor: pointer; }
.chart-row:hover .bar { opacity: .78; }

/* ---------------- table ---------------- */

.table-block { margin-top: 2.4rem; }
.table-scroll {
  overflow-x: auto; margin-top: 1rem;
  border: 1px solid var(--border); border-radius: var(--radius);
  background: var(--surface-1);
}
.band-quiet .table-scroll { background: var(--surface-0); }

.data-table { width: 100%; border-collapse: collapse; font-size: .87rem; min-width: 660px; }
.data-table th, .data-table td {
  padding: 11px 14px; text-align: left;
  border-bottom: 1px solid var(--border); vertical-align: top;
}
.data-table thead th {
  background: var(--surface-2);
  font-size: .76rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .045em;
  color: var(--text-secondary); white-space: nowrap;
  cursor: pointer; user-select: none;
}
.data-table thead th:hover { color: var(--text-primary); }
.data-table thead th .sort-ind { opacity: .45; font-size: .7rem; margin-left: 4px; }
.data-table thead th[aria-sort] .sort-ind { opacity: 1; color: var(--accent); }
.data-table tbody tr:last-child td { border-bottom: 0; }
.data-table tbody tr:hover { background: var(--surface-2); }
.data-table .num { text-align: right; font-family: var(--font-num); white-space: nowrap; }
.data-table .offence-name { font-weight: 560; }
.data-table .offence-note {
  display: block; font-weight: 400; font-size: .79rem;
  color: var(--text-muted); margin-top: 3px; max-width: 46ch;
}
.na { color: var(--text-muted); font-style: italic; font-family: var(--font-sans); font-size: .82rem; }

.chip {
  display: inline-block; padding: 2px 8px; border-radius: 999px;
  font-size: .72rem; font-weight: 600; white-space: nowrap;
  border: 1px solid transparent;
}
.chip-property { color: var(--series-1); border-color: color-mix(in srgb, var(--series-1) 38%, transparent); }
.chip-person   { color: var(--series-2); border-color: color-mix(in srgb, var(--series-2) 38%, transparent); }
.chip-drugs    { color: var(--series-3); border-color: color-mix(in srgb, var(--series-3) 38%, transparent); }
.chip-other    { color: var(--text-muted); border-color: var(--border-strong); }

.calc-flag {
  display: inline-block; margin-left: 5px;
  font-size: .68rem; font-weight: 600; letter-spacing: .03em;
  padding: 1px 5px; border-radius: 4px;
  background: var(--surface-2); color: var(--text-muted);
  border: 1px solid var(--border-strong); cursor: help;
  font-family: var(--font-sans);
}

.delta-val { font-weight: 650; }
.delta-val.up   { color: var(--div-pos); }
.delta-val.down { color: var(--div-neg); }
.delta-val.flat { color: var(--text-muted); }

/* ---------------- hold-ups ---------------- */

.holdups { margin-top: 2.4rem; }
.holdup-row { display: flex; flex-wrap: wrap; gap: 30px; margin: 1rem 0; }
.holdup-item { display: flex; align-items: baseline; gap: 9px; }
.holdup-num {
  font-family: var(--font-num); font-size: 2.1rem;
  font-weight: 660; letter-spacing: -.02em;
}
.holdup-lbl { font-size: .9rem; color: var(--text-secondary); }

/* ---------------- generic blocks ---------------- */

.split { display: grid; gap: 16px; grid-template-columns: repeat(auto-fit, minmax(270px, 1fr)); margin-top: 1.8rem; }

.panel {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  display: flex; flex-direction: column;
}
.band-quiet .panel { background: var(--surface-0); }
.panel h3 { font-size: .98rem; margin-bottom: 1rem; }
.panel > .src-tag { margin-top: auto; }

.stat-row { display: flex; flex-wrap: wrap; gap: 28px; margin-top: 1.7rem; }
.stat { display: flex; flex-direction: column; gap: 2px; }
.stat-num {
  font-family: var(--font-num); font-size: clamp(1.5rem, 3.4vw, 2rem);
  font-weight: 660; letter-spacing: -.02em; line-height: 1.1;
}
.stat-lbl { font-size: .84rem; color: var(--text-secondary); max-width: 26ch; }

/* proportion bars */
.prop { margin-bottom: 14px; }
.prop:last-child { margin-bottom: 0; }
.prop-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 10px; margin-bottom: 5px;
}
.prop-name { font-size: .87rem; color: var(--text-secondary); }
.prop-val { font-family: var(--font-num); font-size: .87rem; font-weight: 650; }
.prop-track {
  height: 9px; border-radius: 4px; background: var(--surface-2);
  overflow: hidden; border: 1px solid var(--border);
}
.prop-fill { height: 100%; border-radius: 4px; }

/* stacked single bar */
.stack { display: flex; gap: 2px; height: 34px; margin: 4px 0 12px; }
.stack-seg {
  border-radius: 4px; display: grid; place-items: center;
  font-size: .78rem; font-weight: 650; font-family: var(--font-num);
  color: #fff; min-width: 2px; overflow: hidden;
}
.stack-legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: .82rem; color: var(--text-secondary); }

/* two-column fact lists */
.fact-cols { display: grid; gap: 18px; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); margin-top: 1.8rem; }
.fact-col { }
.fact-col h3 { display: flex; align-items: center; gap: 8px; }
.fact-col h3::before {
  content: ""; width: 8px; height: 8px; border-radius: 2px; flex: none;
}
.fact-col.known h3::before { background: var(--series-3); }
.fact-col.unknown h3::before { background: var(--series-2); }
.fact-list { margin: 0; padding-left: 0; list-style: none; }
.fact-list li {
  position: relative; padding-left: 18px; margin-bottom: .85rem;
  font-size: .9rem; color: var(--text-secondary);
}
.fact-list li::before {
  content: ""; position: absolute; left: 0; top: .6em;
  width: 6px; height: 2px; background: var(--border-strong);
}

/* method list */
.method-list { margin-top: 1.8rem; padding-left: 0; list-style: none; counter-reset: m; }
.method-list li {
  counter-increment: m; position: relative;
  padding-left: 42px; margin-bottom: 1.4rem;
}
.method-list li::before {
  content: counter(m); position: absolute; left: 0; top: 1px;
  width: 27px; height: 27px; border-radius: 7px;
  display: grid; place-items: center;
  background: var(--surface-2); border: 1px solid var(--border-strong);
  color: var(--text-secondary);
  font-family: var(--font-num); font-size: .8rem; font-weight: 700;
}
.method-list h3 { font-size: .97rem; margin-bottom: .3em; }
.method-list p { font-size: .89rem; color: var(--text-secondary); margin: 0; max-width: 74ch; }

/* sources */
.source-list { margin-top: 1.8rem; padding: 0; list-style: none; display: grid; gap: 10px; }
.source-list li {
  background: var(--surface-1);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 15px 18px;
  display: flex; flex-wrap: wrap; align-items: baseline; gap: 6px 12px;
}
.band-quiet .source-list li { background: var(--surface-0); }
.source-title { font-weight: 580; font-size: .93rem; flex: 1 1 320px; }
.source-pub { font-size: .81rem; color: var(--text-muted); }
.source-link { font-size: .83rem; font-weight: 560; white-space: nowrap; }
.source-id {
  font-family: var(--font-num); font-size: .7rem; color: var(--text-muted);
  border: 1px solid var(--border-strong); border-radius: 4px;
  padding: 1px 6px; flex: none;
}

/* ---------------- tooltip ---------------- */

.tooltip {
  position: fixed; z-index: 80; pointer-events: none;
  max-width: 280px; padding: 9px 12px;
  background: var(--surface-1); color: var(--text-primary);
  border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
  box-shadow: var(--shadow);
  font-size: .82rem; line-height: 1.45;
}
.tooltip strong { display: block; margin-bottom: 2px; font-size: .85rem; }
.tooltip .tt-val { font-family: var(--font-num); }
.tooltip .tt-note { color: var(--text-muted); font-size: .77rem; margin-top: 4px; display: block; }

/* ---------------- footer ---------------- */

.site-footer {
  border-top: 1px solid var(--border);
  background: var(--surface-1);
  padding-block: 34px;
  font-size: .85rem; color: var(--text-muted);
}
.site-footer p { max-width: 76ch; }
.footer-links { display: flex; flex-wrap: wrap; gap: 18px; margin-top: 1rem; }

/* ---------------- narrow screens ---------------- */

@media (max-width: 560px) {
  .brand-text small { display: none; }
  .holdup-row { gap: 22px; }
  .stat-row { gap: 20px; }
  .figure { padding: 15px; }
}
