* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    height: 100%;
    overflow: hidden; /* Prevent scrolling */
}

body {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    background: #f8fafc;
    color: #1e293b;
    font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    text-rendering: optimizeLegibility;
    -webkit-font-smoothing: antialiased;
}

.site-header {
    flex: 0 0 auto;
    background: rgba(255, 255, 255, 0.96);
    border-bottom: 1px solid #e2e8f0;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
    z-index: 20;
}

.site-header-inner {
    max-width: 72rem;
    min-height: 74px;
    margin: 0 auto;
    padding: 10px 24px;
    display: grid;
    grid-template-columns: auto minmax(220px, 1fr) minmax(230px, 250px);
    align-items: center;
    gap: 18px 24px;
}

.site-logo-link {
    display: inline-flex;
    align-items: center;
    flex: 0 0 auto;
}

.site-logo {
    display: block;
    width: auto;
    max-width: 54vw;
    height: 40px;
}

.map-shell {
    flex: 1 1 auto;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.tool-heading {
    min-width: 0;
}

.tool-heading p {
    margin: 0 0 4px;
    color: #256384;
    font-size: 11px;
    font-weight: 800;
    line-height: 1.1;
    text-transform: uppercase;
}

.tool-heading h1 {
    margin: 0;
    color: #0f172a;
    font-size: 21px;
    font-weight: 750;
    line-height: 1.15;
}

#map-container {
    position: relative; /* Keep for map controls */
    width: 100%;
    flex: 1 1 auto;
    min-height: 0;
}

#map {
    width: 100%;
    height: 100%;
    min-height: 0;
    margin: 0;
    padding: 0;
}

.mapboxgl-ctrl-geocoder {
    width: 40px;
    min-width: 40px;
    max-width: 40px;
    transition: max-width 0.3s ease;
    position: relative; /* Ensure dropdown positions correctly */
}

.mapboxgl-ctrl-geocoder.active,
.mapboxgl-ctrl-geocoder:focus-within {
    max-width: 300px;
    width: clamp(200px, 50%, 300px); /* Responsive width */
}

.mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--input {
    font-size: 16px;
    line-height: 20px;
}

.mapboxgl-ctrl-geocoder .suggestions {
    position: absolute;
    top: 100%; /* Place dropdown below the input */
    left: 0;
    width: 100%; /* Match expanded width */
    max-width: 300px;
    z-index: 1000; /* Ensure dropdown is above other elements */
    background: white;
    border: 1px solid #ccc;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

#slider-container {
    width: 100%;
    margin: 0;
    background-color: white;
    border: 1px solid #dbe3eb;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(15, 23, 42, 0.12);
    font-size: 13px;
    padding: 8px 10px 6px 10px;
    text-align: left;
}

#contour-slider {
    width: 100%;
}

#slider-container label {
    display: block;
    margin-top: 2px;
    color: #334155;
    font-weight: 600;
}

.proportion-hidden {
    display: none;
}

.coords-hidden {
    display: none;
}

.sds-hidden {
    display: none;
}

#coordinate-container {
    position: absolute;
    bottom: 10px;
    right: 5px;
    z-index: 10;
    font-size: 10px;
    opacity: 0.7; /* Slightly transparent */
    color: #333; /* Optional: Adjust text color for visibility */
    background-color: white; /* Optional: Background for better visibility */
    opacity: 0.7; /* Slightly transparent */
    padding: 0px 3px;
    line-height: 0.05;
}

#sds-container {
    min-height: 42px;
    padding: 8px 14px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px 12px;
    background: white;
    border-top: 1px solid #dbe3eb;
    font-size: 14px; /* Adjust as needed */
    color: #333;
}

#sds-container span {
    display: inline; /* Single line */
    margin-right: 0;
}

#sds-container.sds-hidden {
    visibility: hidden;
}

#sds-container a {
    color: #0066cc;
    text-decoration: none;
}

#sds-container a:hover {
    text-decoration: underline;
}

/* Style the popup container */
.mapboxgl-popup-content {
    background-color: #ffffff; /* White background */
    opacity: 0.8; /* Slightly transparent */
    border-radius: 1px; /* Rounded corners */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15); /* Subtle shadow */
    padding: 2px 10px 1px 2px; /* top, right, bottom, left padding */
    font-size: 14px; /* Adjust font size */
    color: #333; /* Text color */
}

/* Style the popup close button */
.mapboxgl-popup-close-button {
    color: #666; /* Close button color */
    font-size: 16px; /* Adjust close button size */
    top: -2px; /* Adjust position */
    right: -8px; /* Move further to the right */
}

/* Hover effect for the close button */
.mapboxgl-popup-close-button:hover {
    color: #000; /* Darker color on hover */
}

/* Style the popup tip (the little arrow pointing to the marker) */
.mapboxgl-popup-tip {
    border-top-color: #ffffff; /* Match the popup background */
    opacity: 0; /* Slightly transparent */
}

/* Mobile adjustments for map */
@media (max-width: 700px) {
    .site-header-inner {
        grid-template-columns: auto minmax(0, 1fr) minmax(96px, 28vw);
        min-height: 0;
        padding: 8px 10px;
        align-items: center;
        gap: 8px;
    }

    .site-logo {
        width: auto;
        max-width: 82vw;
        height: 30px;
    }

    .tool-heading p {
        margin-bottom: 2px;
        font-size: 9px;
    }

    .tool-heading h1 {
        font-size: clamp(13px, 4vw, 18px);
    }

    #slider-container {
        width: 100%;
        min-width: 0;
        padding: 5px 7px 4px;
        font-size: 11px;
    }

    #slider-container label {
        margin-top: 0;
        white-space: nowrap;
    }

    .mapboxgl-ctrl-geocoder {
        width: 30px;
        min-width: 30px;
        max-width: 30px;
    }

    .mapboxgl-ctrl-geocoder.active,
    .mapboxgl-ctrl-geocoder:focus-within {
        max-width: 200px; /* Smaller expanded width on mobile */
        width: 100%;
    }

    .mapboxgl-ctrl-geocoder .mapboxgl-ctrl-geocoder--input {
        font-size: 16px; /* Prevents iOS Safari from page-zooming on focus. */
    }
}

@media (max-width: 360px) {
    .site-header-inner {
        grid-template-columns: auto 1fr;
    }

    #slider-container {
        grid-column: 1 / -1;
    }
}
