/* Scientific, subdued polar aesthetic */
:root{
  --bg0:#0b1218;
  --bg1:#0f1a22;
  --ink: rgba(235,245,255,0.92);
  --muted: rgba(235,245,255,0.65);
  --line: rgba(235,245,255,0.14);
  --land: rgba(235,245,255,0.08);
  --coast: rgba(235,245,255,0.18);
  --country: rgba(235,245,255,0.10);
  --circleFill: rgba(255,255,255,0.88);
  --circleStroke: rgba(10,18,25,0.55);

  --titleFont: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, "Helvetica Neue", Arial, "Noto Sans", "Liberation Sans", sans-serif;
}

html, body { height:100%; margin:0; }
body{
  background: radial-gradient(1200px 900px at 55% 35%, rgba(255,255,255,0.10), transparent 55%),
              radial-gradient(900px 650px at 35% 60%, rgba(100,180,255,0.14), transparent 60%),
              linear-gradient(180deg, var(--bg1), var(--bg0));
  color: var(--ink);
  font-family: var(--titleFont);
  overflow: hidden;
}

.masthead{
  position: fixed;
  left: 18px; top: 14px;
  z-index: 50;
  max-width: min(560px, calc(100vw - 36px));
  pointer-events: none;
}
.title{
  font-weight: 750;
  letter-spacing: 0.01em;
  font-size: 22px;
  text-shadow: 0 12px 30px rgba(0,0,0,0.35);
}
.subtitle{
  margin-top: 4px;
  font-size: 13px;
  color: var(--muted);
}

#app{ position:relative; width:100vw; height:100vh; }

#mapWrap{
  position:absolute; inset:0;
  z-index: 1;
  display:flex;
  align-items:center;
  justify-content:center;
}

#svg{
  width: 100%;
  height: 100%;
}

#loading{
  position:absolute;
  z-index: 20;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(10,18,25,0.55);
  border: 1px solid rgba(235,245,255,0.10);
  backdrop-filter: blur(10px);
  font-size: 13px;
  color: var(--muted);
}

.plate{
  filter: drop-shadow(0 24px 70px rgba(0,0,0,0.55));
}

.land { fill: var(--land); stroke: var(--coast); stroke-width: 0.8; }
.countries { fill: none; stroke: var(--country); stroke-width: 0.6; }

.graticule { fill: none; stroke: rgba(235,245,255,0.06); stroke-width: 0.6; }

.symbol{
  fill: var(--circleFill);
  stroke: var(--circleStroke);
  stroke-width: 1.2;
  vector-effect: non-scaling-stroke;
  filter: drop-shadow(0 6px 18px rgba(0,0,0,0.35));
}

.symbol.dim { opacity: 0.25; }

/* Info panel (no pointer/arrow) */
.info{
  position: fixed;
  right: 18px;
  top: 84px;
  width: min(320px, calc(100vw - 36px));
  z-index: 60;
  background: rgba(8, 14, 20, 0.72);
  border: 1px solid rgba(235,245,255,0.12);
  border-radius: 14px;
  padding: 14px 14px 12px 14px;
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
}
.info.hidden{ display:none; }
.close{
  position:absolute; right:10px; top:8px;
  width: 30px; height:30px;
  border-radius: 10px;
  border: 1px solid rgba(235,245,255,0.12);
  background: rgba(255,255,255,0.06);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
}
.infoTitle{
  font-weight: 750;
  margin-bottom: 10px;
}
.row{
  display:flex; justify-content:space-between; gap: 12px;
  padding: 8px 0;
  border-top: 1px solid rgba(235,245,255,0.08);
}
.row:first-of-type{ border-top:none; }
.label{ color: var(--muted); font-size: 12px; }
.value{ font-weight: 700; font-size: 12px; }
.note{
  margin-top: 10px;
  color: rgba(235,245,255,0.55);
  font-size: 12px;
  line-height: 1.35;
}

/* Sources button + modal */
.sourcesBtn{
  position: fixed;
  right: 16px;
  bottom: 16px;
  z-index: 70;
  width: 44px; height: 44px;
  border-radius: 14px;
  border: 1px solid rgba(235,245,255,0.14);
  background: rgba(10,18,25,0.55);
  backdrop-filter: blur(10px);
  cursor:pointer;
}
.hamburger{
  display:block; width: 18px; height: 12px; margin: 0 auto;
  position: relative; top: 1px;
}
.hamburger::before, .hamburger::after, .hamburger{
  border-top: 2px solid rgba(235,245,255,0.75);
}
.hamburger::before, .hamburger::after{
  content:"";
  position:absolute; left:0; right:0;
}
.hamburger::before{ top: -6px; }
.hamburger::after{ top: 6px; }

