/* pairs with js/event_map.js and map/map-style.json.
   Replaces the Leaflet rules for .event-map in event_page.css; .event-map__fallback stays as it is. */

.event-map {
    position: relative;
    isolation: isolate;
    min-height: 360px;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    border-radius: 24px;
    overflow: hidden;
    border: 1px solid rgba(49, 31, 78, 0.1);
    background: #f5f3f9;
    font-family: Montserrat, "Segoe UI", system-ui, sans-serif;
    container-type: inline-size;
}

.event-map .maplibregl-canvas {
    outline: none;
}

.event-map .maplibregl-canvas-container:has(.maplibregl-canvas:focus-visible)::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    box-shadow: inset 0 0 0 3px #8f4ad8;
    pointer-events: none;
}

/* loader until the first map frame is drawn */
.event-map__loading {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: grid;
    place-content: center;
    justify-items: center;
    gap: 12px;
    background:
        linear-gradient(100deg, rgba(255, 255, 255, 0) 30%, rgba(255, 255, 255, 0.55) 50%, rgba(255, 255, 255, 0) 70%) 0 0 / 220% 100%,
        #f2eff8;
    color: #6e6388;
    font-size: 13px;
    font-weight: 600;
    animation: ev-map-shimmer 1.6s linear infinite;
    transition: opacity 0.35s ease;
}

.event-map__loading svg {
    width: 34px;
    height: 34px;
    color: #8f4ad8;
    animation: ev-map-bob 1.2s ease-in-out infinite;
}

.event-map__loading.is-done {
    opacity: 0;
    pointer-events: none;
}

@keyframes ev-map-shimmer {
    from { background-position: 120% 0, 0 0; }
    to { background-position: -120% 0, 0 0; }
}

@keyframes ev-map-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-5px); }
}

/* Zoom and recenter buttons */
.event-map .maplibregl-ctrl-top-right {
    top: 4px;
    right: 4px;
}

.event-map .maplibregl-ctrl-top-right .maplibregl-ctrl {
    margin: 8px 8px 0 0;
}

.event-map .maplibregl-ctrl-group {
    overflow: hidden;
    border: none;
    border-radius: 14px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(43, 31, 68, 0.08), 0 10px 24px rgba(43, 31, 68, 0.14);
}

.event-map .maplibregl-ctrl-group button {
    width: 40px;
    height: 40px;
    color: #6b3bb5;
    transition: background-color 0.15s ease;
}

.event-map .maplibregl-ctrl-group button + button {
    border-top: 1px solid #efeaf6;
}

.event-map .maplibregl-ctrl-group button:not(:disabled):hover {
    background-color: #f4effb;
}

.event-map .maplibregl-ctrl-group button:focus-visible {
    box-shadow: inset 0 0 0 2px #8f4ad8;
}

.event-map .maplibregl-ctrl button.maplibregl-ctrl-zoom-in .maplibregl-ctrl-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b3bb5' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M12 6v12M6 12h12'/%3E%3C/svg%3E");
    background-size: 20px 20px;
}

.event-map .maplibregl-ctrl button.maplibregl-ctrl-zoom-out .maplibregl-ctrl-icon {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236b3bb5' stroke-width='2.4' stroke-linecap='round'%3E%3Cpath d='M6 12h12'/%3E%3C/svg%3E");
    background-size: 20px 20px;
}

.event-map .maplibregl-ctrl button:disabled .maplibregl-ctrl-icon {
    opacity: 0.3;
}

.event-map .ev-map-recenter {
    display: grid;
    place-items: center;
}

.event-map .ev-map-recenter svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
}

/* OpenStreetMap credit: a small pill on wide maps; below 640px MapLibre folds it into an (i) button
   that starts open and collapses once the visitor moves the map. */
.event-map .maplibregl-ctrl-bottom-right .maplibregl-ctrl-attrib:not(.maplibregl-compact) {
    margin: 0 8px 8px 0;
    padding: 2px 9px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.86);
    color: #6e6388;
    font-size: 10.5px;
    line-height: 18px;
}

.event-map .maplibregl-ctrl-attrib.maplibregl-compact {
    margin: 0 8px 8px 0;
    background: rgba(255, 255, 255, 0.9);
    color: #6e6388;
    font-size: 10px;
    line-height: 16px;
}

.event-map .maplibregl-ctrl-attrib a {
    color: #5b5070;
}

.event-map .maplibregl-ctrl-attrib a:hover {
    color: #6b3bb5;
}

/* "Hold Ctrl to zoom" message from cooperative gestures */
.event-map .maplibregl-cooperative-gesture-screen {
    padding: 24px;
    background: rgba(31, 22, 48, 0.5);
    color: #ffffff;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.45;
    text-align: center;
}

/* Venue pin */
.ev-map-pin {
    position: relative;
    width: 48px;
    height: 60px;
    cursor: default;
}

.ev-map-pin__shape {
    position: absolute;
    left: 0;
    top: 0;
    width: 48px;
    height: 60px;
    overflow: visible;
    filter: drop-shadow(0 8px 14px rgba(79, 36, 140, 0.34));
}

.ev-map-pin__icon {
    position: absolute;
    left: 13px;
    top: 12.5px;
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #ffffff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.ev-map-pin__pulse {
    position: absolute;
    left: 50%;
    bottom: -7px;
    width: 30px;
    height: 12px;
    margin-left: -15px;
    border-radius: 50%;
    background: rgba(111, 44, 196, 0.26);
}

.ev-map-pin__pulse::after {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(143, 74, 216, 0.55);
    animation: ev-map-pulse 2.4s ease-out infinite;
}

@keyframes ev-map-pulse {
    0% { transform: scale(0.6); opacity: 0.9; }
    100% { transform: scale(2.6); opacity: 0; }
}

.ev-map-pin__label {
    position: absolute;
    left: calc(100% + 4px);
    top: 7px;
    display: flex;
    flex-direction: column;
    gap: 1px;
    max-width: 220px;
    padding: 7px 12px 8px;
    border-radius: 12px;
    background: #ffffff;
    box-shadow: 0 1px 2px rgba(43, 31, 68, 0.08), 0 10px 24px rgba(43, 31, 68, 0.16);
    white-space: nowrap;
    pointer-events: none;
}

.ev-map-pin__label strong {
    overflow: hidden;
    text-overflow: ellipsis;
    color: #1b1b24;
    font-size: 13px;
    font-weight: 800;
    line-height: 17px;
}

.ev-map-pin__label span {
    overflow: hidden;
    text-overflow: ellipsis;
    color: #6e6388;
    font-size: 12px;
    font-weight: 500;
    line-height: 15px;
}

@media (max-width: 720px) {
    .event-map {
        min-height: 300px;
    }

    .ev-map-pin__label {
        max-width: 170px;
    }
}

@media (max-width: 480px) {
    .event-map {
        min-height: 280px;
        border-radius: 18px;
    }
}

/* Narrow maps: the label goes under the pin so it never runs into the zoom buttons */
@container (max-width: 520px) {
    .ev-map-pin__label {
        left: 50%;
        top: calc(100% + 14px);
        transform: translateX(-50%);
        align-items: stretch;
        width: max-content;
        max-width: 220px;
        text-align: center;
        white-space: normal;
    }

    .ev-map-pin__label strong {
        display: -webkit-box;
        line-clamp: 2;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow-wrap: anywhere;
    }
}

@media (prefers-reduced-motion: reduce) {
    .event-map__loading,
    .event-map__loading svg {
        animation: none;
    }
    .ev-map-pin__pulse::after {
        animation: none;
        opacity: 0;
    }
}
