@import url("https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=Inter:wght@400;500;600&display=swap");

:root {
  color-scheme: light;
  --ink: #15221d;
  --muted: #6d7873;
  --paper: #f4f2eb;
  --accent: #ef5b3f;
  --line: rgba(21, 34, 29, 0.25);
}

* { box-sizing: border-box; }

html, body, #map {
  width: 100%;
  height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  background: var(--paper);
  color: var(--ink);
  font-family: Inter, system-ui, sans-serif;
}

#map { z-index: 0; background: #e9edf0; }

.leaflet-tile-pane {
  filter: saturate(.35) contrast(.94) brightness(1.04);
}

.masthead {
  position: fixed;
  z-index: 500;
  top: 28px;
  left: 32px;
  display: flex;
  align-items: baseline;
  gap: 18px;
  pointer-events: none;
}

.brand {
  color: var(--ink);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: .24em;
  text-decoration: none;
  pointer-events: auto;
}

.masthead p {
  margin: 0;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

.status {
  position: fixed;
  z-index: 500;
  left: 32px;
  bottom: 32px;
  min-width: 270px;
  padding: 18px 20px 17px;
  border: 1px solid rgba(21, 34, 29, .12);
  background: rgba(247, 246, 241, .92);
  box-shadow: 0 12px 35px rgba(22, 31, 27, .08);
  backdrop-filter: blur(12px);
  pointer-events: none;
}

.status__eyebrow,
#coordinates {
  display: block;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
}

#country-name {
  display: block;
  margin: 7px 0 9px;
  font-size: 19px;
  font-weight: 500;
}

#coordinates { letter-spacing: .02em; text-transform: none; }

.hint {
  position: fixed;
  z-index: 500;
  right: 32px;
  bottom: 34px;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .12em;
  text-transform: uppercase;
  transition: opacity .25s ease;
}

.hint span { width: 20px; height: 1px; background: var(--accent); }
.hint.is-hidden { opacity: 0; }

.boundary-note {
  position: fixed;
  z-index: 500;
  top: 24px;
  right: 28px;
  width: min(330px, calc(100vw - 40px));
  margin: 0;
  padding: 11px 13px;
  border: 1px solid rgba(21, 34, 29, .12);
  background: rgba(247, 246, 241, .92);
  box-shadow: 0 8px 28px rgba(22, 31, 27, .07);
  backdrop-filter: blur(12px);
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  line-height: 1.55;
  letter-spacing: .025em;
  pointer-events: none;
}

.level-selector,
.projection-selector,
.basemap-selector {
  position: fixed;
  z-index: 500;
  top: 92px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 4px;
  border: 1px solid rgba(21, 34, 29, .12);
  background: rgba(247, 246, 241, .92);
  box-shadow: 0 8px 28px rgba(22, 31, 27, .07);
  backdrop-filter: blur(12px);
}

.projection-selector { top: 140px; }
.basemap-selector { top: 188px; }

.capital-toggle {
  position: fixed;
  z-index: 500;
  top: 236px;
  right: 28px;
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px 12px;
  border: 1px solid rgba(21, 34, 29, .12);
  background: rgba(247, 246, 241, .92);
  box-shadow: 0 8px 28px rgba(22, 31, 27, .07);
  backdrop-filter: blur(12px);
  color: var(--muted);
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  letter-spacing: .04em;
  text-transform: uppercase;
}

