/* ─────────────────────────────────────────────────────────────────
   Detention Explorer — globe.gl + locate
   Dot-globe entry → type-ahead nearest-centre search (right-side
   blocks) → pick → street-level map zoom + facility file +
   independent-visitors group.
   ───────────────────────────────────────────────────────────────── */

.explorer-section {
  position: relative;
  border-top: 1px solid var(--line);
  background:
    radial-gradient(circle at 50% 44%, rgba(215, 167, 76, 0.10), transparent 38rem),
    radial-gradient(circle at 50% 122%, rgba(127, 81, 18, 0.18), transparent 42rem);
  overflow: hidden;
}

.explorer-head {
  display: grid;
  gap: 0.7rem;
  max-width: 46rem;
  margin-bottom: clamp(1.6rem, 4vw, 2.8rem);
}

.explorer-head h2 {
  color: var(--immi-cream-white);
  font-family: var(--font-display);
  font-size: clamp(2.2rem, 5vw, 5rem);
  font-weight: 700;
  line-height: 0.98;
  letter-spacing: -0.055em;
}

.explorer-head h2 span { color: var(--gold); }

.explorer-sub {
  max-width: 41rem;
  color: var(--muted);
  font-size: clamp(1.02rem, 1.4vw, 1.3rem);
  line-height: 1.62;
}

/* ── Search (single type-ahead: centre / city / country) ──────────── */
.explorer-controls { margin-bottom: clamp(1.2rem, 2.6vw, 1.9rem); }

.explorer-search { position: relative; width: 100%; max-width: 60rem; margin-inline: auto; }

.explorer-search-icon {
  position: absolute;
  left: 1.5rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1.7rem;
  height: 1.7rem;
  fill: var(--gold-bright);
  opacity: 0.85;
  pointer-events: none;
}

.explorer-search-input {
  width: 100%;
  padding: 1.42rem 3.4rem 1.42rem 3.9rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(20, 7, 3, 0.55);
  color: var(--immi-cream-white);
  font-family: var(--font-body);
  font-size: 1.55rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.explorer-search-input::placeholder { color: rgba(255, 252, 250, 0.45); }
.explorer-search-input:focus { outline: none; border-color: var(--gold-bright); box-shadow: 0 0 0 3px rgba(215, 167, 76, 0.14); }
.explorer-search-input::-webkit-search-cancel-button { display: none; }

.explorer-search-clear {
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  width: 2.3rem;
  height: 2.3rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--muted);
  font-size: 1.7rem;
  line-height: 1;
  transition: background 0.2s ease, color 0.2s ease;
}

.explorer-search-clear:hover { background: rgba(255, 252, 250, 0.12); color: var(--immi-cream-white); }

/* ── Globe stage ──────────────────────────────────────────────────── */
.explorer-stage {
  position: relative;
  width: min(100% - (var(--pad-x) * 2), var(--container));
  height: clamp(42rem, 92vh, 64rem);
  margin-inline: auto;
}

.globe-viz { position: absolute; inset: 0; z-index: 1; cursor: grab; }
.globe-viz:active { cursor: grabbing; }
.globe-viz canvas { display: block; outline: none; }

/* ── Street-map layer (Leaflet), shown only in located view ───────── */
.globe-map {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: none;
  opacity: 1;
  border-radius: 16px;
  overflow: hidden;
  background: #0d0704;
  transition: opacity 0.48s ease;
}

.explorer-section.is-located .globe-map { display: block; }
/* Handing back to the globe: fade the flat map out to reveal the globe
   parked behind it at the matched scale — a continuous Google-Earth zoom. */
.explorer-section.is-located.is-map-fading .globe-map { opacity: 0; }

/* Street-map view gets the whole screen width — the globe's column cap
   left half a laptop empty (Wiki, 12/06). */
.explorer-section.is-located .explorer-stage {
  width: calc(100% - (var(--pad-x) * 2));
  max-width: 120rem;
}
.explorer-section.is-located .globe-overview,
.explorer-section.is-located .globe-legend,
.explorer-section.is-located .globe-results { display: none; }

