:root {
    --yec-map-primary-color: #007cba;
    --yec-map-secondary-color: #e74c3c;
    --yec-map-success-color: #27ae60;
    --yec-map-warning-color: #f39c12;
    --yec-map-info-color: #3498db;
    --yec-map-light-color: #ecf0f1;
    --yec-map-dark-color: #2c3e50;
    --yec-map-border-radius: 0.5rem; /* 8px / 16 */
    --yec-map-shadow: 0 0.125rem 0.625rem rgba(0, 0, 0, 0.1); /* 0 2px 10px / 16 */
    --yec-map-transition: all 0.3s ease;
}

.yec-map-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.9375rem; /* 15px / 16 */
}

.yec-map-container {
    position: relative;
    width: 100%;
    height: 25rem; /* 400px / 16 */
    border-radius: var(--yec-map-border-radius);
    overflow: hidden;
}

.yec-map-container[style*="aspect-ratio"] {
    height: auto;
}

.yec-map-legend-external {
    align-self: flex-end;
}

.yec-map {
    width: 100%;
    height: 100%;
    position: relative;
}

/* Map Message */
.yec-map-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    padding: 0.625rem 1.25rem; /* 10px 20px / 16 */
    border-radius: 1.25rem; /* 20px / 16 */
    font-size: 0.875rem; /* 14px / 16 */
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    pointer-events: none;
}

.yec-map-message-visible {
    opacity: 1;
    visibility: visible;
}

.yec-map-message svg {
    width: 1rem; /* 16px / 16 */
    height: 1rem; /* 16px / 16 */
    vertical-align: middle;
    margin-right: 0.375rem; /* 6px / 16 */
}

/* Toggle Interaction Button */
.leaflet-control-custom {
    background: none;
    border: 2px solid rgba(0, 0, 0, 0.2) !important; /* 2px / 16 */
    border-style: solid;
    border-radius: 4px !important; /* 4px / 16 */
}

.yec-toggle-interaction {
    background: white !important;
    min-width: 1.875rem; /* 30px / 16 */
    min-height: 1.875rem; /* 30px / 16 */
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: var(--yec-map-shadow);
    margin: 0;
    padding: 0;
}

.yec-toggle-interaction:hover {
    background: #f4f4f4 !important;
}

.yec-toggle-interaction:active {
    background: #fff !important;
}

.yec-toggle-interaction:focus {
    outline: 0.125rem solid var(--yec-map-primary-color); /* 2px / 16 */
    outline-offset: 0.125rem; /* 2px / 16 */
}

.yec-toggle-interaction svg {
    width: 1.125rem; /* 18px / 16 */
    height: 1.125rem; /* 18px / 16 */
    fill: transparent;
    stroke: #333;   
}

/* Legend */
.yec-map-legend {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 0.5rem; /* 8px / 16 */
}

.yec-map-legend h4 {
    margin: 0 0 0.5rem 0; /* 8px / 16 */
    font-size: 0.875rem; /* 14px / 16 */
    font-weight: 600;
    color: var(--yec-map-dark-color);
    width: 100%;
}

.yec-map-legend-item {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 0.25rem 0.5rem; /* 4px 8px / 16 */
    border-radius: 0.25rem; /* 4px / 16 */
    transition: var(--yec-map-transition);
    white-space: nowrap;
}

.yec-map-legend-item:hover {
    background: rgba(0, 0, 0, 0.05);
}

.yec-map-legend-item.filtered {
    opacity: 0.5;
}

.yec-map-legend-dot {
    width: 0.75rem; /* 12px / 16 */
    height: 0.75rem; /* 12px / 16 */
    border-radius: 50%;
    margin-right: 0.5rem; /* 8px / 16 */
    position: relative;
}

.yec-map-legend-dot::before {
    content: '';
    position: absolute;
    top: -0.125rem; /* -2px / 16 */
    left: -0.125rem; /* -2px / 16 */
    right: -0.125rem; /* -2px / 16 */
    bottom: -0.125rem; /* -2px / 16 */
    border-radius: 50%;
    background: inherit;
    opacity: 0.3;
    animation: yec-pulse 3s infinite;
}

.yec-map-legend-label {
    font-size: 0.75rem; /* 12px / 16 */
    color: var(--yec-map-dark-color);
}

/* Custom Markers */
.yec-map-marker , .yec-map-prune-marker {
    width: 0.75rem; /* 12px / 16 */
    height: 0.75rem; /* 12px / 16 */
    border-radius: 50%;
    border: none;
}

