/* ===========================================================================
   MAP - Carte MapLibre GL, popups, markers
   Hover cards → hover-popup.css (unified card overlay)
   =========================================================================== */

/* ---------------------------------------------------------------------------
   Base MapLibre GL popup
--------------------------------------------------------------------------- */
.maplibregl-popup {
  z-index: 10000 !important;
}

.maplibregl-popup-tip {
  display: none !important;
}



/* ---------------------------------------------------------------------------
   Navigation Control — zoom + compass, glass capsule, bottom-right
--------------------------------------------------------------------------- */

/* Suppress legacy bottom-left slot */
.maplibregl-ctrl-bottom-left { display: none !important; }

/* Positioning */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl {
  margin: 0 16px 20px 0 !important;
}

/* Glass capsule */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
  background: rgba(250, 251, 255, 0.82) !important;
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(255, 255, 255, 0.88) !important;
  border-radius: 18px !important;
  box-shadow:
    0 0 0 1px rgba(0, 0, 0, 0.045),
    0 2px 8px rgba(0, 0, 0, 0.08),
    0 12px 32px rgba(0, 0, 0, 0.07),
    inset 0 1.5px 0 rgba(255, 255, 255, 0.9) !important;
  padding: 5px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

/* Remove MapLibre's default button separator */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group > button + button {
  border-top: none !important;
}

