/* List/map toggle */
.view-on-map-btn {
    @media (width > 600px) {
        &::after {
            content: var(--_view-btn-text, "VIEW ON MAP");
            transition: content 300ms ease;
            text-transform: uppercase;
        }
    }

    .iconify {
        width: var(--_view-on-map-icon-size, 1.5rem);
        height: var(--_view-on-map-icon-size, 1.5rem);
    }

    path {
        stroke-width: 2.25;
    }

    &[data-view="list"] {
        .map-icon {
            display: block;
        }

        .list-icon {
            display: none;
        }
    }

    &[data-view="map"] {
        --_view-btn-text: "VIEW AS LIST";

        .map-icon {
            display: none;
        }

        .list-icon {
            display: block;
        }
    }

    .btn-text {
        display: var(--_btn-text-hidden);
    }

    @media (width <= 600px) {
        --_view-on-map-icon-size: 2rem;
        border-radius: 50%;
    }
}

/* Map */
#map {
    height: 878px;
    border-radius: 1.5rem;
    border: 1px solid var(--white-clr-800);
    animation: fadeIn 300ms ease;
    position: relative;

    @media (width <=600px) {
        padding: 0;
        height: 800px;
    }

    .map-error {
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        height: 100%;
        color: var(--text-clr);
        padding: 20px;
        text-align: center;
    }

    .map-error svg {
        color: var(--secondary-clr);
        margin-bottom: 16px;
        opacity: 0.7;
    }

    .map-error p {
        max-width: 400px;
        font-size: 0.9rem;
    }

    /* Google Maps InfoWindow Overrides */
    .gm-style .gm-style-iw-c {
        padding: 0 !important;
        border-radius: 0.5rem !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
        overflow: visible !important;

        @media (width <=600px) {
            min-width: min(330px, calc(100vw - 2rem)) !important;
            margin-inline: auto;
        }
    }

    .gm-style .gm-style-iw-d {
        overflow: hidden !important;
        padding: 0 !important;
    }

    .gm-style .gm-style-iw-t::after {
        background: var(--white-clr) !important;
    }

    .gm-style-iw-tc {
        filter: drop-shadow(0 -2px 2px rgba(0, 0, 0, 0.1)) !important;
    }

    .gm-ui-hover-effect {
        top: 0 !important;
        right: 0 !important;
        opacity: 0.7 !important;
        transition: opacity 180ms ease !important;
    }

    .gm-ui-hover-effect:hover {
        opacity: 1 !important;
    }

    /* Cluster Marker Styles */
    .cluster-marker {
        cursor: pointer;
        animation: clusterAppear 0.3s ease-out;
    }

    .cluster-content {
        position: relative;
        width: 40px;
        height: 40px;
        border-radius: 50%;
        background-color: var(--secondary-clr);
        display: flex;
        align-items: center;
        justify-content: center;
        border: 2px solid var(--white-clr);
        transition: transform 0.2s ease;

        &::after {
            content: "";
            width: 40px;
            height: 40px;
            position: absolute;
            margin: auto;
            z-index: -1;
            background-color: hsl(from var(--secondary-clr) h s l / 0.5);
            border-radius: 50%;

            box-shadow: 0 0 0 4px rgba(169, 4, 102, 0.3);
            animation: pulse 4s infinite reverse ease-in;
        }
    }

    .cluster-marker:hover .cluster-content {
        transform: scale(1.1);
    }

    .cluster-count {
        color: var(--white-clr);
        font-weight: 600;
        font-size: 0.9rem;
    }
}

.info-window-content {
    max-width: 350px;
    padding: 0;
    margin: 0;
}

.gm-style-iw-chr {
    display: none;
}

/* Counsellor branch info window */
.counsellor-branch-info {
    width: min(20rem, calc(100vw - 4rem));
    padding: 1rem;
    display: grid;
    gap: 0.75rem;

    .counsellor-branch-header {
        display: grid;
        gap: 0.25rem;

        h2 {
            margin: 0;
            font-size: var(--fs-500);
            font-weight: var(--fw-700);
            color: var(--tertiary-clr-900);
        }
    }

    .counsellor-branch-address,
    .counsellor-branch-count {
        margin: 0;
        font-size: var(--fs-300);
        color: var(--text-clr);
    }

    .counsellor-branch-list {
        list-style: none;
        margin: 0;
        padding: 0;
        max-height: 18rem;
        overflow-y: auto;
        display: grid;
        gap: 0.5rem;
    }

    .counsellor-branch-item {
        display: grid;
        grid-template-columns: 2.5rem 1fr;
        align-items: center;
        column-gap: 0.75rem;
        width: 100%;
        padding: 0.5rem;
        border: 1px solid var(--border-clr);
        border-radius: 0.5rem;
        background: none;
        font: inherit;
        text-align: start;
        cursor: pointer;
        color: inherit;
        transition: border-color 180ms ease, background-color 180ms ease;

        &:hover,
        &:focus-visible {
            border-color: var(--secondary-clr);
            background-color: var(--secondary-clr-5);
        }

        img {
            align-self: start;
            width: 2.5rem;
            height: 2.5rem;
            border-radius: 50%;
            object-fit: cover;
        }
    }

    .counsellor-branch-text {
        display: grid;
        gap: 0.125rem;
        min-width: 0;
    }

    .counsellor-branch-name {
        font-weight: var(--fw-700);
        font-size: var(--fs-400);
    }

    .counsellor-branch-qualification {
        font-weight: var(--fw-500);
        font-size: var(--fs-300);
    }

    .counsellor-branch-meta {
        font-size: var(--fs-300);
        color: var(--text-clr);
    }
}
