/* ================================
   Fonts (local, cache-friendly)
   ================================ */
@font-face {
  font-family: 'BeausiteClassicWeb';
  src: url('../fonts/BeausiteClassicWeb-Clear.woff2') format('woff2');
  font-weight: 400; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'BeausiteClassicWeb';
  src: url('../fonts/BeausiteClassicWeb-Medium.woff2') format('woff2');
  font-weight: 500; font-style: normal; font-display: swap;
}
@font-face {
  font-family: 'BeausiteClassicWeb';
  src: url('../fonts/BeausiteClassicWeb-Semibold.woff2') format('woff2');
  font-weight: 700; font-style: normal; font-display: swap;
}

/* ================================
   Global + App namespace
   ================================ */
html, body { font-family: 'BeausiteClassicWeb', Arial, sans-serif !important; }
body { margin: 0; background: #2D182D; color: #fff; }
.leaflet-container, .leaflet-control { font-family: inherit !important; }

.dash-loading {
  text-align: center;
  color: #fff;
  font-size: var(--font-body, 1rem);
  padding: 2rem 0;
  letter-spacing: 0.02em;
}

/* App shell + design tokens scoped to the dashboard */
.map-app {
  position: relative;
  /* Match container height to visible viewport minus header, so no extra space above footer */
  min-height: calc(var(--vh, 100vh) - var(--header-clear, 0px));
  z-index: 0;

  /* Layout */
  --header-clear: 9rem;      /* matches HEADER_CLEAR in page.js */
  --page-pad: 1.5rem;        /* matches <main> side padding */

  /* Type (base, labels, controls, title) */
  --font-body: 1rem;         /* 16px */
  --font-label: 0.875rem;    /* 14px */
  --font-control: 0.9375rem; /* 15px */
  --font-title: clamp(1.375rem, 1rem + 1.2vw, 2rem); /* ~22–32px */

  /* Map controls (zoom/home) */
  --zoom-size: clamp(2.25rem, 2.2vw, 2.75rem);   /* ~36–44px touch target */
  --zoom-font: clamp(1rem, 0.5rem + 1vw, 1.25rem);
  --zoom-radius: 10px;
  
  /* Legend and tooltip */
  --font-legend: clamp(0.65rem, 0.6rem + 0.2vw, 0.75rem);
  --font-tooltip: clamp(0.6rem, 0.55rem + 0.2vw, 0.7rem);
  --font-tip-title: clamp(0.7rem, 0.65rem + 0.2vw, 0.8rem);

  /* Hover info */
  --font-hover-body: 0.9375rem;                              /* 15px */
  --font-hover-name: clamp(1rem, 0.95rem + 0.4vw, 1.125rem); /* ~16–18px */
}

body.filters-open {
  overflow: hidden;
}

/* Viewport-height custom prop used elsewhere */
@supports (height: 100dvh) { .map-app { --vh: 100dvh; } }
@supports not (height: 100dvh) { .map-app { --vh: 100vh; } }



/* ================================s
   Left Panel + Layout (base visuals)
   ================================ */
#side-panel.map-side {
  padding: 16px 16px 0 16px;  /* inner spacing for the panel content */
  border-radius: 0px;        /* rounded corners for the panel */
  background: #2D182D;        /* panel background color */
  z-index: 500;               /* above the map canvas, below floating UI */
  display: flex;              /* vertical stack of panel sections */
  flex-direction: column;     /* stack children top → bottom */
  gap: 16px;                  /* space between sections */
  overflow: visible;
  align-self: stretch;
  height: clamp(52vh, 64vh, calc(var(--vh) - var(--header-clear)));
}

/* ================================
   Panel title (text styling)
   ================================ */
.panel-title {
  position: relative;         /* establishes containing block for ::after underline */
  margin: 0;                  /* rely on panel-heading gap */
  line-height: 1.1;           /* tight heading leading */
  font-weight: 700;           /* bold */
  font-size: var(--font-title);         /* heading size */
  color: #ffffff;             /* TITLE COLOR (mint) — recoloring the text */
  display: inline-block;      /* shrink to text width so the underline matches the title */
}

/* ================================
   Title underline (accent bar)
   ================================ */
.panel-title::after {
  content: "";
  position: absolute;         /* position relative to .panel-title */
  left: 0;
  bottom: -4px;               /* gap between text and line */
  width: 100%;                /* exactly the title width */
  height: 2px;                /* thin line */
  background: #A1FCB9;        /* UNDERLINE COLOR — recoloring the line */
  border-radius: 2px;         /* soft edges */
  display: block;
}

/* Prevent flexbox from stretching the title to full panel width */
#side-panel.map-side .panel-title {
  align-self: flex-start;
}

.panel-heading {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: -6px;
}

.panel-intro {
  margin: 0;
  font-size: var(--font-label);
  line-height: 1.45;
  color: #BCA3BE;
}

/* ================================
   Section blocks inside the panel
   ================================ */
.panel-section { margin: 0; }

/* ================================
   Filters (now INSIDE the panel)
   ================================ */
#filters {
  position: static;             /* no absolute positioning */
  padding: 0;
  margin-top: 12px;
  background: transparent;
  min-width: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: var(--font-label);
}

