/* Belgian surname map — sequential blue ramp, light & dark selected per surface. */

:root {
  color-scheme: light;
  --surface-1: #fcfcfb;
  --surface-2: #ffffff;
  --surface-3: #f2f1ee;
  --border:    #e0dfda;
  --text-1:    #0b0b0b;
  --text-2:    #52514e;
  --text-3:    #85837c;
  --accent:    #2a78d6;

  /* sequential blue, light -> dark (6 carrying classes, max ~7) */
  --s1: #cde2fb;
  --s2: #9ec5f4;
  --s3: #6da7ec;
  --s4: #3987e5;
  --s5: #256abf;
  --s6: #104281;
  --na: #e6e5e1;

  --ink-on-dark: #ffffff;
  --shadow: 0 1px 2px rgba(0,0,0,.06), 0 4px 14px rgba(0,0,0,.06);
}

@media (prefers-color-scheme: dark) {
  :root:where(:not([data-theme="light"])) {
    color-scheme: dark;
    --surface-1: #1a1a19;
    --surface-2: #232322;
    --surface-3: #2b2b29;
    --border:    #3a3a37;
    --text-1:    #ffffff;
    --text-2:    #c3c2b7;
    --text-3:    #94938a;
    --accent:    #3987e5;
    --na:        #35352f;
    --shadow: 0 1px 2px rgba(0,0,0,.4), 0 4px 14px rgba(0,0,0,.35);
  }
}

* { box-sizing: border-box; }

/* class-level `display` beats the UA [hidden] rule, so state it explicitly */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--surface-1);
  color: var(--text-1);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-font-smoothing: antialiased;
}

body { display: flex; min-height: 100%; }

.skip {
  position: absolute; left: -9999px; top: 0; z-index: 3000;
  padding: 10px 16px; background: var(--accent); color: #fff;
}
.skip:focus { left: 0; }

/* ---------- sidebar ---------- */
.side {
  width: 232px; flex: none; display: flex; flex-direction: column;
  padding: 16px 12px; gap: 2px;
  background: var(--surface-3);
  border-right: 1px solid var(--border);
  overflow-y: auto;
}
.side-head { display: flex; gap: 10px; align-items: flex-start; padding: 4px 8px 16px; }
.side-head .logo { font-size: 1.25rem; color: var(--accent); line-height: 1.1; }
.side-head b { display: block; font-size: .95rem; letter-spacing: -.01em; }
.side-head small { display: block; font-size: .72rem; color: var(--text-3); line-height: 1.35; }

.side-lbl {
  margin: 14px 8px 6px; font-size: .68rem; font-weight: 650;
  text-transform: uppercase; letter-spacing: .07em; color: var(--text-3);
}
.side-nav { list-style: none; margin: 0; padding: 0; }
.side-nav a, .side-nav .soon {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 9px; border-radius: 8px;
  font-size: .875rem; color: var(--text-1); text-decoration: none;
}
.side-nav a:hover { background: var(--surface-2); }
.side-nav a.on { background: var(--accent); color: #fff; font-weight: 550; }
.side-nav .ic { font-size: .95rem; width: 18px; text-align: center; flex: none; }
.side-nav.muted .soon { color: var(--text-3); cursor: not-allowed; }
.side-nav.muted .ic { filter: grayscale(1); opacity: .65; }

.side-foot { margin-top: auto; padding-top: 16px; }
.langs { display: flex; flex-wrap: wrap; gap: 4px; padding: 0 4px; }
.langs a {
  padding: 5px 9px; border-radius: 7px; font-size: .8rem;
  color: var(--text-2); text-decoration: none; border: 1px solid transparent;
}
.langs a:hover { background: var(--surface-2); }
.langs a.on { background: var(--surface-2); border-color: var(--border); color: var(--text-1); font-weight: 600; }

/* ---------- page shell ---------- */
.shell { flex: 1; min-width: 0; display: flex; flex-direction: column; }

/* ---------- header ---------- */
/* Positioned with a z-index above Leaflet's panes (400) and controls (800/1000),
   otherwise the autocomplete list is painted behind the map. */
.bar {
  position: relative; z-index: 1100;
  display: flex; align-items: center; gap: 24px; flex-wrap: wrap;
  padding: 14px 20px;
  background: var(--surface-2);
  border-bottom: 1px solid var(--border);
}
.brand h1 { margin: 0; font-size: 1.15rem; font-weight: 650; letter-spacing: -.01em; }
.brand .sub { margin: 2px 0 0; font-size: .82rem; color: var(--text-2); }

.search { position: relative; margin-left: auto; width: min(380px, 100%); }
#q {
  width: 100%; padding: 10px 14px; font-size: 1rem;
  color: var(--text-1); background: var(--surface-1);
  border: 1px solid var(--border); border-radius: 9px;
}
#q:focus { outline: 2px solid var(--accent); outline-offset: 1px; border-color: transparent; }

.ac {
  position: absolute; top: calc(100% + 6px); left: 0; right: 0;
  margin: 0; padding: 4px; list-style: none; z-index: 1200;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
  max-height: 320px; overflow-y: auto;
}
.ac li {
  display: flex; justify-content: space-between; gap: 12px; align-items: baseline;
  padding: 8px 10px; border-radius: 6px; cursor: pointer;
}
.ac li:hover, .ac li[aria-selected="true"] { background: var(--surface-3); }
.ac .n { font-weight: 550; }
.ac .c { font-size: .78rem; color: var(--text-3); white-space: nowrap; }