/* Buttons */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group button {
  width: 40px !important;
  height: 40px !important;
  border-radius: 12px !important;
  background: transparent !important;
  border: none !important;
  cursor: pointer;
  transition: background 0.14s ease, transform 0.1s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group button:not(:disabled):hover {
  background: rgba(0, 0, 0, 0.055) !important;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group button:not(:disabled):active {
  background: color-mix(in srgb, var(--primary, #14AE5C) 14%, transparent) !important;
  transform: scale(0.93);
}

/* Icon sizing */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group .maplibregl-ctrl-icon {
  width: 100% !important;
  height: 100% !important;
  background-size: 20px 20px;
}

/* Thin separator: only when compass is active */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group .maplibregl-ctrl-zoom-out {
  border-bottom: none !important;
  padding-bottom: 0 !important;
  margin-bottom: 0 !important;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group:has(.maplibregl-ctrl-compass.compass--active) .maplibregl-ctrl-zoom-out {
  border-bottom: 1px solid rgba(0, 0, 0, 0.08) !important;
  padding-bottom: 2px !important;
}

/* ── Compass: hidden until bearing/pitch is non-zero ── */
.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group .maplibregl-ctrl-compass {
  /* Explicit height: 0 beats flex-item size calculation */
  height: 0 !important;
  min-height: 0 !important;
  max-height: 0 !important;
  /* position:relative needed so ::before/::after stay inside and are clipped */
  position: relative !important;
  overflow: hidden !important;
  opacity: 0;
  pointer-events: none;
  border-radius: 50% !important;
  transition:
    height 0.45s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity 0.3s ease;
}

.maplibregl-ctrl-bottom-right .maplibregl-ctrl-group .maplibregl-ctrl-compass.compass--active {
  height: 40px !important;
  max-height: 40px !important;
  opacity: 1;
  pointer-events: auto;
}

/* Compass face disc (static, doesn't rotate with bearing) */
.maplibregl-ctrl-compass::before {
  content: '';
  position: absolute;
  inset: 4px;
  border-radius: 50%;
  z-index: 1;
  background:
    radial-gradient(circle at 37% 32%,
      rgba(255, 255, 255, 0.97) 0%,
      rgba(238, 244, 255, 0.90) 42%,
      rgba(220, 228, 248, 0.80) 100%
    );
  border: 1px solid rgba(255, 255, 255, 0.85);
  box-shadow:
    inset 0 2px 5px rgba(255, 255, 255, 0.95),
    inset 0 -2px 4px rgba(0, 0, 0, 0.05),
    0 1px 5px rgba(0, 0, 0, 0.12),
    0 0 0 0.5px rgba(0, 0, 0, 0.06);
}

/* Center metallic pin */
.maplibregl-ctrl-compass::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  z-index: 4;
  width: 6px;
  height: 6px;
  margin: -3px 0 0 -3px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 33%,
    rgba(255, 255, 255, 0.75),
    rgba(55, 58, 80, 0.90)
  );
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    0 0 0 1.5px rgba(255, 255, 255, 0.42);
}

/* Arrow span: remove default MapLibre SVG, use pseudos for needles */
.maplibregl-ctrl-compass .maplibregl-ctrl-icon {
  background-image: none !important;
  position: absolute !important;
  inset: 0 !important;
  z-index: 2;
}

/* North needle — city primary color */
.maplibregl-ctrl-compass .maplibregl-ctrl-icon::before {
  content: '';
  position: absolute;
  left: 50%;
  bottom: 50%;
  margin-left: -4px;
  width: 8px;
  height: 44%;
  transform-origin: bottom center;
  background: linear-gradient(
    180deg,
    color-mix(in srgb, var(--primary) 85%, white) 0%,
    var(--primary) 55%,
    color-mix(in srgb, var(--primary) 70%, black) 100%
  );
  clip-path: polygon(50% 0%, 100% 100%, 50% 76%, 0% 100%);
  filter: drop-shadow(0 1px 3px color-mix(in srgb, var(--primary) 55%, black));
}

/* South needle — pearl white/gray */
.maplibregl-ctrl-compass .maplibregl-ctrl-icon::after {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  margin-left: -3px;
  width: 6px;
  height: 37%;
  transform-origin: top center;
  background: linear-gradient(
    0deg,
    rgba(175, 180, 200, 0.95) 0%,
    rgba(235, 238, 248, 0.80) 100%
  );
  clip-path: polygon(50% 100%, 100% 0%, 50% 26%, 0% 0%);
}

/* Mobile: hide navigation controls */
@media (max-width: 720px) {
  .maplibregl-ctrl-bottom-right,
  .maplibregl-ctrl-bottom-left {
    display: none !important;
  }
}

/* Dark theme */
[data-theme="dark"] .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group {
  background: rgba(14, 16, 26, 0.85) !important;
  border-color: rgba(255, 255, 255, 0.09) !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.035),
    0 2px 8px rgba(0, 0, 0, 0.35),
    0 12px 32px rgba(0, 0, 0, 0.28),
    inset 0 1px 0 rgba(255, 255, 255, 0.06) !important;
}

[data-theme="dark"] .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group button:not(:disabled):hover {
  background: rgba(255, 255, 255, 0.08) !important;
}

[data-theme="dark"] .maplibregl-ctrl-bottom-right .maplibregl-ctrl-group:has(.maplibregl-ctrl-compass.compass--active) .maplibregl-ctrl-zoom-out {
  border-bottom-color: rgba(255, 255, 255, 0.08) !important;
}

/* Dark mode compass face */
[data-theme="dark"] .maplibregl-ctrl-compass::before {
  background:
    radial-gradient(circle at 37% 32%,
      rgba(62, 68, 96, 0.98) 0%,
      rgba(30, 34, 54, 0.96) 100%
    );
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.07),
    inset 0 -2px 4px rgba(0, 0, 0, 0.45),
    0 1px 5px rgba(0, 0, 0, 0.55);
}

[data-theme="dark"] .maplibregl-ctrl-compass::after {
  background: radial-gradient(circle at 38% 33%,
    rgba(255, 255, 255, 0.35),
    rgba(140, 145, 168, 0.92)
  );
}

[data-theme="dark"] .maplibregl-ctrl-compass .maplibregl-ctrl-icon::after {
  background: linear-gradient(
    0deg,
    rgba(120, 124, 145, 0.90) 0%,
    rgba(195, 198, 215, 0.65) 100%
  );
}

/* Dark mode: invert +/- icons to white, leave compass arrow as-is */
[data-theme="dark"] .maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon,
[data-theme="dark"] .maplibregl-ctrl-bottom-right .maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
  filter: brightness(0) invert(1) opacity(0.75);
}