/* Make the Country block use the exact same internal layout as #filters */
#filters-country {
  position: static;
  padding: 0;
  background: transparent;
  min-width: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;                   /* <- same vertical rhythm as the other two controls */
  font-size: var(--font-label);
}

/* Ensure full-width control in that block (matches others) */
#filters-country .map-select { width: 100%; }

#filters label { 
  display: block; 
  font-weight: 500; 
  color: #BCA3BE;
  font-size: var(--font-label);
}

/* Ensure labels in any panel section look like the filters block */
#side-panel .panel-section label {
  display: block;
  font-weight: 500;
  color: #BCA3BE;
  font-size: var(--font-label);  /* match #filters labels */
}

/* Make country-select section use same spacing as #filters */
#side-panel .panel-section select.js-map-select {
  width: 100%;
}
/* Make the custom select wrapper fill the panel width */
#side-panel .map-select {
  display: block;
  width: 100%;
}

/* Hard-normalize typography + rendering for ALL enhanced selects */
#side-panel .map-select__toggle {
  appearance: none;
  -webkit-appearance: none;

  /* one-shot, identical metrics to inputs (wins over UA defaults) */
  font: 400 var(--font-control)/1.25 'BeausiteClassicWeb', Arial, sans-serif !important;
  letter-spacing: 0;

  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

/* Filters heading tweaks: same color/size as labels, no underline */
#side-panel .panel-title { 
  color: #BCA3BE; 
  font-size: clamp(1rem, 0.95rem + 0.5vw, 1.25rem); /* larger than body labels */
  font-weight: 400; /* match thinner subtitle style */
  margin: 0 0 8px 0; 
}
#side-panel .panel-title::after { display: none; }


/* Keep inputs and enhanced selects visually identical in the panel */
#side-panel .panel-section .map-ui-input,
#side-panel .panel-section .map-select__toggle {
  padding: 7px 10px;     /* your current control padding */
  border-radius: 4px;    /* your current control radius */
  width: 100%;
}

/* Top N slider + input layout */
.panel-topn { display: grid; grid-template-columns: 1fr auto; align-items: center; gap: 8px; }
/* Add the same spacing between label and control as other filters */
#filters-topn label + .panel-topn { margin-top: 8px; }
#filters-highlight label + .highlight-combobox { margin-top: 8px; }
.panel-topn {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: nowrap;
}

.panel-range-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  flex: 1;
  min-width: 0;
}

.panel-range {
  --range-fill: 100%;
  width: 100%;
  height: 11px;
  appearance: none;
  -webkit-appearance: none;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    rgba(161,252,194,0.65) 0%,
    rgba(161,252,194,0.65) var(--range-fill),
    rgba(110,95,111,0.45) var(--range-fill),
    rgba(110,95,111,0.45) 100%
  );
}

.panel-range--overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  background: none;
  pointer-events: none;
}

.panel-range--overlay::-webkit-slider-runnable-track,
.panel-range--overlay::-moz-range-track { background: none; }

.panel-range--overlay::-webkit-slider-thumb,
.panel-range--overlay::-moz-range-thumb,
.panel-range--overlay::-ms-thumb {
  pointer-events: auto;
}

.panel-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 15px;
  height: 15px;
  border-radius: 50%;
  background: #a1fcb9;
  border: 0;
  cursor: pointer;
  margin-top: 0px;
}
.panel-range::-moz-range-thumb {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #a1fcb9;
  border: 0;
  cursor: pointer;
}

#topn-range-min::-webkit-slider-thumb,
#topn-range-max::-webkit-slider-thumb { margin-top: 0px; }
#topn-range-min::-moz-range-thumb,
#topn-range-max::-moz-range-thumb { margin-top: 0; }

.panel-range::-webkit-slider-runnable-track,
.panel-range::-moz-range-track {
  height: 11px;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    rgba(161,252,194,0.75) 0%,
    rgba(161,252,194,0.75) var(--range-fill),
    rgba(110,95,111,0.5) var(--range-fill),
    rgba(110,95,111,0.5) 100%
  );
}

#topn-range-wrap {
  --range-start: 0%;
  --range-end: 100%;
  position: relative;
  flex: 1;
  min-width: 0;
  height: 15px;
  touch-action: none;
  border-radius: 6px;
  background: linear-gradient(
    to right,
    #6E5F6F 0%,
    #6E5F6F var(--range-start),
    rgba(161,252,194,0.7) var(--range-start),
    rgba(161,252,194,0.7) var(--range-end),
    #6E5F6F var(--range-end),
    #6E5F6F 100%
  );
}

#topn-range-wrap .panel-range {
  position: absolute;
  left: 0;
  right: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}
#topn-range-min,
#topn-range-max {
  top: 50%;
  transform: translateY(-50%);
}

.panel-topn-readout {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
  font-family: inherit;
  white-space: nowrap;
  font-size: clamp(0.7rem, 0.68rem + 0.12vw, 0.85rem);
}

#filters-topn .panel-number {
  font-size: clamp(0.7rem, 0.68rem + 0.12vw, 0.85rem);
}

