/* ─────────────────────────────────────────────────────────
   BPTK ACF Location Manager — Frontend CSS
   CSS custom properties injected inline by PHP per-instance.
───────────────────────────────────────────────────────── */

.bptk-acm {
    --acm-map-bg:       #0b1c2c;
    --acm-state:        #1a3752;
    --acm-state-active: #1c4b2c;
    --acm-state-hover:  #265c38;
    --acm-border:       #1e5a7a;
    --acm-star:         #c8f542;
    --acm-star-glow:    rgba(200, 245, 66, 0.65);
    --acm-cta:          #22c55e;

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

/* ── Map outer ─────────────────────────────────────────── */

.bptk-acm-map-outer {
    position: relative;
    width: 100%;
    background: var(--acm-map-bg);
    border-radius: 12px;
    overflow: hidden;
}

.bptk-acm-map-wrap {
    position: relative;
    width: 100%;
    line-height: 0;
}

.bptk-acm-map-loading {
    padding: 48px;
    text-align: center;
    color: #6b7280;
    font-size: 14px;
    line-height: 1.5;
}

/* ── SVG states ────────────────────────────────────────── */

.bptk-acm-svg {
    display: block;
    width: 100%;
    height: auto;
}

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

.bptk-acm-state {
    fill: var(--acm-state);
    stroke: none;
    transition: fill .2s ease;
}

.bptk-acm-state.is-active {
    fill: var(--acm-state-active);
    cursor: pointer;
}

.bptk-acm-state.is-active:hover,
.bptk-acm-state.is-tapped {
    fill: var(--acm-state-hover);
}

.bptk-acm-borders {
    fill: none;
    stroke: var(--acm-border);
    stroke-width: .4px;
    pointer-events: none;
}

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

.bptk-acm-network-badge {
    position: absolute;
    top: 14px;
    left: 14px;
    z-index: 20;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: rgba(0,0,0,.45);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 20px;
    padding: 5px 14px 5px 10px;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: .04em;
    pointer-events: none;
}

.bptk-acm-network-dot {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--acm-star);
    box-shadow: 0 0 6px var(--acm-star-glow);
    flex-shrink: 0;
    animation: acm-pulse 2s ease-in-out infinite;
}

@keyframes acm-pulse {
    0%,100% { opacity:1; transform:scale(1); }
    50%     { opacity:.6; transform:scale(.85); }
}

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

.bptk-acm-legend {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-size: 12px;
    color: rgba(255,255,255,.55);
    background: rgba(0,0,0,.25);
    border-top: 1px solid rgba(255,255,255,.06);
}

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

.bptk-acm-legend-sep {
    display: inline-block;
    width: 1px; height: 12px;
    background: rgba(255,255,255,.2);
    margin: 0 4px;
}

.bptk-acm-legend-dot-icon {
    width: 8px; height: 8px;
    border-radius: 50%;
    background: var(--acm-state-active);
    border: 1px solid var(--acm-state-hover);
    flex-shrink: 0;
}

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

.bptk-acm-markers {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.bptk-acm-marker {
    position: absolute;
    transform: translate(-50%, -50%);
    pointer-events: all;
    cursor: pointer;
    text-decoration: none;
    color: inherit;
    z-index: 10;
    padding: 6px;
    margin: -6px;
}

/* Lift the open marker above all sibling stars so its popup is never obscured */
.bptk-acm-marker.is-open {
    z-index: 100;
}

.bptk-acm-star-icon {
    display: block;
    font-size: 20px;
    line-height: 1;
    color: var(--acm-star);
    filter: drop-shadow(0 0 6px var(--acm-star-glow));
    transition: transform .2s ease, filter .2s ease;
    user-select: none;
}

.bptk-acm-marker:hover .bptk-acm-star-icon,
.bptk-acm-marker.is-open .bptk-acm-star-icon {
    transform: scale(1.35);
    filter: drop-shadow(0 0 10px var(--acm-star-glow));
}

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

.bptk-acm-popup {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%) scale(.95);
    transform-origin: bottom center;
    z-index: 30;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transition: opacity .18s ease, visibility .18s ease, transform .18s ease;
    white-space: nowrap;
}

.bptk-acm-marker.is-open .bptk-acm-popup {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) scale(1);
}

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

.bptk-acm-popup.open-right {
    left: calc(100% + 6px);
    bottom: 50%;
    transform: translateY(50%) scale(.95);
    transform-origin: left center;
}
.bptk-acm-marker.is-open .bptk-acm-popup.open-right {
    transform: translateY(50%) scale(1);
}

/* Marker near top of map — popup drops below instead of going above.
   Combine with open-right / open-left for correct edge-safe positioning. */

