.b-map {
    display: flex;
    flex-direction: column;
    width: 100%;
    position: relative;
    background-color: var(--color-white);
    padding-top: calc(16/16*1rem);
    min-height: calc(100svh - (var(--height--header, 0rem) + var(--wp-admin--admin-bar--height, 0rem)));
}

[data-hidden-by-default] {
    display: none !important;
}

/* Initial state before JS sets data-current-view: mobile defaults to list */
.b-map:not([data-current-view]) .b-map__list[data-hidden-by-default] {
    display: flex !important;
}

/* Mobile: toggle between map and list views */
.b-map[data-current-view="map"] .b-map__content {
    display: flex;
}

.b-map[data-current-view="map"] .b-map__list {
    display: none;
}

.b-map[data-current-view="list"] .b-map__content {
    display: none;
}

.b-map[data-current-view="list"] .b-map__list {
    display: flex;
}

.b-map .c-search-box {
    position: relative;
    margin-bottom: calc(12/16*1rem);
}

.b-map__content {
    position: relative;
    flex: 1;
    display: flex;
}

.b-map__container {
    flex: 1;
    min-height: 50vh;
}

.b-map__map-count {
    position: absolute;
    top: calc(20/16*1rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    padding: calc(8/16*1rem) calc(6/16*1rem);
    background-color: var(--color-white);
    border-radius: calc(4/16*1rem);
    box-shadow:
        0 calc(4/16*1rem) calc(4/16*1rem) calc(-1/16*1rem) rgba(12, 12, 13, 0.05),
        0 calc(16/16*1rem) calc(32/16*1rem) calc(-1/16*1rem) rgba(12, 12, 13, 0.10);
    font: var(--typo--transverse-small-body-02);
    font-weight: 700;
    color: var(--color-black);
    margin: 0;
    white-space: nowrap;
    pointer-events: none;

    &:empty {
        display: none;
    }
}

.b-map__list {
    width: 100%;
    /* overflow-y: auto; */
    padding: calc(16/16*1rem);
    display: flex;
    flex-direction: column;
    gap: calc(16/16*1rem);
    max-width: calc(857/16*1rem);
    margin-inline: auto;
    background-color: var(--color-grey--ultra-light);
}

.b-map__list-count {
    font: var(--typo--transverse-small-body-02);
    color: var(--color-black);
    margin: 0;
}

.b-map__toggle-wrapper {
    display: block;
    padding: 0 calc(16/16*1rem) calc(16/16*1rem);
}

.b-map__toggle-inner {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    border-radius: calc(7/16*1rem);
    overflow: hidden;
    padding: calc(10/16*1rem) 0;
}

.b-map__toggle-bg {
    position: absolute;
    inset: 0;
    background-image: var(--this-bg-image);
    background-size: cover;
    background-position: center;
    border-radius: inherit;

    &::after {
        content: '';
        position: absolute;
        inset: 0;
        background-color: rgba(38, 79, 54, 0.3);
        border-radius: inherit;
    }
}

.c-map-marker--cluster {
    position: relative;
    display: block;
    line-height: 0;
    cursor: pointer;
}

.c-map-cluster__count {
    position: absolute;
    /* Circle head centre: x≈49%, y≈36.5% of the pin bounding box */
    top: 36%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--color-white);
    font-weight: 700;
    font-size: calc(13/16*1rem);
    line-height: 1;
    pointer-events: none;
}

.b-map__search-area {
    position: absolute;
    bottom: calc(12/16*1rem);
    left: 50%;
    transform: translateX(-50%);
    z-index: 5;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: calc(8/16*1rem) calc(6/16*1rem);
    background-color: var(--color-white);
    border: none;
    border-radius: calc(6/16*1rem);
    box-shadow:
        0 calc(4/16*1rem) calc(4/16*1rem) calc(-1/16*1rem) rgba(12, 12, 13, 0.05),
        0 calc(16/16*1rem) calc(32/16*1rem) calc(-1/16*1rem) rgba(12, 12, 13, 0.10);
    font: var(--typo--transverse-small-body-02);
    font-weight: 700;
    color: var(--color-black);
    cursor: pointer;
    white-space: nowrap;

    &[hidden] {
        display: none;
    }
}


.b-map__bottom-card {
    position: absolute;
    bottom: calc(16/16*1rem);
    left: calc(16/16*1rem);
    right: calc(16/16*1rem);
    z-index: 10;

    &[hidden] {
        display: none;
    }

    c-card-map-cluster {
        border-radius: calc(8/16*1rem);
        box-shadow:
            0px 1px 2px rgba(0, 0, 0, 0.06),
            0px 2px 4px rgba(0, 0, 0, 0.06),
            0px 4px 8px rgba(0, 0, 0, 0.06),
            0px 8px 16px rgba(0, 0, 0, 0.06),
            0px 16px 32px rgba(0, 0, 0, 0.06);
    }

    .c-card-map-cluster__illustration {
        display: none;
    }
}

.b-map__bottom-card-close {
    position: absolute;
    top: calc(8/16*1rem);
    right: calc(8/16*1rem);
    z-index: 1;
    width: calc(20/16*1rem);
    height: calc(20/16*1rem);
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    color: var(--color-black);
}

.b-map__bottom-card-close svg {
    width: calc(16/16*1rem);
    height: calc(16/16*1rem);
}

@media all and (min-width: 75em) {
    /* Initial state before JS sets data-current-view: desktop defaults to map */
    .b-map:not([data-current-view]) .b-map__content[data-hidden-by-default] {
        display: block !important;
    }

    .b-map {
        background-color: var(--color-grey--ultra-light);
        padding-top: 0;
    }

    /* Desktop: always map mode — hide toggle and list */
    .b-map .c-view-toggle {
        display: none !important;
    }

    .b-map__content {
        display: block;
        height: 100%;
        padding-inline: 0;
    }

    .b-map__map-count {
        display: none;
    }

    .b-map__search-area {
        bottom: auto;
        top: calc(20/16*1rem);
        left: calc((100% + var(--sidebar-offset, 0px)) / 2);
        padding: calc(12/16*1rem) calc(16/16*1rem);
    }

    .b-map__list {
        display: none !important;
    }

    .b-map__toggle-wrapper {
        display: none;
    }

    .b-map__bottom-card {
        display: none !important;
    }

    .b-map .c-search-box {
        margin-bottom: 0;
    }

    .b-map[data-current-view="map"] .c-search-box {
        position: absolute;
        top: calc(20/16*1rem);
        left: calc(20/16*1rem);
        bottom: calc(20/16*1rem);
        z-index: 10;
        width: calc(460/16*1rem);
        border-radius: calc(12/16*1rem);
        box-shadow:
            0 calc(46/16*1rem) calc(80/16*1rem) 0 rgba(0, 0, 0, 0.07),
            0 calc(5.76/16*1rem) calc(10/16*1rem) 0 rgba(0, 0, 0, 0.14);
        overflow: hidden;
    }

    .b-map[data-current-view="list"] .c-search-box {
        margin-top: calc(32/16*1rem);
        margin-inline: auto;
    }
}