.panel-number {
  width: 4ch;
  text-align: right;
  background: transparent;
  color: #A1FCB9;
  font-weight: 700;
  border: none;
  outline: none;
  font-family: inherit;
  font-size: inherit;
}
.panel-number.panel-number--inline {
  width: 4.5ch;
}
.panel-number::-webkit-outer-spin-button,
.panel-number::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.panel-topn-sep,
.panel-topn-of { color: #BCA3BE; font-weight: 500; font-size: inherit; }
.panel-topn-total { color: #BCA3BE; font-weight: 500; min-width: 4ch; display: inline-block; text-align: left; font-family: inherit; font-size: inherit; }

/* Keep Show top section spacing consistent with other filters */
#filters-topn { margin-top: 8px; }

/* Custom select (enhancer output) */
.map-select { position: relative; }
.map-select__toggle {
  background: #6E5F6F; color: #fff; font-family: inherit; font-size: var(--font-control);
  font-weight: 400; border: none; border-radius: 4px; padding: 7px 10px; width: 100%;
  text-align: left; cursor: pointer;
}
.map-select__toggle:focus { outline: none; box-shadow: 0 0 6px 1px rgba(255,255,255,0.15); }
.map-select__chevron {
  position: absolute; right: 10px; top: 50%; transform: translateY(-50%);
  pointer-events: none; opacity: 0.8;
}
.map-select__menu {
  position: absolute; left: 0; right: 0; top: calc(100% + 6px); z-index: 1600;
  display: none; background: rgba(42, 25, 44, 0.98);
  border: 1px solid rgba(255,255,255,0.15); border-radius: 6px; padding: 4px;
  max-height: 240px; overflow-y: auto; font-family: inherit;
}
.map-select.open .map-select__menu { display: block; }
.map-select__group {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #BCA3BE;
  padding: 8px 8px 4px;
  cursor: default;
}
.map-select__option {
  padding: 6px 8px; border-radius: 4px; cursor: pointer; color: #fff; font-weight: 500;
}
.map-select__option:hover,
.map-select__option[aria-selected="true"] { background: #6E5F6F; }

.highlight-combobox {
  position: relative;
}

.highlight-combobox .map-ui-input {
  width: 100%;
}

.highlight-ac {
  position: absolute;
  left: 0;
  right: 0;
  top: calc(100% + 4px);
  display: none;
  max-height: 240px;
  overflow-y: auto;
  background: rgba(42, 25, 44, 0.98);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px;
  z-index: 10;
  box-shadow: 0 8px 16px rgba(0,0,0,0.25);
}

.highlight-ac__option {
  padding: 6px 10px;
  cursor: pointer;
  color: #fff;
  font-size: var(--font-label);
}

.highlight-ac__option:hover,
.highlight-ac__option[aria-selected="true"] {
  background: #6E5F6F;
}

.panel-note {
  margin-top: auto;
  margin-bottom: 0;
  padding-top: 0px;
  padding-bottom:0px;
  font-size: clamp(0.65rem, 0.6rem + 0.2vw, 0.75rem);
  line-height: 1.4;
  color: #BBA1BE;
}
.panel-note:not(:last-child) {
  padding-bottom: 0px;
}
.panel-note + .panel-note {
  margin-top: 0;
  padding-top: 0;
}

/* Kill any legacy Leaflet .info box if still present */
.map-app .info { display: none !important; }

.map-app .leaflet-top.leaflet-right {
  margin-top: 12px;   /* push down from very top */
  margin-right: 12px; /* spacing from right edge */
}

/* ================================
   Search (stays on the map, bottom-right)
   ================================ */

/* Make the input box render cleanly (no cut text/border) */
.map-app #search-region .map-ui-input {
  display: block;
  width: 260px;          /* or 100% if you give #search-region a fixed width */
  height: 36px;          /* consistent box height */
  line-height: 1.2;      /* avoid clipping the text baseline */
  padding: 6px 12px;     /* inside spacing without overflow */
  box-sizing: border-box;
  border: 0;
  -webkit-appearance: none;
  appearance: none;
}

/* Shared input look */
.map-ui-input {
  background: #6E5F6F;
  color: #fff;
  font-family: inherit;
  font-size: var(--font-control);
  font-weight: 400;
  border: none;
  border-radius: 4px;
  padding: 7px 10px;
  width: 100%;
}
.map-ui-input::placeholder { color: #fff; opacity: 1; }
.map-ui-input:focus {
  outline: none;
  box-shadow: 0 0 6px 1px rgba(255,255,255,0.15);
  background-color: #6E5F6F;
}

/* Autocomplete dropdown (JS positions it; ensure above map) */
#region-ac {
  position: fixed;
  z-index: 1500;
  display: none;
  background: rgba(42, 25, 44, 0.98);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  padding: 4px;
  max-height: 240px;
  overflow-y: auto;
  font-family: inherit;
}
#region-ac div {
  padding: 6px 8px; border-radius: 4px; cursor: pointer; color: #fff; font-weight: 500;
}
#region-ac div:hover,
#region-ac div[aria-selected="true"] { background: #6E5F6F; }

/* ================================
   Leaflet background
   ================================ */
.leaflet-container { background: #2D182D; }

/* ================================
   Zoom + Home buttons (top-right by Leaflet control)
   ================================ */



.zoom-home {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 26px;
  padding: 0;
}
.zoom-block + .zoom-block {
  margin-top: 10px;
}
.zoom-block {
  width: 36px;
  background: #6C606E;
  border: none;
  border-radius: 6px;
  box-shadow: 0 6px 16px rgba(15, 10, 25, 0.35);
  overflow: hidden;
}
.zoom-block--knob {
  display: grid;
  grid-template-rows: repeat(3, 36px);
}
.zoom-block__btn {
  width: 36px;
  height: 36px;
  background: #6C606E;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #FFFFFF;
  font-size: 16px;
  font-weight: bold;
  transition: filter 0.12s ease;
}
.zoom-block__btn:hover { filter: brightness(0.9); }
.zoom-block__btn--top { box-shadow: inset 0 -1px rgba(255, 255, 255, 0.12); }
.zoom-block__btn--mid { box-shadow: inset 0 1px rgba(0, 0, 0, 0.16), inset 0 -1px rgba(255, 255, 255, 0.12); }
.zoom-block__btn--bottom { box-shadow: inset 0 1px rgba(0, 0, 0, 0.16); }
.zoom-block__btn--single { font-size: 16px; }

.zoom-block--single {
  display: flex;
}
.zoom-home__icon { font-size: 16px; line-height: 1; color: #FFFFFF; }

.zoom-lock-btn {
  color: #FFFFFF;
  background: #6C606E;
}
.zoom-lock-btn.is-active {
  background: #A1FCB9;
  color: #1F0B20;
}
.zoom-lock__icon {
  pointer-events: none;
  width: 16px;
  height: 16px;
  display: block;
}

/* Prevent sticky white/clear background after click */
.zoom-block__btn:focus-visible {
  outline: 2px solid #A1FCB9;
  outline-offset: 2px;
}
.zoom-block__btn:active {
  filter: brightness(0.82);
}

.zoom-lock-btn:focus-visible {
  outline: 2px solid #A1FCB9;
  outline-offset: 2px;
}

/* ================================
   Small screens (legacy adjustments)
   ================================ */
@media (max-width: 600px) {
  #side-panel.map-side { padding: 14px; }
  .map-app { --font-title: clamp(1.25rem, 1rem + 1vw, 1.75rem); }
}

/* ================================
   Nice scrollbars (optional)
   ================================ */
.map-select__menu::-webkit-scrollbar,
#region-ac::-webkit-scrollbar { width: 8px; }
.map-select__menu::-webkit-scrollbar-track,
#region-ac::-webkit-scrollbar-track { background: rgba(255,255,255,0.06); border-radius: 8px; }
.map-select__menu::-webkit-scrollbar-thumb,
#region-ac::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 8px; }
.map-select__menu::-webkit-scrollbar-thumb:hover,
#region-ac::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.35); }

/* Firefox */
.map-select__menu,
#region-ac {
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.35) rgba(255,255,255,0.06);
}

/* Dashboard-specific scrollbar color override (keeps global mint elsewhere) */
.map-app ::-webkit-scrollbar-thumb {
  background-color: var(--purple);
}
.map-app ::-webkit-scrollbar-thumb:hover {
  background-color: rgba(255,255,255,0.35);
}
.map-app,
.map-app * {
  scrollbar-color: var(--purple) transparent;
}

/* Filters & autocomplete: override global scrollbar tint */
.map-app .map-select__menu::-webkit-scrollbar-thumb,
.map-app #region-ac::-webkit-scrollbar-thumb {
  background-color: #5f4461;
}
.map-app .map-select__menu::-webkit-scrollbar-thumb:hover,
.map-app #region-ac::-webkit-scrollbar-thumb:hover {
  background-color: #5f4461;
}
.map-app .map-select__menu,
.map-app #region-ac {
  scrollbar-color: #5f4461 rgba(255,255,255,0.06);
}

