/* =========================
   Map Explorer (no scroll story)
   Updated for: combined panel (Search + Zoom + Layers)
   ========================= */

/* Full-screen fixed map */
.map-story-map {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  z-index: 0;
}

/* Make sure Mapbox canvas fills cleanly */
.mapboxgl-canvas {
  border-radius: 0;
}

/* Anchor overlays (panel + any absolute controls) */
.map-explorer{
  position: relative;
}

/* Keep Mapbox native controls above the map, below sidebar if desired */
.mapboxgl-ctrl-top-right {
  z-index: 50;
}

/* =========================
   Combined Control Panel
   (replaces .layer-panel and .map-search)
   ========================= */

.map-control-panel{
  position: fixed;
  bottom: 16px;   /* ← moved here */
  left: 16px;
  z-index: 99999;

  width: 300px;
  max-width: calc(100vw - 32px);

  background: rgba(255,255,255,0.95);
  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.18);

  padding: 12px;
  font-size: 14px;

  pointer-events: auto;
}


.mcp-section{
  margin: 0;
}

.mcp-title{
  font-weight: 700;
  margin: 0 0 8px;
  font-size: 14px;
  opacity: 0.9;
}

.mcp-divider{
  height: 1px;
  background: rgba(0,0,0,0.08);
  margin: 10px 0;
}

/* Search */
#mapSearchInput{
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 10px;
  font-size: 14px;
  outline: none;
  background: #fff;
}

#mapSearchInput:focus{
  border-color: rgba(0,0,0,0.28);
}

.mcp-search-results{
  margin-top: 8px;
  max-height: 320px;
  overflow: auto;

  border: 1px solid rgba(0,0,0,0.10);
  border-radius: 10px;
  background: #fff;

  padding: 6px;
}

/* Backwards-compat: if JS still renders .map-search-item */
.mcp-search-results .map-search-item,
.mcp-search-results .result-item{
  padding: 8px 10px;
  border-radius: 10px;
  cursor: pointer;
}

.mcp-search-results .map-search-item:hover,
.mcp-search-results .result-item:hover{
  background: rgba(0,0,0,0.06);
}

/* Backwards-compat: if JS still renders title/meta */
.mcp-search-results .map-search-title{
  font-weight: 600;
  font-size: 14px;
}

.mcp-search-results .map-search-meta{
  font-size: 12px;
  opacity: 0.75;
  margin-top: 2px;
}

/* Zoom */
.mcp-zoom{
  display: flex;
  gap: 8px;
}

.mcp-btn{
  flex: 1;
  padding: 10px 0;

  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 10px;
  background: rgba(255,255,255,0.95);

  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;

  font-size: 18px;
  line-height: 1;
}


/* Hide zoom controls on mobile */
@media (max-width: 768px) {
  .mcp-desktop-only {
    display: none !important;
  }
}



.mcp-btn:hover{
  background: rgba(0,0,0,0.04);
}

.mcp-btn:active{
  background: rgba(0,0,0,0.07);
  transform: translateY(1px);
}

/* Layers */
.mcp-check{
  display: flex;
  align-items: center;
  gap: 8px;

  margin: 6px 0;
  user-select: none;
}

.mcp-check input{
  transform: translateY(1px);
}






/* Peace Triangle sublayers */
.mcp-sublayers {
  display: none;
  margin-left: 20px;
  margin-top: 4px;
  padding-left: 12px;
  border-left: 2px solid rgba(0, 0, 0, 0.08);
}

.mcp-sublayers.mcp-expanded {
  display: block;
}

.mcp-sublayer {
  font-size: 13px;
  margin: 4px 0;
  word-wrap: break-word;
  white-space: normal;
  display: flex;
  align-items: flex-start;
}

.mcp-sublayer input {
  margin-top: 2px;
  flex-shrink: 0;
}

.mcp-parent {
  font-weight: 600;
}







/* =========================
   Sidebar (reusing your existing IDs/classes)
   ========================= */

.country-sidebar {
  position: fixed;
  top: 0;
  right: 0;
  height: 100vh;
  width: min(420px, 40vw);
  background: rgba(255, 255, 255, 0.97);
  box-shadow: -2px 0 10px rgba(0, 0, 0, 0.25);
  z-index: 9999;
  display: flex;
  flex-direction: column;

  transform: translateX(100%);
  transition: transform 0.3s ease;
}

