/* ==========================================================================
   Spota World Map — full-screen live activity map (map.html).
   Self-contained: scoped under #spota-world-map so it can't leak into or
   collide with the Webflow export's generated classes.
   ========================================================================== */

/*
 * Fills the viewport below the page's own slim header (see map.html /
 * .sw-page-header), on every screen size — this is the map's own dedicated
 * page now, not an embedded homepage section, so there's no desktop-only
 * restriction and no breakout-from-a-constrained-container trick needed.
 */
#spota-world-map {
  --map-blue: var(--blurple, #1078FF);
  --map-bg: #14161b;
  --map-panel-bg: #181a20;
  --map-border: rgba(255, 255, 255, 0.08);
  --map-text: #ffffff;
  --map-muted: #9CA3AF;

  display: block;
  position: fixed;
  top: var(--sw-header-height, 64px);
  left: 0;
  right: 0;
  bottom: 0;
  overflow: hidden;
  background: var(--map-bg);
  isolation: isolate;
}

#spota-world-map .sw-canvas {
  position: absolute;
  inset: 0;
}

/* Loading state */
#spota-world-map .sw-loading {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--map-muted);
  font-family: inherit;
  font-size: 14px;
  z-index: 2;
  background: var(--map-bg);
  transition: opacity 0.3s ease;
}

#spota-world-map .sw-loading.is-hidden {
  opacity: 0;
  pointer-events: none;
}

#spota-world-map .sw-spinner {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--map-blue);
  animation: sw-spin 0.8s linear infinite;
}

@keyframes sw-spin {
  to { transform: rotate(360deg); }
}

/* Top overlay: stats + find-my-city */
#spota-world-map .sw-topbar {
  position: absolute;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 3;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  pointer-events: none;
}

@media (max-width: 1023px) {
  #spota-world-map .sw-locate-btn {
    font-size: 12px;
    padding: 8px 10px;
  }
}

@media (max-width: 480px) {
  #spota-world-map .sw-locate-btn span {
    display: none;
  }

  #spota-world-map .sw-locate-btn {
    padding: 10px;
  }

  #spota-world-map .sw-chip {
    height: 30px;
    padding: 0 10px;
    font-size: 11px;
  }
}

/* Filter bar — matches components/map/MapFilterControl.tsx: a horizontally
   scrollable row of pill chips, "All" chip first, then one chip per pin
   type with its icon, live count, and label. */
#spota-world-map .sw-filterbar {
  pointer-events: auto;
  flex: 1 1 360px;
  min-width: 0;
  max-width: 100%;
}

#spota-world-map .sw-filterbar-scroll {
  display: flex;
  align-items: center;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 2px 2px 6px;
  scrollbar-width: thin;
}

#spota-world-map .sw-filterbar-scroll::-webkit-scrollbar {
  height: 4px;
}

#spota-world-map .sw-filterbar-scroll::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 2px;
}

#spota-world-map .sw-chip {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  height: 34px;
  padding: 0 12px;
  border-radius: 17px;
  border: 1px solid var(--map-border);
  background: rgba(14, 17, 23, 0.78);
  color: var(--map-muted);
  font-family: inherit;
  font-size: 12px;
  font-weight: 700;
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

#spota-world-map .sw-chip svg {
  width: 25px;
  height: 25px;
  color: var(--map-muted);
  flex-shrink: 0;
}

#spota-world-map .sw-chip.is-active {
  background: var(--map-panel-bg);
  border-color: var(--chip-color, var(--map-blue));
  color: #fff;
}

#spota-world-map .sw-chip.is-active svg {
  color: var(--chip-color, var(--map-blue));
}

#spota-world-map .sw-chip.is-all {
  color: var(--map-muted);
}

#spota-world-map .sw-chip.is-all.is-active {
  background: #0A84FF;
  border-color: #0A84FF;
  color: #fff;
}

#spota-world-map .sw-locate-btn {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--map-blue);
  color: #fff;
  border: none;
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  box-shadow: 0 6px 16px rgba(16, 120, 255, 0.35);
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

#spota-world-map .sw-locate-btn:hover {
  transform: translateY(-1px);
}

#spota-world-map .sw-locate-btn:active {
  transform: translateY(0);
}

#spota-world-map .sw-locate-btn svg {
  flex-shrink: 0;
}

#spota-world-map .sw-locate-btn.is-loading {
  opacity: 0.75;
  pointer-events: none;
}

/* Toast (feedback after "find my city") */
#spota-world-map .sw-toast {
  position: absolute;
  left: 50%;
  bottom: 18px;
  transform: translate(-50%, 12px);
  z-index: 4;
  background: rgba(10, 11, 14, 0.9);
  backdrop-filter: blur(10px);
  border: 1px solid var(--map-border);
  color: #fff;
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  border-radius: 999px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
  max-width: calc(100% - 32px);
  overflow: hidden;
  text-overflow: ellipsis;
}

#spota-world-map .sw-toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

/* Marker (individual pin) — circular, matching the app's icon glyph on a
   colored badge, with an explicit border rather than a faked box-shadow ring. */
.sw-marker {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1.5px solid #fff;
  box-sizing: border-box;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.4);
  transition: transform 0.15s ease;
}

.sw-marker:hover {
  transform: scale(1.12);
}

.sw-marker svg {
  width: 20px;
  height: 20px;
}