/* Make Leaflet zoom/home buttons keep our dark look in ALL states */
.map-app .leaflet-bar.zoom-home a,
.map-app .leaflet-bar.zoom-home a:hover,
.map-app .leaflet-bar.zoom-home a:focus,
.map-app .leaflet-bar.zoom-home a:active,
.map-app .leaflet-bar.zoom-home a:focus-visible,
.map-app .leaflet-bar.zoom-home a.leaflet-disabled,
.map-app .leaflet-bar.zoom-home a.leaflet-disabled:hover {
  background: #6E5F6F !important;
  color: #fff !important;
  border-color: transparent !important;
  outline: none !important;
  box-shadow: none !important;
  filter: none !important;
   width: var(--zoom-size);
  height: var(--zoom-size);
  line-height: var(--zoom-size);
  text-align: center;
  font-weight: 700;
  border-radius: var(--zoom-radius);
  -webkit-tap-highlight-color: transparent; /* kill iOS/Chrome gray flash */
}

/* Only darken on hover (mouse) */
.map-app .leaflet-bar.zoom-home a:hover {
  filter: brightness(0.9) !important;
}

/* Make sure the dropdown sits over any input glow */
.map-app #region-ac {
  margin: 0;                 /* no stray spacing */
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 10px;
}

/* Reduce the input glow so there’s no 'gap' halo */
.map-app .map-ui-input:focus {
  outline: none;
  box-shadow: 0 0 4px 0 rgba(255,255,255,0.12); /* smaller & softer */
  background-color: #6E5F6F;
}

