/* Local Leaflet layout guard: keeps map tiles locked inside the viewport even if CDN CSS is slow or blocked. */
.signal-atlas-map.leaflet-container,
.signal-atlas-map .leaflet-container {
  position: relative;
  overflow: hidden;
  outline: 0;
}

.signal-atlas-map .leaflet-pane,
.signal-atlas-map .leaflet-tile,
.signal-atlas-map .leaflet-marker-icon,
.signal-atlas-map .leaflet-marker-shadow,
.signal-atlas-map .leaflet-tile-container,
.signal-atlas-map .leaflet-pane > svg,
.signal-atlas-map .leaflet-pane > canvas,
.signal-atlas-map .leaflet-zoom-box,
.signal-atlas-map .leaflet-image-layer,
.signal-atlas-map .leaflet-layer {
  position: absolute;
  left: 0;
  top: 0;
}

.signal-atlas-map .leaflet-pane {
  z-index: 400;
}

.signal-atlas-map .leaflet-tile-pane {
  z-index: 200;
}

.signal-atlas-map .leaflet-overlay-pane {
  z-index: 400;
}

.signal-atlas-map .leaflet-shadow-pane {
  z-index: 500;
}

.signal-atlas-map .leaflet-marker-pane {
  z-index: 600;
}

.signal-atlas-map .leaflet-tooltip-pane {
  z-index: 650;
}

.signal-atlas-map .leaflet-popup-pane {
  z-index: 700;
}

.signal-atlas-map .leaflet-map-pane canvas {
  z-index: 100;
}

.signal-atlas-map .leaflet-map-pane svg {
  z-index: 200;
}

.signal-atlas-map .leaflet-tile,
.signal-atlas-map .leaflet-marker-icon,
.signal-atlas-map .leaflet-marker-shadow {
  -webkit-user-select: none;
  user-select: none;
  -webkit-user-drag: none;
}

.signal-atlas-map .leaflet-tile {
  width: 256px;
  height: 256px;
  max-width: none !important;
  max-height: none !important;
  display: block;
  visibility: hidden;
}

.signal-atlas-map .leaflet-tile-loaded {
  visibility: inherit;
}

.signal-atlas-map .leaflet-marker-icon,
.signal-atlas-map .leaflet-marker-shadow {
  display: block;
  max-width: none !important;
  max-height: none !important;
}

.signal-atlas-map .leaflet-zoom-animated {
  transform-origin: 0 0;
}

.signal-atlas-map .leaflet-interactive {
  cursor: pointer;
}

.signal-atlas-map.leaflet-grab {
  cursor: grab;
}

.signal-atlas-map.leaflet-dragging,
.signal-atlas-map.leaflet-dragging .leaflet-grab {
  cursor: grabbing;
}

.signal-atlas-map .leaflet-control-container .leaflet-top,
.signal-atlas-map .leaflet-control-container .leaflet-bottom {
  position: absolute;
  z-index: 1000;
  pointer-events: none;
}

.signal-atlas-map .leaflet-top {
  top: 0;
}

.signal-atlas-map .leaflet-right {
  right: 0;
}

.signal-atlas-map .leaflet-bottom {
  bottom: 0;
}

.signal-atlas-map .leaflet-left {
  left: 0;
}

.signal-atlas-map .leaflet-control {
  position: relative;
  z-index: 1000;
  pointer-events: auto;
  float: left;
  clear: both;
}

.signal-atlas-map .leaflet-right .leaflet-control {
  float: right;
}

.signal-atlas-map .leaflet-top .leaflet-control {
  margin-top: 10px;
}

.signal-atlas-map .leaflet-bottom .leaflet-control {
  margin-bottom: 10px;
}

.signal-atlas-map .leaflet-left .leaflet-control {
  margin-left: 10px;
}

.signal-atlas-map .leaflet-right .leaflet-control {
  margin-right: 10px;
}

