/* ═══════════════════════════════════════════════════════════
   MAP.CSS — Map chrome, hudbar, timeline, popups, markers,
   clusters, tracks, Leaflet controls, Geoman
   ═══════════════════════════════════════════════════════════ */

/* ═══════════════════════════════════════
   MAP HUD BAR
   ═══════════════════════════════════════ */
body.theme-hud .map-hudbar {
  position: absolute;
  top: var(--hudbar-top);
  left: 50%;
  transform: translateX(-50%);
  width: var(--hudbar-w);
  z-index: 1004;

  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: var(--hudbar-pad-y) var(--hudbar-pad-x);
  border-radius: var(--r-lg);

  background: color-mix(in srgb, var(--ui-surface) 85%, transparent);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-soft);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
}

body.theme-hud .map-hudbar__left,
body.theme-hud .map-hudbar__right {
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

body.theme-hud .map-hudbar__center {
  justify-self: center;
  text-align: center;
}

body.theme-hud .map-hudbar__title {
  font-family: var(--font-title);
  font-size: 9px;
  letter-spacing: .20em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 82%, transparent);
}

@media (max-width: 1100px) {
  body.theme-hud .map-hudbar {
    grid-template-columns: 1fr;
    row-gap: 8px;
    text-align: center;
  }
  body.theme-hud .map-hudbar__left,
  body.theme-hud .map-hudbar__right {
    justify-content: center;
    flex-wrap: wrap;
  }
  body.theme-hud .map-hudbar__center { order: -1; }
}

/* ═══════════════════════════════════════
   TIMELINE
   ═══════════════════════════════════════ */
body.theme-hud .timeline {
  border: 1px solid var(--ui-border);
  background: color-mix(in srgb, var(--ui-surface) 85%, transparent);
  border-radius: var(--r-lg);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  box-shadow: var(--ui-shadow-soft);
}

/* ═══════════════════════════════════════
   LEAFLET ZOOM
   ═══════════════════════════════════════ */
body.theme-hud .leaflet-control-zoom {
  border: 0 !important;
  box-shadow: none !important;
  background: transparent !important;
}

body.theme-hud .leaflet-control-zoom a {
  width: 38px !important;
  height: 38px !important;
  line-height: 38px !important;
  background: color-mix(in srgb, var(--ui-surface) 88%, transparent) !important;
  color: var(--ui-text) !important;
  border: 1px solid var(--ui-border) !important;
  box-shadow: var(--ui-shadow-soft) !important;
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  text-decoration: none !important;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

body.theme-hud .leaflet-control-zoom a:hover {
  border-color: var(--ui-border-strong) !important;
}

/* ═══════════════════════════════════════
   LEAFLET ATTRIBUTION
   ═══════════════════════════════════════ */
body.theme-hud .leaflet-control-attribution {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  color: rgba(255, 255, 255, 0.55) !important;
}

body.theme-hud .custom-attribution {
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--ui-text-2);
  padding: 6px 10px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ui-surface) 85%, transparent);
  border: 1px solid var(--ui-border);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  box-shadow: var(--ui-shadow-soft);
  user-select: none;
  pointer-events: auto;
}

body.theme-hud .custom-attribution::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 8px;
  vertical-align: middle;
  background: var(--ui-accent);
  box-shadow: 0 0 18px color-mix(in srgb, var(--ui-accent) 35%, transparent);
}

body.theme-hud .leaflet-bottom.leaflet-left .custom-attribution,
body.theme-hud .leaflet-bottom.leaflet-right .custom-attribution {
  position: fixed;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  z-index: 1100;
}

/* ═══════════════════════════════════════
   GEOMAN TOOLBAR (hidden by default)
   ═══════════════════════════════════════ */
#hud-maptools { display: none !important; }

body.theme-hud .leaflet-pm-toolbar,
body.theme-hud .leaflet-control.leaflet-pm-toolbar,
body.theme-hud .leaflet-pm-actions-container,
body.theme-hud .leaflet-pm-action,
body.theme-hud .leaflet-pm-toolbar-container,
body.theme-hud .leaflet-pm-toolbar .button-container {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

/* ═══════════════════════════════════════
   BASE PARAMS CONTROL
   ═══════════════════════════════════════ */
body.theme-hud .layers-modern.leaflet-control-layers {
  border: 0 !important;
  background: transparent !important;
  box-shadow: none !important;
}

body.theme-hud .layers-modern .leaflet-control-layers-toggle {
  width: 40px;
  height: 40px;
  border-radius: var(--r-pill);
  background: color-mix(in srgb, var(--ui-surface) 88%, transparent);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-soft);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  display: grid;
  place-items: center;
  background-image: none !important;
  position: relative;
}