.modalOverlay{
  position: fixed; inset:0;
  z-index: 80;
  background: rgba(0,0,0,0.35);
  backdrop-filter: blur(6px);
  display:flex; align-items:center; justify-content:center;
}
.modalOverlay.hidden{ display:none; }
.modal{
  width: min(520px, calc(100vw - 36px));
  border-radius: 16px;
  border: 1px solid rgba(235,245,255,0.14);
  background: rgba(8, 14, 20, 0.86);
  box-shadow: 0 30px 90px rgba(0,0,0,0.55);
  overflow:hidden;
}
.modalHeader{
  display:flex; align-items:center; justify-content:space-between;
  padding: 12px 14px;
  border-bottom: 1px solid rgba(235,245,255,0.10);
}
.modalTitle{ font-weight: 760; }
.closeModal{
  border:none; background: rgba(255,255,255,0.06);
  color: var(--ink);
  width: 34px; height: 34px;
  border-radius: 12px;
  cursor:pointer;
  border: 1px solid rgba(235,245,255,0.12);
}
.modalBody{
  padding: 14px 16px 16px 16px;
  color: rgba(235,245,255,0.78);
  font-size: 14px;
}
.modalBody a{ color: rgba(180,220,255,0.95); }
.modalBody ul{ margin: 0; padding-left: 18px; }
.modalBody li{ margin: 10px 0; }
.smallPrint{ margin-top: 12px; font-size: 12px; color: rgba(235,245,255,0.55); }

@media (max-width: 560px){
  .masthead{ left: 14px; top: 12px; }
  .title{ font-size: 20px; }
  .info{ right: 12px; top: 76px; }
}


/* --- Legend (minimizable, upper-right) --- */
.legend{
  position: fixed;
  right: 18px;
  top: 14px;
  z-index: 65; /* above map, below modal */
  width: min(280px, calc(100vw - 36px));
  pointer-events: auto;
}
.legendToggle{
  width: 100%;
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(235,245,255,0.14);
  background: rgba(10,18,25,0.55);
  backdrop-filter: blur(10px);
  color: var(--ink);
  font-family: var(--titleFont);
  font-weight: 760;
  letter-spacing: 0.01em;
  cursor: pointer;
  box-shadow: 0 16px 52px rgba(0,0,0,0.35);
}
.legendToggle .chev{
  opacity: 0.75;
  transform: translateY(1px);
  transition: transform 180ms ease, opacity 180ms ease;
}
.legendPanel{
  margin-top: 10px;
  border-radius: 16px;
  border: 1px solid rgba(235,245,255,0.12);
  background: rgba(8, 14, 20, 0.72);
  backdrop-filter: blur(14px);
  box-shadow: 0 18px 60px rgba(0,0,0,0.45);
  overflow: hidden;

  transform-origin: top right;
  transform: translateY(-6px);
  opacity: 0;
  max-height: 0;
  transition: max-height 220ms ease, opacity 180ms ease, transform 220ms ease;
}
.legend:not(.minimized) .legendPanel{
  opacity: 1;
  transform: translateY(0);
  max-height: 520px; /* enough for content */
}
.legend:not(.minimized) .legendToggle .chev{
  transform: rotate(180deg);
  opacity: 0.95;
}
.legendGroup{
  padding: 12px 12px 4px 12px;
}
.legendGroup + .legendGroup{
  border-top: 1px solid rgba(235,245,255,0.08);
  padding-top: 10px;
}
.legendGroupTitle{
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 8px;
}
.legendList{
  display:flex;
  flex-direction:column;
  gap: 8px;
  padding-bottom: 10px;
}
.legendItem{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap: 10px;
  font-size: 12px;
  color: rgba(235,245,255,0.86);
}
.legendSym{
  display:flex;
  align-items:center;
  gap: 10px;
}
.legendSvg{
  width: 44px;
  height: 24px;
  overflow: visible;
}
.legendValue{
  color: rgba(235,245,255,0.75);
  font-variant-numeric: tabular-nums;
}

/* --- Symbol classes for trend + no-data --- */
.symbol.stable{
  fill: rgba(255,255,255,0.88);
}
.symbol.growing{
  fill: rgba(235,255,245,0.90); /* green-tinted ice */
}
.symbol.declining{
  fill: rgba(245,235,255,0.90); /* purple-tinted ice */
}
.symbol.nodata{
  fill: transparent;
  stroke: rgba(235,245,255,0.62);
  stroke-width: 1.6;
}

/* Keep hover subtle */
.symbol:hover{
  stroke: rgba(235,245,255,0.75);
  stroke-width: 1.6;
}

@media (max-width: 560px){
  .legend{ right: 12px; top: 72px; width: min(280px, calc(100vw - 24px)); }
}
