/* map-tools.css */

/* ════════════════════════════════════════════════════════════════════════
   Top-right tool cluster
═════════════════════════════════════════════════════════════════════════ */
.map-tool-cluster {
  position: fixed;
  top: 14px;
  right: 14px;
  z-index: 1100;
  display: flex;
  flex-direction: column;
  gap: 5px;
}

/* ════════════════════════════════════════════════════════════════════════
   Basemap hover panel — flies out to the left of the tool cluster
═════════════════════════════════════════════════════════════════════════ */
#basemapPanel {
  position: fixed;
  z-index: 2100;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
  background: rgba(10, 18, 32, 0.97);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6);
  backdrop-filter: blur(10px);
  /* Hidden by default */
  opacity: 0;
  pointer-events: none;
  transform: translateX(8px);
  transition: opacity 0.18s ease, transform 0.18s ease;
}

#basemapPanel.open {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

/* If there's an odd item last, span both columns so it's centered */
#basemapPanel .basemap-btn:last-child:nth-child(odd) {
  grid-column: 1 / -1;
}

.basemap-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  background: rgba(255,255,255,0.04);
  border: 2px solid transparent;
  border-radius: 8px;
  cursor: pointer;
  padding: 5px;
  transition: border-color 0.15s, background 0.15s, transform 0.1s;
}
.basemap-btn:hover {
  background: rgba(255,255,255,0.10);
  transform: scale(1.04);
}
.basemap-btn.active {
  border-color: #1e90ff;
  background: rgba(30,144,255,0.14);
}

.basemap-preview {
  width: 72px;
  height: 54px;
  object-fit: cover;
  border-radius: 6px;
  display: block;
  background: #1a2a3a;
}

.basemap-name {
  font-size: 10px;
  color: rgba(255,255,255,0.65);
  font-weight: 600;
  letter-spacing: 0.3px;
}
.basemap-btn.active .basemap-name { color: #4fc3f7; }

/* ════════════════════════════════════════════════════════════════════════
   Tool cluster buttons (ruler, filter, fullscreen, permalink, minimap)
═════════════════════════════════════════════════════════════════════════ */
.map-tool-btn {
  width: 34px;
  height: 34px;
  background: rgba(15, 23, 36, 0.88);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: rgba(255,255,255,0.85);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(0,0,0,0.35);
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  backdrop-filter: blur(4px);
}
.map-tool-btn:hover {
  background: rgba(30, 144, 255, 0.25);
  border-color: rgba(30, 144, 255, 0.5);
  transform: scale(1.07);
  color: #fff;
}
.map-tool-btn.active {
  background: rgba(241, 196, 15, 0.2);
  border-color: rgba(241, 196, 15, 0.6);
  color: #f1c40f;
}

.map-tool-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  padding: 2px 3px 0;
  pointer-events: none;
}

/* ════════════════════════════════════════════════════════════════════════
   Category filter panel — floats above zoom controls, left of them
═════════════════════════════════════════════════════════════════════════ */
.cat-filter-panel {
  position: fixed !important;
  bottom: 100px !important;   /* clear of zoom buttons */
  right: 60px !important;     /* left of Leaflet zoom controls with breathing room */
}

/* ════════════════════════════════════════════════════════════════════════
   Mini-map — bottom left, moves with sidebar
   Uses CSS transition to shift right when sidebar expands
═════════════════════════════════════════════════════════════════════════ */
.mini-map-container {
  position: fixed;
  bottom: 20px;
  left: calc(var(--sidebar-collapsed, 56px) + 16px);
  width: 180px;
  height: 130px;
  z-index: 1050;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.15);
  box-shadow: 0 4px 18px rgba(0,0,0,0.5);
  transition: left 220ms cubic-bezier(.2,.9,.2,1);
}

/* Minimap follows sidebar via CSS sibling selector — no JS involved.
   Both #mt-sidebar and #miniMapContainer are direct children of <body>. */
