/* Nexus full-bleed live map — map fills viewport, UI floats on top */

body.map-page {
  --map-sea: #14153d;
  --map-label-k: 1;
  overflow: hidden;
  background: var(--map-sea) !important;
}

body.map-page .site-header {
  background: var(--map-sea);
  border-bottom-color: rgba(255, 255, 255, 0.06);
}

body.map-page .bg-grid {
  display: none;
  background: var(--map-sea) !important;
}

body.map-page main {
  max-width: none;
  padding: 0;
  margin: 0;
}

body.map-page footer {
  display: none;
}

.map-root {
  position: relative;
  height: calc(100vh - 56px);
  min-height: 480px;
  overflow: hidden;
  background: var(--map-sea, #14153d);
}

/* Map fills everything behind the UI */
.map-root .map-stage {
  position: absolute;
  inset: 0;
  z-index: 0;
}

.map-root .map-canvas-wrap {
  position: absolute;
  inset: 0;
  min-height: 0;
  height: 100%;
  border: none;
  border-radius: 0;
  box-shadow: none;
  background: var(--map-sea, #14153d);
  cursor: grab;
}

.map-root .map-canvas-wrap.is-panning {
  cursor: grabbing;
}

.map-root .map-canvas {
  width: 100%;
  height: 100%;
  min-height: 0;
  background: var(--map-sea, #14153d);
}

.map-root .map-bg-layer {
  background-color: var(--map-sea, #14153d);
  background-size: 100% 100%;
}

/* Left tool rail — overlays map edge */
.map-rail-left {
  position: absolute;
  left: 0;
  top: 0;
  bottom: 0;
  z-index: 20;
  width: 52px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 0.35rem;
  background: linear-gradient(90deg, rgba(0, 0, 0, 0.78) 0%, rgba(0, 0, 0, 0.45) 75%, transparent 100%);
  pointer-events: none;
}

.map-rail-group {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  padding: 0.35rem 0.25rem;
  border-radius: 10px;
  background: rgba(10, 16, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  pointer-events: auto;
}

.map-rail-bottom {
  margin-top: auto;
}

.map-rail-icons {
  flex: 1;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.45rem 0.3rem;
}

.map-rail-icon {
  width: 38px;
  height: 38px;
  border: 1px solid transparent;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  color: #5eead4;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s, color 0.15s;
  flex-shrink: 0;
}

.map-rail-icon:hover {
  background: rgba(94, 234, 212, 0.12);
  border-color: rgba(94, 234, 212, 0.25);
  color: #99f6e4;
}

.map-rail-icon.active {
  background: rgba(94, 234, 212, 0.18);
  border-color: rgba(94, 234, 212, 0.45);
  color: #fff;
  box-shadow: 0 0 12px rgba(94, 234, 212, 0.15);
}

.map-rail-icon-svg {
  font-size: 1.05rem;
  line-height: 1;
}

.map-rail-left > * {
  pointer-events: auto;
}

.map-rail-btn {
  width: 34px;
  height: 34px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 7px;
  background: rgba(12, 18, 28, 0.88);
  color: rgba(255, 255, 255, 0.88);
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: background 0.15s, border-color 0.15s;
}

.map-rail-btn:hover {
  background: rgba(30, 41, 59, 0.95);
  border-color: rgba(148, 163, 184, 0.45);
  color: #fff;
}

.map-rail-btn.active {
  background: rgba(51, 65, 85, 0.95);
  border-color: rgba(203, 213, 225, 0.55);
  color: #fff;
}

.map-rail-divider {
  width: 22px;
  height: 1px;
  background: rgba(255, 255, 255, 0.12);
  margin: 0.15rem 0;
}

.map-rail-spacer {
  flex: 1;
}

/* Coord bar — minimal top-left */
.map-coord-bar {
  position: absolute;
  top: 0.55rem;
  left: 60px;
  z-index: 18;
  display: flex;
  align-items: center;
  gap: 0.3rem;
  max-width: min(380px, calc(100vw - 120px));
  padding: 0.3rem 0.4rem;
  background: rgba(10, 16, 24, 0.88);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.35);
}

.map-coord-bar input {
  flex: 1;
  min-width: 0;
  border: none;
  background: transparent;
  color: #e2e8f0;
  font-size: 0.76rem;
  outline: none;
}

.map-coord-bar input::placeholder {
  color: rgba(148, 163, 184, 0.65);
}

.map-coord-go,
.map-coord-clear {
  border: none;
  background: rgba(255, 255, 255, 0.06);
  color: #cbd5e1;
  border-radius: 6px;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 0.82rem;
  display: grid;
  place-items: center;
}

.map-coord-go:hover,
.map-coord-clear:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #fff;
}

/* Top status pill */
.map-topbar {
  position: absolute;
  top: 0.55rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 17;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.3rem 0.75rem;
  background: rgba(10, 16, 24, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  font-size: 0.7rem;
  pointer-events: none;
  white-space: nowrap;
}

.map-live-badge {
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  padding: 0.12rem 0.4rem;
  border-radius: 4px;
  background: rgba(239, 68, 68, 0.22);
  color: #fca5a5;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.map-live-badge.paused {
  background: rgba(100, 116, 139, 0.25);
  color: #94a3b8;
  border-color: rgba(100, 116, 139, 0.4);
}

.map-connect.ok { color: #86efac; }
.map-connect.error { color: #fca5a5; }
.map-connect.pending { color: #fcd34d; }

.map-topbar-dot { color: rgba(255, 255, 255, 0.25); }
.map-topbar-name {
  font-weight: 700;
  color: #e2e8f0;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.map-topbar-updated { font-size: 0.62rem; color: #64748b; }

/* Flyout panels — Asura-style layer menus */
.map-flyout {
  position: absolute;
  top: 0.55rem;
  left: 58px;
  z-index: 24;
  width: min(260px, calc(100vw - 5rem));
  max-height: calc(100vh - 120px);
  overflow-y: auto;
  background: rgba(18, 20, 28, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 0.65rem 0.75rem;
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
  scrollbar-width: thin;
}

.map-flyout.hidden { display: none; }

.map-flyout-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.55rem;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.map-flyout-head strong {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #e2e8f0;
}

.map-flyout-close {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 0.95rem;
  padding: 0.15rem 0.25rem;
  line-height: 1;
}

.map-flyout-close:hover { color: #fff; }

.map-flyout-section {
  margin-bottom: 0.55rem;
}

.map-flyout-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.35rem;
}

.map-flyout-section-head span {
  font-size: 0.58rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: #64748b;
  font-weight: 700;
}

.map-eye-btn {
  border: none;
  background: transparent;
  color: #64748b;
  cursor: pointer;
  font-size: 0.75rem;
  padding: 0.1rem 0.25rem;
  line-height: 1;
}

.map-eye-btn:hover { color: #cbd5e1; }

.map-flyout-row {
  display: flex;
  align-items: center;
  gap: 0.45rem;
  font-size: 0.78rem;
  padding: 0.32rem 0.15rem;
  color: #cbd5e1;
  cursor: pointer;
}

.map-flyout-row:hover { color: #f1f5f9; }

.map-flyout-swatch {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255, 255, 255, 0.75);
  flex-shrink: 0;
}

.tone-sanctuary { background: #c084fc; }
.tone-salt { background: #38bdf8; }
.tone-water { background: #38bdf8; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.2); }
.tone-migration { background: transparent; border-color: #fb923c; }
.tone-waypoints { background: #f472b6; }

.map-flyout-hint {
  font-size: 0.62rem;
  color: #64748b;
  margin: 0.35rem 0 0;
  line-height: 1.4;
}

.map-filter-note {
  list-style: none;
  margin: 0 0 0.5rem;
  padding: 0.45rem 0.5rem;
  border-radius: 6px;
  border: 1px solid rgba(251, 146, 60, 0.35);
  background: rgba(251, 146, 60, 0.1);
  font-size: 0.68rem;
  line-height: 1.4;
  color: #fdba74;
}

.map-flyout-kicker {
  margin: 0.45rem 0 0.35rem;
  font-size: 0.58rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: #64748b;
}

.map-style-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.3rem;
}

.map-style-btn {
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.04);
  color: #cbd5e1;
  border-radius: 5px;
  padding: 0.2rem 0.45rem;
  font-size: 0.65rem;
  cursor: pointer;
}

.map-style-btn.active {
  border-color: #64748b;
  background: rgba(100, 116, 139, 0.35);
  color: #fff;
}

/* Bottom-left HUD */
.map-hud-bl {
  position: absolute;
  left: 60px;
  bottom: 0.55rem;
  z-index: 16;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  pointer-events: none;
}

.map-compass {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(10, 16, 24, 0.75);
  display: grid;
  place-items: center;
  font-size: 0.62rem;
  font-weight: 800;
  color: #f87171;
}

.map-scale {
  display: flex;
  align-items: center;
  gap: 0.3rem;
  font-size: 0.6rem;
  color: rgba(255, 255, 255, 0.5);
}

.map-scale-bar {
  display: inline-block;
  width: 40px;
  height: 2px;
  background: rgba(255, 255, 255, 0.4);
}

/* Search pin */
.map-pin.is-search .map-dot-main {
  background: #ff6b9d;
  box-shadow: 0 0 14px rgba(255, 107, 157, 0.95);
  width: 15px;
  height: 15px;
  animation: map-pulse 1.4s ease infinite;
}

.map-pin.is-search {
  z-index: 7;
}

.map-pin.is-search .map-pin-tag,
.map-pin.is-search .map-pin-anchor {
  display: none;
}

@keyframes map-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}

/* Player drawer — hidden until opened */
.map-roster-drawer {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 25;
  width: min(280px, 88vw);
  background: rgba(8, 12, 18, 0.94);
  border-left: 1px solid rgba(255, 255, 255, 0.08);
  backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  padding: 0.65rem;
  transform: translateX(100%);
  transition: transform 0.22s ease;
  box-shadow: -8px 0 32px rgba(0, 0, 0, 0.45);
}

.map-roster-drawer.open {
  transform: translateX(0);
}

.map-roster-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.4rem;
}

.map-roster-head h3 {
  margin: 0;
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #94a3b8;
}

.map-roster-close {
  border: none;
  background: transparent;
  color: #94a3b8;
  cursor: pointer;
  font-size: 1rem;
  padding: 0.2rem;
}

.map-roster-drawer .map-live-meta {
  font-size: 0.66rem;
  margin: 0 0 0.5rem;
  color: #64748b;
  line-height: 1.35;
}

.map-roster-drawer .map-player-list {
  flex: 1;
  overflow-y: auto;
  list-style: none;
  margin: 0;
  padding: 0;
  font-size: 0.8rem;
}

.map-roster-drawer .map-player-list li {
  padding: 0.5rem 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  color: #94a3b8;
}

.map-player-row-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 0.35rem;
}

.map-player-row-head strong {
  color: #e2e8f0;
  font-size: 0.8rem;
}

.map-track-btn {
  font-size: 0.6rem;
  padding: 0.12rem 0.35rem;
}

.map-legend-compact {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 0.6rem;
  margin-bottom: 0.4rem;
  font-size: 0.62rem;
  color: #64748b;
}

.map-legend-compact .lgd-swatch {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.15rem;
  vertical-align: middle;
}

.lgd-you .lgd-swatch { background: #ffb020; }
.lgd-sq .lgd-swatch { background: #a855f7; }
.lgd-fr .lgd-swatch { background: #38c8ff; }
.lgd-other .lgd-swatch { background: #3dd68c; }

.map-overlay-attrib {
  font-size: 0.6rem;
  margin-top: 0.45rem;
  line-height: 1.35;
}

.map-canvas-wrap.is-locked {
  cursor: default;
}

.map-poi-root {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
}

.map-zone-root {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
}

.map-zone {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  border: 2px solid rgba(251, 146, 60, 0.75);
  background: rgba(251, 146, 60, 0.06);
  pointer-events: none;
}

.map-zone-label {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  max-width: 88%;
  line-height: 1.15;
  pointer-events: none;
}

.map-zone-label-main {
  display: block;
  font-family: var(--font, system-ui, sans-serif);
  font-size: calc(11px * var(--map-label-k, 1));
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #fff;
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.88);
  paint-order: stroke fill;
  text-shadow: none;
}

.map-poi {
  position: absolute;
  transform: translate(-50%, -50%);
  pointer-events: auto;
  cursor: default;
}

.map-poi-resource {
  display: flex;
  align-items: center;
  gap: 0.28rem;
  flex-direction: row;
  transform: translate(-50%, -50%);
}

.map-poi-resource .map-poi-dot {
  margin: 0;
  flex-shrink: 0;
  width: 12px;
  height: 12px;
}

.map-poi-dot {
  display: block;
  width: 11px;
  height: 11px;
  margin: 0 auto;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.92);
  box-shadow: 0 1px 5px rgba(0, 0, 0, 0.45);
  background: #94a3b8;
}

.map-poi-sanctuary .map-poi-dot { background: #c084fc; }
.map-poi-salt .map-poi-dot { background: #38bdf8; }

.map-poi-label {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  top: 14px;
  font-family: var(--font, system-ui, sans-serif);
  font-size: calc(10px * var(--map-label-k, 1));
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  -webkit-text-stroke: 1.5px rgba(0, 0, 0, 0.88);
  paint-order: stroke fill;
  text-shadow: none;
  max-width: 110px;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.15s ease;
}

.map-poi-resource .map-poi-label {
  position: static;
  transform: none;
  top: auto;
  left: auto;
  opacity: 1;
  font-size: calc(11px * var(--map-label-k, 1));
  letter-spacing: 0.02em;
}

.map-poi:hover .map-poi-label,
body.map-page.map-show-all-poi-labels .map-poi-label {
  opacity: 1;
}

.map-poi-label-only {
  pointer-events: none;
}

.map-poi-label-only .map-region-name {
  position: absolute;
  left: 0;
  top: 0;
  transform: translate(-50%, -50%) rotate(var(--region-rotate, 0deg));
  font-family: var(--font, system-ui, sans-serif);
  font-weight: 600;
  font-size: calc(var(--region-size, 14px) * var(--map-label-k, 1));
  letter-spacing: 0.02em;
  color: var(--region-color, #ffa500);
  -webkit-text-stroke: 2px rgba(0, 0, 0, 0.9);
  paint-order: stroke fill;
  text-shadow: none;
  pointer-events: none;
  white-space: normal;
  text-align: center;
  line-height: 1.15;
  max-width: 14em;
}

.map-region-name.is-nowrap {
  white-space: nowrap;
  max-width: none;
}

.map-region-name.is-volcano {
  --region-color: #ff5555;
  font-size: calc(var(--region-size, 8px) * var(--map-label-k, 1));
}

.map-controls-compact,
.map-live-stage .map-toolbar {
  display: none;
}

/* Fullscreen */
body.map-fs-active .map-root {
  height: 100vh;
}

body.map-fs-active .site-header {
  display: none !important;
}

body.map-fs-active .map-rail-left {
  top: 0;
}

@media (max-width: 640px) {
  .map-coord-bar {
    left: 48px;
    right: 0.5rem;
    max-width: none;
  }
  .map-topbar {
    top: auto;
    bottom: 3rem;
    max-width: calc(100% - 1rem);
    flex-wrap: wrap;
    justify-content: center;
    white-space: normal;
  }
}
