/* ============================================================
   Cobo Mapper — Frontend CSS
   ============================================================ */

.cobo-mapper-wrap {
    width: 100%;
    min-height: 200px;
    border-radius: 6px;
    overflow: hidden;
    margin: 1.5em 0;
    position: relative;
    z-index: 0;
}

/* ---- Popup / Balloon ---- */

.cobo-mapper-balloon {
    font-family: inherit;
    min-width: 180px;
    max-width: 260px;
    border-radius: 6px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.5;
}

.cobo-mapper-balloon-image {
    width: 100%;
    max-height: 140px;
    overflow: hidden;
}

.cobo-mapper-balloon-image img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    display: block;
}

.cobo-mapper-balloon-body {
    padding: 10px 12px;
}

.cobo-mapper-balloon-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 4px;
}

.cobo-mapper-balloon-source {
    font-size: 12px;
    margin-bottom: 6px;
    opacity: 0.8;
}

.cobo-mapper-balloon-source a {
    text-decoration: none;
}

.cobo-mapper-balloon-source a:hover {
    text-decoration: underline;
}

.cobo-mapper-balloon-description {
    font-size: 13px;
    margin-bottom: 8px;
}

.cobo-mapper-balloon-link {
    margin-top: 6px;
    font-size: 13px;
}

.cobo-mapper-balloon-link a {
    text-decoration: none;
    font-weight: 600;
}

.cobo-mapper-balloon-link a:hover {
    text-decoration: underline;
}

.cobo-mapper-balloon-gmaps {
    margin-top: 4px;
    font-size: 13px;
    border-top: 1px solid rgba(0, 0, 0, 0.08);
    padding-top: 6px;
}

.cobo-mapper-balloon-gmaps a {
    text-decoration: none;
    font-weight: 600;
}

.cobo-mapper-balloon-gmaps a:hover {
    text-decoration: underline;
}

/* Override Leaflet popup padding per balloon custom */
.cobo-mapper-popup .leaflet-popup-content-wrapper {
    padding: 0;
    border-radius: 6px;
    overflow: hidden;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.cobo-mapper-popup .leaflet-popup-content {
    margin: 0;
    width: auto !important;
}

.cobo-mapper-popup .leaflet-popup-tip-container {
    margin-top: -1px;
}

/* ---- Tooltip (hover) ---- */

.cobo-mapper-tooltip {
    font-size: 12px;
}

/* ---- Pulsante fullscreen ---- */

.cobo-mapper-fullscreen-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    padding: 0;
    background: #fff;
    border: 2px solid rgba(0, 0, 0, 0.2);
    border-radius: 4px;
    cursor: pointer;
    color: #333;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.cobo-mapper-fullscreen-btn:hover,
.cobo-mapper-fullscreen-btn:focus-visible {
    background: #f4f4f4;
    color: #000;
    outline: 2px solid #4a90d9;
    outline-offset: 1px;
}

.cobo-mapper-fullscreen-btn svg {
    display: block;
    flex-shrink: 0;
}

/* Stile mappa in fullscreen nativo */
.cobo-mapper-wrap:fullscreen,
.cobo-mapper-wrap:-webkit-full-screen,
.cobo-mapper-wrap:-moz-full-screen,
.cobo-mapper-wrap:-ms-fullscreen {
    width: 100vw !important;
    height: 100vh !important;
    border-radius: 0;
    margin: 0;
    z-index: 9999;
}

/* ---- Hint scroll wheel ---- */

.cobo-mapper-scroll-hint {
    position: absolute;
    bottom: 40px;
    left: 50%;
    transform: translateX(-50%) translateY(6px);
    background: rgba(0, 0, 0, 0.72);
    color: #fff;
    font-size: 13px;
    line-height: 1.4;
    padding: 7px 14px;
    border-radius: 4px;
    pointer-events: none;
    white-space: nowrap;
    opacity: 0;
    transition: opacity 0.2s ease, transform 0.2s ease;
    z-index: 800;
}

.cobo-mapper-scroll-hint--visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ---- Cluster marker ---- */

.cobo-mapper-cluster {
    background: transparent;
    border: 0;
}

.cobo-mapper-cluster span {
    --cobo-mapper-cluster-color: #0073aa;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--cobo-mapper-cluster-color);
    color: #ffffff;
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    border: 3px solid #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.18);
}

.cobo-mapper-cluster--medium span {
    width: 44px;
    height: 44px;
    font-size: 15px;
}

.cobo-mapper-cluster--large span {
    width: 48px;
    height: 48px;
    font-size: 16px;
}

/* ---- Titolo post sorgente / badge / etichetta azione ---- */

.cobo-mapper-source-badge {
    display: inline-block;
    margin-bottom: 6px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    line-height: 1.4;
}

.cobo-mapper-source-title {
    margin-bottom: 8px;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.45;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
}

.cobo-mapper-source-title a {
    text-decoration: none;
}

.cobo-mapper-source-title a:hover,
.cobo-mapper-source-title a:focus-visible {
    text-decoration: underline;
}

.cobo-mapper-source-action {
    margin-top: 8px;
    font-size: 12px;
    line-height: 1.4;
}

.cobo-mapper-source-action a {
    text-decoration: none;
    font-weight: 600;
}

.cobo-mapper-source-action a:hover,
.cobo-mapper-source-action a:focus-visible {
    text-decoration: underline;
}

/* ---- Layer OpenData — linee e poligoni ---- */

/*
 * Leaflet sovrascrive gli stili SVG dei path direttamente via attributi inline,
 * quindi il colore del layer viene gestito via JS (buildGeoStyle).
 * Queste regole gestiscono solo comportamenti hover e focus per accessibilita.
 */

.leaflet-interactive:focus-visible {
    outline: 3px solid #4a90d9;
    outline-offset: 2px;
}

/* Hover su poligoni: leggero incremento di opacita del fill */
.leaflet-overlay-pane path.leaflet-interactive:hover {
    fill-opacity: 0.3;
    cursor: pointer;
}

/* ---- Stato di caricamento (BBox) ---- */

.cobo-mapper-loading::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.6);
    z-index: 1000;
    display: block;
    backdrop-filter: blur(1px);
}

.cobo-mapper-loading::before {
    content: "";
    position: absolute;
    top: calc(50% - 16px);
    left: calc(50% - 16px);
    width: 32px;
    height: 32px;
    border: 3px solid rgba(0, 115, 170, 0.15);
    border-top-color: #0073aa;
    border-radius: 50%;
    animation: cobo-mapper-spin 0.8s linear infinite;
    z-index: 1001;
}

@keyframes cobo-mapper-spin {
    to {
        transform: rotate(360deg);
    }
}