/* ==========================================================================
   Mapa dos Territórios — pixel-art fantasy map.
   The viewport deliberately breaks from the dark cyber chrome into a lit
   sepia parchment world, like a hologram projecting an old map.
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Press+Start+2P&family=VT323&display=swap');

:root {
  --parchment-0: #ead9b4;
  --parchment-1: #dcc48f;
  --parchment-ink: #4a3419;
  --parchment-ink-dim: #7a5c34;
  --parchment-water: #c9ac78;
}

.map-toolbar {
  max-width: 1280px;
  margin: 0 auto 18px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.map-legend-chips { display: flex; flex-wrap: wrap; gap: 6px; }
.legend-chip {
  font-family: var(--font-ui);
  font-size: 10px;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--ink-faint);
  background: transparent;
  border: 1px solid var(--border-soft);
  padding: 5px 9px;
  cursor: pointer;
  transition: all .15s ease;
}
.legend-chip:hover { color: var(--red); border-color: var(--red); }
.legend-chip b { color: var(--pink); margin-right: 4px; }

.zoom-controls { display: flex; gap: 6px; flex-shrink: 0; }
.zoom-btn {
  font-family: var(--font-ui);
  font-weight: 700;
  font-size: 12px;
  letter-spacing: 1px;
  color: var(--red);
  background: transparent;
  border: 1px solid var(--red);
  width: 34px;
  height: 34px;
  cursor: pointer;
  transition: all .15s ease;
}
#zoom-reset { width: auto; padding: 0 12px; font-size: 10px; }
.zoom-btn:hover { background: var(--red); color: var(--bg-0); box-shadow: var(--glow-red); }

/* ---------- Viewport ---------- */
.map-viewport {
  position: relative;
  width: 100%;
  height: 76vh;
  min-height: 520px;
  overflow: hidden;
  background: var(--parchment-water);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  cursor: grab;
  image-rendering: pixelated;
  user-select: none;
  touch-action: none;
}
.map-viewport.grabbing { cursor: grabbing; }
.map-canvas {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}
.map-canvas.smooth { transition: transform .32s ease; }
.map-canvas svg { display: block; }

.map-hint {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  font-family: var(--font-ui);
  font-size: 10.5px;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--parchment-ink);
  background: rgba(234, 217, 180, 0.85);
  border: 1px solid rgba(74,52,25,0.4);
  padding: 6px 14px;
  pointer-events: none;
  z-index: 3;
}

/* ---------- SVG region styling ---------- */
.region-land {
  fill: var(--parchment-0);
  stroke: var(--parchment-ink);
  stroke-width: 3;
  cursor: pointer;
  transition: fill .15s ease, stroke .15s ease;
}
.region-land:hover, .region-land.active {
  fill: #f3e6c4;
  stroke: #c0392b;
}
.region-informal .region-land {
  stroke-dasharray: 10 6;
}
.region-unmapped .region-land {
  fill: #b9a077;
  stroke: #6b5636;
  stroke-dasharray: 4 5;
  opacity: 0.85;
}

.region-label {
  font-family: 'VT323', monospace;
  font-size: 22px;
  fill: var(--parchment-ink);
  text-anchor: middle;
  pointer-events: none;
  paint-order: stroke;
  stroke: var(--parchment-0);
  stroke-width: 4px;
  stroke-linejoin: round;
}
.region-layer-tag {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  fill: #c0392b;
  text-anchor: middle;
  pointer-events: none;
}