.signal-atlas-map .leaflet-popup {
  position: absolute;
  text-align: center;
  margin-bottom: 20px;
}

.signal-atlas-map .leaflet-popup-content-wrapper {
  padding: 1px;
  text-align: left;
}

.signal-atlas-map .leaflet-popup-content {
  margin: 13px 24px 13px 20px;
  line-height: 1.35;
}

.signal-atlas-map .leaflet-popup-tip-container {
  width: 40px;
  height: 20px;
  position: absolute;
  left: 50%;
  margin-left: -20px;
  overflow: hidden;
  pointer-events: none;
}

.signal-atlas-map .leaflet-popup-tip {
  width: 17px;
  height: 17px;
  padding: 1px;
  margin: -10px auto 0;
  transform: rotate(45deg);
}

.signal-atlas-map .leaflet-popup-close-button {
  position: absolute;
  top: 0;
  right: 0;
  width: 24px;
  height: 24px;
  font: 16px/24px Tahoma, Verdana, sans-serif;
  text-align: center;
  text-decoration: none;
  background: transparent;
}

.map-page {
  padding-bottom: 2.5rem;
}

.map-hero {
  padding: clamp(1.6rem, 4vw, 3rem) 0 1rem;
}

.map-hero .page-title {
  margin: 0.85rem 0 0.55rem;
  font-size: clamp(2.85rem, 7vw, 5.9rem);
  letter-spacing: -0.07em;
}

.map-hero .page-lead {
  width: min(900px, 100%);
  margin-bottom: 0;
  font-size: clamp(0.98rem, 1.8vw, 1.2rem);
}

.signal-atlas-section {
  padding-top: 0.85rem;
}

.map-section-head {
  align-items: flex-end;
  margin-bottom: 0.8rem;
}

.map-section-head h2 {
  margin-bottom: 0.25rem;
}

.atlas-workbench {
  display: grid;
  grid-template-columns: minmax(0, 1.65fr) minmax(330px, 0.76fr);
  gap: 1rem;
  align-items: start;
}

.atlas-map-panel,
.atlas-control-panel,
.atlas-selected-panel,
.atlas-control-block {
  border: 1px solid rgba(96, 255, 137, 0.30);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(8, 38, 22, 0.38), rgba(0, 0, 0, 0.30)),
    rgba(0, 0, 0, 0.24);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.atlas-map-panel {
  position: sticky;
  top: 92px;
}

.atlas-control-panel {
  position: sticky;
  top: 92px;
  display: grid;
  gap: 1rem;
  max-height: calc(100vh - 112px);
  overflow: auto;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.atlas-control-panel::-webkit-scrollbar,
.map-case-list::-webkit-scrollbar {
  width: 8px;
}

.atlas-control-panel::-webkit-scrollbar-thumb,
.map-case-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(77, 255, 136, 0.35);
}

.atlas-control-block,
.atlas-selected-panel {
  padding: 1rem;
}

.atlas-control-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.map-reset-btn {
  border: 1px solid rgba(119, 217, 255, 0.45);
  border-radius: 999px;
  padding: 0.46rem 0.7rem;
  color: var(--blue);
  background: rgba(0, 0, 0, 0.34);
  font-family: var(--mono);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  cursor: pointer;
}

