/* World map viewer — ported from in-game WorldMap panel (viewer-only, no player dot) */
.wm-root {
  --wm-green: #4ade80;
  display: flex;
  flex-direction: column;
  gap: 16px;
  position: relative;
  min-height: 620px;
}

.wm-head {
  flex: none;
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.wm-toggle {
  flex: none;
  font: 700 12px 'Chakra Petch', Inter, sans-serif;
  color: var(--text-muted);
  background: rgba(11, 14, 23, 0.7);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 7px 12px;
  cursor: pointer;
  transition: 0.12s;
}

.wm-toggle:hover {
  border-color: var(--cyan);
  color: #cdd6e6;
}

.wm-toggle.on {
  color: var(--cyan);
  border-color: var(--cyan);
  background: rgba(43, 212, 255, 0.1);
}

.wm-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(12px, 2vw, 18px);
  color: var(--cyan);
  margin: 0 0 6px;
  letter-spacing: 1px;
}

.wm-sub {
  font-size: 13px;
  color: var(--text-muted);
}

.wm-sub b {
  color: #fff;
}

.wm-sub-lvl {
  color: var(--text-muted);
  margin-left: 4px;
}

.wm-body {
  display: flex;
  gap: 16px;
  flex: 1;
  min-height: 520px;
}

.wm-canvas {
  flex: 1;
  min-width: 0;
  position: relative;
  overflow: hidden;
  cursor: grab;
  border: 1px solid var(--border-dark);
  border-radius: 10px;
  background:
    radial-gradient(circle at 30% 20%, rgba(43, 212, 255, 0.05), transparent 60%),
    radial-gradient(circle at 70% 80%, rgba(162, 0, 255, 0.05), transparent 60%),
    radial-gradient(rgba(120, 140, 180, 0.06) 1px, transparent 1.4px) 0 0 / 26px 26px,
    #060810;
  touch-action: none;
  user-select: none;
}

.wm-canvas:active {
  cursor: grabbing;
}

.wm-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 14px;
  text-align: center;
  gap: 6px;
  z-index: 2;
}

/* CRITICAL: the [hidden] attribute (set in JS once the map loads) is otherwise
   overridden by the display:flex above, so the overlay never disappeared — it
   covered the whole map at z-index:2 and SWALLOWED every island click (the map
   "couldn't be clicked"). This makes hidden actually hide it. */
.wm-loading[hidden] {
  display: none !important;
}

.wm-dim {
  color: #5d6781;
  font-size: 11px;
}

.wm-stage {
  position: absolute;
  top: 0;
  left: 0;
  will-change: transform;
  transform-origin: 0 0;
}

.wm-lines {
  position: absolute;
  top: 0;
  left: 0;
  pointer-events: none;
  overflow: visible;
}

.wm-lines path {
  stroke: rgba(108, 130, 170, 0.24);
  stroke-width: 1.4;
  stroke-dasharray: 4 5;
  fill: none;
}

.wm-lines path.lit {
  stroke: rgba(90, 170, 230, 0.36);
  stroke-width: 1.6;
}

.wm-lines circle {
  fill: rgba(116, 146, 196, 0.5);
}

.wm-lines circle.lit {
  fill: rgba(43, 212, 255, 0.9);
}

.wm-island {
  position: absolute;
  box-sizing: border-box;
  border: 2px solid var(--cat, var(--wm-green));
  border-radius: 9px;
  background: rgba(11, 14, 23, 0.72);
  overflow: hidden;
  cursor: pointer;
  padding: 0;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.55), inset 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: transform 0.1s, box-shadow 0.12s, filter 0.12s;
  filter: saturate(0.92);
}

.wm-island:hover {
  transform: scale(1.03);
  z-index: 5;
  filter: saturate(1.12) brightness(1.08);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.65), 0 0 0 1px var(--cat);
}

