/* css/mjm-main-map.css */
html, body {
    margin: 0;
    padding: 0;
    min-height: 100%;
}

.map-container {
    position: relative;
    height: 600px; /* Fixed height, adjust as needed */
    margin: 0; /* Remove any theme margins */
    padding: 0; /* Remove any theme padding */
    left: 0; /* Align to left edge */
    overflow: visible; /* Allow popups to extend beyond container boundaries */
}

.is-layout-constrained > :where(:not(.alignleft):not(.alignright):not(.alignfull)) {
    max-width:100%!important;
}

#map {
    width: 100%; /* Fills .map-container */
    height: 100%; /* Matches .map-container height */
    position: absolute; /* Ensures it fills the container */
    top: 0;
    left: 0;
}

#search-toggle-container {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 11;
    background: rgba(255, 255, 255, 0.82);
    padding: 12px;
    border-radius: 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08), 0 0 0 1px rgba(150, 211, 229, 0.15);
    display: flex;
    flex-direction: column;
    gap: 10px;
    width: 22.5%;
    min-width: 250px;
    pointer-events: none;
    border-top: 3px solid #ff4a0a;
}

.search-row {
    display: flex;
    width: 100%;
    justify-content: flex-start;
}

.filter-row {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    flex-wrap: wrap;
    justify-content: flex-start;
}

.filter-row > #filter-mode {
    flex: 1 1 0;
    min-width: 0;
    order: 1;
}

.filter-row > .toggle-switch {
    flex: 0 0 auto;
    order: 2;
}

.filter-row > .date-filters {
    flex: 1 1 100%;
    min-width: 100%;
    order: 3;
}

#map-search,
#filter-mode,
#start-year,
#end-year,
.toggle-switch,
.date-filters,
.zoom-controls,
.zoom-btn {
    pointer-events: auto; /* Re-enable clicks on these */
}

#map-search {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 13px;
    background-color: #fff;
    box-sizing: border-box;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#map-search::placeholder {
    color: #999;
}

#map-search:hover {
    border-color: #ff4a0a;
}

#filter-mode {
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 12px;
    background-color: #fff;
    color: #333;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="%23ff4a0a" d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#filter-mode:hover {
    border-color: #ff4a0a;
}

.date-filters {
    display: flex;
    align-items: center;
    gap: 5px;
    flex: 1;
    min-width: 0;
}

#start-year,
#end-year {
    flex: 1;
    min-width: 0;
    padding: 8px 10px;
    border: 1px solid #ccc;
    border-radius: 5px;
    font-size: 12px;
    background-color: #fff;
    color: #333;
    box-sizing: border-box;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="12" height="12" viewBox="0 0 24 24"><path fill="%23ff4a0a" d="M7 10l5 5 5-5z"/></svg>');
    background-repeat: no-repeat;
    background-position: right 8px center;
    background-size: 16px;
    padding-right: 30px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

#start-year:hover,
#end-year:hover {
    border-color: #ff4a0a;
}

.date-separator {
    color: #c9c9c9;
    font-weight: bold;
    font-size: 14px;
}

.toggle-switch {
    flex: 0 0 50px;
    position: relative;
    margin-left: 0;
    display: inline-block;
    width: 50px;
    height: 28px;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #c9c9c9;
    transition: background-color .4s;
    border-radius: 28px;
    overflow: hidden;
}

.slider-icon {
    position: absolute;
    height: 22px;
    width: 22px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    border-radius: 50%;
    text-align: center;
    line-height: 22px!important;
    font-size: 13px;
    color: #96D3E5;
    transition: transform .4s, color .4s;
}

input:checked + .slider .slider-icon {
    color: #ff4a0a;
}

input:checked + .slider {
    background-color: #ff4a0a;
}

input:checked + .slider .slider-icon {
    transform: translateX(22px); /* Slide right when checked */
}


#exhibit-list {
    position: relative;
    width: 100%;
    background: white;
    padding: 10px;
    overflow-y: auto;
    z-index: 10;
    display: none;
    border-radius: 5px;
    top:75px;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
    max-height: 600px;
}

.exhibit-group {
    margin-bottom: 10px;
}

.exhibit-title {
    display: flex;
    align-items: center;
    padding: 5px 0;
    position: relative;
}

.exhibit-title-text {
    text-decoration: none;
    color: inherit;
    pointer-events: auto;
}

