/* TipPL map shell — aligned with HouseSwapp (list + filters + hm pins) */

.map-shell {
    height: calc(100dvh - var(--header-h));
    display: grid;
    grid-template-columns: 1fr;
    grid-template-areas: 'map';
    overflow: hidden;
    position: relative;
}

.map-panel-list { grid-area: list; }
.map-panel-filters { grid-area: filters; }
.map-canvas-wrap { grid-area: map; }

.map-canvas-wrap {
    position: relative;
    z-index: 1;
    min-width: 0;
    min-height: calc(100dvh - var(--header-h));
    width: 100%;
    background: var(--bg);
}

#tippl-map-canvas,
.map-canvas {
    width: 100%;
    height: 100%;
    min-height: calc(100dvh - var(--header-h));
}

.map-backdrop[hidden] {
    display: none !important;
    pointer-events: none;
}

@media (max-width: 899px) {
    .map-backdrop { display: none !important; pointer-events: none !important; }

    .map-panel-list:not(.is-open),
    .map-panel-filters:not(.is-open) {
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .map-panel-list.is-open ~ .map-mobile-bar,
    .map-panel-filters.is-open ~ .map-mobile-bar {
        visibility: hidden;
        pointer-events: none;
    }

    .map-panel-list.is-open,
    .map-panel-filters.is-open {
        z-index: 1115;
    }
}

.map-panel-list,
.map-panel-filters {
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top));
    bottom: 0;
    width: min(100%, 100vw);
    max-width: 100%;
    height: calc(100dvh - var(--header-h) - var(--safe-top));
    transition: transform 0.28s ease, visibility 0.28s ease;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.22);
    z-index: 1095;
    pointer-events: none;
    visibility: hidden;
}

.map-panel-list {
    left: 0;
    transform: translate3d(-105%, 0, 0);
}

.map-panel-filters {
    right: 0;
    left: auto;
    transform: translate3d(105%, 0, 0);
}

.map-panel-list.is-open,
.map-panel-filters.is-open {
    transform: translate3d(0, 0, 0);
    pointer-events: auto;
    visibility: visible;
    opacity: 1;
}

.map-panel {
    display: flex;
    flex-direction: column;
    height: 100%;
    min-height: 0;
    overflow: hidden;
    background: var(--surface);
    z-index: 11;
}

.map-panel-list { border-right: 1px solid var(--line); }
.map-panel-filters { border-left: 1px solid var(--line); background: var(--surface-soft); }

.map-panel-head {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.85rem 0.9rem;
    border-bottom: 1px solid var(--line);
    background: var(--surface);
}

@media (max-width: 899px) {
    .map-panel-head {
        padding-top: 1rem;
        padding-bottom: 1rem;
    }
}

.map-panel-head-main h2 {
    margin: 0;
    font-size: 0.95rem;
    font-weight: 900;
    line-height: 1.2;
}

.map-toolbar-count {
    display: block;
    font-size: 0.72rem;
    color: var(--muted);
    font-weight: 700;
    margin-top: 0.2rem;
}

.map-panel-head-actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex-shrink: 0;
}

.map-panel-close {
    display: none;
    align-items: center;
    justify-content: center;
    gap: 0.35rem;
    min-height: var(--touch-min);
    padding: 0 0.75rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface-soft);
    color: var(--text);
    font-size: 0.8rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
}

.map-panel-close-label {
    line-height: 1.1;
}

@media (max-width: 899px) {
    .map-panel-close { display: inline-flex; }
    .map-panel-close-label { display: none; }
}

.map-panel-collapse {
    display: none;
    flex-shrink: 0;
    width: 2rem;
    height: 2rem;
    padding: 0;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: var(--surface-soft);
    color: var(--muted);
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1;
    cursor: pointer;
    font-family: inherit;
    align-items: center;
    justify-content: center;
}

