/**
 * [generate_map] — pins, loading state, and the InfoWindow popup card.
 *
 * Brought over from kansascityymca.org's shortcode_map.css, retokened to this
 * theme's --qt-* palette (KC's --blue-md/--blue-dk don't exist here). The pin is
 * the map-pin SVG icon injected by map.js from data-marker-svg, colored through
 * currentColor; per-location overrides come from the map_pin_color ACF field.
 *
 * .marker is display:none while loading because map.js reads those elements for
 * coordinates and info-window HTML — they are data, not layout.
 */

.shortcode-map {
    height: 500px;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0px 3px 6px #00000029;
    position: relative;
    width: 100%;
}

/* Inside the quote tool the map is a rounded frame beside the card rail — flat
   (the design system has no resting shadows) with the photo radius. Height
   comes from quote-tool.css's step-2 grid. */
.quote-tool-map {
    height: 540px;
    border-radius: 30px;
    box-shadow: none;
}

.shortcode-map.loading .marker {
    display: none;
}

.shortcode-map.loading::after {
    content: "";
    position: absolute;
    inset: 0;
    background: rgba(255, 255, 255, 0.6);
}

.shortcode-map.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 28px;
    height: 28px;
    margin: -14px 0 0 -14px;
    border: 3px solid var(--qt-blue);
    border-top-color: transparent;
    border-radius: 50%;
    animation: shortcode-map-spin 0.7s linear infinite;
    z-index: 1;
}

@keyframes shortcode-map-spin {
    to {
        transform: rotate(360deg);
    }
}

/* Pin — a filled circle per the approved design: 20px blue dot with a white
   ring; the active pin grows to 32px magenta. The div itself is the dot (the
   injected SVG is hidden), so the map_pin_color ACF override still works
   through currentColor. */
.shortcode-map__pin {
    position: relative;
    width: 20px;
    height: 20px;
    box-sizing: border-box;
    color: var(--qt-blue);
    background: currentColor;
    border: 3px solid #fff;
    border-radius: 50%;
    cursor: pointer;
    transform-origin: 50% 50%;
    /* AdvancedMarkerElement anchors content bottom-center; nudge the dot down
       so its middle sits on the coordinate. */
    transform: translateY(50%);
    transition: all 0.18s ease-in-out;
}

.shortcode-map__pin:hover {
    transform: translateY(50%) scale(1.2);
}

.shortcode-map__pin.is-active {
    width: 32px;
    height: 32px;
    color: var(--qt-magenta, #c91f88);
    border-width: 4px;
    z-index: 10;
}

.shortcode-map__pin svg {
    display: none;
}

/* ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
/* MARKER POPUP (Google InfoWindow) */

/* Tame Google's InfoWindow chrome so .map-popup controls the whole card:
   no inner padding (image goes edge-to-edge), rounded corners, no focus ring. */
.gm-style .gm-style-iw-c {
    top: -10px !important;
    padding: 0 !important;
    border: none !important;
    outline: none !important;
    border-radius: 14px !important;
    box-shadow: 0 6px 22px rgba(0, 0, 0, 0.18) !important;
    overflow: hidden !important;
}
.gm-style .gm-style-iw-tc {
    top: -10px !important;
}

.gm-style .gm-style-iw-c:focus,
.gm-style .gm-style-iw-c:focus-visible {
    outline: none !important;
}

.gm-style .gm-style-iw-d {
    overflow: hidden !important;
    padding: 0 !important;
    max-width: none !important;
}

/* Collapse the reserved header strip so the content — the image — sits flush to
   the rounded top edge instead of below a white gap. */
.gm-style .gm-style-iw-ch,
.gm-style .gm-style-iw-chr {
    height: 0 !important;
    min-height: 0 !important;
    padding: 0 !important;
}

/* Close button (×): a small, consistent chip pinned inside the card's top-right,
   legible whether it sits over the image or the white body. */
.gm-style .gm-style-iw button.gm-ui-hover-effect {
    position: absolute !important;
    top: 8px !important;
    right: 8px !important;
    width: 28px !important;
    height: 28px !important;
    margin: 0 !important;
    background: rgba(255, 255, 255, 0.92) !important;
    border: 1px solid var(--qt-rule) !important;
    border-radius: 50% !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18) !important;
    opacity: 1 !important;
    z-index: 3 !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}
.gm-style .gm-style-iw button.gm-ui-hover-effect > span {
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    background-color: var(--qt-navy) !important;
}

.map-popup {
    width: 280px;
    max-width: 100%;
    background: var(--qt-white);
}

.map-popup__media {
    width: 100%;
    height: 150px;
    overflow: hidden;
}

.map-popup__media img,
.map-popup__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.map-popup__body {
    padding: 18px 20px 20px;
}

.map-popup__title {
    max-width: 88%;
    margin: 0 0 8px;
    font-family: "Cachet", Geneva, sans-serif;
    font-weight: bold;
    font-size: 16px;
    line-height: 1.1;
    letter-spacing: -0.2px;
    text-transform: uppercase;
    color: var(--qt-navy);
}

.map-popup__address {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    margin: 0 0 8px;
    white-space: pre-line;
    line-height: 1.35;
}

.map-popup__address .icon {
    flex: 0 0 auto;
    margin-top: 3px;
    font-size: 15px;
}

/* Force the brand color onto the pin — Google's .gm-style sets a near-black
   text color the bare .icon would otherwise inherit through currentColor. */
.map-popup .map-popup__address .icon,
.map-popup .map-popup__address .icon svg {
    color: var(--qt-navy);
    fill: var(--qt-navy);
}

.map-popup__phone {
    margin: 0 0 14px;
}

.map-popup__phone a {
    color: var(--qt-navy);
    font-weight: bold;
    text-decoration: none;
}

.map-popup__phone a:hover {
    text-decoration: underline;
}

.map-popup__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

/* Popup buttons. KC leans on its global .btn--blue/.btn--white; this theme has
   no global button system (Bootstrap is deregistered), so both variants are
   defined here in full. */
.map-popup__actions .btn {
    display: inline-block;
    padding: 10px 16px;
    font-size: 14px;
    text-transform: uppercase;
    line-height: 1;
    border-radius: 29px;
    text-decoration: none;
    transition: all 0.18s ease-in-out;
}

.map-popup__actions .btn--blue {
    background: var(--qt-gradient);
    border: 1px solid transparent;
}
.map-popup__actions .btn--blue .btn-text {
    color: var(--qt-white);
}
.map-popup__actions .btn--blue:hover {
    filter: brightness(1.15);
}

.map-popup__actions .btn--white {
    background: var(--qt-white);
    border: 1px solid var(--qt-navy);
}
.map-popup__actions .btn--white .btn-text {
    color: var(--qt-navy);
}
.map-popup__actions .btn--white:hover {
    background: var(--qt-navy);
}
.map-popup__actions .btn--white:hover .btn-text {
    color: var(--qt-white);
}

@media (max-width: 48em) {
    .shortcode-map {
        height: 400px;
    }

    .quote-tool-map {
        height: 300px;
    }

    .gm-style .gm-style-iw-c {
        max-width: 250px;
    }
    .gm-style .gm-style-iw-d {
        max-height: 150px !important;
        overflow-y: auto !important;
    }
}