.exhibit-title a {
    color: black;
    text-decoration: none !important;
}

.exhibit-title a:hover {
    color:  #ff4a0a;
}

.expand-toggle {
    display: inline-block;
    width: 20px;
    height: 20px;
    text-align: center;
    margin-right: 10px;
    font-size: 16px;
    font-weight: bold;
    color: #ff4a0a;
    cursor: pointer;
}

.exhibit-title[data-expandable="true"] {
    cursor: pointer;
}

.exhibit-title[data-expandable="true"]::before {
    content: "+";
    display: inline-block;
    width: 20px;
    height: 33px;
    text-align: center;
    margin-right: 10px;
    font-size: 24px;
    font-weight: 400;
    color: #ff4a0a;
}

.exhibit-title[data-expandable="true"][aria-expanded="true"]::before {
    content: "−";
}

.exhibit-count {
    margin-left: 10px;
    font-size: 12px;
    color: #666;
}

.exhibit-subitems {
    margin-left: 30px; /* Indent sub-items */
    padding: 5px 0;
}

.exhibit-item {
    padding: 5px 0;
}

.exhibit-item a {
    text-decoration: none;
    color: inherit;
    pointer-events: auto; /* Ensure links receive pointer events */
}

.exhibit-item a:hover {
    color:  #ff4a0a;
}

.carousel {
    max-width: 100%;
}

/* Ensure uniform column sizes and height */
.carousel .row {
    display: flex;
    flex-wrap: nowrap; /* Prevent wrapping within carousel */
    margin: 0; /* Remove row margins */
}

.carousel .col-md-4 {
    flex: 0 0 33.333333%; /* Exact thirds */
    max-width: 33.333333%;
    padding: 5px; /* Match g-2 gutter */
    height: 200px; /* Fixed container height */
    display: flex; /* Center image vertically */
    align-items: center; /* Vertical centering */
}

/* Uniform image size */
.exhibit-image {
    width: 100%; /* Full column width */
    height: 200px!important; /* Fixed height */
    object-fit: cover; /* Crop to fit */
    cursor: pointer; /* Indicate clickability */
    display: block; /* Prevent alignment issues */
}

/* Modal image */
.modal-body .img-fluid {
    max-height: 70vh; /* Limit height */
    width: 100%;
    object-fit: contain; /* Show full image */
}

.exhibit-image .img-fluid {
    height: 200px!important;
}

/* Ensure Mapbox map fits */
#single-exhibit-map {
    width: 100% !important;
    height: 400px;
}

.mapboxgl-ctrl-top-right {
    display: none !important;
}

/* ============================================
   ACCESSIBILITY IMPROVEMENTS
   ============================================ */

/* Focus styles for form elements */
#map-search:focus,
#filter-mode:focus,
#start-year:focus,
#end-year:focus {
    outline: none;
    border-color: #ff4a0a;
    box-shadow: 0 0 0 3px rgba(255, 74, 10, 0.2);
}

/* Focus styles for toggle switch */
.toggle-switch input:focus + .slider {
    outline: 2px solid #ff4a0a;
    outline-offset: 2px;
}

.toggle-switch input:focus:not(:focus-visible) + .slider {
    outline: none;
}

/* Focus styles for expandable titles */
.exhibit-title[data-expandable="true"]:focus {
    outline: 2px solid #ff4a0a;
    outline-offset: 2px;
    border-radius: 4px;
}

.exhibit-title[data-expandable="true"]:focus:not(:focus-visible) {
    outline: none;
}

/* Focus styles for links */
.exhibit-title a:focus,
.exhibit-item a:focus {
    outline: 2px solid #ff4a0a;
    outline-offset: 2px;
}

.exhibit-title a:focus:not(:focus-visible),
.exhibit-item a:focus:not(:focus-visible) {
    outline: none;
}

