/**
 * Interactive Park Maps Styles
 * 
 * @package StateParksCPT
 * @version 1.0.0
 */

/* ==========================================================================
   Map Container
   ========================================================================== */

.asp-park-map {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    position: relative;
    background: #e5e7eb;
}

.asp-park-map[data-loading="true"]::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #2d5016;
    border-top-color: transparent;
    border-radius: 50%;
    animation: asp-spin 0.8s linear infinite;
    z-index: 1000;
}

@keyframes asp-spin {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}

/* ==========================================================================
   Custom Marker
   ========================================================================== */

.asp-map-marker {
    background: transparent !important;
    border: none !important;
}

.asp-map-marker svg {
    width: 32px;
    height: 40px;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
    transition: transform 0.2s ease;
}

.asp-map-marker:hover svg {
    transform: scale(1.1);
}

/* ==========================================================================
   Marker Clusters (Dynamic Colors)
   Background colors are set inline via JavaScript based on activity category
   ========================================================================== */

.asp-marker-cluster {
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
    border: 3px solid #fff;
}

.asp-marker-cluster div {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    border-radius: 50%;
}

.asp-marker-cluster span {
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

.asp-marker-cluster-small {
    width: 36px !important;
    height: 36px !important;
}

.asp-marker-cluster-medium {
    width: 44px !important;
    height: 44px !important;
}

.asp-marker-cluster-medium span {
    font-size: 15px;
}

.asp-marker-cluster-large {
    width: 52px !important;
    height: 52px !important;
}

.asp-marker-cluster-large span {
    font-size: 16px;
}

/* ==========================================================================
   Popups
   ========================================================================== */

.leaflet-popup-content-wrapper {
    border-radius: 12px;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.2);
}

.leaflet-popup-content {
    margin: 0;
    min-width: 200px;
}

.asp-map-popup {
    display: flex;
    flex-direction: column;
}