.map-reset-btn:hover {
  color: #00131b;
  background: linear-gradient(180deg, #a7e8ff, #58cfff);
}

.atlas-map-toolbar {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.5rem;
  margin-bottom: 0.85rem;
}

.filter-btn {
  min-height: 2.28rem;
  border: 1px solid rgba(96, 255, 137, 0.34);
  border-radius: 12px;
  padding: 0.46rem 0.55rem;
  color: rgba(227, 255, 233, 0.80);
  background: rgba(0, 0, 0, 0.26);
  box-shadow: inset 0 0 12px rgba(77, 255, 136, 0.05);
  font-family: var(--mono);
  font-size: 0.70rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 160ms ease, border-color 160ms ease, background 160ms ease, color 160ms ease;
}

.filter-btn:hover,
.filter-btn.active {
  color: #001405;
  border-color: rgba(77, 255, 136, 0.92);
  background: linear-gradient(180deg, #85ffab, #2cdb70);
  box-shadow:
    0 0 14px rgba(77, 255, 136, 0.20),
    inset 0 0 10px rgba(255, 255, 255, 0.24);
  transform: translateY(-1px);
}

.signal-atlas-map {
  position: relative;
  z-index: 1;
  width: 100%;
  height: min(72vh, 760px);
  min-height: 560px;
  max-height: 760px;
  overflow: hidden;
  background: #d9e5d2;
  isolation: isolate;
}

.atlas-map-note {
  position: relative;
  z-index: 5;
  margin: 0;
  padding: 0.82rem 1rem;
  border-top: 1px solid rgba(96, 255, 137, 0.20);
  color: rgba(227, 255, 233, 0.70);
  background: rgba(0, 0, 0, 0.68);
  font-family: var(--mono);
  font-size: 0.76rem;
  line-height: 1.55;
}

.map-case-list {
  display: grid;
  gap: 0.55rem;
  max-height: 285px;
  overflow: auto;
  padding-right: 0.2rem;
}

.map-case-item {
  border: 1px solid rgba(96, 255, 137, 0.22);
  border-radius: 14px;
  padding: 0.72rem;
  background:
    linear-gradient(90deg, rgba(77, 255, 136, 0.07), transparent 38%),
    rgba(0, 0, 0, 0.28);
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.map-case-item:hover,
.map-case-item.active {
  border-color: rgba(77, 255, 136, 0.68);
  background:
    linear-gradient(90deg, rgba(77, 255, 136, 0.18), transparent 42%),
    rgba(2, 20, 10, 0.74);
  transform: translateX(2px);
}

.map-case-item__topline {
  display: flex;
  justify-content: space-between;
  gap: 0.5rem;
  color: rgba(119, 217, 255, 0.82);
  font-family: var(--mono);
  font-size: 0.64rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.map-case-item h3 {
  margin: 0.42rem 0 0.2rem;
  color: var(--hot);
  font-size: 1rem;
  line-height: 1.15;
}

.map-case-item p {
  margin: 0;
  color: rgba(227, 255, 233, 0.68);
  font-size: 0.82rem;
  line-height: 1.45;
}

.selected-case,
.selected-case-empty {
  position: relative;
}

.selected-case h2,
.selected-case-empty h2 {
  margin: 0.85rem 0 0.45rem;
  color: var(--hot);
  font-size: clamp(1.35rem, 2.1vw, 1.95rem);
  line-height: 1.04;
  letter-spacing: -0.045em;
}

.selected-case p,
.selected-case-empty p {
  color: rgba(227, 255, 233, 0.73);
  line-height: 1.68;
}

.selected-case__where {
  color: var(--blue) !important;
  font-family: var(--mono);
  font-size: 0.82rem;
}

.selected-case-map {
  margin: 1rem 0;
  border: 1px solid rgba(119, 217, 255, 0.24);
  border-radius: 16px;
  overflow: hidden;
  background: rgba(0, 0, 0, 0.34);
}

.selected-case-map img {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  filter: saturate(1.03) contrast(1.03);
}

.selected-case-map figcaption {
  padding: 0.72rem;
  color: rgba(227, 255, 233, 0.64);
  font-family: var(--mono);
  font-size: 0.72rem;
  line-height: 1.45;
}

.selected-case-facts {
  display: grid;
  gap: 0.55rem;
  margin: 1rem 0;
}

.selected-case-facts div {
  display: grid;
  grid-template-columns: 7rem 1fr;
  gap: 0.6rem;
  border: 1px solid rgba(96, 255, 137, 0.16);
  border-radius: 12px;
  padding: 0.62rem;
  background: rgba(0, 0, 0, 0.24);
}

.selected-case-facts dt,
.selected-case-facts dd {
  margin: 0;
  font-family: var(--mono);
  font-size: 0.73rem;
}

.selected-case-facts dt {
  color: rgba(161, 247, 182, 0.58);
  text-transform: uppercase;
}

.selected-case-facts dd {
  color: rgba(227, 255, 233, 0.86);
}

.map-fallback {
  display: grid;
  min-height: inherit;
  place-content: center;
  padding: 2rem;
  text-align: center;
  background:
    radial-gradient(circle, rgba(77, 255, 136, 0.14), transparent 55%),
    rgba(0, 0, 0, 0.38);
}

.map-fallback h2 {
  margin: 1rem 0 0.35rem;
  color: var(--hot);
}

.map-fallback p {
  max-width: 50ch;
  color: rgba(227, 255, 233, 0.72);
  line-height: 1.7;
}

.leaflet-container {
  font-family: var(--sans);
  background: #d9e5d2;
}

.leaflet-control-zoom {
  border: 1px solid rgba(0, 0, 0, 0.35) !important;
  border-radius: 12px !important;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35) !important;
}

.leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  color: #031009 !important;
  background: rgba(238, 255, 241, 0.96) !important;
  border-bottom-color: rgba(0, 0, 0, 0.22) !important;
  font-size: 1.45rem !important;
  font-weight: 900 !important;
  line-height: 38px !important;
  text-shadow: none !important;
}

.leaflet-control-zoom a:hover {
  color: #001405 !important;
  background: #8affad !important;
}

.leaflet-control-attribution {
  color: rgba(0, 0, 0, 0.72) !important;
  background: rgba(255, 255, 255, 0.78) !important;
  font-family: var(--mono);
  font-size: 0.62rem;
}

.leaflet-control-attribution a {
  color: #005b7a !important;
}

.mr-map-pin-wrap {
  border: 0;
  background: transparent;
}

.mr-map-pin {
  position: relative;
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 1px solid rgba(0, 86, 32, 0.70);
  border-radius: 50% 50% 50% 14%;
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(180deg, rgba(77, 255, 136, 0.96), rgba(0, 112, 47, 0.96));
  box-shadow:
    0 0 0 3px rgba(0, 0, 0, 0.22),
    0 0 18px rgba(0, 120, 52, 0.48);
  transform: rotate(-45deg);
}

.mr-map-pin__pulse {
  position: absolute;
  inset: -8px;
  border: 1px solid rgba(0, 110, 44, 0.30);
  border-radius: 50%;
  animation: atlasPinPulse 2.8s ease-out infinite;
}

.mr-map-pin__core {
  display: grid;
  width: 23px;
  height: 23px;
  place-items: center;
  border-radius: 50%;
  color: #001405;
  background: rgba(248, 255, 250, 0.96);
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 1000;
  letter-spacing: -0.08em;
  transform: rotate(45deg);
}

.mr-map-pin--folklore {
  border-color: rgba(114, 79, 0, 0.76);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(180deg, rgba(255, 211, 106, 0.98), rgba(146, 91, 18, 0.96));
}

.mr-map-pin--folklore .mr-map-pin__pulse {
  border-color: rgba(120, 76, 15, 0.32);
}

.mr-map-pin--supernatural {
  border-color: rgba(20, 91, 123, 0.76);
  background:
    radial-gradient(circle at 35% 28%, rgba(255, 255, 255, 0.58), transparent 24%),
    linear-gradient(180deg, rgba(119, 217, 255, 0.98), rgba(22, 95, 138, 0.96));
}

.mr-map-pin--supernatural .mr-map-pin__pulse {
  border-color: rgba(22, 95, 138, 0.32);
}

.mr-map-pin.is-active {
  filter: brightness(1.10) saturate(1.2);
  box-shadow:
    0 0 0 4px rgba(0, 0, 0, 0.30),
    0 0 0 7px rgba(255, 255, 255, 0.42),
    0 0 28px rgba(0, 120, 52, 0.52);
}

@keyframes atlasPinPulse {
  0% {
    transform: scale(0.72);
    opacity: 0.75;
  }

  100% {
    transform: scale(1.55);
    opacity: 0;
  }
}

.mainely-atlas-popup .leaflet-popup-content-wrapper {
  border: 1px solid rgba(96, 255, 137, 0.36);
  border-radius: 18px;
  background:
    linear-gradient(180deg, rgba(4, 26, 14, 0.98), rgba(0, 0, 0, 0.96)),
    rgba(0, 0, 0, 0.92);
  box-shadow:
    0 0 22px rgba(77, 255, 136, 0.20),
    0 0 70px rgba(0, 0, 0, 0.52);
  color: var(--text);
}

.mainely-atlas-popup .leaflet-popup-content {
  width: min(300px, 72vw) !important;
  margin: 1rem;
}

.mainely-atlas-popup .leaflet-popup-tip {
  border: 1px solid rgba(96, 255, 137, 0.26);
  background: rgba(0, 0, 0, 0.94);
}

.atlas-popup__meta,
.atlas-popup__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.55rem;
  flex-wrap: wrap;
  font-family: var(--mono);
}

.atlas-popup__meta span {
  border: 1px solid rgba(96, 255, 137, 0.30);
  border-radius: 999px;
  padding: 0.16rem 0.45rem;
  color: var(--muted);
  background: rgba(0, 0, 0, 0.38);
  font-size: 0.64rem;
  text-transform: uppercase;
}

.atlas-popup h3 {
  margin: 0.65rem 0 0.35rem;
  color: var(--hot);
  font-size: 1.18rem;
  line-height: 1.08;
}

.atlas-popup p {
  margin: 0.45rem 0;
  color: rgba(227, 255, 233, 0.72);
  line-height: 1.55;
}

.atlas-popup__location {
  color: var(--blue) !important;
  font-family: var(--mono);
  font-size: 0.75rem;
}

.atlas-popup__footer {
  margin-top: 0.85rem;
  border-top: 1px solid rgba(96, 255, 137, 0.20);
  padding-top: 0.75rem;
}

.atlas-popup__footer span {
  color: rgba(255, 211, 106, 0.82);
  font-size: 0.68rem;
}

.atlas-popup__footer a {
  color: #001405;
  border: 1px solid rgba(77, 255, 136, 0.70);
  border-radius: 999px;
  padding: 0.42rem 0.6rem;
  background: linear-gradient(180deg, #85ffab, #2cdb70);
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 900;
}

.empty-state {
  border: 1px solid rgba(96, 255, 137, 0.24);
  border-radius: 14px;
  padding: 0.95rem;
  color: rgba(227, 255, 233, 0.74);
  background: rgba(0, 0, 0, 0.32);
}

@media (max-width: 1050px) {
  .atlas-workbench {
    grid-template-columns: 1fr;
  }

  .atlas-map-panel,
  .atlas-control-panel {
    position: relative;
    top: auto;
  }

  .atlas-control-panel {
    grid-template-columns: 1fr 1fr;
    max-height: none;
    overflow: visible;
  }

  .signal-atlas-map {
    height: 560px;
    min-height: 560px;
  }
}

@media (max-width: 760px) {
  .map-page {
    width: min(100% - 1rem, var(--max));
  }

  .atlas-control-panel {
    grid-template-columns: 1fr;
  }

  .atlas-map-toolbar {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .signal-atlas-map {
    height: 440px;
    min-height: 440px;
    max-height: 440px;
  }

  .map-case-list {
    max-height: 260px;
  }

  .selected-case-facts div {
    grid-template-columns: 1fr;
  }
}