.yec-map-marker::before , .yec-map-prune-marker::before {
    content: '';
    position: absolute;
    top: -0.375rem; /* -6px / 16 */
    left: -0.375rem; /* -6px / 16 */
    right: -0.375rem; /* -6px / 16 */
    bottom: -0.375rem; /* -6px / 16 */
    border-radius: 50%;
    background: inherit;
    opacity: 0.4;
    animation: yec-pulse 3s infinite;
    z-index: -1;
}

/* Cluster Icons */
.yec-cluster-wrapper {
    background: transparent !important;
    border: none !important;
}

.yec-cluster-container {
    cursor: pointer;
}

.yec-cluster-icon::before {
    content: '';
    position: absolute;
    top: -0.5rem; /* -8px / 16 */
    left: -0.5rem; /* -8px / 16 */
    right: -0.5rem; /* -8px / 16 */
    bottom: -0.5rem; /* -8px / 16 */
    border-radius: 50%;
    background: rgba(0,0,0,0.08);
    opacity: 0.3;
    animation: yec-pulse 3s infinite;
    z-index: -1;
}

/* Dim/disable other clusters when one is active */
.yec-clusters-busy .leaflet-marker-icon , .yec-clusters-busy .yec-cluster-icon {
    opacity: .25;
    filter: saturate(0.6);
    pointer-events: none;
    transition: opacity .2s ease;
}
.yec-clusters-busy .leaflet-marker-icon.is-active , .yec-clusters-busy .yec-cluster-icon.is-active
.yec-clusters-busy .leaflet-marker-icon.yec-exploded-marker , .yec-clusters-busy .yec-cluster-icon.yec-exploded-marker {
    opacity: .8;
    filter: none;
    pointer-events: auto;
}

/* Vector markers (CircleMarker / Polyline) */
.yec-clusters-busy path.leaflet-interactive {
    opacity: .25;
    pointer-events: none;
}
.yec-clusters-busy path.leaflet-interactive.yec-exploded-marker, .yec-clusters-busy path.leaflet-interactive.yec-cluster-icon {
    opacity: 1;
    pointer-events: auto;
}

/* Popup Styles */
.leaflet-popup-content-wrapper {
    border-radius: 0.5rem; /* 8px / 16 */
    box-shadow: 0 0.25rem 0.75rem rgba(0, 0, 0, 0.15); /* 0 4px 12px / 16 */
    border: none;
    padding: 0;
}

.leaflet-popup-content {
    margin: 0;
    padding: 0;
    border-radius: 0.5rem; /* 8px / 16 */
    overflow: hidden;
}

.yec-map-popup {
    max-width: 18.75rem; /* 300px / 16 */
    min-width: 15.625rem; /* 250px / 16 */
    font-family: inherit;
}

.leaflet-popup-content{
    border-radius: 0;
}

.yec-map-popup-content {
    padding: 1rem; /* 16px / 16 */
}

.yec-map-popup-type {
    font-size: 0.625rem; /* 10px / 16 */
    font-weight: 600;
    margin: 0 0 0.5rem 0; /* 8px / 16 */
    color: #333;
    line-height: 1.3;
}

.yec-map-popup-title {
    font-size: 1.125rem; /* 18px / 16 */
    font-weight: 600;
    margin: 0 0 0.5rem 0; /* 8px / 16 */
    color: #333;
    line-height: 1.3;
}

.yec-map-popup-excerpt {
    font-size: 0.875rem; /* 14px / 16 */
    color: #666;
    margin: 0 0 1rem 0; /* 16px / 16 */
    line-height: 1.5;
}

.yec-map-popup-cta {
    display: inline-block;
    background: #007cba;
    color: white;
    padding: 0.625rem 1.25rem; /* 10px 20px / 16 */
    border-radius: 0.375rem; /* 6px / 16 */
    text-decoration: none;
    font-size: 0.875rem; /* 14px / 16 */
    font-weight: 500;
    transition: all 0.3s ease;
    border: none;
    cursor: pointer;
}

.yec-map-popup-cta:hover {
    background: #005a87;
    color: white;
    text-decoration: none;
    transform: translateY(-0.0625rem); /* -1px / 16 */
}

.leaflet-popup-tip {
    display: none !important;
}

