/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    overflow: hidden;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Full screen map */
#map {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 100%;
    height: 100vh;
}

#loading-message {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    padding: 10px 20px;
    border-radius: 5px;
    font-size: 1.25rem;
    color: #333;
    display: none;
}

/* Mapbox controls positioning */
.mapboxgl-ctrl-top-right {
    top: 10px;
    right: 10px;
}

.mapboxgl-ctrl-top-left {
    top: 10px;
    left: 10px;
}

.mapboxgl-ctrl-bottom-left {
    bottom: 10px;
    left: 10px;
}

.mapboxgl-ctrl-bottom-right {
    bottom: 10px;
    right: 10px;
}

/* Custom popup styles with pencil-drawn aesthetic */
.mapboxgl-popup {
    max-width: 320px;
}

.pencil-popup .mapboxgl-popup-content {
    padding: 18px;
    border-radius: 3px;
    background: #FDFBF7;
    border: 2px solid #4A4A4A;
    border-style: solid;
    border-width: 1.5px 2px 2px 1.5px;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    font-family: 'Georgia', serif;
    color: #2C2C2C;
}

.pencil-popup .mapboxgl-popup-content h3 {
    font-family: 'Georgia', serif;
    color: #2C2C2C;
    border-bottom: 1px dashed #8B8B8B;
    padding-bottom: 8px;
    margin-bottom: 10px;
}

.pencil-popup .mapboxgl-popup-content p {
    font-size: 14px;
    line-height: 1.5;
    margin: 8px 0;
}

.pencil-popup .mapboxgl-popup-content a {
    color: #556B2F;
    text-decoration: underline;
    text-decoration-style: wavy;
    text-underline-offset: 2px;
}

.pencil-popup .mapboxgl-popup-content a:hover {
    color: #8B4513;
}

.pencil-popup .mapboxgl-popup-tip {
    border-top-color: #4A4A4A;
}

.mapboxgl-popup-close-button {
    font-size: 20px;
    padding: 5px;
    color: #4A4A4A;
}

/* Wine marker styles */
.wine-marker {
    background-image: url('data:image/svg+xml;charset=utf-8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23722f37"><path d="M5 21h14v2H5v-2zm7-2c-3.31 0-6-2.69-6-6 0-2.97 2.16-5.43 5-5.91V3h8v4.09c2.84.48 5 2.94 5 5.91 0 3.31-2.69 6-6 6h-6z"/></svg>');
    background-size: cover;
    width: 30px;
    height: 30px;
    cursor: pointer;
}

/* Loading spinner */
.loading-spinner {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #722f37;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* Map title overlay */
#map-title {
    position: absolute;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 100;
    background: rgba(253, 251, 247, 0.95);
    padding: 15px 30px;
    border: 2px solid #4A4A4A;
    border-radius: 3px;
    text-align: center;
    pointer-events: none;
    box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}

#map-title h1 {
    font-family: 'Georgia', serif;
    font-size: 28px;
    color: #2C2C2C;
    margin: 0;
    letter-spacing: 1px;
}

#map-title p {
    font-family: 'Georgia', serif;
    font-size: 14px;
    color: #6B6B6B;
    margin: 5px 0 0 0;
    font-style: italic;
}

/* Mobile responsive */
@media (max-width: 768px) {
    .mapboxgl-popup-content {
        max-width: 250px;
    }
    
    #map-title {
        top: 10px;
        padding: 10px 20px;
    }
    
    #map-title h1 {
        font-size: 22px;
    }
    
    #map-title p {
        font-size: 12px;
    }
}

@media (prefers-color-scheme: dark) {
    body {
        background-color: #111;
        color: #e0e0e0;
    }

    #loading-message {
        background: rgba(0, 0, 0, 0.85);
        color: #eee;
    }

    #map-title {
        background: rgba(34, 34, 34, 0.95);
        border-color: #bbb;
        box-shadow: 3px 3px 0 rgba(255, 255, 255, 0.1);
    }

    #map-title h1 {
        color: #f0f0f0;
    }

    #map-title p {
        color: #ccc;
    }

    .pencil-popup .mapboxgl-popup-content {
        background: #FDFBF7;
        border-color: #4A4A4A;
        color: #2C2C2C;
        box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
    }

    .pencil-popup .mapboxgl-popup-content h3 {
        color: #2C2C2C;
        border-bottom-color: #8B8B8B;
    }

    .pencil-popup .mapboxgl-popup-content a {
        color: #556B2F;
    }

    .pencil-popup .mapboxgl-popup-content a:hover {
        color: #8B4513;
    }

    .pencil-popup .mapboxgl-popup-tip {
        border-top-color: #4A4A4A;
    }
}