.country-sidebar.open {
  transform: translateX(0);
}

.country-sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0,0,0,0.12);
  background: rgba(247, 247, 247, 0.95);
}

.country-sidebar-header h3 {
  margin: 0;
  font-size: 1.05rem;
}

#country-sidebar-close {
  border: none;
  background: transparent;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 6px;
}

.country-sidebar-content {
  padding: 16px;
  overflow-y: auto;
  font-size: 0.95rem;
}

/* Sidebar content helpers used by map-story.js */
.sidebar-media img {
  width: 100%;
  height: auto;
  border-radius: 10px;
  display: block;
  margin: 10px 0 12px;
}

.sidebar-summary {
  font-size: 14px;
  line-height: 1.45;
}

.sidebar-kv {
  margin: 12px 0 0;
  padding: 0;
  list-style: none;
  font-size: 13px;
  opacity: 0.9;
}

.sidebar-kv li {
  margin: 6px 0;
}

.related {
  margin-top: 14px;
  padding-top: 12px;
  border-top: 1px solid rgba(0,0,0,0.10);
}

.related h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.related .related-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.related button {
  border: 1px solid rgba(0,0,0,0.18);
  background: rgba(0,0,0,0.03);
  padding: 6px 10px;
  border-radius: 999px;
  cursor: pointer;
  font-size: 12px;
}

/* Footer / layer controls */
.country-sidebar-footer {
  margin-top: auto;
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(0,0,0,0.10);
  background: rgba(255,255,255,0.97);
}

.layer-controls-title {
  font-weight: 600;
  margin-bottom: 8px;
}

.layer-controls label {
  display: block;
  font-size: 13px;
  margin: 6px 0;
}

/* Mobile: sidebar becomes full width */
@media (max-width: 768px) {
  .country-sidebar {
    width: 70%;
  }
}

/* =========================
   Countries table (reusing your existing IDs/classes)
   ========================= */
.countries-table .country-row {
  cursor: pointer;
}

.countries-table .country-row.is-selected {
  background: rgba(255, 235, 160, 0.35);
  outline: 2px solid rgba(0,0,0,0.2);
}

/* =========================
   REMOVE/NEUTRALIZE old UI blocks
   (in case any leftover markup remains)
   ========================= */

/* Old panels are no longer used; harmless if present */
.layer-panel,
.map-search{
  display: none;
}

/* =========================
   Panel collapse (DESKTOP + ALL SIZES)
   ========================= */

.map-control-panel .mcp-handle{
  display: flex;
  align-items: center;
  justify-content: center;
  height: 56px;
  padding: 0 12px;
  cursor: pointer;
  user-select: none;
}

.map-control-panel .mcp-grip{
  width: 44px;
  height: 5px;
  border-radius: 999px;
  background: rgba(0,0,0,.18);
}

/* Collapsed state: hide content everywhere */
.map-control-panel[data-state="collapsed"] .mcp-content{
  display: none;
}

/* Desktop-only collapsed sizing (so mobile bottom-sheet rules stay in control) */
@media (min-width: 769px){
  .map-control-panel[data-state="collapsed"]{
    padding: 0;
    height: 56px;
    overflow: hidden;
  }
}

.mcp-handle, #panelCollapseBtn{
  touch-action: manipulation;
}


/* =========================
   Mobile UX tweaks (Bottom sheet panel)
   ========================= */