/* ── User location marker ────────────────────────────────────────────────── */

.gp-user-location {
  position: relative;
  width: 20px;
  height: 20px;
}

.gp-user-location__dot {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--primary, #14AE5C);
  border: 2.5px solid #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.28);
  z-index: 1;
}

.gp-user-location__pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary, #14AE5C) 38%, transparent);
  animation: gpLocPulse 2.2s ease-out infinite;
}

@keyframes gpLocPulse {
  0%   { transform: scale(1);   opacity: 0.9; }
  65%  { transform: scale(2.8); opacity: 0;   }
  100% { transform: scale(2.8); opacity: 0;   }
}

/* ── Search marker wrapper ────────────────────────────────────────────────── */

.gp-search-marker-wrap {
  animation: gpSearchDrop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes gpSearchDrop {
  from { opacity: 0; transform: translateY(-16px) scale(0.5); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ── Search popup (card) ─────────────────────────────────────────────────── */

.gp-search-popup-wrap .maplibregl-popup-content {
  background: transparent;
  box-shadow: none;
  border: none;
  padding: 0;
}

.gp-search-popup-wrap .maplibregl-popup-tip { display: none; }
.gp-search-popup-wrap .maplibregl-popup-close-button { display: none !important; }

.gp-search-card {
  width: 260px;
  background: var(--surface, #fff);
  backdrop-filter: blur(16px) saturate(1.6);
  -webkit-backdrop-filter: blur(16px) saturate(1.6);
  border-radius: 14px;
  border: 1px solid color-mix(in srgb, var(--primary, #14AE5C) 18%, rgba(255,255,255,0.45));
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.14),
    0 2px 8px rgba(0, 0, 0, 0.06),
    inset 0 1px 0 rgba(255, 255, 255, 0.55);
  overflow: hidden;
  animation: gpCardIn 0.32s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

[data-theme="dark"] .gp-search-card {
  background: color-mix(in srgb, var(--surface, #1e1e2e) 92%, transparent);
  border-color: rgba(255, 255, 255, 0.10);
  box-shadow:
    0 8px 32px rgba(0, 0, 0, 0.36),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

/* Body row: icon + text */
.gp-search-card__body {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px 10px;
}

.gp-search-card__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  border-radius: 9px;
  background: var(--primary-lighter, color-mix(in srgb, var(--primary, #14AE5C) 12%, transparent));
  color: var(--primary, #14AE5C);
  font-size: 0.82rem;
}

.gp-search-card__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.gp-search-card__title {
  font-weight: 650;
  font-size: 0.82rem;
  line-height: 1.3;
  color: var(--text-primary, #111);
}

.gp-search-card__sub {
  font-size: 0.72rem;
  color: var(--text-secondary, #666);
}

/* Footer row: coords + close */
.gp-search-card__footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 14px 8px;
  border-top: 1px solid color-mix(in srgb, var(--text-tertiary, #888) 12%, transparent);
}

.gp-search-card__coords {
  font-family: ui-monospace, 'SF Mono', 'Menlo', monospace;
  font-size: 0.64rem;
  color: var(--text-tertiary, #888);
  letter-spacing: 0.01em;
}

.gp-search-card__close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  border: none;
  border-radius: 6px;
  background: transparent;
  color: var(--text-tertiary, #888);
  font-size: 0.68rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}

.gp-search-card__close:hover {
  background: color-mix(in srgb, var(--danger, #EF4444) 12%, transparent);
  color: var(--danger, #EF4444);
}

@keyframes gpCardIn {
  from { opacity: 0; transform: translateY(8px) scale(0.94); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