body.theme-hud .layers-modern .leaflet-control-layers-toggle::before {
  content: "";
  width: 16px;
  height: 16px;
  display: block;
  background:
    linear-gradient(var(--ui-accent), var(--ui-accent)) 0 2px / 100% 2px no-repeat,
    linear-gradient(color-mix(in srgb, var(--ui-accent) 70%, transparent), color-mix(in srgb, var(--ui-accent) 70%, transparent)) 0 7px / 100% 2px no-repeat,
    linear-gradient(color-mix(in srgb, var(--ui-accent) 48%, transparent), color-mix(in srgb, var(--ui-accent) 48%, transparent)) 0 12px / 100% 2px no-repeat;
  opacity: .95;
}

body.theme-hud .layers-modern .bp-panel {
  margin-top: 10px;
  min-width: 240px;
  max-width: 280px;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--ui-surface), var(--ui-surface-2));
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  overflow: hidden;
}

body.theme-hud .layers-modern:not(.leaflet-control-layers-expanded) .bp-panel {
  display: none;
}

body.theme-hud .layers-modern .bp-head {
  padding: 12px 12px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-border) 80%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--ui-accent) 10%, transparent), transparent 70%);
}

body.theme-hud .layers-modern .bp-title {
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 88%, transparent);
}

body.theme-hud .layers-modern .bp-subtitle {
  margin-top: 4px;
  font-size: 11px;
  color: var(--ui-text-dim);
}

body.theme-hud .layers-modern .bp-section {
  padding: 12px;
  display: grid;
  gap: 10px;
}

body.theme-hud .layers-modern .bp-divider {
  height: 1px;
  background: color-mix(in srgb, var(--ui-border) 80%, transparent);
  margin: 0 12px;
}

body.theme-hud .layers-modern .bp-row {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ui-text-2);
  font-size: 12px;
  user-select: none;
}

body.theme-hud .layers-modern .bp-row input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--ui-accent);
  cursor: pointer;
}

body.theme-hud .layers-modern .bp-btns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

body.theme-hud .layers-modern .bp-btn {
  border-radius: var(--r-pill);
  border: 1px solid var(--ui-border);
  background: color-mix(in srgb, var(--ui-surface) 82%, transparent);
  color: var(--ui-text-2);
  font-family: var(--font-title);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  padding: 8px;
  cursor: pointer;
  transition: transform var(--dur-fast) ease, box-shadow var(--dur-normal) ease,
              background var(--dur-normal) ease, border-color var(--dur-normal) ease;
}

body.theme-hud .layers-modern .bp-btn:hover {
  background: color-mix(in srgb, var(--ui-accent) 8%, var(--ui-surface));
  border-color: var(--ui-border-strong);
  color: var(--ui-text);
}

body.theme-hud .layers-modern .bp-btn.active {
  background: linear-gradient(90deg, var(--ui-accent), var(--ui-accent-2));
  color: rgba(0, 0, 0, .92);
  border-color: color-mix(in srgb, var(--ui-accent) 55%, transparent);
  box-shadow: var(--ui-glow);
}

/* ═══════════════════════════════════════
   POPUPS
   ═══════════════════════════════════════ */
body.theme-hud .leaflet-popup-content-wrapper {
  background: transparent !important;
  border: 0 !important;
  box-shadow: none !important;
  padding: 0 !important;
}

body.theme-hud .leaflet-popup-content {
  margin: 0 !important;
  width: auto !important;
  min-width: 300px;
  max-width: 420px;
}

body.theme-hud .leaflet-popup-tip {
  background: var(--ui-surface) !important;
  border: 1px solid var(--ui-border) !important;
  box-shadow: var(--ui-shadow-soft) !important;
}

body.theme-hud .leaflet-popup-close-button {
  color: var(--ui-accent) !important;
  font-size: 18px !important;
  padding: 8px 10px !important;
}

body.theme-hud .leaflet-popup,
body.theme-hud .leaflet-popup *,
body.theme-hud .leaflet-popup-content-wrapper,
body.theme-hud .leaflet-popup-content {
  pointer-events: auto !important;
}