#mt-sidebar:hover ~ #miniMapContainer,
#mt-sidebar.expanded ~ #miniMapContainer,
#mt-sidebar.pinned ~ #miniMapContainer,
#mt-sidebar.focused ~ #miniMapContainer {
  left: calc(var(--sidebar-expanded, 220px) + 16px);
}
#mt-sidebar.force-collapsed ~ #miniMapContainer {
  left: calc(var(--sidebar-collapsed, 56px) + 16px) !important;
  transition: none;
}

/* ════════════════════════════════════════════════════════════════════════
   Ruler
═════════════════════════════════════════════════════════════════════════ */
body.ruler-mode { cursor: crosshair !important; }

.ruler-label { background: transparent !important; border: none !important; pointer-events: none; }
.ruler-label-box {
  display: inline-block;
  background: rgba(15, 23, 36, 0.92);
  color: #f1c40f;
  font-size: 11px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 4px;
  border: 1px solid rgba(241, 196, 15, 0.45);
  white-space: nowrap;
  box-shadow: 0 2px 6px rgba(0,0,0,0.5);
  transform: translate(-50%, -50%);   /* center over the midpoint anchor */
  position: relative;
}

.map-tool-hint {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 3000;
  background: rgba(15, 23, 36, 0.94);
  border: 1px solid rgba(241, 196, 15, 0.35);
  border-radius: 9px;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 14px;
  font-size: 13px;
  color: rgba(255,255,255,0.85);
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  backdrop-filter: blur(4px);
}
.map-tool-hint button {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 5px;
  color: #fff;
  padding: 3px 9px;
  font-size: 12px;
  cursor: pointer;
}
.map-tool-hint button:hover { background: rgba(255,255,255,0.2); }

/* ── Bathymetry contour hover tooltip ────────────────────────────────────── */
.leaflet-tooltip.bathy-tooltip {
  background: #0d1829;
  color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 6px;
  font-size: 11px;
  padding: 3px 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
}
.leaflet-tooltip.bathy-tooltip::before {
  border-top-color: rgba(255,255,255,0.15);
}

/* ── Bathymetry color-scale legend ───────────────────────────────────────── */
.bathy-legend {
  position: fixed;
  bottom: 166px; /* sits just above the mini-map (130px tall + 20px gap + 16px clearance) */
  left: calc(var(--sidebar-collapsed, 56px) + 16px);
  z-index: 1060; /* above the mini-map (1050) */
  width: 180px;
  background: #0d1829;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 10px;
  padding: 12px 14px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.5);
  color: rgba(255,255,255,0.85);
  font-family: 'DM Mono', monospace;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.25s ease, transform 0.25s ease, left 220ms cubic-bezier(.2,.9,.2,1);
}
.bathy-legend.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Follow the sidebar exactly like the mini-map does (CSS sibling selector —
   #bathyLegend is appended to <body> after #mt-sidebar, same as #miniMapContainer) */
#mt-sidebar:hover ~ #bathyLegend,
#mt-sidebar.expanded ~ #bathyLegend,
#mt-sidebar.pinned ~ #bathyLegend,
#mt-sidebar.focused ~ #bathyLegend {
  left: calc(var(--sidebar-expanded, 220px) + 16px);
}
#mt-sidebar.force-collapsed ~ #bathyLegend {
  left: calc(var(--sidebar-collapsed, 56px) + 16px) !important;
  transition: none;
}

.bathy-legend-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 4px;
}
.bathy-legend-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.4);
  font-size: 12px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.bathy-legend-close:hover { color: rgba(255,255,255,0.9); }
.bathy-legend-sub {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-bottom: 8px;
}
.bathy-legend-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  padding: 2px 0;
}
.bathy-legend-swatch {
  width: 18px;
  height: 3px;
  border-radius: 2px;
  flex-shrink: 0;
}
.bathy-legend-label {
  color: rgba(255,255,255,0.75);
}
.bathy-legend-hint {
  margin-top: 8px;
  font-size: 10px;
  color: rgba(255,255,255,0.35);
  border-top: 1px solid rgba(255,255,255,0.08);
  padding-top: 6px;
}
@media (max-width: 600px) {
  .bathy-legend { width: 160px; bottom: 156px; }
}