.map-panel-collapse:hover,
.map-panel-close:hover {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.map-panel-body,
.map-panel-filters-body {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    position: relative;
}

.map-panel-filters-body {
    padding: 0.75rem 0.85rem 1rem;
}

.map-results-meta {
    flex-shrink: 0;
    margin: 0;
    padding: 0.5rem 1rem 0.35rem;
    font-size: 0.78rem;
    color: var(--muted);
    font-weight: 700;
    border-bottom: 1px solid var(--line-soft, var(--line));
    background: var(--surface);
}

.map-sidebar-list {
    flex: 1 1 auto;
    min-height: 0;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 0.5rem 0.65rem 0.65rem;
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.map-mobile-bar {
    display: flex;
    position: fixed;
    top: calc(var(--header-h) + var(--safe-top) + 0.5rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 1110;
    gap: 0.45rem;
    align-items: center;
    width: calc(100% - 1rem);
    max-width: 24rem;
    justify-content: center;
    pointer-events: auto;
}

.map-mobile-toggle {
    display: inline-flex;
    gap: 0.5rem;
    align-items: center;
    box-shadow: var(--shadow-sm);
}

.map-mobile-toggle.primary {
    box-shadow: 0 12px 32px color-mix(in srgb, var(--brand) 35%, transparent);
}

.map-mobile-discover {
    text-decoration: none;
    white-space: nowrap;
}

.map-mobile-count {
    background: rgba(255, 255, 255, 0.25);
    padding: 0.1rem 0.45rem;
    border-radius: 999px;
    font-size: 0.75rem;
}

.map-edge-toggle {
    display: none;
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    z-index: 15;
    align-items: center;
    gap: 0.35rem;
    padding: 0.5rem 0.65rem;
    min-height: var(--touch-min);
    border: 1px solid var(--line);
    background: var(--surface);
    color: var(--text);
    font-size: 0.78rem;
    font-weight: 800;
    font-family: inherit;
    cursor: pointer;
    box-shadow: var(--shadow-sm);
}

.map-edge-toggle--list { left: 0; border-left: 0; border-radius: 0 12px 12px 0; }
.map-edge-toggle--filters { right: 0; border-right: 0; border-radius: 12px 0 0 12px; }

.map-locate-fab {
    position: absolute;
    bottom: 1rem;
    right: 0.75rem;
    top: auto;
    z-index: 16;
    width: 42px;
    height: 42px;
    padding: 0;
    display: grid;
    place-items: center;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    background: var(--surface);
    border: 1px solid var(--line);
    cursor: pointer;
    color: var(--text);
}

.map-view-toggle {
    position: absolute;
    bottom: 3.85rem;
    right: 0.75rem;
    z-index: 16;
    min-width: 42px;
    height: 36px;
    padding: 0 0.7rem;
    border-radius: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    cursor: pointer;
    font-family: inherit;
    line-height: 1;
}

.map-view-toggle.is-3d {
    background: var(--brand-soft);
    color: var(--brand);
    border-color: rgba(124, 58, 237, 0.15);
}

.map-view-toggle:focus-visible {
    outline: 2px solid var(--brand);
    outline-offset: 1px;
}

.map-view-toggle__label {
    display: block;
}

.map-search-wrap { position: relative; margin-bottom: 0.75rem; }

.map-search-icon {
    position: absolute;
    left: 0.85rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    pointer-events: none;
}

.map-search-wrap input {
    width: 100%;
    padding: 0.65rem 0.85rem 0.65rem 2.5rem;
    border: 1px solid var(--line);
    border-radius: 999px;
    background: var(--surface);
    color: var(--text);
    font: inherit;
    font-size: 0.875rem;
}

.map-filter-group {
    margin-bottom: 0.45rem;
    border: 1px solid var(--line);
    border-radius: 12px;
    background: var(--surface);
    overflow: hidden;
}

.map-filter-group summary {
    padding: 0.5rem 0.65rem;
    font-size: 0.72rem;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
    cursor: pointer;
    list-style: none;
}

.map-filter-group summary::-webkit-details-marker { display: none; }

.map-chip-scroll {
    display: flex;
    flex-wrap: nowrap;
    gap: 0.35rem;
    overflow-x: auto;
    padding: 0 0.5rem 0.55rem;
    scrollbar-width: thin;
}

.map-chip-wrap { flex-wrap: wrap; overflow-x: visible; }

.map-chip {
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--text);
    border-radius: 999px;
    padding: 0.35rem 0.75rem;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    font-family: inherit;
}

.map-chip.is-active {
    background: var(--gradient);
    color: #fff;
    border-color: transparent;
}

.map-section-label {
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    color: var(--muted);
    margin-bottom: 0.4rem;
    display: block;
}

.map-sort-row { margin-top: 0.75rem; }

.map-sort-tabs { display: flex; flex-wrap: wrap; gap: 0.35rem; }

.map-sort {
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: 999px;
    padding: 0.4rem 0.7rem;
    font-size: 0.72rem;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    color: var(--text);
}

.map-sort.is-active {
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
    color: var(--brand);
}

.map-home-card {
    display: grid;
    grid-template-columns: 4.75rem 1fr auto;
    gap: 0.65rem;
    align-items: start;
    padding: 0.65rem;
    border-radius: var(--radius);
    border: 1px solid var(--line);
    background: var(--surface);
    transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
    cursor: pointer;
}

.map-home-card:hover,
.map-home-card.is-selected {
    border-color: color-mix(in srgb, var(--brand) 40%, var(--line));
    box-shadow: var(--shadow-sm);
}

.map-home-card.is-selected {
    border-color: var(--brand-mid);
    box-shadow: 0 8px 24px color-mix(in srgb, var(--brand) 12%, transparent);
}

.map-home-thumb {
    width: 4.75rem;
    height: 4.75rem;
    border-radius: 12px;
    overflow: hidden;
    background: var(--brand-soft);
    flex-shrink: 0;
}

.map-home-thumb img { width: 100%; height: 100%; object-fit: cover; }

.map-home-body { min-width: 0; }

.map-home-top {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.35rem;
}

.map-home-top h3 {
    margin: 0 0 0.2rem;
    font-size: 0.875rem;
    font-weight: 700;
    line-height: 1.3;
}

.map-home-meta,
.map-home-body .meta {
    margin: 0.15rem 0 0;
    font-size: 0.75rem;
    color: var(--muted);
}

.map-home-open {
    align-self: center;
    width: 2rem;
    height: 2rem;
    display: grid;
    place-items: center;
    border-radius: 999px;
    border: 1px solid var(--line);
    background: var(--surface-soft);
    color: var(--brand);
    font-weight: 800;
    text-decoration: none;
    flex-shrink: 0;
}

.map-home-open:hover {
    background: var(--brand-soft);
    border-color: color-mix(in srgb, var(--brand) 35%, var(--line));
}

.map-empty.hidden { display: none; }

/* HouseSwapp map pins */
.hm-wrap {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    user-select: none;
    border: 0;
    padding: 0;
    margin: 0;
    background: transparent;
    font: inherit;
}

.hm-ring {
    position: relative;
    width: 48px;
    height: 48px;
    display: grid;
    place-items: center;
    background: #fff;
    border-radius: 50%;
    border: 3px solid #fff;
    box-shadow: 0 6px 18px rgba(15, 23, 42, 0.22);
}

.hm-stack {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 1.15rem;
    height: 1.15rem;
    padding: 0 0.25rem;
    border-radius: 999px;
    background: var(--brand);
    color: #fff;
    font-size: 0.62rem;
    font-weight: 800;
    line-height: 1.15rem;
    text-align: center;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.25);
    z-index: 2;
}

.hm-ring.live::before {
    content: '';
    position: absolute;
    inset: -5px;
    border-radius: 50%;
    border: 2px solid var(--good);
    animation: hm-pulse 2.2s ease-out infinite;
}

.hm-icon { font-size: 1.35rem; line-height: 1; }

.hm-badge {
    margin-top: 4px;
    background: var(--gradient);
    color: #fff !important;
    font-size: 10px;
    font-weight: 800;
    line-height: 1.3;
    padding: 3px 9px;
    border-radius: 20px;
    border: 1.5px solid #fff;
    white-space: nowrap;
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.35);
}

