/* ═══════════════════════════════════════════════════════
   BPTK Location Manager — Frontend Styles
   All map colours are driven by CSS custom properties
   injected inline by the PHP shortcode renderer.
   This makes every [bptk_locations id="X"] instance
   independently colour-themeable.

   Property reference (set on .bptk-lm wrapper):
     --lm-map-bg         map container background
     --lm-state          default (inactive) state fill
     --lm-state-active   states with locations
     --lm-state-hover    active state on hover
     --lm-border         state border stroke colour
     --lm-star           star marker colour
     --lm-star-glow      semi-transparent star glow (auto-derived by PHP)
     --lm-cta            CTA button background
═══════════════════════════════════════════════════════ */

/* ── Fallback defaults (used when no inline style is present) */
.bptk-lm {
    --lm-map-bg:       #0b1c2c;
    --lm-state:        #1a3752;
    --lm-state-active: #1c4b2c;
    --lm-state-hover:  #265c38;
    --lm-border:       #1e5a7a;
    --lm-star:         #c8f542;
    --lm-star-glow:    rgba(200,245,66,0.65);
    --lm-cta:          #22c55e;

    width: 100%;
    font-family: inherit;
}

/* ── Map wrapper ─────────────────────────────────────── */

.bptk-lm-map-outer {
    position: relative;
    background: var(--lm-map-bg);
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 0 0 1px rgba(30,100,160,.2), 0 8px 48px rgba(0,0,0,.55);
}

/* ── Network badge ───────────────────────────────────── */

.bptk-lm-network-badge {
    position: absolute;
    top: 16px;
    left: 18px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 5px 12px 5px 9px;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.1);
    border-radius: 20px;
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: .1em;
    text-transform: uppercase;
    color: rgba(255,255,255,.7);
}

.bptk-lm-network-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--lm-star);
    box-shadow: 0 0 6px var(--lm-star);
    flex-shrink: 0;
}

/* ── SVG map container ───────────────────────────────── */

.bptk-lm-map-wrap {
    position: relative;
    width: 100%;
    aspect-ratio: 960 / 600;
    overflow: visible; /* allow popups to overflow on desktop */
}

.bptk-lm-map-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255,255,255,.3);
    font-size: 14px;
}

.bptk-lm-svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.bptk-lm-map-bg {
    fill: var(--lm-map-bg);
}

/* ── State fills ─────────────────────────────────────── */

.bptk-lm-state {
    fill: var(--lm-state);
    transition: fill .2s ease;
    cursor: default;
}

.bptk-lm-state.is-active {
    fill: var(--lm-state-active);
}

@media (hover: hover) {
    .bptk-lm-state.is-active:hover {
        fill: var(--lm-state-hover);
    }
}

.bptk-lm-state.is-tapped {
    fill: var(--lm-state-hover) !important;
}

/* ── State borders ───────────────────────────────────── */

.bptk-lm-borders {
    fill: none;
    stroke: var(--lm-border);
    stroke-width: 0.6;
    stroke-linejoin: round;
}

/* ── Marker layer ────────────────────────────────────── */

.bptk-lm-markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
    overflow: visible;
}

.bptk-lm-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: all;
    cursor: pointer;
    z-index: 10;
}

/* Star icon */
.bptk-lm-star-icon {
    display: block;
    font-size: 22px;
    line-height: 1;
    color: var(--lm-star);
    filter:
        drop-shadow(0 0 3px var(--lm-star))
        drop-shadow(0 0 10px var(--lm-star-glow))
        drop-shadow(0 0 22px var(--lm-star-glow));
    transition: transform .18s ease, filter .18s ease;
    user-select: none;
}

.bptk-lm-marker:hover .bptk-lm-star-icon,
.bptk-lm-marker.is-open .bptk-lm-star-icon {
    transform: scale(1.25);
    filter:
        drop-shadow(0 0 4px var(--lm-star))
        drop-shadow(0 0 14px var(--lm-star))
        drop-shadow(0 0 30px var(--lm-star-glow));
}

/* ── Popup card ──────────────────────────────────────── */

.bptk-lm-popup {
    position: absolute;
    width: 280px;
    background: #fff;
    border-radius: 14px;
    box-shadow: 0 4px 24px rgba(0,0,0,.22), 0 1px 6px rgba(0,0,0,.12);
    opacity: 0;
    pointer-events: none;
    transform: translateY(6px) scale(.97);
    transition: opacity .2s ease, transform .2s ease;
    z-index: 100;
}

.bptk-lm-marker.is-open .bptk-lm-popup {
    opacity: 1;
    pointer-events: all;
    transform: translateY(0) scale(1);
}

/* Default: open upward-right of the marker */
.bptk-lm-popup {
    bottom: calc(100% + 10px);
    left: 0;
    transform-origin: bottom left;
}

