/*---*\
Half Text / Half Map Block
Adds map-side presentation for the wp-company-manager shortcode while the
shared half-and-half layout, spacing, and typography remain in fx_half_image_text.

KEY FEATURES:
- Keeps map content constrained within the media column.
- Styles shortcode output wrappers and search form controls for this block only.
- Phase 1 static HTML uses <picture> + .half-text-half-map__map-image and an
  optional mobile-only contact card (hidden from 768px up where artwork bakes it in).
- Preserves keyboard-visible focus styles on map links and controls.

IMPLEMENTATION NOTES:
- SimpleMaps / wp-company-manager output fixed IDs (#map, #locations_map, etc.).
  Selectors scope those IDs under .half-text-half-map__map so block classes lead.
\*---*/

.half-text-half-map__map {
    width: 100%;
}

.half-text-half-map__map picture {
    display: block;
    width: 100%;
}

.half-text-half-map__map-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: var(--border-radius-card);
}

.half-text-half-map__card {
    position: relative;
    margin-top: 1rem;
    padding: 1rem 2.875rem 1rem 1rem;
    border-radius: var(--border-radius-card);
    box-shadow: var(--shadow-md);
    background-color: var(--color-white);
    color: var(--color-heading);
}

.half-text-half-map__card-heading {
    margin: 0 0 0.625rem;
    font-family: var(--font-heading);
    font-size: var(--font-size-h3);
    line-height: var(--line-height-heading);
}

.half-text-half-map__card-list {
    margin: 0;
    padding: 0;
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.half-text-half-map__card-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
}

.half-text-half-map__card-icon {
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.25rem;
    height: 1.25rem;
    margin-top: 0.125rem;
    color: var(--color-primary);
}

.half-text-half-map__card-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

.half-text-half-map__card-link {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: 2px;
    word-break: break-word;
}

.half-text-half-map__card-link:hover,
.half-text-half-map__card-link:focus-visible {
    color: var(--color-primary);
}

.half-text-half-map__card-close {
    position: absolute;
    top: 0.625rem;
    right: 0.625rem;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.125rem;
    height: 2.125rem;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: var(--border-radius-sm);
    background: transparent;
    color: var(--color-heading);
    cursor: pointer;
}

.half-text-half-map__card-close svg {
    display: block;
    width: 0.9375rem;
    height: 0.9375rem;
}

.half-text-half-map__map #map {
    width: 100%;
    border-radius: var(--border-radius-card);
    overflow: visible;
}

.half-text-half-map__map .wpcm-locations-map-root[data-wpcm-hide-zip="1"] #wpcm_zip {
    display: none !important;
}

.half-text-half-map__map .wpcm-locations-map-root[data-wpcm-hide-zip="1"] .wpcm-zip__form {
    display: none !important;
}

.half-text-half-map__map .wpcm-zip__form .input-field {
    margin-bottom: 12px;
}

.half-text-half-map__map .wpcm-zip__zipcode {
    width: 100%;
}

.location-map__content {
    position: relative;
    z-index: 1;
}

/*
 * SimpleMaps adds #map_access for keyboard/focus and interaction routing.
 * display:none breaks hover/popup behavior; do not hide it.
 */
.half-text-half-map__map #map #map_access {
    display: none !important;
}

.half-text-half-map__map #map rect {
    stroke: none;
}

.half-text-half-map__map #map path {
    stroke-width: 1.5px;
}

.half-text-half-map__map #map .tt_name_sm {
    color: var(--color-primary);
    font-size: 24px;
    font-family: var(--font-heading);
    text-transform: uppercase;
    padding-right: 20px;
}

.half-text-half-map__map #map .tt_sm {
    background: var(--color-white);
    box-shadow: 0 0 10px rgba(90, 95, 99, 0.2);
    opacity: 1;
    font-size: 16px;
    line-height: 1.45;
    font-family: var(--font-heading);
    padding: 20px;
    position: relative;
}

/* Hide the heading only for fallback/default-state popups. */
.wpcm-half-map-tooltip.is-default .tt_name_sm {
    display: none;
}

@media (max-width: 1199.98px) {

    .half-text-half-map.half-and-half:not(.half-text-half-form) .half-and-half__col--media {
        margin-bottom: 0;
    }

}

@media ( max-width: 767px ) {
    .half-text-half-map__map #map #tt_sm_map {
        position: relative !important;
        inset: unset !important;
        max-width: unset !important;
    }

    .half-text-half-map.half-and-half:not(.half-text-half-form) .half-and-half__col--media.is-clicked + .half-and-half__col--text {
        margin-top: var(--section-margins);
        padding-top: var(--section-margins);
    }
}