/* Legend */
.legend {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: stretch;
}
.legend__title {
  font-size: var(--font-legend);
  color: #BCA3BE;
  white-space: nowrap;
}
.legend__value { font-size: var(--font-legend); color: #ffffff; white-space: nowrap; }

.legend__row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex: 1;
  min-width: 0;
}

.legend__scale {
  display: flex;
  flex: 1;
  min-width: 0;
}

.legend__swatch {
  height: 14px;
  flex: 1;
  border-radius: 0;
}

.leaflet-control-zoom-home .zh-icon {
  width: 14px;
  height: 14px;
  vertical-align: middle;
  pointer-events: none; /* so clicks go through to the button */
}

/* On-map tooltip */
.leaflet-tooltip.map-tip {
  background:  #341C37;
  color: #fff;
  border: 0;
  border-radius: 8px;
  padding: 12px 16px;
  box-shadow: 0 2px 8px rgba(0,0,0,.25);
  font-size: var(--font-tooltip);
  line-height: 1.25;
  max-width: none;
  width: min(270px, calc(100vw - 32px));
  white-space: normal;
  word-wrap: break-word;
  text-align: left;
}
.map-tip .tip-title {
  color: #A1FCB9;   
  font-weight: 600; 
  font-size: var(--font-tip-title);

}

.map-tip .tip-row { display: flex; gap: 8px; align-items: baseline; }
.map-tip .tip-m { opacity: 0.85; }
.map-tip .tip-v { margin-left: auto; font-weight: 600; }
.map-tip .tip-spark { display: block; margin-top: 4px; }

.map-tip .tip-delta {
  margin-top: 2px;
  font-size: var(--font-tooltip);
  line-height: 1.2;
  color:#c6c6c6
}
.map-tip .tip-delta--national { color: #FFFFFF; }
.dot-plot-tip .tip-delta--eu { color: #B8B8C2; }
.dot-plot-tip .tip-delta--national { color: #FFFFFF; }
.map-tip .tip-line--value,
.dot-plot-tip .tip-line--value {
  display: block;
  margin-top: 6px;
}
.map-tip .tip-line--value .tip-line-text,
.dot-plot-tip .tip-line--value .tip-line-text {
  display: block;
  color: #A1FCB9;
}
.map-tip .tip-line--value .tip-line-text .tip-value,
.dot-plot-tip .tip-line--value .tip-line-text .tip-value {
  display: inline;
  font-weight: 600;
}

.dot-plot-tip {
  font-size: clamp(0.7rem, 0.65rem + 0.2vw, 0.8rem) !important;
  line-height: 1.2;
  padding: 6px 12px;
  max-width: none;
  width: min(420px, calc(100vw - 32px));
  white-space: normal;
}
.dot-plot-tip .tip-v {
  font-weight: 600;
  letter-spacing: 0.01em;
}

.leaflet-tooltip.map-tip::before,
.leaflet-tooltip.map-tip::after {
  display: none !important;
  content: none !important;
}

/* Kill the iOS/Safari tap highlight on the map + controls */
#map,
.leaflet-container,
.leaflet-control a,
.map-select__toggle {
  -webkit-tap-highlight-color: transparent; /* iOS Safari */
}

/* Also suppress default outlines on mouse/touch,
   but keep keyboard focus rings via :focus-visible */
.leaflet-container:focus,
.leaflet-control a:focus,
.map-select__toggle:focus {
  outline: none !important;
  box-shadow: none !important;
}

.leaflet-container:focus-visible,
.leaflet-control a:focus-visible,
.map-select__toggle:focus-visible {
  /* If you prefer a subtle brand ring instead of none, swap these two lines: */
  outline: none !important;
  box-shadow: none !important;
}

/* Some browsers draw a box-shadow focus ring on anchors; neutralize it */
.leaflet-control a {
  box-shadow: none !important;
}

/* Chrome/Webkit: remove their internal focus highlight */
.leaflet-container,
.leaflet-control a {
  -webkit-tap-highlight-color: transparent; /* Safari/iOS */
  outline: none !important;
}

/* Idle map: custom grab cursor (with PNG fallback) */
.leaflet-container {
  cursor: url("../cursors/grab.svg") 16 16, url("../cursors/grab.png") 16 16, grab !important;
}
.leaflet-dragging .leaflet-container {
  cursor: url("../cursors/grabbing.svg") 16 16, url("../cursors/grabbing.png") 16 16, grabbing !important;
}

/* Hover / Click (triggered by JS adding classes to <body>) */
body.cursor-hover,
body.cursor-hover * {
  cursor: url("../cursors/hover.svg") 6 2, url("../cursors/hover.png") 6 2, pointer !important;
}
body.cursor-click,
body.cursor-click * {
  cursor: url("../cursors/click.svg") 6 2, url("../cursors/click.png") 6 2, pointer !important;
}

/* === Cursor override (strong selectors) === */
html body #map.cursor-hover,
html body #map.cursor-hover * ,
html body #map.cursor-hover .leaflet-pane,
html body #map.cursor-hover .leaflet-pane * ,
html body #map.cursor-hover canvas {
  cursor: url("/assets/cursors/hover.svg") 6 2, url("/assets/cursors/hover.png") 6 2, pointer !important;
}
html body #map.cursor-click,
html body #map.cursor-click * ,
html body #map.cursor-click .leaflet-pane,
html body #map.cursor-click .leaflet-pane * ,
html body #map.cursor-click canvas {
  cursor: url("/assets/cursors/click.svg") 6 2, url("/assets/cursors/click.png") 6 2, pointer !important;
}

/* Global cursor override while hovering/clicking a region */
body.cursor-hover,
body.cursor-hover * {
  cursor: url("/assets/cursors/hover.svg") 6 2, url("/assets/cursors/hover.png") 6 2, pointer !important;
}
body.cursor-click,
body.cursor-click * {
  cursor: url("/assets/cursors/click.svg") 6 2, url("/assets/cursors/click.png") 6 2, pointer !important;
}

/* === Custom cursor sprite (robust across Canvas/SVG) === */
#map .map-cursor {
  position: absolute;
  width: 32px;
  height: 32px;
  background-repeat: no-repeat;
  background-size: contain;
  pointer-events: none;
  transform: translate(-6px, -2px); /* hotspot offset */
  z-index: 9999;
  display: none;
}