.asp-popup-thumb {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.asp-popup-content {
    padding: 12px 16px;
}

.asp-popup-title {
    display: block;
    font-weight: 600;
    font-size: 15px;
    color: #1a1a1a;
    text-decoration: none;
    line-height: 1.3;
    margin-bottom: 4px;
}

.asp-popup-title:hover {
    color: #2d5016;
}

.asp-popup-state {
    display: block;
    font-size: 13px;
    color: #666;
    margin-bottom: 8px;
}

/* Activity Tags in Popup */
.asp-popup-activities {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.asp-popup-activity {
    display: inline-block;
    padding: 3px 8px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 12px;
    white-space: nowrap;
    border: 1px solid;
    /* Colors are set inline via JavaScript */
}

.asp-popup-link {
    text-decoration: none;
    color: inherit;
}

.leaflet-popup-tip {
    background: #fff;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

/* ==========================================================================
   Map Count
   ========================================================================== */

.asp-map-count {
    text-align: center;
    padding: 12px 0;
    font-size: 14px;
    color: #666;
}

.asp-map-count-number {
    font-weight: 700;
    color: #2d5016;
    font-size: 18px;
}

/* ==========================================================================
   Map Wrapper & Legend
   ========================================================================== */

.asp-map-wrapper {
    position: relative;
}

/* Legend Base — Card-style, position absolute on map */
.asp-map-wrapper .asp-map-legend {
    position: absolute !important;
    bottom: 20px !important;
    left: 20px !important;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.97) !important;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border-radius: 14px !important;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12), 0 0 0 1px rgba(0, 0, 0, 0.04) !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 13px !important;
    overflow: hidden;
}

/* Single Legend (Activity Archives) */
.asp-map-wrapper .asp-map-legend.asp-map-legend-single {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 12px 16px !important;
}

/* Multi Legend (State Archives) */
.asp-map-wrapper .asp-map-legend.asp-map-legend-multi {
    min-width: 220px;
    max-width: 280px;
}

.asp-map-wrapper .asp-map-legend .asp-legend-toggle {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    width: 100% !important;
    padding: 12px 16px !important;
    background: linear-gradient(180deg, #f8f9f7 0%, #f1f3ef 100%) !important;
    border: none !important;
    border-bottom: 1px solid rgba(0,0,0,0.05) !important;
    cursor: pointer !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    letter-spacing: 0.02em;
    color: #2d5016 !important;
    text-align: left !important;
    border-radius: 14px 14px 0 0 !important;
    transition: background 0.2s !important;
    text-transform: uppercase;
}

.asp-map-wrapper .asp-map-legend .asp-legend-toggle:hover {
    background: linear-gradient(180deg, #f1f3ef 0%, #e9ece6 100%) !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-toggle svg {
    flex-shrink: 0 !important;
    color: #2d5016 !important;
    opacity: 0.85;
}

.asp-map-wrapper .asp-map-legend .asp-legend-toggle[aria-expanded="false"] {
    border-bottom: none !important;
    border-radius: 14px !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-toggle[aria-expanded="false"] + .asp-legend-items {
    display: none !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-items {
    display: flex !important;
    flex-direction: column !important;
    gap: 1px !important;
    padding: 8px !important;
    max-height: 280px !important;
    overflow-y: auto !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-item {
    display: flex !important;
    align-items: center !important;
    gap: 10px !important;
    padding: 8px 10px !important;
    border-radius: 8px !important;
    transition: background 0.18s !important;
    cursor: default !important;
    line-height: 1.3 !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-item:hover {
    background: rgba(0, 0, 0, 0.05) !important;
}

/* Pin-shaped marker icon instead of round dot — matches map markers */
.asp-map-wrapper .asp-map-legend .asp-legend-dot {
    /* Pin-shaped marker icon — inherits color from inline style="background-color: ..."
       The mask cuts the pin shape out of whatever background-color is set inline */
    width: 18px !important;
    height: 22px !important;
    flex-shrink: 0 !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    /* background-color is set via inline style attr — do NOT override */
    -webkit-mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z'/><circle cx='12' cy='9' r='2.5' fill='white'/></svg>") !important;
    mask-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'><path d='M12 2C8.13 2 5 5.13 5 9c0 5.25 7 13 7 13s7-7.75 7-13c0-3.87-3.13-7-7-7z'/><circle cx='12' cy='9' r='2.5' fill='white'/></svg>") !important;
    -webkit-mask-size: contain !important;
    mask-size: contain !important;
    -webkit-mask-repeat: no-repeat !important;
    mask-repeat: no-repeat !important;
    -webkit-mask-position: center !important;
    mask-position: center !important;
    display: inline-block !important;
}

.asp-map-wrapper .asp-map-legend .asp-legend-label {
    color: #333 !important;
    font-weight: 500 !important;
    white-space: nowrap !important;
    overflow: hidden !important;
    text-overflow: ellipsis !important;
    flex: 1 !important;
}

/* Slim scrollbar */
.asp-map-wrapper .asp-map-legend .asp-legend-items::-webkit-scrollbar {
    width: 5px !important;
}
.asp-map-wrapper .asp-map-legend .asp-legend-items::-webkit-scrollbar-track {
    background: transparent !important;
}
.asp-map-wrapper .asp-map-legend .asp-legend-items::-webkit-scrollbar-thumb {
    background: rgba(45, 80, 22, 0.2) !important;
    border-radius: 3px !important;
}
.asp-map-wrapper .asp-map-legend .asp-legend-items::-webkit-scrollbar-thumb:hover {
    background: rgba(45, 80, 22, 0.4) !important;
}

/* Park-Count below the map — prominenter */
.asp-map-count {
    text-align: center !important;
    padding: 14px 0 !important;
    font-size: 14px !important;
    color: #777 !important;
    letter-spacing: 0.02em;
}
.asp-map-count-number {
    font-weight: 800 !important;
    color: #2d5016 !important;
    font-size: 20px !important;
    margin-right: 4px;
}


/* ==========================================================================
   Leaflet Overrides
   ========================================================================== */

.leaflet-control-zoom {
    border: none !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15) !important;
    border-radius: 8px !important;
    overflow: hidden;
}

.leaflet-control-zoom a {
    width: 32px !important;
    height: 32px !important;
    line-height: 32px !important;
    font-size: 16px !important;
    color: #333 !important;
    background: #fff !important;
    border: none !important;
}

.leaflet-control-zoom a:hover {
    background: #f5f5f5 !important;
}

.leaflet-control-attribution {
    font-size: 10px;
    background: rgba(255, 255, 255, 0.8) !important;
    padding: 2px 6px !important;
    border-radius: 4px 0 0 0;
}

/* ==========================================================================
   Map in Single Park Template
   ========================================================================== */

.sp-single-map-section {
    max-width: 100%;
    padding: 40px clamp(20px, 5vw, 80px);
}

.sp-single-map-header {
    margin-bottom: 24px;
}

.sp-single-map-header h2 {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 1.5rem;
    font-weight: 700;
    color: #1a5a1a;
    margin: 0;
}

.sp-single-map-header svg {
    width: 28px;
    height: 28px;
    color: #4CAF50;
}

.sp-single-map-container {
    width: 100%;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.sp-single-map-container .asp-park-map {
    width: 100% !important;
    min-height: 450px;
}

.sp-single-map-address {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 16px;
    padding: 12px 16px;
    background: #f8faf8;
    border-radius: 8px;
    font-size: 0.95rem;
    color: #333;
}

.sp-map-address-icon {
    color: #1a5a1a;
}

.sp-map-address-icon svg {
    width: 18px;
    height: 18px;
}

/* ==========================================================================
   Map in State Archive Template
   ========================================================================== */

.sp-map-section {
    padding: 60px 0;
    background: linear-gradient(to bottom, #f8faf8, #fff);
}

.sp-map-section .sp-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

.sp-map-container {
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

.sp-map-container .asp-park-map {
    border-radius: 0;
}

/* ==========================================================================
   Map in Activity Archive Template
   ========================================================================== */

.sp-activity-map-section {
    padding: 40px 20px;
    background: linear-gradient(135deg, #f0f7f0 0%, #e8f5e9 100%);
    margin-bottom: 40px;
}

.sp-activity-map-header {
    max-width: 1200px;
    margin: 0 auto 24px;
    text-align: center;
}

.sp-activity-map-header h2 {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    font-size: 1.75rem;
    font-weight: 700;
    color: #1a5a1a;
    margin: 0 0 12px;
}

.sp-activity-map-header h2 svg {
    width: 32px;
    height: 32px;
    color: #4CAF50;
}

.sp-activity-map-header p {
    font-size: 1.1rem;
    color: #666;
    margin: 0;
}

.sp-activity-map-container {
    max-width: 1200px;
    margin: 0 auto;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.12);
}

/* ==========================================================================
   Responsive
   ========================================================================== */

@media (max-width: 992px) {
    .sp-single-map-section {
        padding: 24px;
    }

    .sp-map-section {
        padding: 40px 0;
    }

    .sp-activity-map-section {
        padding: 32px 16px;
    }

    .sp-activity-map-header h2 {
        font-size: 1.5rem;
    }
}

@media (max-width: 768px) {
    .asp-park-map-multi {
        height: 350px !important;
    }

    .asp-popup-thumb {
        height: 100px;
    }

    .leaflet-popup-content {
        min-width: 180px;
    }

    .sp-single-map-section {
        padding: 16px;
    }

    .sp-single-map-header h2 {
        font-size: 1.25rem;
    }

    .sp-activity-map-header h2 {
        font-size: 1.25rem;
        flex-direction: column;
        gap: 8px;
    }

    .sp-activity-map-header p {
        font-size: 1rem;
    }
}

/* ==========================================================================
   Mobile Legend - Better touch experience
   ========================================================================== */

@media (max-width: 640px) {
    .asp-map-wrapper .asp-map-legend {
        /* Position below map instead of overlaying */
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        margin: 12px !important;
        width: calc(100% - 24px) !important;
        max-width: none !important;
    }

    .asp-map-wrapper .asp-map-legend.asp-map-legend-multi {
        max-width: none !important;
    }

    .asp-map-wrapper .asp-map-legend .asp-legend-items {
        max-height: 150px !important;
        /* Reduced height for mobile */
    }

    .asp-legend-toggle {
        padding: 12px 16px;
        /* Larger touch target */
    }
}