/* ---------- Kingdom markers ---------- */
.kingdom-marker { cursor: pointer; }
.kingdom-dot {
  fill: var(--parchment-ink);
  stroke: var(--parchment-0);
  stroke-width: 2;
  transition: r .15s ease, fill .15s ease;
}
.kingdom-marker:hover .kingdom-dot,
.kingdom-marker.active .kingdom-dot { fill: #c0392b; }
.kingdom-name {
  font-family: 'VT323', monospace;
  font-size: 14px;
  fill: var(--parchment-ink-dim);
  text-anchor: middle;
  pointer-events: none;
}
.kingdom-count {
  font-family: 'Press Start 2P', monospace;
  font-size: 8px;
  fill: #fff;
}
.kingdom-count-bg { fill: #c0392b; }

.creature-mini {
  cursor: pointer;
}
.creature-mini circle {
  fill: var(--parchment-1);
  stroke: var(--parchment-ink);
  stroke-width: 1.5;
}
.creature-mini image { clip-path: circle(50%); }
.creature-mini:hover circle { stroke: #c0392b; }

/* ---------- Decorations ---------- */
.deco { pointer-events: none; opacity: 0.85; }
.deco-mountain { fill: #8a7048; stroke: var(--parchment-ink); stroke-width: 1.5; }
.deco-mountain-snow { fill: var(--parchment-0); }
.deco-tree { fill: #6f7a45; stroke: var(--parchment-ink); stroke-width: 1; }
.deco-cloud { fill: #f3e6c4; stroke: var(--parchment-ink); stroke-width: 1.5; }
.deco-castle { fill: #8a7048; stroke: var(--parchment-ink); stroke-width: 1.5; }
.deco-wave { stroke: var(--parchment-ink-dim); stroke-width: 1.5; fill: none; }
.deco-circuit { stroke: #c0392b; stroke-width: 1.5; fill: none; }

/* ---------- Compass + cartouche ---------- */
.compass-ring { fill: none; stroke: var(--parchment-ink); stroke-width: 2; }
.compass-needle { fill: var(--parchment-ink); }
.compass-label {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  fill: var(--parchment-ink);
  text-anchor: middle;
}
.cartouche-box { fill: var(--parchment-0); stroke: var(--parchment-ink); stroke-width: 2.5; }
.cartouche-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  fill: var(--parchment-ink);
  text-anchor: middle;
}
.cartouche-sub {
  font-family: 'VT323', monospace;
  font-size: 15px;
  fill: var(--parchment-ink-dim);
  text-anchor: middle;
}

/* ==========================================================================
   Side panel — slide-in field journal
   ========================================================================== */
.map-panel-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  z-index: 90;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s ease;
}
.map-panel-backdrop.open { opacity: 1; pointer-events: auto; }

.map-panel {
  position: fixed;
  top: 0;
  right: 0;
  height: 100%;
  width: min(440px, 92vw);
  background: var(--parchment-0);
  color: var(--parchment-ink);
  border-left: 3px solid var(--parchment-ink);
  box-shadow: -12px 0 40px rgba(0,0,0,0.5);
  z-index: 91;
  transform: translateX(100%);
  transition: transform .25s ease;
  overflow-y: auto;
  font-family: 'VT323', monospace;
}
.map-panel.open { transform: translateX(0); }

.map-panel-close {
  position: sticky;
  top: 0;
  float: right;
  margin: 14px 14px 0 0;
  width: 34px; height: 34px;
  background: var(--parchment-1);
  border: 2px solid var(--parchment-ink);
  color: var(--parchment-ink);
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  cursor: pointer;
  z-index: 2;
}
.map-panel-close:hover { background: #c0392b; color: #fff; border-color: #c0392b; }

.map-panel-content { padding: 20px 26px 40px; clear: both; }

.panel-eyebrow {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: #8a5a2b;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.panel-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 18px;
  line-height: 1.5;
  color: var(--parchment-ink);
  margin-bottom: 6px;
}
.panel-layer-badge {
  display: inline-block;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  background: #c0392b;
  color: #fff;
  padding: 4px 8px;
  margin-bottom: 14px;
}
.panel-desc {
  font-size: 18px;
  line-height: 1.5;
  color: var(--parchment-ink-dim);
  margin-bottom: 22px;
  padding-bottom: 18px;
  border-bottom: 2px dashed var(--parchment-ink-dim);
}

.kingdom-block { margin-bottom: 26px; }
.kingdom-block-title {
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  color: var(--parchment-ink);
  margin-bottom: 4px;
}
.kingdom-block-tech {
  font-size: 16px;
  color: #8a5a2b;
  margin-bottom: 6px;
  font-style: italic;
}
.kingdom-block-desc {
  font-size: 16px;
  color: var(--parchment-ink-dim);
  margin-bottom: 12px;
}
.kingdom-empty {
  font-size: 16px;
  color: var(--parchment-ink-dim);
  font-style: italic;
  padding: 8px 0;
}

.panel-creature-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(74,52,25,0.25);
  cursor: pointer;
}
.panel-creature-row:hover .pc-name { color: #c0392b; }
.pc-portrait {
  width: 34px; height: 34px;
  border: 1.5px solid var(--parchment-ink);
  background: var(--parchment-1);
  flex-shrink: 0;
  overflow: hidden;
  display: grid;
  place-items: center;
  font-size: 14px;
}
.pc-portrait img { width: 100%; height: 100%; object-fit: cover; }
.pc-info { flex: 1; min-width: 0; }
.pc-name { font-size: 18px; color: var(--parchment-ink); transition: color .15s ease; }
.pc-meta { font-size: 13px; color: #8a5a2b; }
.pc-tag-secundario {
  font-family: 'Press Start 2P', monospace;
  font-size: 7px;
  color: #fff;
  background: #8a7048;
  padding: 2px 5px;
}

@media (max-width: 860px) {
  .map-viewport { height: 62vh; min-height: 400px; }
  .map-toolbar { padding: 0 14px; }
}