/* Hide system cursor while our sprite is visible */
#map.cursor-none,
#map.cursor-none * {
  cursor: none !important;
}

/* === Responsive grid layout for dashboard === */
.map-app { --header-clear: 9rem; } /* unified clearance for header + layout */

/* Vertical divider aligned to the map edge (desktop only) */
/* Divider drawn relative to the dashboard container (main) */
.dash-main { position: relative; }
.dash-main::before {
  content: "";
  position: absolute;
  top: 0;          /* start at top of dashboard content (just under header) */
  bottom: 0;       /* end at bottom of dashboard content (above footer) */
  left: calc(var(--dash-divider-left-rel, -9999px) + var(--dash-divider-nudge, 0px)); /* set via JS; optional pixel nudge */
  width: 1px;
  background: var(--dash-divider-color, rgba(255,255,255,0.2));
  pointer-events: none;
  z-index: 1;
}

@media (max-width: 1024px) {
  .dash-main::before { display: none; }
}
@supports (height: 100dvh) { .map-app { --vh: 100dvh; } }
@supports not (height: 100dvh) { .map-app { --vh: 100vh; } }


.dash-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) clamp(220px, 18vw, 280px);
  grid-template-areas:
    "header filters"
    "visual filters";
  gap: 12px;
  height: calc(var(--vh) - var(--header-clear));
  min-height: 0;
}

.dash-content {
  grid-area: header;
  display: grid;
  grid-template-rows: auto auto;
  row-gap: 10px;
}
.dash-header {
  margin-bottom: 6px;
  padding-right: 1.5rem;
}
.dash-title { 
  margin: 0 0 6px 0; 
  color: #A1FCB9; 
  font-weight: 500; 
  font-size: clamp(0.9rem, 0.85rem + 1.2vw, 1.85rem);
}
.dash-subtitle { 
  margin: 0; 
  color: #ffffff; 
  font-size: clamp(0.8rem, 0.75rem + 0.24vw, 0.95rem);
}

/* Split: left text/plot, right map */




.dash-visual {
  grid-area: visual;
  display: grid;
  grid-template-columns: minmax(260px, 34%) 1fr;
  gap: 16px;
  align-items: stretch;
  min-height: 0;
  height: auto;
}


.dash-visual .dash-left,
.dash-visual .map-wrap {
  height: auto;
  min-height: 0;
}

.dash-visual .dash-left { 
  display: grid; 
  grid-template-rows: 1fr auto; 
  row-gap: 12px; 
  min-width: 0; 
  min-height: clamp(48vh, 58vh, calc(var(--vh) - var(--header-clear)));
  --dot-gutter: 12px;           /* space reserved for scrollbar lane */
  --dot-size: 19px;             /* shared dot diameter */
  --dot-left-pad: calc(var(--dot-size) / 2); /* keep min-value dot fully visible */
  --dot-right-extra: 4px;       /* extra breathing room beyond the max-value dot */
}

.dash-visual .dash-left #dot-plot {
  height: 100%;
  max-height: none;
  overflow-y: auto;
  scrollbar-gutter: stable;
  overscroll-behavior: contain;
}

.dash-subhead { 
  font-size: clamp(0.85rem, 0.8rem + 0.6vw, 1.05rem);
  line-height: 1.25;
  font-weight: 400;
  color: #ffffff; 
  display: inline-block;
  padding-bottom: 2px;
  margin-bottom: 2px;
  align-self: start;
  justify-self: start;
  word-break: break-word;
  max-width: 90%;
}
.dash-subhead__text,
.dash-subhead__meta {
  display: inline;
  white-space: normal;
  line-height: 1.25;
}

.dash-subhead::after {
  content: "";
  display: inline-block;
  width: 100%;
  height: 2px;
  background: #A1FCB9;
  margin-top: 4px;
}

@media (max-width: 720px) {
  .dash-subhead {
    display: block;
    line-height: 1.3;
  }
  .dash-subhead__meta {
    white-space: normal;
  }
}

