/* =========================================================================
   GTA 6 Interactive Map, module styles
   Self-contained. Themed to gta6map.org (dark #07050d, pink #ff2a8a,
   cyan #00e0ff, purple #b14bff). Mobile-first; must not cause horizontal
   scroll at 360px. Falls back to site CSS vars when present.
   ========================================================================= */

:root {
  --map-ink-900: #07050d;
  --map-ink-800: #0d0817;
  --map-ink-700: #150f24;
  --map-ink-600: #1d1633;
  --map-line: #34294f;
  --map-line-2: #463a66;
  --map-pink: #ff2a8a;
  --map-cyan: #00e0ff;
  --map-purple: #b14bff;
  --map-yellow: #ffd23f;
  --map-text: #f4eefb;
  --map-text-2: #c3b8d6;
  --map-text-3: #9286ab;
  --map-font-display: var(--font-display, "Sora", system-ui, -apple-system, sans-serif);
  --map-font-body: var(--font-body, "Inter", system-ui, -apple-system, sans-serif);
}

/* ----- Container (the homepage element) ------------------------------- */
.gta6-map {
  position: relative;
  width: 100%;
  max-width: 100%;
  height: clamp(360px, 64vh, 680px);
  overflow: hidden;
  background:
    radial-gradient(80% 120% at 50% -20%, rgba(255, 42, 138, 0.16), transparent 60%),
    radial-gradient(90% 120% at 100% 120%, rgba(0, 224, 255, 0.12), transparent 60%),
    var(--map-ink-800);
  border-radius: 0;
  isolation: isolate;
  touch-action: pan-x pan-y;
}

@media (max-width: 700px) {
  .gta6-map { height: clamp(360px, 60vh, 560px); }
}

/* Hide the empty-state placeholder once Leaflet has mounted */
.gta6-map.gta6-map--ready::before,
.gta6-map.gta6-map--ready::after { content: none !important; }

/* Leaflet root must fill the container */
/* Leaflet adds .leaflet-container to the SAME element as #gta6-map. The element's
   size comes from .gta6-map's own clamp() height, do NOT force 100% here or it
   collapses to 0 (its parent has no fixed height). Only theme it. The !important
   beats leaflet.css .leaflet-container{background:#ddd} regardless of load order. */
.gta6-map.leaflet-container {
  background: var(--map-ink-900) !important;
  font-family: var(--map-font-body);
  outline: none;
}
/* Any genuinely nested .leaflet-container (defensive) should fill its parent. */
.gta6-map .leaflet-container {
  width: 100%;
  height: 100%;
  background: var(--map-ink-900) !important;
  font-family: var(--map-font-body);
  outline: none;
}

/* ----- Loading / error overlay ---------------------------------------- */
.gta6-map__status {
  position: absolute;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 1.4rem;
  background: var(--map-ink-800);
  color: var(--map-text-2);
}
.gta6-map__status-inner {
  max-width: 32ch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}
.gta6-map__spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(177, 75, 255, 0.25);
  border-top-color: var(--map-cyan);
  border-right-color: var(--map-pink);
  animation: gta6mapspin 0.85s linear infinite;
}
@keyframes gta6mapspin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) {
  .gta6-map__spinner { animation: none; border-top-color: var(--map-cyan); }
}
.gta6-map__status h3 {
  margin: 0;
  font-family: var(--map-font-display);
  font-size: 1.05rem;
  color: var(--map-text);
  letter-spacing: 0.02em;
}
.gta6-map__status p { margin: 0; font-size: 0.92rem; line-height: 1.5; }
.gta6-map__status--error .gta6-map__spinner { display: none; }
.gta6-map__retry {
  margin-top: 0.3rem;
  padding: 0.5rem 1.05rem;
  border-radius: 999px;
  border: 1px solid var(--map-cyan);
  background: var(--map-ink-600);
  color: var(--map-cyan);
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
}
.gta6-map__retry:hover { background: var(--map-ink-700); }