.bptk-acm-popup.open-right.open-above {
    /* Drop below marker, align left edge with marker — extends rightward */
    left: 0;
    right: auto;
    bottom: auto;
    top: calc(100% + 6px);
    transform: scale(.95);
    transform-origin: top left;
}
.bptk-acm-marker.is-open .bptk-acm-popup.open-right.open-above {
    transform: scale(1);
}

.bptk-acm-popup.open-left.open-above {
    /* Drop below marker, align right edge with marker — extends leftward */
    left: auto;
    right: 0;
    bottom: auto;
    top: calc(100% + 6px);
    transform: scale(.95);
    transform-origin: top right;
}
.bptk-acm-marker.is-open .bptk-acm-popup.open-left.open-above {
    transform: scale(1);
}

/* Fallback: open-above alone (centered, rare) */
.bptk-acm-popup.open-above:not(.open-right):not(.open-left) {
    bottom: auto; top: calc(100% + 6px);
    transform-origin: top center;
    transform: translateX(-50%) scale(.95);
}
.bptk-acm-marker.is-open .bptk-acm-popup.open-above:not(.open-right):not(.open-left) {
    transform: translateX(-50%) scale(1);
}

/* ── Popup inner ───────────────────────────────────────── */

.bptk-acm-popup-inner {
    background: rgba(10, 20, 35, .96);
    border: 1px solid rgba(255,255,255,.12);
    border-radius: 10px;
    padding: 14px 16px;
    min-width: 210px;
    max-width: 270px;
    box-shadow: 0 8px 24px rgba(0,0,0,.5);
    white-space: normal;
}

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

/* Logo image in popup */
.bptk-acm-popup-logo-wrap {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 6px;
    overflow: hidden;
    background: rgba(255,255,255,.1);
    display: flex;
    align-items: center;
    justify-content: center;
}

.bptk-acm-popup-logo {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* Star fallback (no logo) */
.bptk-acm-popup-star-wrap {
    font-size: 20px;
    color: var(--acm-star);
    filter: drop-shadow(0 0 4px var(--acm-star-glow));
    flex-shrink: 0;
    line-height: 1.2;
}

.bptk-acm-popup-title-wrap {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
    flex: 1;
}

.bptk-acm-popup-title {
    font-size: 14px;
    font-weight: 700;
    color: #fff;
    line-height: 1.2;
    display: block;
    margin-bottom: 5px;
}

.bptk-acm-popup-sub {
    font-size: 12px;
    color: rgba(255,255,255,.55);
    display: block;
    line-height: 1.4;
}

.bptk-acm-popup-details {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-bottom: 12px;
}

.bptk-acm-popup-row {
    display: flex;
    align-items: center;
    gap: 7px;
    font-size: 13px;
    color: rgba(255,255,255,.75);
    line-height: 1.5;
}

.bptk-acm-popup-icon {
    font-size: 12px;
    flex-shrink: 0;
    opacity: .75;
}

.bptk-acm-popup-cta {
    display: block;
    background: var(--acm-cta);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    text-align: center;
    padding: 12px 16px;
    border-radius: 7px;
    letter-spacing: .02em;
}

/* ── Mobile card list ──────────────────────────────────── */

.bptk-acm-mobile-list {
    margin-top: 16px;
}

.bptk-acm-mobile-state-title {
    font-size: 16px;
    font-weight: 700;
    color: #111827;
    margin: 0 0 10px;
}

.bptk-acm-mobile-cards {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bptk-acm-mobile-card {
    display: flex;
    align-items: center;
    gap: 12px;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    padding: 10px 14px;
    text-decoration: none;
    color: #111827;
    transition: box-shadow .15s, border-color .15s;
}

.bptk-acm-mobile-card:hover {
    box-shadow: 0 2px 10px rgba(0,0,0,.08);
    border-color: #d1d5db;
}

/* Logo in mobile card */
.bptk-acm-mobile-card-logo {
    width: 44px;
    height: 44px;
    border-radius: 6px;
    object-fit: cover;
    flex-shrink: 0;
    background: #f3f4f6;
}

/* Star fallback in mobile card */
.bptk-acm-mobile-card-star {
    font-size: 24px;
    color: var(--acm-star, #c8f542);
    filter: drop-shadow(0 0 4px var(--acm-star-glow, rgba(200,245,66,.65)));
    flex-shrink: 0;
}

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

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

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

.bptk-acm-mobile-card-loc {
    color: #9ca3af !important;
}

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

/* ── Responsive ────────────────────────────────────────── */

@media (max-width: 640px) {
    .bptk-acm-map-outer { border-radius: 8px; }
    .bptk-acm-network-badge { font-size: 11px; padding: 4px 10px 4px 8px; top: 8px; left: 8px; }
    .bptk-acm-legend { font-size: 11px; padding: 6px 10px; }
}
