/* assets/css/search-map-view.css — Ticket #7
 * Map-open layout for the search-results page, aligned to the reference demo.
 * Authored LTR. Loaded only on the search page. Normal (closed) view untouched.
 */

/* Map placeholder hidden until the user opens the map. */
.search-res-n-map:not(.map-opened) .the-map { display: none; }

/* Results column: full width when the map is closed; smooth width change on open/close. */
.search-res-n-map #the-search-res {
  transition: 0.2s all;
  width: 100%;
}

/* --- Map OPEN: two columns — results (left) + map (right) --- */
.search-res-n-map.map-opened {
  display: grid;
  grid-template-columns: minmax(340px, 42%) minmax(0, 58%);
  gap: 16px;
  align-items: start;
}
.search-res-n-map.map-opened #the-search-res {
  order: 1;
  overflow: auto;
  max-height: calc(100vh - 130px);
}
.search-res-n-map.map-opened .the-map {
  order: 2;
  position: sticky;
  top: 12px;
  height: calc(100vh - 130px);
  min-height: 520px;
  background: none !important;   /* drop the Canada placeholder image */
}
.search-res-n-map.map-opened #spa-map { width: 100%; height: 100%; position: relative; }

/* --- Card-on-map: clicking a marker shows the spa's card pinned to the map bottom --- */
.map-card-slot {
  position: absolute; left: 12px; right: 12px; bottom: 12px; z-index: 6;
  display: none; pointer-events: none;
}
.map-card-slot.is-shown { display: block; }
.map-card-slot .spa-box {
  pointer-events: auto; position: relative;
  max-width: 420px; margin: 0 auto;
  background: #fff; border-radius: 14px; box-shadow: 0 8px 30px rgba(0,0,0,.22);
  overflow: hidden;
}
/* Compact the cloned card so it doesn't swallow the map. */
.map-card-slot .spa-box .img { height: 130px !important; }
.map-card-slot .spa-box-content .desc { display: none; }
.map-card-slot .spa-box .slider { height: 130px; }
.map-card-slot .spa-box .slider img { width: 100%; height: 130px; object-fit: cover; }
.map-card-close {
  pointer-events: auto; position: absolute; top: 6px; right: 6px; z-index: 3;
  width: 28px; height: 28px; border: 0; border-radius: 50%;
  background: rgba(0,0,0,.55); color: #fff; font-size: 18px; line-height: 26px;
  text-align: center; cursor: pointer; padding: 0;
}

/* One card per row inside the narrow results column. */
.search-res-n-map.map-opened .promoted { grid-template-columns: 1fr !important; }

/* Cards horizontal: image + content side by side (spas AND packages — both .spa-box).
 * inline-flex activates the row layout for package boxes (which render as block). */
.search-res-n-map.map-opened .spa-box {
  display: inline-flex !important;
  flex-direction: row;
  align-items: stretch;
}
.search-res-n-map.map-opened .spa-box .img {
  flex: 0 0 42%;
  max-width: 160px;
  height: 160px;
  padding: 0 !important;
}
.search-res-n-map.map-opened .spa-box .spa-box-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
}
/* Hide the long description in the compact map-mode card. */
.search-res-n-map.map-opened .spa-box-content .desc { display: none; }
/* "X matching packages" (.count_packs) sits BELOW the price (.s-from). */
.search-res-n-map.map-opened .spa-box .count_packs { order: 99; margin-top: 6px; }

/* Toggle: show ONLY the selected section (spas OR packages). */
.search-res-n-map .block-res.is-hidden { display: none; }

/* Desktop fix: results column fills its grid cell. */
@media (min-width: 993px) {
  .search-res-n-map.map-opened #the-search-res { width: 100%; }
}

/* Tablet (601–992): stack — map on top, results below. */
@media (min-width: 601px) and (max-width: 992px) {
  .search-res-n-map.map-opened { grid-template-columns: 1fr; }
  .search-res-n-map.map-opened .the-map {
    order: 1; position: relative; top: 0; height: 60vh; min-height: 320px;
  }
  .search-res-n-map.map-opened #the-search-res { order: 2; max-height: none; }
}

/* Phone (≤600): map is a full-screen overlay toggled by a floating button;
   the results list stays in its normal vertical layout underneath. */
@media (max-width: 600px) {
  /* Floating "map" button over the results (sticky bottom). */
  #open-spa-map {
    position: fixed !important; left: 50%; transform: translateX(-50%);
    bottom: 16px; z-index: 1100; margin: 0;
    background: #fff; color: #1f2733; border: 1px solid #ccc;
    box-shadow: 0 6px 20px rgba(0,0,0,.28); border-radius: 999px;
    height: auto; padding: 12px 22px; white-space: nowrap;
  }
  /* Full-screen map when opened. */
  .search-res-n-map.map-opened .the-map {
    position: fixed !important; inset: 0 !important; top: 0 !important;
    width: 100vw !important; height: 100vh !important; max-height: none !important;
    margin: 0 !important; border-radius: 0 !important; z-index: 1000;
  }
  .search-res-n-map.map-opened #spa-map { width: 100% !important; height: 100% !important; }
  /* Undo the desktop horizontal (map-mode) card — keep normal vertical cards on phone. */
  .search-res-n-map.map-opened .spa-box { display: block !important; }
  .search-res-n-map.map-opened .spa-box .img {
    flex: none !important; max-width: none !important; height: auto !important; padding: 0 !important;
  }
  .search-res-n-map.map-opened .spa-box-content .desc { display: block; }
  .search-res-n-map.map-opened .spa-box .count_packs { order: 0; }
  /* Lift the map card above the floating button. */
  .map-card-slot { bottom: 84px; }
  /* The card-on-map stays horizontal (image + content side by side), even though
     the list cards above revert to vertical on phone. */
  .search-res-n-map.map-opened .map-card-slot .spa-box {
    display: inline-flex !important; flex-direction: row; align-items: stretch;
  }
  .search-res-n-map.map-opened .map-card-slot .spa-box .img {
    flex: 0 0 42% !important; max-width: 160px !important; height: 130px !important; padding: 0 !important;
  }
  .search-res-n-map.map-opened .map-card-slot .spa-box-content .desc { display: none; }
}