.leaflet-popup-close-button{
    color: white;
    filter: drop-shadow(var(--drop-shadow-md));
}
.leaflet-popup-close-button svg{
    border: 0.03125rem solid black; /* 0.5px / 16 */
}

/* Disabled State */
.yec-map.interaction-disabled {
    pointer-events: none;
}

.yec-map.interaction-disabled::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.1);
    z-index: 999;
    cursor: pointer;
}

/* Animations */
@keyframes yec-pulse {
    0% {
        transform: scale(0);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.1);
        opacity: 0.3;
    }
    100% {
        transform: scale(1.3);
        opacity: 0;
    }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes skeleton-pulse {
    0% { background-color: #e0e0e0; }
    50% { background-color: #f0f0f0; }
    100% { background-color: #e0e0e0; }
}

/* Spinner */
.yec-spinner {
    animation: spin 1s linear infinite;
}

/* Popup Image Container */
.yec-map-popup-image-container {
    aspect-ratio: 16/9;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.25rem; /* 4px / 16 */
    overflow: hidden;
}

.yec-map-popup-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    margin: 0;
}

/* Legend Skeleton */
.yec-map-legend-skeleton {
    display: flex;
    flex-wrap: wrap;
    flex-direction: row;
    gap: 0.5rem; /* 8px / 16 */
}

.yec-map-legend-skeleton-item {
    display: flex;
    align-items: center;
    gap: 0.5rem; /* 8px / 16 */
    padding: 0.25rem 0.5rem; /* 4px 8px / 16 */
}

.yec-map-legend-skeleton-dot {
    width: 0.75rem; /* 12px / 16 */
    height: 0.75rem; /* 12px / 16 */
    border-radius: 50%;
    animation: skeleton-pulse 1.5s ease-in-out infinite;
}

.yec-map-legend-skeleton-label {
    height: 0.875rem; /* 14px / 16 */
    border-radius: 0.25rem; /* 4px / 16 */
    animation: skeleton-pulse 1.5s ease-in-out infinite;
    animation-delay: 0.2s;
}

.yec-map-legend-skeleton-label.short { width: 3.75rem; } /* 60px / 16 */
.yec-map-legend-skeleton-label.medium { width: 5rem; } /* 80px / 16 */
.yec-map-legend-skeleton-label.long { width: 6.25rem; } /* 100px / 16 */

/* Accessibility */
.yec-map-legend-item:focus {
    outline: 0.125rem solid var(--yec-map-primary-color); /* 2px / 16 */
    outline-offset: 0.125rem; /* 2px / 16 */
}

/* Responsive */
@media (max-width: 48rem) { /* 768px / 16 */
    .yec-map-legend-external {
        align-self: stretch;
    }
    

    
    .yec-map-legend h4 {
        font-size: 0.75rem; /* 12px / 16 */
    }
    
    .yec-map-legend-label {
        font-size: 0.6875rem; /* 11px / 16 */
    }
    
    .yec-map-popup {
        max-width: 15rem; /* 240px / 16 */
    }
    
    .yec-map-popup-content {
        padding: 0.75rem; /* 12px / 16 */
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .yec-map-legend {
        background: white;
        border: 0.125rem solid black; /* 2px / 16 */
    }
    
    .yec-map-interaction-control {
        border-color: black;
    }
    
    .yec-map-popup-cta {
        border: 0.125rem solid black; /* 2px / 16 */
    }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
    .yec-map-marker::before,
    .yec-map-legend-dot::before {
        animation: none;
    }
    
    * {
        transition: none !important;
    }
}

/*
 * Animazione di apertura dei cluster della mappa
 */

/* Stato iniziale del marker esploso */
.yec-exploded-marker {
  /* Usa le variabili CSS impostate da JavaScript per la posizione iniziale */
  transform: translate(var(--dx, 0), var(--dy, 0));
  opacity: 0;
  transition: transform 0.3s cubic-bezier(0.25, 0.8, 0.25, 1), opacity 0.2s ease-out;
}

/* Stato iniziale della linea di collegamento */
.yec-exploded-line {
  opacity: 0;
  transition: opacity 0.3s ease-in;
}

/* Stato finale (visibile) del marker, quando la classe .is-visible viene aggiunta */
.yec-exploded-marker.is-visible {
  transform: translate(0, 0);
  opacity: 0.9;
}

/* Stato finale (visibile) della linea */
.yec-exploded-line.is-visible {
  opacity: 0.7;
}