.mapboxgl-marker .hm-wrap,
.mapboxgl-marker .hm-badge { opacity: 1 !important; pointer-events: none; }
.mapboxgl-marker .hm-wrap { pointer-events: auto; }

@keyframes hm-pulse {
    0% { transform: scale(1); opacity: 0.9; }
    70% { transform: scale(1.35); opacity: 0; }
    100% { transform: scale(1.35); opacity: 0; }
}

.mapboxgl-popup-content {
    border-radius: 14px;
    padding: 0;
    overflow: hidden;
    color: var(--text);
    box-shadow: 0 20px 50px rgba(15, 23, 42, 0.2);
}

.map-popup-img {
    display: block;
    width: 100%;
    height: 140px;
    min-height: 140px;
    object-fit: cover;
}

.map-popup-img--empty {
    background: linear-gradient(135deg, var(--brand-soft), color-mix(in srgb, var(--brand-2) 15%, white));
}

.map-detail-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 6;
    max-height: min(68%, 380px);
    overflow-x: hidden;
    overflow-y: auto;
    border-top: 1px solid var(--line);
    background: var(--surface);
    box-shadow: 0 -16px 40px rgba(15, 23, 42, 0.16);
}

.map-detail-panel[hidden] {
    display: none !important;
}

.map-detail-close {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    z-index: 2;
    width: 32px;
    height: 32px;
    border: 0;
    border-radius: 10px;
    background: rgba(15, 23, 42, 0.55);
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    line-height: 1;
}