.globe-map .leaflet-container { background: #e9e0cd; }

/* Detailed cartographic basemaps in NEUTRAL GREYSCALE, recoloured to the
   cocoa/champagne brand by the tint below. Grey base + tint keeps every
   road/park/label crisp — tinting a colourful base is what muddied v12. */
.globe-map.tiles-carto .leaflet-tile-pane,
.globe-map.tiles-geoapify .leaflet-tile-pane { filter: sepia(0.45) saturate(1.25) hue-rotate(-8deg) brightness(0.82) contrast(1.06); }

/* Facility pin — big, pulsing, unmissable on light tiles */
.globe-pin span {
  position: relative;
  display: block;
  width: 18px;
  height: 18px;
  margin: 10px;
  border-radius: 50%;
  background: var(--gold-bright);
  border: 3px solid #2a1206;
  box-shadow: 0 0 0 3px rgba(255, 252, 250, 0.92), 0 3px 12px rgba(20, 8, 4, 0.5);
}

.globe-pin span::before {
  content: "";
  position: absolute;
  inset: -14px;
  border-radius: 50%;
  border: 3px solid rgba(180, 120, 30, 0.85);
  animation: pin-pulse 1.8s ease-out infinite;
}

@keyframes pin-pulse {
  0% { transform: scale(0.45); opacity: 1; }
  100% { transform: scale(1.5); opacity: 0; }
}

/* Leaflet controls → dark / gold */
.globe-map .leaflet-bar a {
  background: rgba(20, 7, 3, 0.92);
  color: var(--gold-bright);
  border-bottom-color: rgba(166, 137, 102, 0.3);
}
.globe-map .leaflet-bar a:hover { background: rgba(215, 167, 76, 0.2); color: var(--immi-cream-white); }
.globe-map .leaflet-control-attribution {
  background: rgba(16, 6, 2, 0.78);
  color: rgba(255, 252, 250, 0.55);
  padding: 0 6px;
}
.globe-map .leaflet-control-attribution a { color: var(--gold); }
.globe-map .leaflet-popup-content-wrapper,
.globe-map .leaflet-popup-tip {
  background: rgba(20, 7, 3, 0.96);
  color: var(--immi-cream-white);
  border: 1px solid var(--line);
}
.globe-map .leaflet-popup-content { font-family: var(--font-body); }
.globe-map .leaflet-popup-content strong { color: var(--immi-cream-white); }
.globe-map .leaflet-popup-close-button { color: var(--muted); }

/* ── Back-to-globe button (located view) ──────────────────────────── */
.globe-back {
  position: absolute;
  top: 0.85rem;
  left: 0.85rem;
  z-index: 7;
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.55rem 1rem;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgba(16, 6, 2, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--immi-cream-white);
  font-family: var(--font-tech);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.globe-back[hidden] { display: none; }
.globe-back:hover { background: rgba(215, 167, 76, 0.18); border-color: var(--gold-bright); }

/* ── Results — nearest centres as pickable blocks (right) ─────────── */
.globe-results {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 6;
  width: min(86%, 19.5rem);
  max-height: 100%;
  overflow-y: auto;
  margin: 0;
  padding: 0.4rem;
  list-style: none;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: rgba(16, 6, 2, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
}

.globe-results[hidden] { display: none; }

.globe-results-head {
  padding: 0.5rem 0.6rem 0.35rem;
  color: var(--muted);
  font-family: var(--font-tech);
  font-size: 0.52rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.globe-result {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.65rem;
  border: 1px solid transparent;
  border-radius: 10px;
  text-align: left;
  transition: background 0.15s ease, border-color 0.15s ease;
}

.globe-result + .globe-result { margin-top: 0.12rem; }
.globe-result:hover,
.globe-result:focus-visible,
.globe-result.is-active { background: rgba(215, 167, 76, 0.14); border-color: rgba(215, 167, 76, 0.3); outline: none; }

.gr-name { color: var(--immi-cream-white); font-size: 0.86rem; line-height: 1.18; }
.gr-sub { display: block; margin-top: 0.12rem; color: var(--muted); font-size: 0.68rem; line-height: 1.2; }
.gr-end { display: flex; align-items: center; gap: 0.5rem; }
.gr-dist { color: var(--gold-bright); font-family: var(--font-tech); font-size: 0.6rem; white-space: nowrap; }
.gr-dot { width: 0.55rem; height: 0.55rem; border-radius: 50%; box-shadow: 0 0 6px currentColor; }
.globe-results-empty { padding: 0.85rem; color: var(--muted); font-size: 0.85rem; font-style: italic; }

/* ── Overview stats — monospace "Detention Overview" panel ────────── */
.globe-overview {
  position: absolute;
  right: 0;
  bottom: 0;
  z-index: 3;
  padding: clamp(0.85rem, 2vw, 1.2rem) clamp(1rem, 2.4vw, 1.5rem);
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 7, 3, 0.62);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  pointer-events: none;
}

.globe-overview-title {
  margin-bottom: 0.65rem;
  color: var(--gold-bright);
  font-family: var(--font-tech);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  opacity: 0.92;
}

.globe-overview-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.6rem 1.5rem; margin: 0; }
.globe-overview-grid dt { color: var(--muted); font-family: var(--font-tech); font-size: 0.52rem; letter-spacing: 0.16em; text-transform: uppercase; }
.globe-overview-grid dd { margin: 0.1rem 0 0; color: var(--immi-cream-white); font-family: var(--font-tech); font-size: clamp(1.05rem, 2vw, 1.5rem); font-weight: 700; line-height: 1.05; }

/* ── Legend ───────────────────────────────────────────────────────── */
.globe-legend {
  position: absolute;
  left: 0;
  bottom: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 0.42rem;
  padding: 0.8rem 1rem;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgba(20, 7, 3, 0.5);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--muted);
  font-size: 0.72rem;
  pointer-events: none;
}

.globe-legend span { display: flex; align-items: center; gap: 0.5rem; }
.globe-legend .dot { width: 0.62rem; height: 0.62rem; border-radius: 50%; box-shadow: 0 0 8px currentColor; }
.dot-op { color: #d7a74c; background: #d7a74c; }
.dot-cont { color: #c98f3a; background: #c98f3a; }
.dot-closed { color: #8a6440; background: #8a6440; box-shadow: none; }

/* ── Facility detail panel (right) ────────────────────────────────── */
.globe-detail {
  position: absolute;
  top: 0;
  right: 0;
  z-index: 7;
  width: min(100%, 23rem);
  max-height: 100%;
  overflow-y: auto;
  display: grid;
  gap: 0.85rem;
  align-content: start;
  padding: clamp(1.3rem, 2.5vw, 1.85rem);
  border: 1px solid var(--line);
  border-radius: 14px;
  background:
    radial-gradient(circle at 12% 0%, rgba(166, 137, 102, 0.14), transparent 60%),
    rgba(20, 7, 3, 0.9);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5);
  transform: translateX(10px);
  opacity: 0;
  transition: opacity 0.32s var(--ease), transform 0.32s var(--ease);
}

.explorer-section.has-detail .globe-detail { transform: none; opacity: 1; }
.globe-detail[hidden] { display: none; }

.globe-detail-close {
  position: absolute;
  top: 0.5rem;
  right: 0.6rem;
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: var(--immi-cream-white);
  font-size: 1.5rem;
  line-height: 1;
  transition: background 0.2s ease, transform 0.2s ease;
}

.globe-detail-close:hover { background: rgba(255, 252, 250, 0.12); transform: scale(1.08); }

.globe-detail-kicker { padding-right: 2rem; color: var(--gold-bright); font-family: var(--font-tech); font-size: 0.68rem; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; }
.globe-detail-name { color: var(--immi-cream-white); font-family: var(--font-display); font-size: clamp(1.5rem, 2.7vw, 2rem); font-weight: 700; line-height: 1.08; letter-spacing: -0.02em; }
.globe-detail-loc { margin-top: -0.3rem; color: var(--muted); font-size: 1.04rem; line-height: 1.4; }

.globe-detail-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.9rem 1rem; margin: 0.2rem 0 0; }
.globe-detail-grid dt { margin-bottom: 0.22rem; color: var(--muted); font-family: var(--font-tech); font-size: 0.58rem; letter-spacing: 0.14em; text-transform: uppercase; }
.globe-detail-grid dd { margin: 0; color: var(--immi-cream-white); font-size: 1.08rem; line-height: 1.3; }
.globe-detail-grid dd[data-d="status"] { font-weight: 700; color: var(--gold-bright); }

.globe-detail-note { color: var(--muted); font-size: 0.8rem; font-style: italic; opacity: 0.8; }

/* ── Visitor / support group block ────────────────────────────────── */
.globe-detail-groups { display: grid; gap: 0.7rem; }
.globe-detail-groups:empty { display: none; }
.dg-label { color: var(--gold-bright); font-family: var(--font-tech); font-size: 0.58rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; }
.dg-group { display: grid; gap: 0.35rem; padding-top: 0.65rem; border-top: 1px solid var(--line); }
.dg-name { color: var(--immi-cream-white); font-family: var(--font-display); font-weight: 700; font-size: 1.12rem; line-height: 1.15; }
.dg-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.5; }
.dg-contacts { display: flex; flex-direction: column; gap: 0.25rem; margin-top: 0.2rem; }
.dg-contacts a { width: fit-content; color: var(--gold-bright); font-size: 0.92rem; }
.dg-contacts a:hover { text-decoration: underline; }
.dg-empty { color: var(--muted); font-size: 0.8rem; font-style: italic; opacity: 0.8; }

.globe-detail-src {
  justify-self: start;
  margin-top: 0.1rem;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.5rem 1.05rem;
  border: 1px solid rgba(215, 167, 76, 0.5);
  border-radius: 999px;
  color: var(--gold-bright);
  font-family: var(--font-tech);
  font-size: 0.6rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  transition: background 0.24s ease, border-color 0.24s ease;
}

.globe-detail-src:hover { background: rgba(215, 167, 76, 0.16); border-color: var(--gold-bright); }

/* ── globe.gl point tooltip ───────────────────────────────────────── */
.globe-tip { font-family: var(--font-body); text-align: left; max-width: 14rem; }
.globe-tip b { display: block; color: var(--immi-cream-white); font-size: 0.85rem; line-height: 1.15; }
.globe-tip span { color: var(--gold-bright); font-size: 0.72rem; }

/* ── Fallback (no WebGL) ──────────────────────────────────────────── */
.globe-fallback {
  position: absolute;
  inset: 0;
  display: none;
  place-items: center;
  padding: 2rem;
  text-align: center;
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
}

.explorer-section.is-fallback .globe-fallback { display: grid; }
.explorer-section.is-fallback .globe-overview,
.explorer-section.is-fallback .globe-legend { display: none; }

@media (max-width: 720px) {
  .explorer-stage { height: clamp(34rem, 80vh, 50rem); }
  .globe-overview { top: 0; bottom: auto; right: 0; left: auto; }
  .globe-legend { display: none; }
  .globe-results { width: 100%; max-height: 60%; }
  .globe-detail {
    width: 100%;
    top: auto;
    bottom: 0;
    max-height: 68%;
    border-radius: 14px 14px 0 0;
    transform: translateY(12px);
  }
  .explorer-section.has-detail .globe-detail { transform: none; }
  .explorer-section.has-detail .globe-overview { opacity: 0; }
  .explorer-search { max-width: none; }
  .explorer-search-input { font-size: 1.2rem; padding: 1.1rem 3rem 1.1rem 3.2rem; }
}

/* ── v9: detail-panel call CTA + street-map failure notice ──────── */

.globe-detail-cta {
  display: block;
  margin-top: 0.95rem;
  padding: 0.72rem 0.85rem;
  border-radius: 8px;
  text-align: center;
  background: linear-gradient(135deg, rgba(215, 167, 76, 0.94), rgba(201, 143, 58, 0.9));
  color: #1e0b06;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.globe-detail-cta:hover,
.globe-detail-cta:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 10px 26px rgba(215, 167, 76, 0.28);
  outline: none;
}

.globe-detail-cta { padding: 0.85rem 0.9rem; }

.globe-detail-cta .cta-lead {
  display: block;
  font-family: var(--font-tech);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.85;
}

.globe-detail-cta .cta-phone {
  display: block;
  margin: 0.12rem 0 0.1rem;
  font-family: var(--font-display);
  font-size: clamp(1.5rem, 2.6vw, 1.9rem);
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.005em;
}

.globe-detail-cta .cta-tag {
  display: block;
  font-family: var(--font-tech);
  font-size: 0.58rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  opacity: 0.8;
}

/* Author display:grid would otherwise defeat the [hidden] attribute the JS
   toggles on the clear button (pre-existing; the other panels already do this). */
.explorer-search-clear[hidden] { display: none; }

/* Refining a search while a facility file is open: the dropdown must sit
   ABOVE the detail panel (both are pinned top-right), or it renders unseen
   behind the panel's opaque glass and steals no clicks. */
.explorer-section.has-detail:not(.is-located) .globe-results { z-index: 8; }

.globe-detail-map-btn {
  display: block;
  width: 100%;
  margin-top: 0.55rem;
  padding: 0.6rem 0.85rem;
  border-radius: 8px;
  border: 1px solid rgba(215, 167, 76, 0.45);
  background: transparent;
  color: var(--gold-bright);
  font-family: var(--font-tech);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s ease, border-color 0.2s ease;
}

.globe-detail-map-btn:hover,
.globe-detail-map-btn:focus-visible {
  background: rgba(215, 167, 76, 0.12);
  border-color: rgba(215, 167, 76, 0.7);
  outline: none;
}

/* Already on the street map → no need for the button */
.explorer-section.is-located .globe-detail-map-btn { display: none; }

.globe-map-error {
  margin: 0.6rem 0 0;
  padding: 0.55rem 0.7rem;
  border-radius: 6px;
  border: 1px solid rgba(215, 167, 76, 0.4);
  background: rgba(215, 167, 76, 0.1);
  color: var(--gold-bright);
  font-size: 0.8rem;
  line-height: 1.45;
}
