/* Google Maps Elements – front-end styles
 * Hardcoded values (FIX #15) replaced with builder-controlled CSS vars emitted
 * by google_maps_style(). Fallback values here are intentionally minimal.
 */

.google-maps-element {
    position: relative;
    width: 100%;
}

.google-maps-container {
    width: 100%;
    height: 100%;
}

.static-map {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    cursor: pointer;
}

/* Position, offset, width, padding and title font-size all come from the
 * style template. Only structural / non-customisable rules remain here. */
.map-info-window {
    position: absolute;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    background: white;
    border-radius: 20px;
    z-index: 10;
    overflow: hidden;
}

/* Mobile: stack info window below the map as a normal block element.
 *
 * Cornerstone's frame partial renders:
 *   .x-frame.x-frame-google-map > .x-frame-inner > [ .x-google-map + .map-info-window ]
 *
 * The theme rule  `.x-frame-inner > div`  forces
 *   position: absolute !important; top:0; left:0; width:100%; height:100%;
 * on every direct child <div> inside .x-frame-inner (matching .x-google-map).
 * That is correct at desktop — the map fills the frame's aspect-ratio box.
 *
 * On mobile we must:
 *   1. Make .x-frame-inner a flex column so its children can stack.
 *   2. Override the theme's !important absolute positioning on the map <div>
 *      so it becomes a normal flow element with an explicit height.
 *   3. Override the inline top/bottom/left/right on .map-info-window
 *      (written by PHP) so it stacks beneath the map.
 */
@media (max-width: 767px) {

    /* 1. Flex container on the actual parent of map + info-window */
    .x-frame-google-map .x-frame-inner {
        display: flex !important;
        flex-direction: column-reverse !important;
        position: relative !important;
        height: auto !important;
        padding: 0 !important;
    }

    /* 2. Pull the map div out of absolute positioning.
     *    Needs double-class specificity + !important to beat the theme's
     *    `.x-frame-inner > div { position: absolute !important; … }` rule. */
    .x-frame-google-map .x-frame-inner > .x-google-map {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 300px;
        aspect-ratio: 4 / 3;
        order: 2;
    }

    /* Static overlay — same treatment */
    .x-frame-google-map .x-frame-inner > .static-map {
        position: relative !important;
        top: auto !important;
        left: auto !important;
        width: 100% !important;
        height: auto !important;
        min-height: 300px;
        aspect-ratio: 4 / 3;
        order: 2;
    }

    /* 3. Info window stacks below */
    .x-frame-google-map .x-frame-inner > .map-info-window {
        position: relative !important;
        top: auto !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box;
        border-radius: 0;
        margin-top: 0;
        order: 1;
    }
}

.map-info-window h5 {
    margin-top: 0;
    margin-bottom: 0.5em;
}

.location-image img {
    margin-bottom: 0.75em;
}

/* Link button – background colour comes from the style template.
 * Displayed as a full-width block below the title. */
.location-link {
    display: block;
    margin-top: 1em;
    padding: 0.6em 1em;
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    border-radius: 4px;
    font-weight: 600;
    transition: opacity 0.15s ease;
}

.location-link:hover {
    opacity: 0.85;
    color: #ffffff;
}


/* Bounce animation for AdvancedMarkerElement.
 *
 * The animation is applied to marker.content — the inner content node —
 * NOT marker.element. Google Maps positions marker.element via a CSS transform
 * (e.g. translate(-50%, -100%) translate(-3px, -181px)). Animating that outer
 * element overrides the positioning transform on every keyframe and snaps the
 * marker to the map center. Animating the inner content node avoids this
 * entirely because it carries no positioning transform of its own.
 */
@keyframes markerBounce {
    0%   { transform: translateY(0); }
    30%  { transform: translateY(-12px); }
    60%  { transform: translateY(-4px); }
    80%  { transform: translateY(-8px); }
    100% { transform: translateY(0); }
}

.marker--bounce {
    animation: markerBounce 0.75s ease;
    transform-origin: bottom center;
}

/* API key missing notice */
.google-maps-api-notice {
    padding: 1em;
    background: #fff3cd;
    border: 1px solid #ffc107;
    border-radius: 4px;
    color: #856404;
    margin: 0;
}