.map-detail-hero {
    width: 100%;
    aspect-ratio: 16 / 10;
    max-height: 180px;
    overflow: hidden;
    background: var(--brand-soft);
}

.map-detail-hero img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.map-detail-content {
    padding: 0.75rem 0.85rem 0.85rem;
}

.map-detail-content h3 {
    margin: 0.35rem 0 0.2rem;
    font-size: 0.95rem;
    line-height: 1.25;
}

.map-detail-content .button.block {
    width: 100%;
    margin-top: 0.65rem;
    text-align: center;
}

.map-panel-body.is-detail-open .map-sidebar-list {
    padding-bottom: 0.35rem;
}

.map-popup-body { padding: 0.75rem 0.9rem; }
.map-popup-body strong { display: block; font-size: 0.95rem; }
.map-popup-body p { margin: 0.25rem 0 0; font-size: 0.8rem; color: var(--muted); }

.map-popup-cta {
    display: inline-block;
    margin-top: 0.55rem;
    font-size: 0.78rem;
    font-weight: 800;
    color: var(--brand);
}

.mapboxgl-ctrl-group {
    border-radius: 1rem !important;
    overflow: hidden;
    box-shadow: 0 18px 40px rgba(15, 23, 42, 0.18) !important;
}

.thin-scroll::-webkit-scrollbar { width: 4px; }
.thin-scroll::-webkit-scrollbar-thumb { background: var(--line); border-radius: 4px; }

@media (min-width: 900px) {
    .map-shell {
        --map-list-col: minmax(280px, 320px);
        --map-filters-col: minmax(260px, 290px);
        grid-template-columns: var(--map-list-col) minmax(0, 1fr) var(--map-filters-col);
        grid-template-areas: 'list map filters';
        transition: grid-template-columns 0.28s ease;
    }

    .map-shell.is-filters-collapsed:not(.is-list-collapsed) {
        grid-template-columns: var(--map-list-col) minmax(0, 1fr);
        grid-template-areas: 'list map';
    }

    .map-shell.is-list-collapsed:not(.is-filters-collapsed) {
        grid-template-columns: minmax(0, 1fr) var(--map-filters-col);
        grid-template-areas: 'map filters';
    }

    .map-shell.is-list-collapsed.is-filters-collapsed {
        grid-template-columns: minmax(0, 1fr);
        grid-template-areas: 'map';
    }

    .map-mobile-bar { display: none; }

    .map-panel-list,
    .map-panel-filters {
        position: relative;
        top: auto;
        bottom: auto;
        left: auto;
        right: auto;
        width: auto;
        height: 100%;
        transform: none;
        box-shadow: none;
        pointer-events: auto;
        visibility: visible;
    }

    .map-panel-list.is-collapsed,
    .map-panel-filters.is-collapsed {
        display: none !important;
    }

    .map-panel-collapse,
    .map-edge-toggle:not([hidden]) { display: inline-flex; }

    .map-panel-close { display: none !important; }

    .map-canvas-wrap { min-height: 100%; }
}
