/* Shared: Leaflet + map marker UI */

/* Ottimizzazioni critiche per LCP e CLS */
#map {
    height: 100% !important;
    width: 100% !important;
    background-color: #e5e3df;
    background-image:
        linear-gradient(rgba(255, 255, 255, 0.3) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255, 255, 255, 0.3) 1px, transparent 1px);
    background-size: 50px 50px;
    contain: layout style paint;
    /* content-visibility: auto rimosso: impedisce a Lighthouse di rilevare l'LCP element */
}

/* Leaflet rendering priorities */
.leaflet-tile-container { will-change: transform; }
.leaflet-tile-container img {
    transition: opacity 0.15s ease-in;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: crisp-edges;
    decoding: async;
}
.leaflet-marker-pane,
.leaflet-popup-pane { contain: layout style; }
.leaflet-pane { will-change: transform; }
.leaflet-zoom-animated { will-change: transform; }
.leaflet-popup-content { color: #000; }

/* Loader area-search (spinner piccolo, gestito da map-main.js) */
.loader, #map-loader {
    transition: opacity 0.3s ease-out;
    will-change: opacity;
}

/* ── Map loading skeleton ──────────────────────────────────────────────────
   Overlay a piena copertura con shimmer, visibile mentre le tile CartoDB
   si caricano. Rimosso via JS appena la prima tile è pronta (leaflet-tile-loaded).
   ──────────────────────────────────────────────────────────────────────── */
#map-loading-skeleton {
    position: absolute;
    inset: 0;
    z-index: 450; /* sopra le tile (200-400), sotto i controlli Leaflet (500+) */
    pointer-events: none;
    background: linear-gradient(
        105deg,
        #dedad5 0%,
        #e8e4de 30%,
        #f2ede7 48%,
        #f5f0ea 50%,
        #f2ede7 52%,
        #e8e4de 70%,
        #dedad5 100%
    );
    background-size: 300% 100%;
    animation: map-shimmer 2s ease-in-out infinite;
    transition: opacity 0.4s ease-out;
    will-change: opacity, background-position;
}

@keyframes map-shimmer {
    0%   { background-position: 100% 0; }
    100% { background-position: -100% 0; }
}

/* La ricerca è automatica */
#search-area-button { display: none !important; }

/* Marker avatar */
.custom-marker-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background-color: white;
    color: #FF7601;
    font-weight: bold;
    font-size: 16px;
    text-align: center;
    overflow: hidden;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3);
    overflow: visible;
}
.custom-marker-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}
.current-user-marker {
    background-color: #FF7601;
    color: white;
    border-color: white;
}

/* Match % badge on marker */
.match-percentage {
    position: absolute;
    bottom: -7px;
    right: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 9px;
    font-weight: bold;
    z-index: 9999;
    font-family: Agrandir Grand Heavy, sans-serif;
    border-radius: 3px;
    padding: 2px 4px;
    min-width: 20px;
}

/* Skeleton loader per match in caricamento */
.match-skeleton {
    background: linear-gradient(
        90deg,
        rgba(200, 200, 200, 0.3) 0%,
        rgba(220, 220, 220, 0.5) 50%,
        rgba(200, 200, 200, 0.3) 100%
    );
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite ease-in-out;
    min-width: 24px;
    height: 14px;
    border: none;
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Badge per utenti con eventi creati */
.user-event-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    background: linear-gradient(135deg, #FF7601 0%, #FF9A42 100%);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 9px;
    box-shadow: 0 2px 6px rgba(255, 118, 1, 0.4);
    z-index: 10000;
    cursor: pointer;
}
.user-event-badge:hover {
    transform: scale(1.1);
    box-shadow: 0 3px 8px rgba(255, 118, 1, 0.6);
}

/* Airbnb-style pill markers */
.airbnb-marker {
    background: #222222;
    color: #fff;
    padding: 7px 13px;
    border-radius: 24px;
    font-size: 12px;
    font-weight: 700;
    font-family: 'Agrandir Grand Heavy', sans-serif;
    white-space: nowrap;
    box-shadow: 0 2px 10px rgba(0,0,0,0.28);
    cursor: pointer;
    border: 2.5px solid #fff;
    transition: transform 0.15s ease, background 0.15s ease, box-shadow 0.15s ease;
    line-height: 1;
    display: inline-block;
}
.airbnb-marker:hover { transform: scale(1.12); box-shadow: 0 4px 14px rgba(0,0,0,0.35); }
.airbnb-marker--current { background: #FF7601; }
.airbnb-marker--high { background: rgb(22, 163, 74); }
.airbnb-marker--mid { background: #FF7601; }
.airbnb-marker--low { background: #222222; }
.airbnb-marker--active {
    background: #fff !important;
    color: #222 !important;
    border-color: #222;
    transform: scale(1.12);
    box-shadow: 0 4px 16px rgba(0,0,0,0.38);
}

