/**
 * ThreatMap Styles
 * @countermeasure/web-components
 *
 * Tile-based map viewer with markers and zoom controls.
 */

/* ============================================================================
   MAP WRAPPER
   ============================================================================ */
.cmm-map {
  position: relative;
  width: 100%;
  height: 400px;
  overflow: hidden;
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  background-color: hsl(var(--muted));
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
}

.cmm-map:active {
  cursor: grabbing;
}

/* ============================================================================
   TILE LAYER
   ============================================================================ */
.cmm-map__tile-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.cmm-map__tile {
  position: absolute;
  width: 256px;
  height: 256px;
  image-rendering: auto;
}

.cmm-map__tile--loading {
  background-color: hsl(var(--muted));
}

.cmm-map__tile--error {
  background-color: hsl(var(--muted));
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  color: hsl(var(--muted-foreground));
}

/* ============================================================================
   MARKER LAYER
   ============================================================================ */
.cmm-map__marker-layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.cmm-map__marker {
  position: absolute;
  transform: translate(-50%, -100%);
  pointer-events: auto;
  cursor: pointer;
  transition: transform var(--transition-fast);
}

.cmm-map__marker:hover {
  transform: translate(-50%, -100%) scale(1.15);
  z-index: 10;
}

.cmm-map__marker-pin {
  width: 24px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.3)); /* TODO(phase-1): tokenize drop-shadow */
}

.cmm-map__marker-label {
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  margin-top: 2px;
  padding: 1px 4px;
  font-size: 0.6875rem;
  font-weight: 500;
  color: hsl(var(--foreground));
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-sm);
  white-space: nowrap;
  pointer-events: none;
}

/* ============================================================================
   POPUP
   ============================================================================ */
.cmm-map__popup {
  position: absolute;
  transform: translate(-50%, -100%);
  margin-top: -40px;
  padding: 0.5rem 0.75rem;
  background-color: hsl(var(--background));
  border: 1px solid hsl(var(--border));
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md); /* was rgba(0,0,0,0.15) elevation shadow */
  font-size: 0.8125rem;
  color: hsl(var(--foreground));
  max-width: 200px;
  z-index: 20;
  pointer-events: auto;
}

.cmm-map__popup-close {
  position: absolute;
  top: 2px;
  right: 4px;
  padding: 0;
  border: none;
  background: none;
  font-size: 0.875rem;
  color: hsl(var(--muted-foreground));
  cursor: pointer;
  line-height: 1;
}

.cmm-map__popup-close:hover {
  color: hsl(var(--foreground));
}

/* ============================================================================
   ZOOM CONTROLS
   ============================================================================ */
.cmm-map__controls {
  position: absolute;
  top: 10px;
  right: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 15;
}

.cmm-map__zoom-btn {
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid hsl(var(--border));
  background-color: hsl(var(--background));
  color: hsl(var(--foreground));
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background-color var(--transition-fast);
}

.cmm-map__zoom-btn:first-child {
  border-radius: var(--radius-sm) var(--radius-sm) 0 0;
}

.cmm-map__zoom-btn:last-child {
  border-radius: 0 0 var(--radius-sm) var(--radius-sm);
}

.cmm-map__zoom-btn:hover {
  background-color: hsl(var(--accent));
}

.cmm-map__zoom-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* ============================================================================
   ATTRIBUTION
   ============================================================================ */
.cmm-map__attribution {
  position: absolute;
  bottom: 2px;
  right: 4px;
  font-size: 0.625rem;
  color: hsl(var(--muted-foreground));
  background-color: hsl(var(--background) / 0.7);
  padding: 1px 4px;
  border-radius: var(--radius-sm);
  z-index: 15;
  pointer-events: none;
}
