:root{
  --bg:#0b0f14;
  --panel:rgba(18, 24, 34, 0.92);
  --border:rgba(255,255,255,0.12);
  --text:rgba(255,255,255,0.92);
  --muted:rgba(255,255,255,0.68);
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
  --radius: 16px;
  --mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  --sans: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji","Segoe UI Emoji";
  --parchment: rgba(243,231,200,0.92);
  --ink: rgba(25,18,10,0.92);
}

*{ box-sizing:border-box; }
html, body{ height:100%; }
body{
  margin:0;
  font-family: var(--sans);
  background: radial-gradient(1200px 600px at 20% 0%, #162033 0%, var(--bg) 55%);
  color: var(--text);
}

.layout{
  height:100%;
  display:flex;
}

.map-wrap{
  position:relative;
  flex: 0 0 75%;
  min-width: 320px;
}

#map{
  position:absolute;
  inset:0;
}

/* Give the map an "old parchment" treatment */
#map canvas{
  filter: sepia(0.45) saturate(0.85) contrast(1.05) brightness(0.98);
}

/* Parchment/grain overlay over the map ONLY (so legend stays crisp) */
.map-wrap::before{
  content:"";
  position:absolute;
  inset:0;
  pointer-events:none;
  z-index:3;
  background:
    radial-gradient(900px 650px at 30% 20%, rgba(255,235,200,0.18), rgba(0,0,0,0) 60%),
    radial-gradient(900px 750px at 70% 80%, rgba(210,180,140,0.16), rgba(0,0,0,0) 60%),
    repeating-linear-gradient(0deg,
      rgba(255,255,255,0.03) 0px,
      rgba(255,255,255,0.03) 1px,
      rgba(0,0,0,0.00) 3px,
      rgba(0,0,0,0.00) 6px);
  mix-blend-mode: overlay;
  opacity: 0.95;
}

/* Vignette on map */
.map-wrap::after{
  content:"";
  position:absolute;
  inset:-40px;
  pointer-events:none;
  z-index:4;
  background: radial-gradient(circle at center,
    rgba(0,0,0,0) 55%,
    rgba(0,0,0,0.25) 78%,
    rgba(0,0,0,0.60) 100%);
}

/* Legend sidebar */
.legend{
  flex: 0 0 25%;
  min-width: 260px;
  padding: 14px;
  background: rgba(10, 13, 18, 0.65);
  border-left: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(10px);
  overflow:auto;
}

.legend-card{
  border-radius: var(--radius);
  border: 1px solid rgba(255,255,255,0.12);
  padding: 14px 14px 12px 14px;
  background: rgba(18, 24, 34, 0.85);
  box-shadow: 0 18px 50px rgba(0,0,0,0.25);
}

.legend-title{ font-weight: 900; letter-spacing: 0.2px; font-size: 16px; }
.legend-sub{ margin-top: 4px; color: rgba(255,255,255,0.70); font-size: 12px; }
.legend-section{ margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(255,255,255,0.10); }
.legend-h{ font-weight: 800; margin-bottom: 8px; }
.legend-list{
  margin:0;
  padding-left: 16px;
  color: rgba(255,255,255,0.76);
  font-size: 13px;
  line-height: 1.45;
}
.legend-note{ color: rgba(255,255,255,0.68); font-size: 13px; line-height: 1.45; }
.legend-pill{
  display:inline-block;
  margin-top: 10px;
  padding: 8px 10px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,0.12);
  background: rgba(255,255,255,0.06);
  font-size: 12px;
  color: rgba(255,255,255,0.84);
}
.legend-foot{
  margin-top: 14px;
  color: rgba(255,255,255,0.55);
  font-size: 12px;
}

.mono{ font-family: var(--mono); }

/* MapLibre controls a bit nicer */
.maplibregl-ctrl-group{
  border-radius: 12px !important;
  overflow:hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.35);
}

/* Modal – parchment style */
.modal{
  position: fixed;
  inset: 0;
  z-index: 80;
  display: none;
}
.modal[aria-hidden="false"]{ display:block; }
.modal-backdrop{
  position:absolute;
  inset:0;
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(6px);
}
.modal-card{
  position:absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: min(560px, calc(100vw - 28px));
  padding: 18px 18px 14px 18px;
  border-radius: 18px;
  border: 1px solid rgba(0,0,0,0.35);
  background:
    radial-gradient(800px 500px at 20% 10%, rgba(255,245,220,0.95), rgba(243,231,200,0.90) 60%),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.03) 0px, rgba(0,0,0,0.03) 1px, rgba(0,0,0,0) 4px, rgba(0,0,0,0) 8px);
  color: var(--ink);
  box-shadow: 0 18px 60px rgba(0,0,0,0.55);
}
.modal-close{
  position:absolute;
  right: 10px;
  top: 8px;
  width: 34px;
  height: 34px;
  border-radius: 12px;
  border: 1px solid rgba(0,0,0,0.22);
  background: rgba(255,255,255,0.30);
  color: rgba(20,12,6,0.85);
  font-size: 22px;
  line-height: 30px;
  cursor:pointer;
}
.modal-close:hover{ background: rgba(255,255,255,0.45); }

.modal-kicker{
  font-size: 12px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(30,20,10,0.55);
  margin-bottom: 6px;
}
.modal-title{
  font-size: 22px;
  font-weight: 900;
  color: rgba(20,12,6,0.92);
  margin-bottom: 10px;
}
.modal-body{
  font-size: 14px;
  line-height: 1.55;
  color: rgba(20,12,6,0.78);
}
.modal-footnote{
  margin-top: 12px;
  font-size: 12px;
  color: rgba(20,12,6,0.55);
}

/* Responsive: stack on small screens */
@media (max-width: 900px){
  .layout{ flex-direction: column; }
  .map-wrap{ flex-basis: auto; height: 62vh; }
  .legend{ flex-basis: auto; border-left: none; border-top: 1px solid rgba(255,255,255,0.10); }
}