@media (max-width: 768px) {

  /* Bottom-sheet control panel */
  .map-control-panel {
    position: fixed;
    left: 12px;
    right: auto;
    bottom: 12px;
    top: auto;

    width: 60%;
    max-width: 320px;

    border-radius: 16px;
    box-shadow: 0 8px 24px rgba(0,0,0,.18);
    z-index: 60;

    transition: max-height 180ms ease, transform 180ms ease;
    overflow: hidden;
  }

  /* EXPANDED state - must come BEFORE collapsed */
  .map-control-panel[data-state="expanded"] {
    max-height: 75vh;
  }

  /* COLLAPSED state - must come AFTER expanded */
  .map-control-panel[data-state="collapsed"] {
    max-height: 56px !important;  /* !important to ensure it overrides */
  }

  /* content area scrolling only when expanded */
  .map-control-panel .mcp-content {
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    max-height: calc(75vh - 56px);
  }

  .map-control-panel[data-state="collapsed"] .mcp-content {
    display: none !important;  /* !important to ensure it overrides */
  }




  





  /* Handle / grip (top bar) */
  .mcp-handle {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 56px;
    padding: 0 12px;
    cursor: pointer;
    user-select: none;
    touch-action: manipulation;
  }

  .mcp-grip {
    width: 44px;
    height: 5px;
    border-radius: 999px;
    background: rgba(0,0,0,.18);
  }

  /* Mobile safety rules */
  html, body {
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
  }

  #map-story-map, .mapboxgl-canvas {
    touch-action: none;
  }

  /* If you kept a top toggle button, keep this.
     If you removed it (as you asked), this can be omitted safely. */
  .mcp-toggle {
    border: 0;
    background: transparent;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
  }

}

/* Remove WordPress page title flash on Map Story (page ID 17190) */
.page-id-17190 .entry-title {
  display: none !important;
}

/* =========================
   USA button 
   ========================= */
/* Arrow styling for panel-embedded Jump USA button */
.jump-usa-btn--panel .jump-usa-arrow{
  font-size: 14px;      /* smaller arrow */
  line-height: 1;
  opacity: 0.9;
}

.jump-usa-btn--panel .jump-usa-text{
  font-size: 14px;
  letter-spacing: 0.3px;
}

/* Tight, clean spacing */
.jump-usa-btn--panel{
  gap: 6px;
}




/* =========================
   Intro Modal (welcome overlay)
   ========================= */

.intro-overlay {
  position: fixed !important;
  inset: 0;
  display: none;                 /* hidden by default */
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 999999 !important;

  /* softened dim so map context remains visible */
  background: rgba(0, 0, 0, 0.15);
}

.intro-overlay.intro-open {
  display: flex;
}

.intro-modal {
  width: min(900px, 92vw);
  height: min(650px, 85vh);
  overflow: auto;

  border-radius: 14px;
  padding: 22px 22px 18px;

  /* semi-transparent glass panel */
  background: rgba(255, 255, 255, 0.55);
  backdrop-filter: blur(8px);

  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.25);
  position: relative;
}

.intro-title {
  margin: 0 38px 12px 0;
  font-size: 22px;
}

.intro-body p {
  margin: 0 0 12px 0;
  line-height: 1.45;
}

.intro-body ul {
  margin: 0 0 14px 18px;
  padding: 0;
  line-height: 1.5;
}

.intro-body hr {
  border: none;
  border-top: 1px solid rgba(0,0,0,0.12);
  margin: 14px 0;
}

.intro-remember {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  font-size: 14px;
  margin-top: 6px;
  user-select: none;
}

/* Close control: diagonal cross drawn with lines */
/* Close icon: rounded square + thick X (matching border colour) */
.intro-close{
  position: absolute;
  top: 14px;
  right: 16px;

  width: 44px;
  height: 44px;

  background: transparent;
  border: 2px solid rgba(0, 0, 0, 0.25);
  border-radius: 12px;

  cursor: pointer;
  padding: 0;
  box-shadow: none;
  outline: none;

  /* use currentColor so border + X match automatically */
  color: rgba(0, 0, 0, 0.25);
}

.intro-close::before,
.intro-close::after{
  content: "";
  position: absolute;
  left: 50%;
  top: 50%;

  width: 62%;
  height: 3px;                 /* thickness of the X */
  background: currentColor;
  border-radius: 999px;        /* rounded line ends */

  transform-origin: center;
}

.intro-close::before{ transform: translate(-50%, -50%) rotate(45deg); }
.intro-close::after { transform: translate(-50%, -50%) rotate(-45deg); }

/* Hover: background changes, X + border revert to your “panel transparency” tone */
.intro-close:hover{
  background: rgba(255, 255, 255, 0.10);  /* subtle hover fill */
  color: rgba(0, 0, 0, 0.25);              /* keep X/border same tone */
  border-color: currentColor;
}

/* Montserrat for map UI panels */
.intro-modal,
.map-control-panel,
.country-sidebar {
  font-family: "Montserrat", system-ui, -apple-system, BlinkMacSystemFont,
               "Segoe UI", Roboto, Arial, sans-serif;
  font-weight: 400;
}