.capital-toggle input { position: absolute; opacity: 0; pointer-events: none; }
.capital-toggle span {
  width: 9px;
  height: 9px;
  border: 1px solid #2864dc;
  background: transparent;
}
.capital-toggle input:checked + span { background: #2864dc; box-shadow: inset 0 0 0 2px #f7f6f1; }

.level-selector > span,
.projection-selector > span,
.basemap-selector > span {
  padding: 0 9px 0 7px;
  color: var(--muted);
  font-family: "DM Mono", monospace;
  font-size: 8px;
  letter-spacing: .1em;
  text-transform: uppercase;
}

.level-selector button,
.projection-selector button,
.basemap-selector button {
  appearance: none;
  padding: 8px 10px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-family: "DM Mono", monospace;
  font-size: 9px;
  transition: background .18s ease, color .18s ease;
}

.level-selector button:hover:not(:disabled),
.projection-selector button:hover,
.basemap-selector button:hover:not(:disabled) { color: var(--ink); }
.level-selector button.is-active,
.projection-selector button.is-active,
.basemap-selector button.is-active { background: var(--ink); color: #f7f6f1; }
.level-selector button:disabled { cursor: default; opacity: .35; }
.level-selector.is-loading [data-level="regions"] { animation: level-pulse 1s ease-in-out infinite alternate; }

body.is-mollweide #map { background: #f4f2eb; }
body.is-mollweide .leaflet-container { cursor: default; }
body.is-globe,
body.is-globe #map { background: #010205; }
body.is-globe #map::after {
  position: fixed;
  inset: 0;
  content: "";
  pointer-events: none;
}
.globe-nebula {
  position: fixed;
  z-index: 1;
  inset: -18%;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 22% 33%, rgba(134, 80, 240, .9), transparent 36%),
    radial-gradient(ellipse at 75% 64%, rgba(40, 134, 255, .82), transparent 35%),
    radial-gradient(ellipse at 59% 16%, rgba(190, 86, 233, .62), transparent 30%),
    conic-gradient(from 25deg at 48% 52%, transparent, rgba(89, 68, 220, .62), transparent 36%);
  filter: blur(32px) saturate(1.18);
  mix-blend-mode: screen;
  opacity: .8;
  -webkit-mask-image: radial-gradient(ellipse at center, transparent 0 34%, #000 64%);
  mask-image: radial-gradient(ellipse at center, transparent 0 34%, #000 64%);
  animation: globe-nebula-drift 28s ease-in-out infinite alternate;
}
body.is-globe #map::after {
  z-index: 2;
  background-image:
    radial-gradient(circle at 12% 18%, rgba(255, 255, 255, .92) 0 1px, transparent 1.35px),
    radial-gradient(circle at 73% 13%, rgba(197, 220, 235, .82) 0 1px, transparent 1.3px),
    radial-gradient(circle at 87% 68%, rgba(255, 255, 255, .72) 0 .8px, transparent 1.2px),
    radial-gradient(circle at 31% 79%, rgba(185, 209, 226, .78) 0 .8px, transparent 1.15px),
    radial-gradient(circle at 52% 44%, rgba(255, 255, 255, .58) 0 .65px, transparent 1px);
  background-size: 270px 230px, 390px 330px, 340px 370px, 470px 420px, 210px 290px;
  background-position:
    var(--stars-x-1, 0) var(--stars-y-1, 0),
    var(--stars-x-2, 0) var(--stars-y-2, 0),
    var(--stars-x-3, 0) var(--stars-y-3, 0),
    var(--stars-x-4, 0) var(--stars-y-4, 0),
    var(--stars-x-5, 0) var(--stars-y-5, 0);
  opacity: .72;
}

@keyframes globe-nebula-drift {
  0% { transform: translate3d(calc(var(--nebula-x, 0px) - 1.5%), calc(var(--nebula-y, 0px) - 1%), 0) rotate(-1deg) scale(1); opacity: .62; }
  55% { transform: translate3d(calc(var(--nebula-x, 0px) + 1%), calc(var(--nebula-y, 0px) + .5%), 0) rotate(1.2deg) scale(1.035); opacity: .78; }
  100% { transform: translate3d(calc(var(--nebula-x, 0px) + 1.8%), calc(var(--nebula-y, 0px) - 1.2%), 0) rotate(2deg) scale(1.06); opacity: .68; }
}

.maplibregl-canvas { outline: none; }
.maplibregl-ctrl-bottom-left { display: none; }
.maplibregl-ctrl-bottom-right { right: 18px; bottom: 18px; }
.maplibregl-ctrl-group {
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: rgba(247, 246, 241, .94);
  box-shadow: 0 5px 20px rgba(22, 31, 27, .1);
}
.maplibregl-ctrl-group button { width: 34px; height: 34px; }
body.is-auto-moving .maplibregl-ctrl-group { pointer-events: none; opacity: .55; }

@keyframes level-pulse { to { opacity: .7; } }

.leaflet-control-zoom {
  margin: 0 28px 28px 0 !important;
  border: 0 !important;
  box-shadow: 0 5px 20px rgba(22, 31, 27, .1) !important;
}

.leaflet-control-zoom a {
  width: 34px !important;
  height: 34px !important;
  border: 0 !important;
  color: var(--ink) !important;
  background: rgba(247, 246, 241, .94) !important;
  font: 300 18px/34px Inter, sans-serif !important;
}

body.is-auto-moving .masthead,
body.is-auto-moving .level-selector,
body.is-auto-moving .projection-selector,
body.is-auto-moving .basemap-selector,
body.is-auto-moving .capital-toggle,
.leaflet-container.is-auto-moving .leaflet-control-zoom,
.leaflet-container.is-auto-moving .leaflet-interactive {
  pointer-events: none;
}

.leaflet-container.is-auto-moving .leaflet-control-zoom,
body.is-auto-moving .level-selector,
body.is-auto-moving .projection-selector,
body.is-auto-moving .basemap-selector,
body.is-auto-moving .capital-toggle {
  opacity: 0.55;
}

.leaflet-control-attribution {
  padding: 3px 7px !important;
  background: rgba(247, 246, 241, .75) !important;
  color: #818985 !important;
  font-size: 8px !important;
}

.leaflet-control-attribution a { color: #626d68 !important; }
.country-shape { cursor: pointer; }

.extent-guide { animation: guide-flow 1.4s linear infinite; }
.capital-guide { animation: guide-flow .9s linear infinite reverse; }
.comparison-corner-guide { animation: guide-flow 1.1s linear infinite; }
.comparison-capital-guide { animation: guide-flow .85s linear infinite reverse; }
.comparison-bounds { animation: none; stroke-linecap: round; }

@keyframes guide-flow {
  to { stroke-dashoffset: -24; }
}

@media (prefers-reduced-motion: reduce) {
  .globe-nebula { animation: none; }
  .extent-guide,
  .capital-guide,
  .comparison-corner-guide,
  .comparison-capital-guide { animation: none; }
}

@media (max-width: 600px) {
  .masthead { top: 20px; left: 20px; }
  .masthead p { display: none; }
  .status { right: 20px; bottom: 20px; left: 20px; min-width: 0; }
  .hint { display: none; }
  .leaflet-control-zoom { margin: 0 18px 130px 0 !important; }
  .boundary-note { top: 56px; right: 16px; width: 220px; }
  .level-selector { top: 142px; right: 16px; }
  .projection-selector { top: 190px; right: 16px; }
  .basemap-selector { top: 238px; right: 16px; }
  .capital-toggle { top: 286px; right: 16px; }
  .level-selector > span,
  .projection-selector > span,
  .basemap-selector > span { display: none; }
}