/* Territory marker (small badge, not a full pin) */
.sw-territory-marker {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(10, 11, 14, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  border: 2px solid;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.sw-territory-marker svg {
  width: 14px;
  height: 14px;
}

/* Cluster bubble */
.sw-cluster {
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: var(--map-blue);
  color: #fff;
  font-weight: 800;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(16, 120, 255, 0.45), 0 0 0 6px rgba(16, 120, 255, 0.14);
  transition: transform 0.15s ease;
}

.sw-cluster:hover {
  transform: scale(1.08);
}

/* Mapbox attribution/logo: keep, but themed to sit quietly in dark UI */
#spota-world-map .mapboxgl-ctrl-logo {
  opacity: 0.6;
}

#spota-world-map .mapboxgl-ctrl-attrib {
  background: rgba(10, 11, 14, 0.55) !important;
  border-radius: 6px;
}

#spota-world-map .mapboxgl-ctrl-attrib a {
  color: var(--map-muted) !important;
}

#spota-world-map .mapboxgl-popup-content {
  background: var(--map-panel-bg);
  color: var(--map-text);
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.5);
  border: 1px solid var(--map-border);
}

#spota-world-map .mapboxgl-popup-tip {
  border-top-color: var(--map-panel-bg) !important;
  border-bottom-color: var(--map-panel-bg) !important;
}

#spota-world-map .mapboxgl-popup-close-button {
  color: var(--map-muted);
  font-size: 18px;
  padding: 4px 8px;
}

/* Territory popover content */
.sw-territory-popup {
  padding: 14px 16px;
  min-width: 200px;
  font-family: inherit;
}

.sw-territory-popup .sw-tp-name {
  font-size: 15px;
  font-weight: 800;
  color: #fff;
  margin: 0 0 4px;
}

.sw-territory-popup .sw-tp-owner {
  font-size: 13px;
  color: var(--map-muted);
  margin: 0 0 10px;
}

.sw-territory-popup .sw-tp-cta {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--map-blue);
  color: #fff;
  font-size: 12.5px;
  font-weight: 700;
  padding: 8px 12px;
  border-radius: 10px;
  text-decoration: none;
  width: 100%;
  justify-content: center;
  box-sizing: border-box;
}

/* ==========================================================================
   Detail panel — right-side drawer on desktop, bottom sheet on mobile.
   Positioned relative to the map container so it never breaks page layout.
   ========================================================================== */

#spota-world-map .sw-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 5;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

#spota-world-map .sw-panel-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

#spota-world-map .sw-panel {
  position: absolute;
  z-index: 6;
  background: var(--map-panel-bg);
  border: 1px solid var(--map-border);
  color: var(--map-text);
  display: flex;
  flex-direction: column;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.4);
  transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
}

/* Desktop: right-side drawer */
@media (min-width: 768px) {
  #spota-world-map .sw-panel {
    top: 0;
    right: 0;
    bottom: 0;
    width: 460px;
    max-width: 90%;
    border-radius: 0;
    border-left-width: 1px;
    transform: translateX(100%);
  }

  #spota-world-map .sw-panel.is-open {
    transform: translateX(0);
  }
}

/* Mobile: bottom sheet */
@media (max-width: 767px) {
  #spota-world-map .sw-panel {
    left: 0;
    right: 0;
    bottom: 0;
    max-height: 78%;
    border-radius: 18px 18px 0 0;
    transform: translateY(100%);
  }

  #spota-world-map .sw-panel.is-open {
    transform: translateY(0);
  }
}

#spota-world-map .sw-panel-handle {
  display: none;
  align-items: center;
  justify-content: center;
  padding: 10px 0 4px;
  flex-shrink: 0;
}

@media (max-width: 767px) {
  #spota-world-map .sw-panel-handle {
    display: flex;
  }
}

#spota-world-map .sw-panel-handle span {
  width: 36px;
  height: 4px;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.2);
}

#spota-world-map .sw-panel-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2;
}

#spota-world-map .sw-panel-body {
  overflow-y: auto;
  flex: 1;
  -webkit-overflow-scrolling: touch;
}

#spota-world-map .sw-panel-image {
  width: 100%;
  aspect-ratio: 16 / 9;
  object-fit: cover;
  background: #0d0e11;
  display: block;
}

#spota-world-map .sw-panel-content {
  padding: 18px 20px 22px;
}

#spota-world-map .sw-panel-type-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 15px;
}

#spota-world-map .sw-panel-type-icon {
  width: 26px;
  height: 26px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

#spota-world-map .sw-panel-type-icon svg {
  width: 40px;
  height: 40px;
}

#spota-world-map .sw-panel-type-label {
  font-size: 16px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--map-muted);
}

#spota-world-map .sw-panel-title {
  color: #ffffff;
  font-size: 21px;
  font-weight: 800;
  line-height: 1.25;
  margin: 0 0 6px;
}

#spota-world-map .sw-panel-location {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 13px;
  color: var(--map-muted);
  margin-bottom: 12px;
}

#spota-world-map .sw-panel-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 14px;
}

#spota-world-map .sw-panel-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  font-weight: 700;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

#spota-world-map .sw-panel-badge.is-xp {
  background: rgba(16, 120, 255, 0.16);
  color: #6fb3ff;
}

#spota-world-map .sw-panel-description {
  font-size: 14.5px;
  line-height: 1.6;
  color: #d6d8dc;
  margin: 0 0 20px;
}

#spota-world-map .sw-panel-cta-label {
  font-size: 14px;
  color: var(--map-muted);
  margin-bottom: 10px;
}

#spota-world-map .sw-panel-download {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
}

#spota-world-map .sw-panel-download img {
  height: 44px;
  width: auto;
}

#spota-world-map .map-btn-img-google {
  width: 190px !important;
  height: 75px !important;
}

#spota-world-map .map-btn-img-apple {
  width: 190px !important;
  height: 51px !important;
  margin-top: 12px;
}

/* Empty state */
#spota-world-map .sw-empty {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  color: var(--map-muted);
  font-size: 14px;
  z-index: 1;
}

#spota-world-map .sw-empty.is-visible {
  display: flex;
}