/* ---------- layout ---------- */
main { flex: 1; display: flex; min-height: 0; }
.mapwrap { position: relative; flex: 1; min-width: 0; }
#map { position: absolute; inset: 0; background: var(--surface-3); }

.panel {
  width: 340px; flex: none; overflow-y: auto;
  padding: 20px; border-left: 1px solid var(--border);
  background: var(--surface-2);
}

/* ---------- panel content ---------- */
.empty h2, #result h2 { margin: 0 0 8px; font-size: 1.3rem; letter-spacing: -.015em; }
.empty p { color: var(--text-2); font-size: .9rem; }
.empty .note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--border); font-size: .84rem; }

.lnk {
  font: inherit; color: var(--accent); background: none; border: 0;
  padding: 0; cursor: pointer; text-decoration: underline;
}

.stats { display: flex; gap: 8px; margin: 14px 0 16px; }
.stat {
  flex: 1; padding: 10px; border-radius: 9px;
  background: var(--surface-3); text-align: center;
}
.stat b { display: block; font-size: 1.05rem; font-variant-numeric: tabular-nums; }
.stat span { font-size: .7rem; color: var(--text-2); }

.regions { display: flex; height: 26px; border-radius: 6px; overflow: hidden; gap: 2px; margin-bottom: 4px; }
.regions div {
  display: flex; align-items: center; justify-content: center;
  font-size: .72rem; font-weight: 600; color: var(--ink-on-dark); min-width: 0;
}
.reglab { display: flex; gap: 14px; font-size: .74rem; color: var(--text-2); margin-bottom: 18px; }
.reglab i { width: 9px; height: 9px; border-radius: 2px; display: inline-block; margin-right: 4px; }

#result h3 {
  margin: 18px 0 8px; font-size: .78rem; text-transform: uppercase;
  letter-spacing: .06em; color: var(--text-2); font-weight: 650;
}
#result h3 .hint { text-transform: none; letter-spacing: 0; color: var(--text-3); font-weight: 400; }

.ranked { margin: 0; padding: 0; list-style: none; }
.ranked li {
  display: grid; grid-template-columns: 1fr auto; gap: 8px; align-items: center;
  padding: 5px 0; border-bottom: 1px solid var(--border); font-size: .87rem;
  cursor: pointer;
}
.ranked li:hover { color: var(--accent); }
.ranked li:last-child { border-bottom: 0; }
.ranked .v { font-variant-numeric: tabular-nums; font-weight: 600; }
.ranked .p { font-size: .72rem; color: var(--text-3); }

/* ---------- legend & modes ---------- */
.legend, .modes {
  position: absolute; z-index: 500;
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow);
}
.legend { left: 12px; bottom: 22px; padding: 10px 12px; font-size: .78rem; }
.legend-head { font-weight: 600; margin-bottom: 6px; }
.legend ul { margin: 0; padding: 0; list-style: none; }
.legend li { display: flex; align-items: center; gap: 7px; padding: 1px 0; color: var(--text-2); }
.sw { width: 15px; height: 11px; border-radius: 2px; display: inline-block; flex: none; }
.sw.na { background: var(--na); border: 1px solid var(--border); }
.legend-na { display: flex; align-items: center; gap: 7px; margin-top: 6px;
             padding-top: 6px; border-top: 1px solid var(--border); color: var(--text-3); }

.modes { right: 12px; top: 12px; display: flex; padding: 3px; gap: 3px; }
.modes button {
  font: inherit; font-size: .8rem; padding: 6px 11px; border: 0; border-radius: 7px;
  background: none; color: var(--text-2); cursor: pointer;
}
.modes button.on { background: var(--accent); color: #fff; font-weight: 550; }

/* ---------- map bits ---------- */
.leaflet-container { font: inherit; background: var(--surface-3); }

/* our tooltip brings its own shell — drop Leaflet's box and arrow */
.leaflet-tooltip.bare {
  background: none; border: 0; box-shadow: none; padding: 0;
  white-space: nowrap;
}
.leaflet-tooltip.bare::before { display: none; }
.tip {
  padding: 7px 10px; border-radius: 8px; font-size: .82rem;
  background: var(--surface-2); color: var(--text-1);
  border: 1px solid var(--border); box-shadow: var(--shadow);
}
.tip b { display: block; font-size: .9rem; }
.tip .v { font-variant-numeric: tabular-nums; }
.tip .m { color: var(--text-3); font-size: .76rem; }

/* ---------- footer ---------- */
.foot {
  padding: 12px 20px; border-top: 1px solid var(--border);
  background: var(--surface-2); font-size: .76rem; color: var(--text-2);
}
.foot p { margin: 0 0 5px; }
.foot p:last-child { margin-bottom: 0; }
.foot .warn { color: var(--text-1); }

/* ---------- responsive ---------- */
@media (max-width: 1040px) {
  body { flex-direction: column; }
  .side {
    width: auto; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px; padding: 10px 12px; overflow-x: auto;
    border-right: 0; border-bottom: 1px solid var(--border);
  }
  .side-head { padding: 0 8px 0 0; }
  .side-head small { display: none; }
  .side-lbl { display: none; }
  .side-nav { display: flex; gap: 4px; }
  .side-foot { margin: 0 0 0 auto; padding: 0; }
}

@media (max-width: 860px) {
  main { flex-direction: column; }
  .mapwrap { height: 56vh; flex: none; }
  .panel { width: auto; border-left: 0; border-top: 1px solid var(--border); }
  .bar { gap: 12px; }
  .search { margin-left: 0; width: 100%; }
  .side-nav.muted { display: none; }   /* keep the mobile bar to what works */
}