.bptk-lm-popup.open-right {
    left: calc(100% + 10px);
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) scale(.97);
    transform-origin: left center;
}
.bptk-lm-marker.is-open .bptk-lm-popup.open-right {
    transform: translateY(-50%) scale(1);
}

.bptk-lm-popup.open-left {
    right: calc(100% + 10px);
    left: auto;
    bottom: auto;
    top: 50%;
    transform: translateY(-50%) scale(.97);
    transform-origin: right center;
}
.bptk-lm-marker.is-open .bptk-lm-popup.open-left {
    transform: translateY(-50%) scale(1);
}

.bptk-lm-popup.open-above {
    bottom: auto;
    top: calc(100% + 10px);
    transform-origin: top left;
}

/* Popup contents */
.bptk-lm-popup-inner {
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.bptk-lm-popup-header {
    display: flex;
    align-items: flex-start;
    gap: 10px;
}

.bptk-lm-popup-star-wrap {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    background: #f0fdf4;
    border: 1.5px solid #bbf7d0;
    border-radius: 9px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    color: #16a34a;
}

.bptk-lm-popup-title-wrap {
    flex: 1;
    min-width: 0;
}

.bptk-lm-popup-title {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    font-size: 14px;
    font-weight: 700;
    color: #111827;
    line-height: 1.3;
}

.bptk-lm-popup-sub {
    display: block;
    font-size: 12px;
    color: #2563eb;
    font-weight: 500;
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bptk-lm-popup-details {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.bptk-lm-popup-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 12.5px;
    color: #4b5563;
}

.bptk-lm-popup-icon {
    flex-shrink: 0;
    font-size: 13px;
    color: #9ca3af;
    width: 16px;
    text-align: center;
}

/* CTA uses --lm-cta for background */
.bptk-lm-popup-cta {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 9px 14px;
    background: var(--lm-cta);
    color: #fff !important;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    text-decoration: none !important;
    transition: filter .15s ease;
}

.bptk-lm-popup-cta:hover {
    filter: brightness(.88);
}

/* ── Legend bar ──────────────────────────────────────── */

.bptk-lm-legend {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 10px 14px;
    background: rgba(0,0,0,.35);
    font-size: 12px;
    color: rgba(255,255,255,.55);
}

.bptk-lm-legend-star {
    color: var(--lm-star);
    font-size: 14px;
    filter: drop-shadow(0 0 4px var(--lm-star-glow));
}

.bptk-lm-legend-sep {
    width: 1px;
    height: 12px;
    background: rgba(255,255,255,.2);
    margin: 0 2px;
}

.bptk-lm-legend-dot-icon {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,.4);
}

/* ══════════════════════════════════════════════════════
   MOBILE  (≤ 640 px)
══════════════════════════════════════════════════════ */

@media (max-width: 640px) {

    /* Stars hidden; states tapped instead */
    .bptk-lm-markers { display: none; }

    .bptk-lm-state.is-active { cursor: pointer; }

    .bptk-lm-legend-sep,
    .bptk-lm-legend-dot-icon { display: none; }

    /* Mobile list */
    .bptk-lm-mobile-list { margin-top: 20px; }
    .bptk-lm-mobile-list[hidden] { display: none; }

    .bptk-lm-mobile-state-title {
        font-size: 15px;
        font-weight: 700;
        color: #1f2937;
        margin: 0 0 12px;
    }

    .bptk-lm-mobile-cards {
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    .bptk-lm-mobile-card {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 14px 16px;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        box-shadow: 0 2px 8px rgba(0,0,0,.06);
        text-decoration: none !important;
        color: inherit !important;
        transition: box-shadow .15s, border-color .15s;
    }

    .bptk-lm-mobile-card:hover {
        border-color: var(--lm-cta);
        box-shadow: 0 4px 16px rgba(0,0,0,.1);
    }

    .bptk-lm-mobile-card-star {
        flex-shrink: 0;
        width: 36px;
        height: 36px;
        background: #f0fdf4;
        border: 1.5px solid #bbf7d0;
        border-radius: 9px;
        display: flex;
        align-items: center;
        justify-content: center;
        font-size: 18px;
        color: var(--lm-cta);
    }

    .bptk-lm-mobile-card-info {
        flex: 1;
        min-width: 0;
        display: flex;
        flex-direction: column;
        gap: 2px;
    }

    .bptk-lm-mobile-card-info strong {
        font-size: 14px;
        font-weight: 700;
        color: #111827;
    }

    .bptk-lm-mobile-card-info span { font-size: 12.5px; color: #6b7280; }

    .bptk-lm-mobile-card-loc { color: #2563eb !important; font-size: 12px !important; }

    .bptk-lm-mobile-card-arrow { flex-shrink: 0; font-size: 18px; color: #9ca3af; }
}