.wm-island.sel {
  z-index: 6;
  box-shadow: 0 0 0 2px #fff, 0 0 18px var(--cat), 0 8px 26px rgba(0, 0, 0, 0.55);
}

.wm-island.cat-interior {
  filter: saturate(0.82) brightness(0.9);
}

.wm-isl-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  opacity: 0.95;
}

.wm-island.no-thumb {
  background: rgba(20, 26, 40, 0.82);
}

.wm-island.cat-city.no-thumb {
  background: rgba(0, 40, 52, 0.78);
}

.wm-island.cat-dungeon.no-thumb {
  background: rgba(40, 8, 16, 0.78);
}

.wm-isl-grad {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 60%;
  pointer-events: none;
  background: linear-gradient(to top, rgba(4, 5, 12, 0.94) 0%, rgba(4, 5, 12, 0.55) 48%, transparent 100%);
}

.wm-isl-badge {
  position: absolute;
  top: 3px;
  left: 5px;
  font-size: 13px;
  line-height: 1;
  z-index: 2;
  text-shadow: 0 1px 3px #000, 0 0 5px #000;
}

.wm-isl-label {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  padding: 3px 4px 4px;
  z-index: 2;
}

.wm-isl-name {
  font: 700 10px 'Chakra Petch', Inter, system-ui, sans-serif;
  color: #fff;
  text-align: center;
  line-height: 1.06;
  max-width: 98%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-shadow: 0 1px 3px #000, 0 0 6px #000;
}

.wm-isl-lvl {
  font: 700 8px 'Chakra Petch', sans-serif;
  color: var(--cat, #8b9bb4);
  letter-spacing: 0.5px;
  text-shadow: 0 1px 2px #000;
}

.wm-viewer {
  position: absolute;
  inset: 0;
  z-index: 50;
  overflow: hidden;
  background: #000;
  cursor: grab;
  touch-action: none;
  user-select: none;
  animation: wmFade 0.22s ease-out;
}

.wm-viewer:active {
  cursor: grabbing;
}

.wm-viewer-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transform-origin: center center;
  will-change: transform;
}

.wm-viewer-map {
  position: relative;
  flex: none;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.65);
}

.wm-viewer-img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: fill;
}

.wm-viewer-head {
  position: absolute;
  top: 14px;
  left: 16px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: calc(100% - 80px);
  pointer-events: none;
}

.wm-modal-conns,
.wm-conn-btn {
  pointer-events: auto;
}

.wm-viewer-name {
  font: 800 17px 'Chakra Petch', Inter, sans-serif;
  text-shadow: 0 1px 4px #000, 0 0 8px #000;
}

.wm-viewer-lvl,
.wm-viewer-type {
  font: 700 11px 'Chakra Petch', sans-serif;
  color: #9aa6bd;
  background: rgba(2, 3, 8, 0.74);
  padding: 4px 9px;
  border-radius: 6px;
  border: 1px solid var(--border-dark);
}

