/* Map Sidebar Styles
   Copyright (c) 2023-2025 Christian Werner, WERNER.Solutions <office@werner.solutions> */

/* Map loading overlay */
#map {
    width: 100%;
    height: calc(100dvh - 200px);
    min-height: 500px;
    position: relative;
}

/* Tighten the hero/heading spacing above the map on mobile — the map is
   the main content of this page, it shouldn't need a long scroll to reach. */
@media (max-width: 768px) {
    body.page-id-20 .article-header {
        padding-top: 12px;
        padding-bottom: 12px;
        margin-bottom: 8px;
    }

    body.page-id-20 .entry-content {
        margin-bottom: 8px;
    }
}

.map-loading-overlay {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: #f5f3ee;
    z-index: 999;
    gap: 16px;
    color: #666;
    font-size: 14px;
}

.map-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0ddd6;
    border-top-color: #4CAF50;
    border-radius: 50%;
    animation: map-spin 0.8s linear infinite;
}

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

.map-loading-overlay p {
    max-width: 420px;
    text-align: center;
    margin: 0;
}

.map-load-anyway-btn {
    background: #4CAF50;
    color: #fff;
    border: none;
    border-radius: 4px;
    padding: 10px 20px;
    font-size: 14px;
    cursor: pointer;
}

.map-load-anyway-btn:hover,
.map-load-anyway-btn:focus {
    background: #3d8b40;
}

/* Full-width breakout from WP content container */
.map-sidebar-wrapper {
    display: flex;
    width: 100vw;
    height: calc(100dvh - 200px);
    min-height: 500px;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
    overflow: hidden;
    border-top: 1px solid #ddd;
    border-bottom: 1px solid #ddd;
}

/* Sidebar Container */
.grenzstein-sidebar {
    position: absolute;
    top: 0;
    right: 0;
    width: 0;
    height: 100%;
    background: white;
    box-shadow: -2px 0 5px rgba(0,0,0,0.2);
    transition: width 0.3s ease-in-out;
    z-index: 1000;
    overflow: hidden;
}

/* Sidebar Open State */
.grenzstein-sidebar.open {
    width: 350px;
}

/* Close Button */
.sidebar-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 30px;
    height: 30px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 50%;
    cursor: pointer;
    font-size: 20px;
    line-height: 26px;
    text-align: center;
    z-index: 1001;
    transition: background 0.2s;
}

.sidebar-close:hover {
    background: #f0f0f0;
}

/* Sidebar Content */
.sidebar-content {
    padding: 50px 20px 20px;
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    box-sizing: border-box;
}

.sidebar-content h3 {
    margin: 0 0 15px 0;
    color: #333;
    font-size: 20px;
    font-weight: bold;
    border-bottom: 2px solid #4CAF50;
    padding-bottom: 10px;
}

.sidebar-content p {
    margin: 10px 0;
    font-size: 14px;
    line-height: 1.6;
}

.sidebar-content .meta {
    color: #666;
    font-size: 13px;
    margin-bottom: 15px;
}

.sidebar-content .meta strong {
    color: #333;
}

/* Sidebar Image */
.sidebar-image {
    width: 100%;
    margin: 20px 0;
    border-radius: 4px;
    overflow: hidden;
}

.sidebar-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Description Text */
.sidebar-description {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-left: 3px solid #4CAF50;
    border-radius: 3px;
}

/* Links in Sidebar */
.sidebar-links {
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #ddd;
}

.sidebar-links a {
    display: inline-block;
    padding: 8px 15px;
    background: #4CAF50;
    color: white;
    text-decoration: none;
    border-radius: 3px;
    font-size: 13px;
    transition: background 0.3s;
}

.sidebar-links a:hover {
    background: #45a049;
}

/* Map Container Adjustment */
.map-with-sidebar {
    width: 100%;
    height: 100%;
    position: relative;
    overflow: hidden;
    transition: width 0.3s ease-in-out;
    flex-shrink: 0;
}

/* When sidebar is open, reduce map width */
.map-sidebar-wrapper.sidebar-open .map-with-sidebar {
    width: calc(100% - 350px);
}

/* Highlighted Marker */
.leaflet-marker-selected {
    filter: hue-rotate(120deg) brightness(1.5) drop-shadow(0 0 10px rgba(255, 215, 0, 0.8));
    z-index: 1000 !important;
    transform: scale(1.2);
    transition: all 0.3s ease;
}

.leaflet-marker-selected img {
    border: 3px solid #ffd700;
    border-radius: 50%;
    box-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
}

/* Hide drag handle by default (desktop) */
.sidebar-drag-handle {
    display: none;
}

/* Mobile and Tablet Styles - Bottom Sidebar */
@media (max-width: 1020px) {
    .map-sidebar-wrapper {
        display: block;
        width: 100vw;
        height: auto;
        min-height: calc(100dvh - 200px);
        overflow: hidden;
    }

    .grenzstein-sidebar {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        width: 100%;
        height: 0;
        max-height: none;
        transition: height 0.3s ease-in-out;
        border-radius: 0;
        box-shadow: 0 -2px 5px rgba(0,0,0,0.2);
        z-index: 1001;
        overflow: hidden;
        margin-top: -1px;
    }

    .grenzstein-sidebar.open {
        height: auto;
        max-height: 60vh;
        width: 100%;
        border-top: 1px solid #ddd;
        overflow-y: auto;
    }

    /* Map stays full width and uses dvh */
    .map-with-sidebar {
        width: 100%;
        height: calc(100dvh - 200px);
        min-height: 500px;
    }

    .map-sidebar-wrapper.sidebar-open .map-with-sidebar {
        width: 100%;
        height: calc(100dvh - 200px);
        min-height: 500px;
    }

    .sidebar-content {
        padding: 50px 20px 30px;
        height: auto;
        min-height: 200px;
        overflow-y: auto;
        overflow-x: hidden;
    }

    /* Add drag handle for mobile */
    .sidebar-drag-handle {
        display: block;
        position: absolute;
        top: 10px;
        left: 50%;
        transform: translateX(-50%);
        width: 40px;
        height: 4px;
        background: #ccc;
        border-radius: 2px;
    }

    /* Close button positioning for mobile */
    .grenzstein-sidebar.open .sidebar-close {
        position: absolute;
        top: 10px;
        right: 10px;
    }
}

/* Loading State */
.sidebar-loading {
    text-align: center;
    padding: 50px 20px;
}

.sidebar-loading:after {
    content: "Lade Grenzstein-Daten...";
    color: #666;
    font-style: italic;
}