/**
 * Reliance Map — scoped to `.reliance-map-wrap`.
 */

.reliance-map-wrap {
    --map-color-orange: #f05c3b;
    --map-color-orange-hover: #d04a2f;
    --map-color-text: #2C2B2B;
    --map-color-text-muted: #a7a7a7;
    --map-color-link: #4285f4;
    --map-color-white: #fff;
    --map-color-charcoal: #353434;
    --map-color-silver: #f0f0f0;
    --map-panel-bg: rgb(53 52 52 / 80%);
    --map-panel-border: rgb(255 255 255 / 50%);
    --map-font: 'Roboto', 'Roboto Condensed', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --map-font-condensed: 'Roboto Condensed', 'Roboto', sans-serif;
    --map-shadow-panel: 0 10px 8px rgb(0 0 0 / 18%);
    --map-shadow-btn: 0 5px 20px rgb(0 0 0 / 30%);
    --reliance-map-block-size: 48rem;

    box-sizing: border-box;
    min-height: var(--reliance-map-block-size);
    position: relative;
    width: 100%;

    /*
     * Stacked: min-height ensures room; content can grow (page scroll).
     * Desktop: fixed height so the map layer fills behind positioned controls.
     */
    @media (width >= 1024px) {
        height: var(--reliance-map-block-size);
        min-height: var(--reliance-map-block-size);
    }

    &.reliance-map-wrap--missing-key {
        align-items: center;
        border: 1px dashed #ccc;
        background: #f5f5f5;
        display: flex;
        justify-content: center;

        .reliance-map-wrap__missing-key-msg {
            color: #666;
            margin: 0;
            text-align: center;
        }
    }

    *,
    *::before,
    *::after {
        box-sizing: border-box;
    }

    .map-container {
        display: flex;
        flex-direction: column;
        gap: 0.75rem;
        position: relative;
        width: 100%;
        background-color: #0a3a62;

        @media (width >= 1024px) {
            display: block;
            gap: 0;
            height: 100%;
            min-height: 0;
        }
    }

    .reliance-map-canvas {
        height: max(20rem, 45vh);
        overflow: hidden;
        position: relative;
        width: 100%;

        @media (width >= 1024px) {
            height: 100%;
            inset: 0;
            min-height: 0;
            overflow: visible;
            position: absolute;
        }
    }

    .map-controls {
        font-family: var(--map-font);
        max-width: 100%;
        padding-inline: 0.5rem;
        padding-bottom: 0.5rem;
        position: relative;
        transform: none;
        width: 100%;
        z-index: 10;

        @media (width >= 1024px) {
            flex: none;
            left: 5%;
            max-width: none;
            padding: 0;
            position: absolute;
            right: auto;
            top: 50%;
            transform: translateY(-50%);
            width: 25.5rem;
        }

        .map-controls-panel {
            background: var(--map-panel-bg);
            backdrop-filter: blur(1.25rem);
            border: 1px solid var(--map-panel-border);
            border-radius: 1.875rem;
            box-shadow: var(--map-shadow-panel);
            padding: 1.25rem 0.5rem;

            @media (width >= 1024px) {
                padding: 1.5rem;
            }

            &.is-results-mode {
                display: flex;
                flex-direction: column;
                max-height: 580px;
                /* max-height: min(36rem, calc(var(--reliance-map-block-size) - 2rem)); */
                padding: 1.5rem;

                @media (width >= 1024px) {
                    /* max-height: calc(var(--reliance-map-block-size) - 2rem); */
                    width: 25.5rem;
                }
            }
        }

        .map-controls-main {
            display: flex;
            flex-direction: column;
            gap: 1.5rem;

            @media (width >= 1024px) {
                gap: 2.5rem;
            }
        }

        .map-controls-section {
            display: flex;
            flex-direction: column;
            gap: 1rem;

            @media (width >= 1024px) {
                gap: 1.5rem;
            }

            &.map-controls-section-filters {
                gap: 1rem;

                @media (width >= 1024px) {
                    gap: 2rem;
                }
            }
        }

        .map-controls-heading,
        .map-controls-label {
            color: var(--map-color-white);
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1.125rem;
            font-weight: 700;
            line-height: 1.1;
            margin: 0;
            text-align: center;
            text-transform: none;

            @media (width >= 1024px) {
                font-size: 1.25rem;
            }
        }

        .map-controls-location-card {
            align-items: center;
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }

        .map-controls-btn {
            align-items: center;
            border: none;
            border-radius: 2.5rem;
            cursor: pointer;
            display: inline-flex;
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1rem;
            font-weight: 700;
            gap: 0.625rem;
            justify-content: center;
            line-height: 1.4;
            padding: 0.75rem 1rem;
            text-transform: uppercase;
            white-space: nowrap;

            .map-controls-btn-icon {
                display: inline-flex;
                flex-shrink: 0;
                height: 1.5rem;
                width: 1.5rem;

                svg {
                    height: 100%;
                    width: 100%;
                }
            }

            &.map-controls-btn-primary {
                background: var(--map-color-orange);
                border: 1px solid var(--map-color-orange);
                box-shadow: var(--map-shadow-btn);
                color: var(--map-color-white);
                font-size: 1.1875rem;
                height: 3.5625rem;
                transition: background-color 0.2s;
                width: 100%;

                &:hover {
                    background: var(--map-color-orange-hover);
                }
            }

            &.map-controls-btn-reset {
                background: var(--map-color-text);
                color: var(--map-color-white);
                font-size: 1rem;
                gap: 0.5rem;
                height: 2.5rem;
                padding: 0.75rem;
                width: 48%;

                @media (width >= 1024px) {
                    padding-inline: 1rem;
                }

                &:hover {
                    background: var(--map-color-orange-hover);
                }
            }
        }

        .map-controls-distance-wrap {
            align-items: center;
            border: 1px solid var(--map-color-white);
            border-radius: 6.25rem;
            display: flex;
            height: 3.375rem;
            padding: 0;

            &.is-open .map-controls-chevron {
                transform: rotate(180deg);
            }
        }

        .map-controls-distance-warning {
            background: rgb(240 92 59 / 15%);
            border: 1px solid rgb(240 92 59 / 60%);
            border-radius: 0.5rem;
            color: var(--map-color-white);
            font-family: var(--map-font);
            font-size: 0.875rem;
            line-height: 1.4;
            margin: 0;
            padding: 0.625rem 0.75rem;
            text-align: center;
        }

        .map-controls-distance-label,
        .map-controls-select-native {
            border: 0;
            clip: rect(0, 0, 0, 0);
            height: 1px;
            margin: -1px;
            overflow: hidden;
            padding: 0;
            position: absolute;
            width: 1px;
        }

        .map-controls-select-native {
            opacity: 0;
            pointer-events: none;
        }

        .map-controls-distance-field {
            align-items: stretch;
            display: flex;
            position: relative;
            width: 100%;
        }

        .map-controls-distance-trigger {
            align-items: center;
            background: transparent;
            border: none;
            border-radius: 6.25rem;
            color: var(--map-color-white);
            cursor: pointer;
            display: flex;
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1rem;
            font-weight: 700;
            gap: 0.625rem;
            height: 3.375rem;
            justify-content: space-between;
            line-height: 1;
            padding: 1rem 0.875rem 1rem 1.5rem;
            text-align: left;
            width: 100%;
        }

        .map-controls-distance-value {
            flex: 1 1 0;
            min-width: 0;
            text-align: center;
        }

        .map-controls-chevron {
            color: var(--map-color-white);
            flex-shrink: 0;
            height: 1.5rem;
            transition: transform 0.2s ease;
            width: 1.5rem;

            svg {
                height: 100%;
                width: 100%;
            }
        }

        .map-controls-distance-dropdown {
            background: var(--map-color-white);
            border-radius: 1.25rem;
            box-shadow: var(--map-shadow-panel);
            left: 0;
            max-height: 17.5rem;
            overflow: hidden;
            overflow-y: auto;
            position: absolute;
            right: 0;
            top: calc(100% + 0.25rem);
            z-index: 20;
        }

        .map-controls-distance-option {
            background: var(--map-color-white);
            border: none;
            border-bottom: 1px solid #e8e8e8;
            color: var(--map-color-text);
            cursor: pointer;
            display: block;
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1rem;
            font-weight: 700;
            line-height: 1;
            padding: 0.875rem 1.5rem;
            text-align: left;
            transition: background 0.15s ease;
            width: 100%;

            &:last-child {
                border-bottom: none;
            }

            &:hover,
            &:focus {
                background: #f5f5f5;
                outline: none;
            }

            &[aria-selected='true'] {
                background: rgb(240 92 59 / 12%);
                color: var(--map-color-text);
            }
        }

        .map-controls-divider {
            background: var(--map-panel-border);
            height: 1px;
            width: 100%;
        }

        .map-controls-filter-group {
            display: flex;
            flex-direction: column;
            gap: 0.75rem;
        }

        .map-controls-input {
            background: var(--map-color-white);
            border: none;
            border-radius: 6.25rem;
            box-shadow: inset 0 2px 1px rgb(0 0 0 / 25%);
            color: var(--map-color-text);
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1rem;
            height: 3.375rem;
            line-height: 1;
            padding: 1rem 1.5rem;
            text-align: center;
            width: 100%;

            &::placeholder {
                color: var(--map-color-text-muted);
            }

            &:focus {
                box-shadow:
                    inset 0 2px 1px rgb(0 0 0 / 25%),
                    0 0 0 2px var(--map-color-orange);
                outline: none;
            }
        }

        .map-controls-actions {
            align-items: center;
            display: flex;
            flex-wrap: wrap;
            gap: 0.75rem;
            justify-content: flex-start;
            margin-inline: auto;
            width: 100%;
        }

        .map-controls-results {
            align-items: center;
            background: var(--map-color-text);
            border: 1px solid var(--map-color-white);
            border-radius: 6.25rem;
            cursor: pointer;
            display: inline-flex;
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1rem;
            font-weight: 700;
            gap: 0.25rem;
            height: 2.5rem;
            justify-content: center;
            line-height: 1;
            padding: 0.75rem;
            width: 48%;
            transition: background-color 0.2s ease, border-color 0.2s ease;

            @media (width >= 1024px) {
                padding-inline: 1rem;
            }

            &:hover {
                background: var(--map-color-charcoal);
            }

            .map-controls-results-label {
                color: var(--map-color-white);
            }

            .map-controls-results-count {
                color: var(--map-color-white);
            }
        }


        .map-controls-results-view {
            display: flex;
            flex: 1 1 auto;
            flex-direction: column;
            gap: 1rem;
            min-height: 0;
            padding-top: 0.5rem;
            width: 100%;
        }

        .map-controls-results-header {
            align-items: center;
            display: flex;
            flex-shrink: 0;
            justify-content: space-between;
            width: 100%;
        }

        .map-controls-back-btn {
            align-items: center;
            background: transparent;
            border: none;
            color: var(--map-color-white);
            cursor: pointer;
            display: inline-flex;
            font-family: var(--map-font-condensed);
            font-stretch: 75%;
            font-size: 1.1875rem;
            font-weight: 700;
            gap: 0.5rem;
            line-height: 1.4;
            padding: 0;
            text-transform: uppercase;

            &:hover {
                opacity: 0.85;
            }
        }

        .map-controls-back-btn-icon {
            display: inline-flex;
            flex-shrink: 0;
            height: 1.5rem;
            transform: rotate(90deg);
            width: 1.5rem;

            svg {
                display: block;
                height: 100%;
                width: 100%;
            }
        }

        .map-controls-results-summary {
            color: var(--map-color-white);
            font-family: var(--map-font-condensed);
            font-size: 1rem;
            font-stretch: 75%;
            font-weight: 400;
            line-height: 1;
            margin: 0;
            text-align: center;
        }

        .map-controls-results-card {
            display: flex;
            filter: drop-shadow(0 4px 4px rgb(0 0 0 / 18%));
            flex: 1 1 auto;
            flex-direction: column;
            min-height: 0;
            width: 100%;
        }

        .map-controls-results-card-title {
            align-items: center;
            background: var(--map-color-charcoal);
            border-radius: 1.5625rem 1.5625rem 0 0;
            box-shadow: 0 4px 2.5px rgb(0 0 0 / 25%);
            display: flex;
            flex-shrink: 0;
            justify-content: center;
            padding: 0.5rem 1.5rem;
            width: 100%;

            p {
                color: var(--map-color-white);
                font-family: var(--map-font-condensed);
                font-size: 1.1875rem;
                font-stretch: 75%;
                font-weight: 700;
                line-height: 1.4;
                margin: 0;
                text-align: center;
                text-transform: uppercase;
            }
        }

        .map-controls-results-list-wrap {
            background: var(--map-color-white);
            border-radius: 0 0 1.5625rem 1.5625rem;
            display: flex;
            flex: 1 1 auto;
            min-height: 0;
            overflow: hidden;
            padding-inline: 1rem;
            width: 100%;
        }

        .map-controls-results-list {
            display: flex;
            flex: 1 1 auto;
            flex-direction: column;
            gap: 0.625rem;
            max-height: min(28rem, 55vh);
            min-height: 0;
            overflow-x: hidden;
            overflow-y: auto;
            padding-block: 1rem;
            scrollbar-color: var(--map-color-orange) var(--map-color-silver);
            scrollbar-width: thin;
            width: 100%;

            @media (width >= 1024px) {
                max-height: none;
            }

            &::-webkit-scrollbar {
                width: 3px;
            }

            &::-webkit-scrollbar-track {
                background: var(--map-color-silver);
                border-radius: 1.875rem;
            }

            &::-webkit-scrollbar-thumb {
                background: var(--map-color-orange);
                border-radius: 1.875rem;
            }
        }

        .map-controls-result-item {
            margin: 0;
        }

        .map-controls-result-item-btn {
            background: var(--map-color-silver);
            border: none;
            border-radius: 1.25rem;
            cursor: pointer;
            display: block;
            padding: 1rem;
            text-align: left;
            transition: background-color 0.15s ease;
            width: 100%;

            &:hover {
                background: #e8e8e8;
            }
        }

        .map-controls-result-name {
            color: var(--map-color-orange);
            font-family: var(--map-font-condensed);
            font-size: 1.25rem;
            font-stretch: 75%;
            font-weight: 700;
            line-height: 1.1;
            margin: 0;
            text-transform: uppercase;
            width: 100%;
        }

        .map-controls-result-divider {
            background: var(--map-color-charcoal);
            height: 1px;
            margin-block: 0.5rem;
            width: 100%;
        }

        .map-controls-result-data {
            display: flex;
            flex-direction: column;
            gap: 0.25rem;
            width: 100%;
        }

        .map-controls-result-company {
            color: var(--map-color-charcoal);
            font-family: var(--map-font);
            font-size: 1rem;
            line-height: 1.4;
            margin: 0;
        }

        .map-controls-result-row {
            align-items: center;
            color: var(--map-color-charcoal);
            display: flex;
            font-family: var(--map-font);
            font-size: 1rem;
            gap: 0.5rem;
            line-height: 1.4;

            &--address {
                align-items: flex-start;
            }

            &--directions {
                justify-content: space-between;
            }
        }

        .map-controls-result-directions {
            align-items: center;
            display: inline-flex;
            gap: 0.5rem;
        }

        .map-controls-result-icon {
            color: var(--map-color-charcoal);
            flex-shrink: 0;
            line-height: 0;

            svg {
                display: block;
            }
        }

        .map-controls-result-text {
            flex: 1 1 auto;
            min-width: 0;
        }

        .map-controls-result-row--address .map-controls-result-text span {
            display: block;
        }

        .map-controls-result-distance {
            color: var(--map-color-charcoal);
            flex-shrink: 0;
            font-family: var(--map-font);
            font-size: 1rem;
            line-height: 1.4;
            white-space: nowrap;
        }

        .map-controls-result-link {
            color: inherit;
            text-decoration: none;

            &:hover {
                text-decoration: underline;
            }
        }

        .map-controls-results-empty {
            color: var(--map-color-text-muted);
            font-family: var(--map-font);
            font-size: 1rem;
            line-height: 1.4;
            margin: 0;
            padding-block: 1rem;
            text-align: center;
        }
    }

    [x-cloak] {
        display: none !important;
    }

    .gm-style-iw-d {
        max-height: none !important;
        overflow: visible !important;
    }

    .gm-style-iw-c {
        background: rgba(255, 255, 255, 0.80);
        backdrop-filter: blur(1.25rem);
        border: 2px solid var(--map-color-text);
        border-radius: 1.25rem;
        max-height: none !important;
        max-width: 18.75rem !important;
        padding: 1.25rem !important;
    }

    .gm-style-iw-chr {
        border-bottom: 1px solid var(--map-color-text);
        box-sizing: border-box !important;
        display: flex !important;
        gap: 0.5rem;
        margin-bottom: 0.75rem !important;
        padding: 0 0 0.75rem !important;

        button.gm-ui-hover-effect {
            background-color: var(--map-color-orange) !important;
            border-radius: 9999px;
            display: flex !important;
            flex-shrink: 0;
            height: 1.24rem !important;
            margin: 0 !important;
            opacity: 1 !important;
            position: relative !important;
            top: 0.2em !important;
            right: auto !important;
            width: 1.24rem !important;

            span {
                background-color: var(--map-color-white);
                margin: 0 !important;
            }
        }

        .gm-style-iw-ch {
            padding-top: 0 !important;
        }

        .gm-fullscreen-control {
            border-radius: 9999px;
        }

        .map-balloon-name {
            flex: 1 1 auto;
            min-width: 0;
        }
    }

    .map-balloon .map-balloon-name,
    .gm-style-iw-chr .map-balloon-name {
        color: var(--map-color-orange);
        font-family: var(--map-font-condensed);
        font-stretch: 75%;
        font-size: 1.25rem;
        font-weight: 700;
        line-height: 1.2;
        margin-bottom: 0;
        text-transform: uppercase;

        @media (width >= 1024px) {
            font-size: 1.5rem;
        }
    }

    .map-balloon .map-balloon-name:not(:last-child) {
        margin-bottom: 0.25rem;
    }

    .gm-style-iw-t {
        bottom: 0 !important;

        &::after {
            background: var(--map-color-orange) !important;
        }
    }

    .gm-style-iw-tc:after {
        background: var(--map-color-text) !important;
    }

    .map-balloon {
        display: flex;
        flex-direction: column;
        font-family: var(--map-font);
        gap: 0.375rem;
        max-width: 18.75rem;
        min-width: 13.75rem;

        .map-balloon-company,
        .map-balloon-address,
        .map-balloon-phone,
        .map-balloon-web,
        .map-balloon-directions {
            color: var(--map-color-text);
            font-size: 1rem;
            line-height: 1.4;

            a {
                text-decoration: none;

                &:hover {
                    text-decoration: underline;
                }

                &:focus {
                    outline: none;
                }

                &:focus-visible {
                    outline: 2px solid var(--map-color-link);
                    outline-offset: 2px;
                }
            }
        }

        .map-balloon-address,
        .map-balloon-phone,
        .map-balloon-web,
        .map-balloon-directions {
            align-items: flex-start;
            display: flex;
            gap: 0.75rem;
        }

        .map-balloon-address__icon,
        .map-balloon-phone__icon,
        .map-balloon-web__icon,
        .map-balloon-directions__icon {
            flex-shrink: 0;
            line-height: 0;
            margin-top: 0.2em;

            svg {
                display: block;
            }
        }

        .map-balloon-address__text,
        .map-balloon-phone__text,
        .map-balloon-web__text,
        .map-balloon-directions__text {
            flex: 1 1 auto;
            min-width: 0;
            font-weight: 400;
        }

        .map-balloon-address__text {
            font-weight: 500;
        }
    }
}