@supports (-webkit-touch-callout: none) {
    @media (max-width: 767px) {
        .half-text-half-map.half-and-half:not(.half-text-half-form) .half-and-half__col--media.is-clicked + .half-and-half__col--text {
            margin-top: calc(var(--section-margins) + 24px);
            padding-top: calc(var(--section-margins) + 24px);
        }
    }
}

.half-text-half-map__map #map .xmark_sm {
    float: none;
    position: absolute;
    top: 20px;
    right: 10px;
    margin: 0;
}

.half-text-half-map__map #map .xmark_sm a img {
    display: none;
}

.half-text-half-map__map #map .xmark_sm a {
    position: relative;
}

.half-text-half-map__map #map .xmark_sm a::before {
    font-size: 16px;
    font-family: var(--font-icon);
    color: #BCBCBC;
    content: "\e902";
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1;
    transition: color 0.3s ease-in-out;
}

.half-text-half-map__map #map .xmark_sm a:hover::before {
    color: var(--color-primary);
}

/* Optimize SVG rendering */
.half-text-half-map__map #map svg {
    /* Performance hint for smoother rendering */
    shape-rendering: optimizeSpeed;
    transform: translateZ(0);
}

/* Preloader Styles */
.half-text-half-map__map #locations_map {
    position: relative;
    min-height: 600px;
    /* Performance optimization: contain layout and paint operations */
    contain: layout paint;
}

@media (min-width: 1025px) and (max-width: 1200px) {
    .half-text-half-map__map #locations_map {
        min-height: 400px;
    }
}

.half-text-half-map__map #locations_map::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
    pointer-events: none;
}

.half-text-half-map__map #locations_map::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 50px;
    height: 50px;
    margin: -25px 0 0 -25px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: #ffffff;
    border-radius: 50%;
    z-index: 1001;
    animation: spinner 0.8s linear infinite;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

@keyframes spinner {
    to {
        transform: rotate(360deg);
    }
}

/* Hide preloader when map is loaded */
.half-text-half-map__map #locations_map.map-loaded::before,
.half-text-half-map__map #locations_map.map-loaded::after {
    opacity: 0;
    visibility: hidden;
}

/* Hide the map initially while loading */
.half-text-half-map__map #locations_map #map {
    opacity: 0;
    transition: opacity 0.5s ease;
}

/* Show the map after loading */
.half-text-half-map__map #locations_map.map-loaded #map {
    opacity: 1;
}

/*
 * Do NOT hide .sm_location here: wp-company-manager + SimpleMaps need visible pins with
 * pointer-events so hover popups work on dynamic REST-fed locations.
 */

.location-map__content .tt_name_sm {
    font-size: 25px;
    font-family: var(--font-heading);
}

.location-map__content .tt_custom_sm {
    font-size: 16px;
}

.half-text-half-map__map #map path.is-clicked {
    fill: var(--color-primary);
    transition: fill var(--transition-medium);
}

@media (min-width: 768px) {

    .half-text-half-map--innerpage:not(.half-text-half-form):not(.half-text-half-images) .half-and-half__col--text {
        text-align: left;
    }

    .half-text-half-map--innerpage:not(.half-text-half-form):not(.half-text-half-images) .half-and-half__col--text .sub-heading {
        justify-content: flex-start;
    }

    .half-text-half-map__map #map .tt_sm::before {
        content: '';
        width: 0;
        height: 0;
        border-top: 20px solid transparent;
        border-bottom: 20px solid transparent;
        border-right: 20px solid var(--color-white);
        position: absolute;
        left: -10px;
        transform: translateY(-50%);
        top: 50%;
    }

    .half-text-half-map.half-text-half-map--homepage {
        --section-margins: 50px;
    }

    .half-text-half-map__card {
        display: none;
    }

    .half-text-half-map__map #map {
        min-height: 420px;
    }
}

@media (min-width: 1200px) {
    .half-text-half-map__map #map {
        min-height: 350px;
    }

    .half-and-half:has( + section.bg-light-green ) {
        padding-bottom: calc(var(--section-margins) / 2);
    }

    .half-text-half-map.half-text-half-map--homepage {
        --section-margins: 65px;
    }

    .half-text-half-map__map #map path.has-popup:hover {
        fill: var(--color-primary);
        transition: fill var(--transition-medium);
    }
}

/* @media ( min-width: 1367px ) {
    .half-text-half-map__map #map {
        margin-left: 35px;
        min-height: 550px;
        width: 100%;
    }

    .half-and-half--media-left .half-text-half-map__map #map {
        margin-left: 0;
        margin-right: 35px;
    }
} */

@media ( min-width: 1366px ) {
    .half-text-half-map .half-and-half__col--text-inner {
        max-width: 715px;
        width: 100%;
        margin-left: auto;
        padding-right: 43px;
    }

    .half-text-half-map.half-and-half--media-left .half-and-half__col--text-inner {
        max-width: 720px;
        margin-left: unset;
        padding-right: 0;
        padding-left: 43px;
    }
}