/* ── Popup card ── */
body.theme-hud .popup-card.popup-card--clean {
  background: linear-gradient(180deg, var(--ui-surface), var(--ui-surface-2));
  border: 1px solid var(--ui-border);
  border-radius: var(--r-lg);
  box-shadow: var(--ui-shadow);
  backdrop-filter: var(--ui-blur);
  -webkit-backdrop-filter: var(--ui-blur);
  overflow: hidden;
  color: var(--ui-text);
}

body.theme-hud .popup-header {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 10px;
  align-items: start;
  padding: 12px 12px 10px;
  border-bottom: 1px solid color-mix(in srgb, var(--ui-border) 80%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--ui-accent) 12%, transparent), transparent 70%);
}

body.theme-hud .popup-title {
  font-family: var(--font-title);
  font-size: 12px;
  letter-spacing: .16em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 86%, transparent);
}

body.theme-hud .popup-datetime {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .12em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  white-space: nowrap;
}

body.theme-hud .popup-body {
  padding: 12px;
  display: grid;
  gap: 10px;
}

body.theme-hud .popup-section {
  background: color-mix(in srgb, var(--ui-surface) 65%, transparent);
  border: 1px solid var(--ui-border);
  border-left: 3px solid color-mix(in srgb, var(--ui-accent) 85%, transparent);
  border-radius: var(--r-md);
  padding: 10px;
}

body.theme-hud .popup-label {
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 88%, transparent);
  margin-bottom: 8px;
}

body.theme-hud .popup-text {
  font-size: 12px;
  color: var(--ui-text-2);
  line-height: 1.35;
  margin: 6px 0;
}

body.theme-hud .popup-text b {
  color: var(--ui-text);
  font-weight: 700;
}

body.theme-hud .popup-text--desc {
  white-space: pre-wrap;
  word-break: break-word;
}

body.theme-hud .popup-coords--grid {
  display: grid;
  gap: 6px;
}

body.theme-hud .popup-coord-row {
  display: grid;
  grid-template-columns: 72px 1fr;
  gap: 10px;
  align-items: baseline;
}

body.theme-hud .popup-coord-k {
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
}

body.theme-hud .popup-coord-v {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--ui-text);
}

body.theme-hud .popup-footer {
  padding: 10px 12px 12px;
  border-top: 1px solid color-mix(in srgb, var(--ui-border) 80%, transparent);
  background: linear-gradient(90deg, color-mix(in srgb, var(--ui-accent) 8%, transparent), transparent 70%);
}

body.theme-hud .popup-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 14px;
  align-items: center;
  justify-content: space-between;
}

body.theme-hud .popup-id,
body.theme-hud .popup-source {
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .10em;
  text-transform: uppercase;
  color: var(--ui-text-dim);
  white-space: nowrap;
}

/* ── CK-42 collapsible ── */
body.theme-hud .popup-section details > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
  font-family: var(--font-title);
  font-size: 11px;
  letter-spacing: .14em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--ui-accent) 88%, transparent);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

body.theme-hud .popup-section details > summary::-webkit-details-marker {
  display: none;
}

body.theme-hud .popup-section details > summary::after {
  content: "";
  width: 10px;
  height: 10px;
  flex: 0 0 auto;
  border-right: 2px solid rgba(255, 255, 255, 0.55);
  border-bottom: 2px solid rgba(255, 255, 255, 0.55);
  transform: rotate(45deg);
  transition: transform .16s ease;
}

body.theme-hud .popup-section details[open] > summary::after {
  transform: rotate(-135deg);
}

body.theme-hud .popup-section details > .popup-coords {
  margin-top: 8px;
}

/* ═══════════════════════════════════════
   MARKERS
   ═══════════════════════════════════════ */
body.theme-hud .custom-marker {
  background: transparent !important;
  border: 0 !important;
}

