/* EnterHome: usable full-map controls, centered phone preview, and full-screen chat. */

/* The map controller marks the split pane; the actual shared page shell uses body.eh9. */
@media (min-width: 801px) {
  body.eh9:has(#eh9-map) .eh9-discovery:has(.eh9-split.is-map-only) > .eh9-searchbar {
    position: fixed !important;
    top: var(--eh-map-header-bottom, 76px) !important;
    left: 0 !important;
    right: 0 !important;
    z-index: 1900 !important;
    display: block !important;
    width: 100% !important;
    max-height: calc(100dvh - var(--eh-map-header-bottom, 76px) - 8px) !important;
    box-sizing: border-box !important;
    overflow: visible !important;
    padding: 8px 18px 0 !important;
    background: rgb(255 255 255 / 98%) !important;
    border-bottom: 1px solid #e3d9dc !important;
    box-shadow: 0 3px 12px rgb(48 32 39 / 12%) !important;
    backdrop-filter: blur(8px);
  }

  body.eh9:has(#eh9-map) .eh9-discovery:has(.eh9-split.is-map-only) .eh9-filter-row {
    display: flex !important;
    visibility: visible !important;
    opacity: 1 !important;
  }

  body.eh9:has(#eh9-map) .eh9-split.is-map-only .eh9-restore-results {
    position: fixed !important;
    top: calc(var(--eh-map-header-bottom, 76px) + var(--eh-map-full-controls-height, 112px) + 9px) !important;
    right: 18px !important;
    z-index: 1910 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-width: 76px !important;
    min-height: 42px !important;
    padding: 8px 14px !important;
    border: 1px solid #a81031 !important;
    border-radius: 8px !important;
    background: #a81031 !important;
    color: #fff !important;
    font-size: 14px !important;
    font-weight: 700 !important;
    box-shadow: 0 2px 8px rgb(48 32 39 / 18%) !important;
  }

  /* One map/list switch: the dock button is the visible control in full-map mode. */
  body.eh9:has(#eh9-map) .eh9-split.is-map-only #eh9-mobile-view { display: none !important; }
}

/* MapLibre normally anchors previews to the pin. On phones, portal that same card into
   a predictable bottom sheet so taps never recenter the map or clip the card at an edge. */
@media (max-width: 800px) {
  body.eh9:has(#eh9-map) .maplibregl-popup.eh-mobile-pin-preview {
    position: fixed !important;
    inset: auto 12px calc(10px + env(safe-area-inset-bottom)) 12px !important;
    z-index: 1300 !important;
    display: block !important;
    width: auto !important;
    max-width: 560px !important;
    margin: 0 auto !important;
    opacity: 1 !important;
    transform: none !important;
    transition: none !important;
    animation: none !important;
    pointer-events: auto !important;
  }

  body.eh9:has(#eh9-map) .maplibregl-popup.eh-mobile-pin-preview .maplibregl-popup-tip { display: none !important; }
  body.eh9:has(#eh9-map) .maplibregl-popup.eh-mobile-pin-preview .maplibregl-popup-content {
    box-sizing: border-box !important;
    width: 100% !important;
    max-width: 100% !important;
    max-height: min(48dvh, 430px) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    padding: 0 !important;
    border: 1px solid #e4d8dc !important;
    border-radius: 16px !important;
    background: #fff !important;
    box-shadow: 0 12px 35px rgb(28 20 24 / 30%) !important;
  }

  body.eh9:has(#eh9-map) .maplibregl-popup.eh-mobile-pin-preview .maplibregl-popup-close-button {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    z-index: 4 !important;
    width: 38px !important;
    height: 38px !important;
    padding: 0 !important;
    border: 1px solid rgb(255 255 255 / 85%) !important;
    border-radius: 50% !important;
    background: rgb(48 32 39 / 78%) !important;
    color: #fff !important;
    font-size: 25px !important;
    line-height: 36px !important;
    text-align: center !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview {
    position: relative !important;
    display: grid !important;
    grid-template-columns: minmax(0, 1fr) !important;
    align-items: start !important;
    width: 100% !important;
    max-width: none !important;
    min-width: 0 !important;
    overflow: hidden !important;
    background: #fff !important;
    font-family: inherit !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview .eh91-pin-photo {
    display: block !important;
    width: 100% !important;
    height: clamp(112px, 20dvh, 178px) !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #f2eef0 !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview .eh91-pin-photo img {
    display: block !important;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview .eh93-preview-tools {
    position: absolute !important;
    top: 8px !important;
    left: 8px !important;
    z-index: 3 !important;
    margin: 0 !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview .eh93-preview-tools .eh92-save,
  body.eh9:has(#eh9-map) .eh9-preview .eh93-preview-tools button,
  body.eh9:has(#eh9-map) .eh9-preview .eh93-preview-tools a {
    min-height: 36px !important;
    padding: 6px 11px !important;
    border: 1px solid #e4d8dc !important;
    border-radius: 8px !important;
    background: #fff !important;
    color: #302027 !important;
    box-shadow: 0 2px 8px rgb(0 0 0 / 18%) !important;
  }

  body.eh9:has(#eh9-map) .eh9-preview-body { padding: 12px 15px 14px !important; }
  body.eh9:has(#eh9-map) .eh9-preview-body > strong { color: #302027 !important; font-size: 23px !important; line-height: 1.2 !important; }
  body.eh9:has(#eh9-map) .eh9-preview-body > small { color: #a81031 !important; font-size: 12px !important; font-weight: 700 !important; }
  body.eh9:has(#eh9-map) .eh9-preview-body > p { margin: 5px 0 !important; color: #48505a !important; font-size: 13px !important; line-height: 1.35 !important; }
  body.eh9:has(#eh9-map) .eh9-preview-body > p:first-of-type { color: #302027 !important; font-size: 15px !important; font-weight: 700 !important; }
  body.eh9:has(#eh9-map) .eh92-preview-actions { display: flex !important; flex-wrap: wrap !important; gap: 10px !important; margin-top: 10px !important; }
  body.eh9:has(#eh9-map) .eh92-preview-actions > * { min-height: 40px !important; display: inline-flex !important; align-items: center !important; }

  body.eh9:has(#eh9-map).eh-mobile-pin-preview-open #eh9-mobile-view,
  body.eh9:has(#eh9-map).eh-mobile-pin-preview-open .ehqc .ehqc-launch,
  body.eh9:has(#eh9-map).eh-mobile-pin-preview-open .ehqc .eh9-map-chat-launch {
    bottom: calc(min(48dvh, 430px) + 24px + env(safe-area-inset-bottom)) !important;
  }

  /* A phone chat is a full-screen conversation. Minimize and Close remain in its header. */
  body.eh9:has(#eh9-map) .ehqc-mobile-portal {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483000 !important;
    width: 0 !important;
    height: 0 !important;
    overflow: visible !important;
    transform: none !important;
    filter: none !important;
    perspective: none !important;
    contain: none !important;
    pointer-events: none !important;
  }

  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-panel:not([hidden]) {
    position: fixed !important;
    inset: 0 !important;
    z-index: 2147483001 !important;
    display: flex !important;
    flex-direction: column !important;
    box-sizing: border-box !important;
    width: 100vw !important;
    max-width: none !important;
    min-width: 0 !important;
    height: 100vh !important;
    height: 100dvh !important;
    max-height: none !important;
    min-height: 0 !important;
    margin: 0 !important;
    padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left) !important;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
    border: 0 !important;
    border-radius: 0 !important;
    background: #fff !important;
    box-shadow: none !important;
    pointer-events: auto !important;
  }

  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-panel[hidden] { display: none !important; }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-launch {
    position: fixed !important;
    right: max(14px, env(safe-area-inset-right)) !important;
    bottom: max(14px, env(safe-area-inset-bottom)) !important;
    left: auto !important;
    z-index: 1290 !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    box-sizing: border-box !important;
    width: 52px !important;
    min-width: 52px !important;
    max-width: 52px !important;
    height: 52px !important;
    min-height: 52px !important;
    max-height: 52px !important;
    padding: 0 !important;
    overflow: hidden !important;
    border: 1px solid #a81031 !important;
    border-radius: 50% !important;
    background: #a81031 !important;
    color: transparent !important;
    font-size: 0 !important;
    box-shadow: 0 3px 12px rgb(48 32 39 / 24%) !important;
    pointer-events: auto !important;
  }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-launch::before {
    content: "✉" !important;
    display: block !important;
    color: #fff !important;
    font-size: 22px !important;
    line-height: 1 !important;
  }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-launch > * { display: none !important; }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-panel > header {
    position: sticky !important;
    top: 0 !important;
    z-index: 5 !important;
    flex: 0 0 auto !important;
    min-height: 60px !important;
    margin: 0 !important;
    padding: 8px 12px !important;
    background: #fff !important;
    border-bottom: 1px solid #e4d8dc !important;
  }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-window-actions { display: flex !important; gap: 8px !important; align-items: center !important; }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-window-actions button,
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-close { min-width: 44px !important; min-height: 44px !important; }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehcl-transcript {
    flex: 1 1 auto !important;
    min-height: 180px !important;
    max-height: none !important;
    overflow-y: auto !important;
    overscroll-behavior: contain !important;
    -webkit-overflow-scrolling: touch !important;
  }
  body.eh9:has(#eh9-map) .ehqc-mobile-portal .ehqc-form { flex: 0 0 auto !important; width: 100% !important; }
}