/* ----- Preview banner -------------------------------------------------- */
.gta6-map__banner {
  position: absolute;
  top: 10px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: calc(100% - 92px);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: color-mix(in srgb, var(--map-ink-900) 78%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-line-2);
  color: var(--map-text-2);
  font-size: 0.74rem;
  line-height: 1.25;
  font-weight: 500;
  text-align: center;
  box-shadow: 0 4px 18px rgba(0, 0, 0, 0.4);
  pointer-events: none;
}
.gta6-map__banner::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--map-pink);
  box-shadow: 0 0 8px var(--map-pink);
}
@media (max-width: 600px) {
  /* On phones, move the banner to the bottom (above attribution) so it never
     collides with the top-left search box or the top-right control stack. */
  .gta6-map__banner {
    top: auto;
    bottom: 44px;
    font-size: 0.68rem;
    padding: 0.35rem 0.7rem;
    max-width: calc(100% - 20px);
  }
}

/* ----- Search box ------------------------------------------------------ */
.gta6-map__search {
  position: absolute;
  top: 48px;
  left: 10px;
  z-index: 1000;
  width: min(232px, calc(100% - 64px));
}
.gta6-map__search-field {
  position: relative;
  display: flex;
  align-items: center;
}
.gta6-map__search-field::before {
  content: "";
  position: absolute;
  left: 11px;
  width: 13px;
  height: 13px;
  border: 2px solid var(--map-text-3);
  border-radius: 50%;
  pointer-events: none;
}
.gta6-map__search-field::after {
  content: "";
  position: absolute;
  left: 21px;
  top: 22px;
  width: 6px;
  height: 2px;
  background: var(--map-text-3);
  transform: rotate(45deg);
  transform-origin: left center;
  pointer-events: none;
}
.gta6-map__search input {
  width: 100%;
  padding: 0.5rem 0.7rem 0.5rem 2rem;
  border-radius: 999px;
  border: 1px solid var(--map-line-2);
  background: color-mix(in srgb, var(--map-ink-700) 92%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  color: var(--map-text);
  font-family: var(--map-font-body);
  font-size: 0.86rem;
  line-height: 1.2;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}
.gta6-map__search input::placeholder { color: var(--map-text-3); }
.gta6-map__search input:focus-visible {
  outline: none;
  border-color: var(--map-cyan);
  box-shadow: 0 0 0 2px rgba(0, 224, 255, 0.35);
}
.gta6-map__results {
  list-style: none;
  margin: 6px 0 0;
  padding: 4px;
  border-radius: 12px;
  background: var(--map-ink-700);
  border: 1px solid var(--map-line-2);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
  max-height: 188px;
  overflow-y: auto;
}
.gta6-map__results:empty { display: none; }
.gta6-map__results li {
  margin: 0;
  padding: 0.45rem 0.6rem;
  border-radius: 8px;
  font-size: 0.84rem;
  color: var(--map-text-2);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.gta6-map__results li:hover,
.gta6-map__results li[aria-selected="true"] {
  background: var(--map-ink-500, #2a2247);
  color: var(--map-text);
}
.gta6-map__results .gta6-map__dot {
  flex: none;
  width: 9px;
  height: 9px;
  border-radius: 50%;
}
.gta6-map__results .gta6-map__no-result {
  color: var(--map-text-3);
  cursor: default;
  font-style: italic;
}
.gta6-map__results .gta6-map__no-result:hover { background: none; color: var(--map-text-3); }

@media (max-width: 480px) {
  .gta6-map__search { width: calc(100% - 58px); }
}

/* ----- Legend ---------------------------------------------------------- */
.gta6-map__legend {
  position: absolute;
  left: 10px;
  bottom: 10px;
  z-index: 1000;
  padding: 0.55rem 0.7rem;
  border-radius: 12px;
  background: color-mix(in srgb, var(--map-ink-800) 86%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.42);
  font-size: 0.74rem;
  color: var(--map-text-2);
  max-width: calc(100% - 20px);
}
.gta6-map__legend h4 {
  margin: 0 0 0.4rem;
  font-family: var(--map-font-display);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--map-text-3);
  font-weight: 700;
}
.gta6-map__legend ul { list-style: none; margin: 0; padding: 0; display: grid; gap: 0.3rem; }
.gta6-map__legend li { display: flex; align-items: center; gap: 0.45rem; }
.gta6-map__legend .gta6-map__dot { flex: none; width: 11px; height: 11px; border-radius: 50%; }
.gta6-map__legend-sep {
  margin: 0.45rem 0 0.35rem;
  height: 1px;
  background: var(--map-line);
}
.gta6-map__legend .gta6-map__conf { display: flex; align-items: center; gap: 0.45rem; }
.gta6-map__legend .gta6-map__conf span:first-child {
  flex: none;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  border: 2px solid currentColor;
}
.gta6-map__legend .gta6-map__conf--confirmed { color: var(--map-yellow); }
.gta6-map__legend .gta6-map__conf--rumoured { color: var(--map-purple); }
.gta6-map__legend .gta6-map__conf strong { color: var(--map-text-2); font-weight: 500; }

@media (max-width: 560px) {
  .gta6-map__legend { font-size: 0.68rem; padding: 0.5rem 0.6rem; bottom: 8px; }
  /* On very small screens, let the legend collapse to keep the map usable */
  .gta6-map__legend.is-collapsed ul,
  .gta6-map__legend.is-collapsed .gta6-map__legend-sep,
  .gta6-map__legend.is-collapsed .gta6-map__conf { display: none; }
  .gta6-map__legend-toggle {
    display: inline-block;
    margin-left: 0.4rem;
    color: var(--map-cyan);
    font-size: 0.66rem;
  }
}
.gta6-map__legend-toggle { display: none; cursor: pointer; }

/* ----- Custom markers -------------------------------------------------- */
.gta6-map__pin {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50% 50% 50% 2px;
  transform: rotate(45deg);
  border: 2px solid #fff;
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.4), 0 4px 10px rgba(0, 0, 0, 0.55);
  position: relative;
}
.gta6-map__pin::after {
  content: "";
  position: absolute;
  width: 7px;
  height: 7px;
  top: 50%;
  left: 50%;
  margin: -3.5px 0 0 -3.5px;
  border-radius: 50%;
  background: rgba(7, 5, 13, 0.92);
}
.gta6-map__pin--city { background: var(--map-pink); }
.gta6-map__pin--region { background: var(--map-cyan); }
.gta6-map__pin--landmark { background: var(--map-purple); }
.gta6-map__pin--found { filter: grayscale(0.4) brightness(0.78); }
.gta6-map__pin--found::after { background: var(--map-yellow); }
.gta6-map__pin--hit {
  animation: gta6pinpulse 1.4s ease-out 2;
  z-index: 1100 !important;
}
@keyframes gta6pinpulse {
  0%, 100% { box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 4px 10px rgba(0,0,0,0.5); }
  50% { box-shadow: 0 0 0 1px rgba(0,0,0,0.35), 0 0 0 7px rgba(0, 224, 255, 0.4); }
}
@media (prefers-reduced-motion: reduce) {
  .gta6-map__pin--hit { animation: none; }
}

/* ----- Popups ---------------------------------------------------------- */
.gta6-map .leaflet-popup-content-wrapper {
  background: var(--map-ink-700);
  color: var(--map-text);
  border: 1px solid var(--map-line-2);
  border-radius: 14px;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}
.gta6-map .leaflet-popup-tip {
  background: var(--map-ink-700);
  border: 1px solid var(--map-line-2);
}
.gta6-map .leaflet-popup-content { margin: 0; font-family: var(--map-font-body); }
.gta6-map .leaflet-popup-close-button { color: var(--map-text-3); padding: 6px 8px 0 0; }
.gta6-map .leaflet-popup-close-button:hover { color: var(--map-text); }

.gta6-map__popup { padding: 0.85rem 0.95rem 0.9rem; width: min(248px, 70vw); }
.gta6-map__popup-head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}
.gta6-map__popup-dot { flex: none; width: 11px; height: 11px; border-radius: 50%; }
.gta6-map__popup h3 {
  margin: 0;
  font-family: var(--map-font-display);
  font-size: 1.02rem;
  line-height: 1.2;
  color: var(--map-text);
  letter-spacing: -0.01em;
}
.gta6-map__badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.64rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  padding: 2px 9px;
  border-radius: 999px;
  border: 1px solid transparent;
  margin-bottom: 0.5rem;
}
.gta6-map__badge::before { content: ""; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.gta6-map__badge--confirmed {
  background: rgba(255, 210, 63, 0.14);
  color: var(--map-yellow);
  border-color: rgba(255, 210, 63, 0.4);
}
.gta6-map__badge--rumoured {
  background: rgba(177, 75, 255, 0.14);
  color: #c97bff;
  border-color: rgba(177, 75, 255, 0.42);
}
.gta6-map__popup p {
  margin: 0 0 0.7rem;
  font-size: 0.84rem;
  line-height: 1.5;
  color: var(--map-text-2);
  max-width: none;
}
.gta6-map__popup-actions { display: flex; flex-wrap: wrap; gap: 0.5rem; align-items: center; }
.gta6-map__popup-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--map-cyan);
  text-decoration: none;
  border-bottom: 1px solid transparent;
}
.gta6-map__popup-link:hover { color: #5cefff; border-bottom-color: #5cefff; }
.gta6-map__popup-found {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 0.78rem;
  color: var(--map-text-3);
  cursor: pointer;
  user-select: none;
}
.gta6-map__popup-found input { accent-color: var(--map-yellow); margin: 0; }

/* ----- Leaflet controls reskin ---------------------------------------- */
.gta6-map .leaflet-bar {
  border: 1px solid var(--map-line-2);
  border-radius: 10px;
  overflow: hidden;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.45);
}
.gta6-map .leaflet-bar a,
.gta6-map .leaflet-control-zoom-in,
.gta6-map .leaflet-control-zoom-out {
  background: var(--map-ink-700);
  color: var(--map-text);
  border-bottom: 1px solid var(--map-line);
  width: 34px;
  height: 34px;
  line-height: 34px;
  font-size: 1.1rem;
}
.gta6-map .leaflet-bar a:hover { background: var(--map-ink-600); color: var(--map-cyan); }
.gta6-map .leaflet-bar a:last-child { border-bottom: none; }