body.theme-hud .custom-marker .marker-outer {
  --marker-color: var(--c-neon);
  width: 32px;
  height: 32px;
  border-radius: var(--r-pill);
  position: relative;
  display: grid;
  place-items: center;

  background:
    radial-gradient(closest-side, rgba(255, 255, 255, 0.06), transparent 60%),
    radial-gradient(closest-side, color-mix(in srgb, var(--ui-accent) 10%, transparent), transparent 75%),
    var(--ui-glass);

  border: 1px solid var(--ui-border);
  box-shadow: 0 14px 46px rgba(0, 0, 0, .55), 0 0 0 1px rgba(0, 242, 255, 0.08) inset;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.theme-hud .custom-marker .marker-outer::after {
  content: "";
  position: absolute;
  inset: 3px;
  border-radius: var(--r-pill);
  border: 2px solid color-mix(in srgb, var(--marker-color) 75%, rgba(0, 242, 255, 0.30));
  box-shadow: 0 0 18px color-mix(in srgb, var(--marker-color) 45%, transparent);
  opacity: .95;
  pointer-events: none;
}

body.theme-hud .custom-marker .marker-inner {
  width: 22px;
  height: 22px;
  border-radius: var(--r-pill);
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--ui-accent) 5%, transparent);
  border: 1px solid color-mix(in srgb, var(--ui-accent) 14%, transparent);
}

body.theme-hud .custom-marker .marker-inner i {
  font-size: 12px;
  color: var(--ui-text);
  text-shadow: 0 0 14px color-mix(in srgb, var(--ui-accent) 12%, transparent);
}

/* ── New marker ── */
body.theme-hud .custom-marker.marker-new .marker-outer {
  border-color: color-mix(in srgb, var(--c-green) 28%, transparent);
  box-shadow: 0 14px 46px rgba(0, 0, 0, .55),
              0 0 0 1px color-mix(in srgb, var(--c-green) 14%, transparent) inset,
              0 0 26px color-mix(in srgb, var(--c-green) 10%, transparent);
}

body.theme-hud .custom-marker.marker-new .marker-outer::before {
  content: "";
  position: absolute;
  top: -5px;
  right: -5px;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: var(--c-green);
  border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 0 18px color-mix(in srgb, var(--c-green) 30%, transparent);
}

/* ═══════════════════════════════════════
   CLUSTERS
   ═══════════════════════════════════════ */
body.theme-hud .cluster-icon {
  background: transparent !important;
  border: 0 !important;
}

body.theme-hud .cluster-marker .marker-outer {
  --marker-color: var(--c-red);
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: var(--r-pill);
  background:
    radial-gradient(closest-side, rgba(255, 255, 255, 0.06), transparent 62%),
    radial-gradient(closest-side, color-mix(in srgb, var(--ui-accent) 10%, transparent), transparent 72%),
    var(--ui-glass);
  border: 1px solid var(--ui-border);
  box-shadow: 0 16px 60px rgba(0, 0, 0, .55);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: grid;
  place-items: center;
}

body.theme-hud .cluster-marker .cluster-badge {
  position: absolute;
  top: -8px;
  right: -8px;
  min-width: 24px;
  height: 24px;
  padding: 0 7px;
  border-radius: var(--r-pill);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font-mono);
  font-size: 11px;
  color: rgba(0, 0, 0, .92);
  background: linear-gradient(90deg, var(--ui-accent), var(--ui-accent-2));
  border: 1px solid color-mix(in srgb, var(--ui-accent) 55%, transparent);
  box-shadow: var(--ui-glow);
}

body.theme-hud .cluster-marker .cluster-dots {
  position: absolute;
  left: 50%;
  bottom: -7px;
  transform: translateX(-50%);
  display: inline-flex;
  gap: 6px;
  padding: 4px 8px;
  background: var(--ui-glass);
  border: 1px solid var(--ui-border);
  border-radius: var(--r-pill);
  box-shadow: var(--ui-shadow-soft);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

body.theme-hud .cluster-marker .cluster-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.18);
}

/* ═══════════════════════════════════════
   TRACKS
   ═══════════════════════════════════════ */
body.theme-hud .leaflet-overlay-pane path {
  filter: drop-shadow(0 0 10px color-mix(in srgb, var(--ui-accent) 10%, transparent));
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ═══════════════════════════════════════
   POPUP PHOTO
   ═══════════════════════════════════════ */
body.theme-hud .popup-photo {
  width: 100%;
  max-width: 420px;
  max-height: 210px;
  object-fit: cover;
  border-radius: var(--r-md);
  background: color-mix(in srgb, var(--ui-surface) 75%, transparent);
  border: 1px solid var(--ui-border);
  box-shadow: var(--ui-shadow-soft);
  cursor: pointer;
}

body.theme-hud .popup-photo:hover {
  border-color: var(--ui-border-strong);
  box-shadow: var(--ui-glow);
}

body.theme-hud .popup-hint {
  margin-top: 8px;
  font-size: 11px;
  color: var(--ui-text-dim);
}