/* ==========================================================================
   DIJKSTRA CITY MAP SIMULATOR STYLES
   Aesthetics: Clean Glassmorphism, CartoDB Positron/Voyager Harmonious Styling,
   Glowing Polylines, Dynamic Radar Pulse Markers, and Editorial Tables.
   ========================================================================== */

/* Map View Container */
#map-viewport {
  width: 100%;
  height: 100%;
  min-height: 580px;
  border-radius: 1.25rem;
  overflow: hidden;
  position: relative;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.08);
  border: 1px solid rgba(226, 232, 240, 0.85);
  background: #f1f5f9;
  z-index: 10;
}

/* Mapbox GL Canvas & Controls */
.mapboxgl-canvas {
  outline: none;
}

.mapboxgl-ctrl-bottom-right {
  bottom: 4.5rem !important;
  right: 1rem !important;
}

/* Custom City Marker Styling */
.city-marker-container {
  background: transparent;
  border: none;
}

.city-marker {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.city-marker:hover {
  transform: scale(1.08) translateY(-2px);
  z-index: 999 !important;
}

/* Pulse animation under dot */
.city-marker-pulse {
  position: absolute;
  left: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.city-marker.active-extract .city-marker-pulse {
  opacity: 1;
  background: rgba(245, 158, 11, 0.4);
  animation: radar-sweep 1.4s infinite ease-out;
}

.city-marker.destination-target .city-marker-pulse {
  opacity: 0.8;
  background: rgba(225, 29, 72, 0.3);
  animation: radar-sweep 1.8s infinite ease-out;
}

.city-marker.start-origin .city-marker-pulse {
  opacity: 0.8;
  background: rgba(16, 185, 129, 0.3);
  animation: radar-sweep 1.8s infinite ease-out;
}

@keyframes radar-sweep {
  0% {
    transform: translateY(-50%) scale(0.6);
    opacity: 0.9;
  }
  100% {
    transform: translateY(-50%) scale(2.4);
    opacity: 0;
  }
}

/* Center dot */
.city-marker-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #ffffff;
  border: 3px solid #64748b;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.25s ease;
  z-index: 2;
}

.city-marker-dot .city-dot-inner {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #64748b;
}

/* City Card Info Pill */
.city-marker-card {
  display: flex;
  align-items: center;
  gap: 6px;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 3px 8px 3px 8px;
  border-radius: 9999px;
  border: 1px solid rgba(203, 213, 225, 0.9);
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.08);
  font-family: 'Lexend', system-ui, sans-serif;
  transition: all 0.25s ease;
  white-space: nowrap;
}

.city-name {
  font-size: 11px;
  font-weight: 700;
  color: #1e293b;
  letter-spacing: -0.01em;
}

.city-dist-badge {
  font-family: '"Fira Code"', monospace;
  font-size: 10px;
  font-weight: 600;
  padding: 1px 6px;
  border-radius: 9999px;
  background: #f1f5f9;
  color: #475569;
  border: 1px solid #e2e8f0;
}

/* ==========================================================================
   STATE CLASSES FOR MARKERS
   ========================================================================== */

/* Start Origin City */
.city-marker.start-origin .city-marker-dot {
  border-color: #059669;
}
.city-marker.start-origin .city-marker-dot .city-dot-inner {
  background: #059669;
}
.city-marker.start-origin .city-marker-card {
  border-color: #6ee7b7;
  background: rgba(240, 253, 244, 0.96);
}
.city-marker.start-origin .city-dist-badge {
  background: #059669;
  color: #ffffff;
  border-color: #059669;
}

/* Destination Target City */
.city-marker.destination-target .city-marker-dot {
  border-color: #e11d48;
}
.city-marker.destination-target .city-marker-dot .city-dot-inner {
  background: #e11d48;
}
.city-marker.destination-target .city-marker-card {
  border-color: #fda4af;
  background: rgba(255, 241, 242, 0.96);
}
.city-marker.destination-target .city-name {
  color: #9f1239;
}

/* Active Extracted City (Golden glow) */
.city-marker.active-extract .city-marker-dot {
  border-color: #d97706;
  transform: scale(1.2);
}
.city-marker.active-extract .city-marker-dot .city-dot-inner {
  background: #d97706;
}
.city-marker.active-extract .city-marker-card {
  border-color: #f59e0b;
  background: rgba(254, 243, 199, 0.98);
  box-shadow: 0 0 14px rgba(245, 158, 11, 0.35);
}
.city-marker.active-extract .city-name {
  color: #92400e;
}
.city-marker.active-extract .city-dist-badge {
  background: #f59e0b;
  color: #ffffff;
  border-color: #d97706;
}