/* Dot plot */
.dot-plot { 
  display: grid; 
  row-gap: 12px; 
  width: 100%; 
  max-width: 100%; 
  min-height: 0; 
  overflow-y: auto; /* show native scrollbar only when overflow exists */
  overflow-x: hidden;  /* never show horizontal scroll */
  scrollbar-gutter: stable; /* keeps layout stable when scrollbar appears */
  --dot-gutter: 6px; /* keep dots away from scrollbar */
  --scroll-width: 8px; /* overlay scrollbar width */
  --scroll-inset: 4px; /* distance from the right edge of the dot-plot to the overlay */
  --scroll-buffer: 12px; /* extra breathing room between thumb and content */
  padding-right: calc(var(--dot-gutter) + var(--scroll-width) + var(--scroll-buffer)); /* keep content clear of thumb */
  box-sizing: border-box;
  position: relative;
  user-select: none; /* avoid text selection during thumb drag */
  scroll-behavior: smooth;
}

.map-app #dot-plot {
  scrollbar-width: none; /* Firefox: hide native scrollbar */
}
.map-app #dot-plot::-webkit-scrollbar {
  width: 0;
  height: 0;
}

.dot-scroll-thumb {
  position: fixed;
  width: 8px;
  min-height: 16px;
  background: rgb(86, 63, 89); /* darker muted purple */
  border-radius: 0;
  box-shadow: 0 0px 0px rgba(8, 3, 15, 0.55);
  opacity: 0.9;
  display: none;
  pointer-events: none;
  z-index: 900;
  transition: opacity 0.15s ease;
}

.dot-row { 
  display: grid; 
  grid-template-rows: auto auto;  /* label above, track below */
  grid-template-columns: 1fr; 
  align-items: center; 
  row-gap: 3px;                /* tighter spacing so label sits just above dot */
  min-width: 0; 
  transition: opacity 0.18s ease;
}
.dot-label { 
  color: #ffffff; 
  font-weight: 500;  /* in-between weight */
  font-size: var(--font-legend);  /* smaller labels */
  white-space: normal; 
  overflow-wrap: anywhere; 
}
.dot-track { position: relative; height: 22px; background: transparent; }
.dot-area { position: absolute; left: var(--dot-left-pad); right: calc(var(--dot-gutter) + var(--dot-left-pad)); top: 0; bottom: 0; }
.dot-area::before {
  content: "";
  position: absolute;
  left: calc(-1 * var(--dot-left-pad));
  right: calc(-1 * (var(--dot-left-pad) + var(--dot-right-extra)));
  top: 50%;
  height: 1px;
  background: #6E5F6F;
  border-radius: 999px;
  transform: translateY(-0.5px);
}
.dot { position: absolute; top: 50%; transform: translate(-50%, -50%); width: var(--dot-size); height: var(--dot-size); border-radius: 50%; background: #307A79; box-shadow: 0 0 0 2px rgba(0,0,0,0.08); transition: transform 0.16s ease, box-shadow 0.16s ease, opacity 0.16s ease; }
.dot--avg {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.7);
  box-shadow: 0 0 0 1px rgba(0,0,0,0.25);
  pointer-events: none;
}
.dot-row--hover .dot--avg,
.dot-row--focus .dot--avg {
  opacity: 1;
  transform: translate(-50%, -50%) scale(0.95);
}
.dot--avg-eu { background: #9CA0A8; }
.dot--avg-national { background: #FFFFFF; box-shadow: 0 0 0 1px rgba(0,0,0,0.35); }
.dot-row--hover .dot--value,
.dot-row--focus .dot--value,
.dot--value.dot--active {
  background: #A1FCB9 !important;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.18);
}

.dot-row--focus .dot-label { color: #A1FCB9; font-weight: 600; }
.dot-row--focus .dot {
  transform: translate(-50%, -50%) scale(1.08);
}
.dot-plot--has-focus .dot-row:not(.dot-row--focus) { opacity: 0.35; }



/* Dot plot scrollbar (thin and subtle) */
/* Hide native scrollbar (we provide a custom indicator). Still scrollable. */

.map-wrap {
  position: relative;
  border-radius: 0px; /* rounding the map border */
  overflow: hidden;
  background: #2D182D;
  min-height: clamp(48vh, 58vh, calc(var(--vh) - var(--header-clear)));
  height: auto;
}
#map { width: 100%; height: 100%; }

/* DESKTOP/TABLET: panel behaves like a sticky column */
#side-panel.map-side {
  grid-area: filters;
  position: sticky;
  top: 0;
  align-self: stretch;
  height: auto;
  overflow: visible;
  z-index: 500;
}

/* Keep your existing on-map controls */
#search-region {
  position: absolute;     
  right: 12px;
  bottom: 12px;
  z-index: 600;           /* above tiles, below menus is fine */
}

/* Filters toggle + sheet scrim (mobile-first, hidden by default) */
.panel-toggle {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translate(-50%, 0);
  display: none;
  align-items: center;
  gap: 10px;
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: 999px;
  background: #A1FCB9;
  color: #1F0B20;
  font-family: inherit;
  font-size: var(--font-control);
  font-weight: 600;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 16px 34px rgba(15, 10, 25, 0.48);
  z-index: 1500;
  transition: opacity 0.22s ease, transform 0.22s ease;
  opacity: 0;
  pointer-events: none;
}

.panel-toggle:focus-visible {
  outline: 2px solid rgba(31, 11, 32, 0.9);
  outline-offset: 3px;
}

.map-app.in-view .panel-toggle {
  opacity: 1;
  pointer-events: auto;
}

.map-app.panel-open .panel-toggle {
  opacity: 1;
  pointer-events: auto;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 28px);
  top: auto;
  transform: translate(-50%, 0);
}