.wm-viewer-ctrl {
  position: absolute;
  top: 14px;
  right: 14px;
  z-index: 4;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wm-viewer-ctrl button {
  width: 38px;
  height: 38px;
  border-radius: 9px;
  border: 1px solid rgba(43, 212, 255, 0.4);
  background: rgba(11, 14, 23, 0.92);
  color: var(--cyan);
  font-size: 17px;
  line-height: 1;
  cursor: pointer;
  transition: 0.12s;
}

.wm-viewer-ctrl button:hover {
  background: rgba(43, 212, 255, 0.16);
}

.wm-vc-x {
  border-color: rgba(255, 255, 255, 0.3) !important;
  color: #fff !important;
  margin-bottom: 8px;
}

.wm-vc-x:hover {
  background: rgba(255, 80, 80, 0.35) !important;
  border-color: #ff6b6b !important;
}

.wm-side {
  width: 270px;
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 12px;
  overflow-y: auto;
  max-height: 520px;
}

.wm-card {
  background: rgba(11, 14, 23, 0.85);
  border: 1px solid var(--border-dark);
  border-radius: 8px;
  padding: 12px 14px;
  box-shadow: inset 0 0 18px rgba(0, 0, 0, 0.5);
}

.wm-card-h {
  font: 800 10px 'Chakra Petch', Inter, sans-serif;
  letter-spacing: 1.4px;
  color: #7e8aa3;
  margin-bottom: 8px;
}

.wm-card-h.cyan {
  color: var(--cyan);
}

.wm-card-h.gold {
  color: var(--gold);
}

.wm-d-thumb {
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  image-rendering: pixelated;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  margin-bottom: 10px;
  background: #06070f;
}

.wm-d-row {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  color: #9aa6bd;
  padding: 3px 0;
}

.wm-d-row b {
  color: #fff;
}

.wm-leg {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: #cdd6e6;
  padding: 3px 0;
}

.wm-leg-dot {
  width: 10px;
  height: 10px;
  border-radius: 3px;
  flex: none;
}

.wm-ev {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 5px 0;
  border-bottom: 1px solid rgba(74, 60, 134, 0.16);
}

.wm-ev:last-child {
  border-bottom: none;
}

.wm-ev-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex: none;
}

.wm-ev-dot.buff {
  background: var(--cyan);
}

.wm-ev-dot.danger {
  background: #ff4d6d;
}

.wm-ev-dot.event {
  background: var(--gold);
}

.wm-ev-name {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}

.wm-ev-t {
  font-size: 10px;
  color: var(--text-muted);
}

.wm-zoom {
  position: absolute;
  right: 12px;
  bottom: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  z-index: 30;
}

.wm-zoom button {
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid rgba(43, 212, 255, 0.35);
  background: rgba(11, 14, 23, 0.9);
  color: var(--cyan);
  font-size: 16px;
  cursor: pointer;
}

.wm-zoom button:hover {
  background: rgba(43, 212, 255, 0.15);
}

.wm-modal-conns {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
  min-width: 0;
}

.wm-modal-conns-h {
  font: 800 10px 'Chakra Petch', sans-serif;
  letter-spacing: 1.2px;
  color: #7e8aa3;
  white-space: nowrap;
  flex: none;
}

.wm-modal-conns-list {
  display: flex;
  gap: 7px;
  overflow-x: auto;
  padding-bottom: 2px;
}

.wm-conn-btn {
  font: 600 12px 'Chakra Petch', sans-serif;
  color: #cdd6e6;
  background: rgba(255, 255, 255, 0.05);
  white-space: nowrap;
  border: 1px solid var(--border-dark);
  border-radius: 6px;
  padding: 6px 11px;
  cursor: pointer;
  flex: none;
}

.wm-conn-btn:hover {
  background: rgba(43, 212, 255, 0.12);
  border-color: var(--cyan);
  color: #fff;
}

@keyframes wmFade {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* Click an area -> the viewer GROWS from that island (a zoom-into-the-map),
   not a centred pop-up. --wm-zoom-from + transform-origin are set inline from
   the clicked island's size/position. */
@keyframes wmZoomIn {
  from { transform: scale(var(--wm-zoom-from, 0.3)); opacity: 0.35; }
  to { transform: scale(1); opacity: 1; }
}

@media (max-width: 1024px) {
  .wm-body {
    flex-direction: column;
    min-height: 480px;
  }

  .wm-side {
    width: 100%;
    flex-direction: row;
    flex-wrap: wrap;
    max-height: none;
  }

  .wm-side .wm-card {
    flex: 1;
    min-width: 160px;
  }

  .wm-zoom {
    right: 12px;
    bottom: 12px;
  }

  .wm-viewer {
    inset: 0;
  }
}

@media (max-width: 600px) {
  .wm-root {
    min-height: 520px;
  }

  .wm-canvas {
    min-height: 360px;
  }
}