/* Examining Neighbor */
.city-marker.examining-neighbor .city-marker-dot {
  border-color: #0284c7;
}
.city-marker.examining-neighbor .city-marker-card {
  border-color: #38bdf8;
  background: rgba(240, 249, 255, 0.95);
}

/* Settled City (Optimal distance finalized) */
.city-marker.settled .city-marker-dot {
  border-color: #10b981;
}
.city-marker.settled .city-marker-dot .city-dot-inner {
  background: #10b981;
}
.city-marker.settled .city-marker-card {
  border-color: #a7f3d0;
}
.city-marker.settled .city-dist-badge {
  background: #ecfdf5;
  color: #047857;
  border-color: #a7f3d0;
}

/* Shortest Path Member */
.city-marker.path-highlight .city-marker-dot {
  border-color: #2563eb;
  transform: scale(1.25);
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.45);
}
.city-marker.path-highlight .city-marker-dot .city-dot-inner {
  background: #2563eb;
}
.city-marker.path-highlight .city-marker-card {
  border-color: #60a5fa;
  background: rgba(239, 246, 255, 0.98);
  box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
}
.city-marker.path-highlight .city-dist-badge {
  background: #2563eb;
  color: #ffffff;
  border-color: #1d4ed8;
}

/* Connect target selected */
.city-marker.selected-connect-target .city-marker-card {
  border-color: #8b5cf6;
  background: #f5f3ff;
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.4);
}

/* ==========================================================================
   ROUTE POLYLINES & DISTANCE PILLS
   ========================================================================== */

.route-distance-pill-wrapper {
  background: transparent;
  border: none;
}

.route-distance-pill {
  font-family: '"Fira Code"', monospace;
  font-size: 9px;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(4px);
  color: #64748b;
  border: 1px solid #cbd5e1;
  padding: 1px 5px;
  border-radius: 9999px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  text-align: center;
  white-space: nowrap;
  pointer-events: none;
  transition: all 0.25s ease;
}

.route-distance-pill.active-examining {
  background: #fef3c7;
  color: #b45309;
  border-color: #f59e0b;
  font-weight: 700;
  transform: scale(1.15);
}

.route-distance-pill.relaxed-success {
  background: #cffafe;
  color: #0e7490;
  border-color: #06b6d4;
  font-weight: 700;
  transform: scale(1.2);
}

.route-distance-pill.path-highlight {
  background: #dbeafe;
  color: #1d4ed8;
  border-color: #3b82f6;
  font-weight: 800;
  transform: scale(1.25);
  box-shadow: 0 2px 10px rgba(59, 130, 246, 0.35);
}

/* Glowing Animated Shortest Path Polyline */
.shortest-path-polyline {
  stroke-dasharray: 12, 6;
  animation: dash-flow 1.5s linear infinite;
  filter: drop-shadow(0 0 6px rgba(59, 130, 246, 0.7));
}

@keyframes dash-flow {
  to {
    stroke-dashoffset: -36;
  }
}

/* ==========================================================================
   PRIORITY QUEUE CARDS & HUD
   ========================================================================== */

.pq-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 8px;
  font-family: '"Fira Code"', monospace;
  font-size: 11px;
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  transition: all 0.2s ease;
}

.pq-chip:first-child {
  background: #fef3c7;
  border-color: #f59e0b;
  color: #92400e;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.15);
}

/* Code Tracking Highlighter */
.pseudocode-line {
  display: block;
  padding: 2px 8px;
  border-radius: 4px;
  font-family: '"Fira Code"', monospace;
  font-size: 11px;
  line-height: 1.6;
  transition: all 0.15s ease;
}

.pseudocode-line.active {
  background: rgba(245, 158, 11, 0.18);
  border-left: 3px solid #f59e0b;
  color: #92400e;
  font-weight: 700;
}

/* Step Trace Table Styling */
.trace-table th {
  position: sticky;
  top: 0;
  background: #f8fafc;
  z-index: 10;
}

.trace-table tr:hover td {
  background-color: #f1f5f9;
}