.panel-scrim {
  position: fixed;
  inset: 0;
  background: rgba(12, 6, 18, 0.68);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 1150;
  display: none;
}

.panel-scrim.is-active {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.panel-close {
  display: none;
}


/* MOBILE/TABLET: single-column layout + bottom-sheet filters */
@media (max-width: 1024px) {
  .dash-title {
    font-size: clamp(1.35rem, 1.1rem + 1.6vw, 2.1rem);
  }

  .dash-subtitle {
    font-size: clamp(1.05rem, 1rem + 0.6vw, 1.35rem);
  }

  .dash-subhead {
    font-size: clamp(0.9rem, 0.85rem + 0.45vw, 1.12rem);
  }

  .map-app {
    padding-bottom: 88px;
  }

  .map-app.panel-open {
    padding-bottom: 24px;
  }

  .dash-grid {
    grid-template-columns: 1fr;
    height: auto;
    min-height: 0;
  }

  .dash-visual {
    display: flex;
    flex-direction: column;
    gap: 16px;
    height: auto;
    min-height: 0;
    margin-bottom: 0;
  }

  .dash-visual .map-wrap {
    order: 1;
    height: auto;
    min-height: 60dvh;
  }

  .dash-visual .dash-left {
    order: 2;
    height: auto;
    min-height: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
  }

  .dash-visual .dash-left,
  .dash-visual .map-wrap {
    height: auto;
  }

  .dash-visual .dash-left #dot-plot {
    order: 1;
    max-height: 60vh;
    height: auto;
    overflow-y: auto;
    scrollbar-gutter: stable;
    overscroll-behavior: contain;
    touch-action: pan-y;
  }

  #legend-under-plot {
    order: 0;
    margin-bottom: 4px;
  }

  .panel-toggle,
  .panel-scrim {
    display: block;
  }

  .panel-toggle {
    font-size: clamp(0.95rem, 0.9rem + 0.4vw, 1.05rem);
    padding: 0.75rem 1.9rem;
  }

  .panel-scrim {
    backdrop-filter: blur(3px);
    display: block;
  }

  .panel-close {
    align-items: center;
    gap: 6px;
    align-self: flex-end;
    margin-left: auto;
    margin-bottom: 8px;
    padding: 0.35rem 0.75rem;
    border: none;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    font-family: inherit;
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    cursor: pointer;
  }

  .map-app.panel-open .panel-close {
    display: inline-flex;
  }

  .panel-close:focus-visible {
    outline: 2px solid rgba(255, 255, 255, 0.45);
    outline-offset: 3px;
  }

  #side-panel.map-side {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0 auto;
    width: min(640px, 100%);
    padding-top: clamp(28px, 5vh, 44px);
    padding-inline: 20px;
    padding-bottom: calc(28px + 76px);
    border-radius: 24px 24px 0 0;
    background: rgba(45, 24, 45, 0.3);
    box-shadow: 0 -18px 46px rgba(8, 3, 12, 0.65);
    transform: translateY(110%);
    transition: transform 0.32s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.22s ease;
    max-height: min(78vh, calc(var(--vh) - 120px));
    overflow-y: auto;
    pointer-events: none;
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(0px);
    opacity: 0;
    visibility: hidden;
    z-index: 1300;
  }

  .map-app.panel-open #side-panel.map-side {
    transform: translateY(0);
    pointer-events: auto;
    opacity: 1;
    visibility: visible;
  }

  .map-app.panel-open #search-region {
    bottom: calc(20px + 56px);
  }

  #filters-highlight {
    display: none !important;
  }
}

/* Let page scroll vertically when finger is over the map (mobile/tablet) */
@media (pointer: coarse), (max-width: 1024px) {
  .leaflet-container {
    touch-action: pan-y !important; /* allow vertical pan to bubble to page */
  }
}

/* Mobile/tablet: match the dashboard’s small-screen rhythm */
@media (max-width: 1024px) {
  #eu-home-map {
    min-height: 60dvh;  /* dashboard uses this for its map on small screens */
    height: auto;
  }
}

/* Kill the default Leaflet control box around the group */
.map-app .leaflet-bar.zoom-home {
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
}

/* Optional: remove the thin separators Leaflet adds between <a> items */
.map-app .leaflet-bar.zoom-home a {
  border: none !important;          /* no inner borders */
}

/* Optional: tighten the vertical stack spacing (looks like a tidy pill stack) */
.map-app .leaflet-bar.zoom-home {
  display: inline-flex;              /* let us control spacing cleanly */
  flex-direction: column;
  gap: 0px;                          /* adjust to taste (6–10px) */
}