/* Visually hidden but accessible to screen readers */
.visually-hidden {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* Reduced motion preferences */
@media (prefers-reduced-motion: reduce) {
    .slider,
    .slider-icon {
        transition: none !important;
    }
}

/* ============================================
   CUSTOM ZOOM CONTROLS
   ============================================ */

.zoom-controls {
    display: flex;
    gap: 10px;
    margin-top: 0;
    width: 100%;
}

.zoom-btn {
    pointer-events: auto;
    flex: 1;
    height: 30px;
    border: 1px solid #ccc;
    border-radius: 5px;
    background-color: #fff;
    cursor: pointer;
    font-size: 13px;
    color: #333;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background-color 0.2s, border-color 0.2s;
}

.zoom-btn:hover {
    background-color: #ff4a0a;
    border-color: #ff4a0a;
    color: #fff;
}

.zoom-btn:focus {
    outline: 2px solid #ff4a0a;
    outline-offset: 2px;
}

.zoom-btn:active {
    background-color: #e04000;
}

@media (prefers-reduced-motion: reduce) {
    .zoom-btn {
        transition: none !important;
    }

    #map-search,
    #filter-mode,
    #start-year,
    #end-year {
        transition: none !important;
    }
}

/* ============================================
   RESPONSIVE DESIGN
   ============================================ */

/* Large screens (1200px and above) */
@media screen and (min-width: 1200px) {
    #search-toggle-container {
        max-width: 300px;
    }
}

/* Tablet (768px and below) */
@media screen and (max-width: 768px) {
    #search-toggle-container {
        width: 40%;
        min-width: 280px;
        padding: 10px;
        gap: 8px;
    }

    #map-search,
    #filter-mode,
    #start-year,
    #end-year {
        font-size: 16px;
        padding: 10px;
    }

    .zoom-btn {
        height: 40px;
    }

    .toggle-switch {
        flex: 0 0 54px;
        width: 54px;
        height: 32px;
    }

    .slider-icon {
        height: 26px;
        width: 26px;
        left: 3px;
        bottom: 3px;
        line-height: 26px !important;
    }

    input:checked + .slider .slider-icon {
        transform: translateX(22px);
    }
}

/* Mobile (480px and below) */
@media screen and (max-width: 480px) {
    #search-toggle-container {
        width: auto;
        min-width: unset;
        right: 10px;
        left: 10px;
        padding: 12px;
    }

    .filter-row {
        gap: 8px;
    }

    .filter-row > .date-filters {
        flex: 1 1 auto;
        order: 1;
    }

    .filter-row > .toggle-switch {
        order: 2;
    }

    .date-filters {
        gap: 3px;
    }

    #map-search,
    #filter-mode,
    #start-year,
    #end-year {
        font-size: 16px; /* Prevents iOS zoom on focus */
        padding: 12px;
        min-height: 44px; /* Touch target */
    }

    .date-separator {
        font-size: 12px;
    }

    .zoom-btn {
        height: 44px; /* Touch target */
        font-size: 16px;
    }

    .toggle-switch {
        flex: 0 0 58px;
        width: 58px;
        height: 36px;
    }

    .slider-icon {
        height: 30px;
        width: 30px;
        left: 3px;
        bottom: 3px;
        line-height: 30px !important;
        font-size: 15px;
    }

    input:checked + .slider .slider-icon {
        transform: translateX(22px);
    }
}

/* Mobile Portrait - Search above map */
@media screen and (max-width: 480px) and (orientation: portrait) {
    .map-container {
        display: flex;
        flex-direction: column;
        height: auto;
        min-height: 600px;
        overflow: visible; /* Allow popups to extend beyond container */
    }

    #search-toggle-container {
        position: relative;
        top: auto;
        right: auto;
        left: auto;
        width: 100%;
        order: 1;
        border-radius: 10px 10px 0 0;
    }

    #map {
        position: relative;
        top: auto;
        left: auto;
        flex: 1;
        min-height: 450px;
        order: 2;
        border-radius: 0 0 10px 10px;
    }

    #exhibit-list {
        position: relative;
        top: auto;
        order: 2;
        max-height: 450px;
    }
}

/* ============================================
   HIGH CONTRAST MODE SUPPORT
   ============================================ */

@media (forced-colors: active) {
    #map-search,
    #filter-mode,
    #start-year,
    #end-year,
    .zoom-btn {
        border: 2px solid CanvasText;
    }

    #map-search:focus,
    #filter-mode:focus,
    #start-year:focus,
    #end-year:focus,
    .zoom-btn:focus {
        outline: 3px solid Highlight;
        outline-offset: 2px;
    }

    .slider {
        border: 2px solid CanvasText;
    }

    .zoom-btn:hover {
        background-color: Highlight;
        color: HighlightText;
    }
}