.gta6-map__fs-btn { font-size: 1rem !important; font-weight: 700; }

/* Layers control */
.gta6-map .leaflet-control-layers {
  background: color-mix(in srgb, var(--map-ink-700) 94%, transparent);
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
  border: 1px solid var(--map-line-2);
  border-radius: 12px;
  color: var(--map-text-2);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.gta6-map .leaflet-control-layers-toggle {
  background-color: var(--map-ink-700);
  border-radius: 10px;
  width: 38px;
  height: 38px;
}
.gta6-map .leaflet-control-layers-expanded { padding: 0.6rem 0.7rem; }
.gta6-map .leaflet-control-layers label {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin: 0.2rem 0;
  font-size: 0.84rem;
  color: var(--map-text-2);
}
.gta6-map .leaflet-control-layers label:hover { color: var(--map-text); }
.gta6-map .leaflet-control-layers input { accent-color: var(--map-cyan); }
.gta6-map .leaflet-control-layers-separator { border-top-color: var(--map-line); }

/* Attribution */
.gta6-map .leaflet-control-attribution {
  background: color-mix(in srgb, var(--map-ink-900) 78%, transparent);
  color: var(--map-text-3);
  font-size: 0.66rem;
  padding: 2px 7px;
  border-radius: 8px 0 0 0;
}
.gta6-map .leaflet-control-attribution a { color: var(--map-text-2); }

/* Fullscreen state */
.gta6-map.gta6-map--fs {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  z-index: 9999;
  border-radius: 0;
}

/* Keep everything visually inside the rounded shell */
.gta6-map .leaflet-control-container .leaflet-top { top: 0; }
