#map {
    width: 100%;
    height: 100dvh; /* ✅ iOS Safari 16+ correct dynamic height */
}

/* Always set the map height explicitly to define the size of the div element that contains the map. */
gmp-map {
    height: 100%;
}

#grave-info-modal .modal-dialog {
    position: fixed;
    margin: 0;
    height: 100%;
    right: 0;
}

#grave-info-modal .modal-content {
    height: 100%;
    background-color: rgba(247, 247, 247, 0.9);
    color: #2D3436 !important;
}

#grave-info-modal .modal-content h5, #grave-info-modal .modal-content .h5 {
    font-size: 22px !important;
}

#grave-info-modal .modal-body {
    overflow-y: auto;
}

/* Grave panel width is defined in grave-details.css */

.grave-details {
    color: #2D3436;
    font-size: 16px;
    font-family: 'Open Sans', sans-serif;
}

#contact-modal .modal-content {
    background-color: var(--modal-bg);
    color: var(--modal-text) !important;
}

.map-legend {
    /* container is only the button footprint */
    position: relative;
    display: inline-block;

    margin: 10px 10px 38px;

    z-index: 5;
}

/* Button (always stays in same place) */
.map-legend .legend-toggle {
    cursor: pointer;
    user-select: none;
    -webkit-tap-highlight-color: transparent;

    width: 40px;
    height: 40px;

    display: flex;
    align-items: center;
    justify-content: center;

    border-radius: 0;
    border: 1px solid #ccc;
    background: rgba(255, 255, 255);

    box-shadow: 0 2px 6px rgba(0,0,0,.15);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
}

.map-legend:not(.open) .legend-content {
    display: none;
}

.map-legend .legend-content {
    position: absolute;
    left: 0;
    bottom: calc(36px + 8px);

    background: rgba(247, 247, 247, 0.85);
    border: 1px solid #ccc;
    border-radius: .25rem;
    padding: 10px;

    font-size: 12px;
    line-height: 14px;

    box-shadow: 0 2px 6px rgba(0,0,0,.15);

    width: max-content;
    max-width: 85vw;

    display: none;
}

.map-legend.open .legend-content {
    display: block;
}

.map-legend .row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 0;
}

.map-legend .swatch {
    width: 14px;
    height: 14px;
    border-radius: 3px;
    border: 1px solid rgba(0, 0, 0, 0.25);
}

.map-legend .legend-action {
    width: 100%;
    display: inline-flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 8px 10px;
    margin-top: 8px;
    border: 1px solid rgba(0, 0, 0, 0.12);
    border-radius: 4px;
    background: rgba(255, 255, 255, 0.92);
    color: #212529;
    font-size: 12px;
    line-height: 14px;
    cursor: pointer;
}

.map-legend .legend-action:hover {
    background: rgba(255, 255, 255, 0.98);
}

.map-legend .legend-action:focus {
    outline: none;
    box-shadow: 0 0 0 2px rgba(74, 144, 226, 0.28);
}

.map-legend .legend-action-main {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.map-legend .legend-action-icon {
    width: 16px;
    height: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #495057;
}

.map-legend .legend-action-text {
    font-weight: 600;
}

.map-legend .legend-action-state {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 44px;
    padding: 2px 8px;
    border-radius: 999px;
    background: rgba(74, 144, 226, 0.16);
    color: #1f5fa8;
    font-weight: 700;
    font-size: 11px;
    letter-spacing: 0;
}

.map-legend .legend-action.is-off .legend-action-state {
    background: rgba(108, 117, 125, 0.14);
    color: #495057;
}

/* Modal animation */

.modal.modal-slide-right .modal-dialog {
    transform: translateX(100%);
    transition: transform 0.3s ease-out;
    margin: 0;
    height: 100%;
    position: fixed;
    right: 0;
}

.modal.modal-slide-right.show .modal-dialog {
    transform: translateX(0);
}

/* ==========================================================================
   Map search — the bar floating over the map (cemeteries/map-search.html,
   js/cemeteries/map-search.js). Under the navbar across the top on a phone,
   top-left beside the map on a wider screen, with the results hanging under
   it on both. Themed through the shared tokens only.

   Stacking: above the map controls, under the navbar (1030) so an expanded
   hamburger menu covers it; while the results are open, above the grave
   sheet (1025) too, which they would otherwise run under.
   ========================================================================== */

.map-search {
    position: absolute;
    top: calc(var(--map-search-navbar, 56px) + 12px);
    left: 12px;
    right: 12px;
    z-index: 1020;
    color: var(--nav-dropdown-text);
    --map-search-bg: var(--nav-dropdown-bg);
    --map-search-list-bg: var(--nav-dropdown-bg);
}

.map-search.is-open {
    z-index: 1028;
}

/* Over the map the bar and its results let a little of it through. */
@supports (background: color-mix(in srgb, red 50%, transparent)) {
    .map-search {
        --map-search-bg: color-mix(in srgb, var(--nav-dropdown-bg) 79%, transparent);
        --map-search-list-bg: var(--map-search-bg);
    }
}

/* A phone's list is narrow and dense, and reads poorly with the map showing through. */
@supports (background: color-mix(in srgb, red 50%, transparent)) {
    @media (max-width: 767.98px) {
        .map-search {
            --map-search-list-bg: color-mix(in srgb, var(--nav-dropdown-bg) 95%, transparent);
        }
    }
}

@media (min-width: 768px) {
    .map-search {
        right: auto;
        width: 400px;
    }
}

.map-search-bar {
    display: flex;
    align-items: center;
    height: 48px;
    background: var(--map-search-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--nav-dropdown-border);
    border-radius: 24px;
    box-shadow: 0 4px 14px rgba(15, 23, 42, 0.2);
    transition: border-color .15s ease-in-out;
}

.map-search.is-open .map-search-bar {
    border-radius: 24px 24px 0 0;
    /* the results carry the shadow; the bar's would show through them */
    box-shadow: none;
}

/* The bar as a whole shows the focus, instead of the site-wide outline around the input alone. */
.map-search-bar:focus-within {
    border-color: var(--gd-border-strong);
}

body .map-search .map-search-input:focus,
body .map-search .map-search-clear:focus:not(:focus-visible) {
    outline: none !important;
    box-shadow: none !important;
}

.map-search-lupa,
.map-search-clear {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--modal-muted);
}

.map-search-lupa {
    font-size: .95rem;
    pointer-events: none;
}

.map-search-clear {
    padding: 0;
    border: 0;
    background: transparent;
    font-size: 1.05rem;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}

.map-search-clear:hover {
    color: var(--nav-dropdown-text);
}

.map-search-clear[hidden] {
    display: none;
}

.map-search-input {
    flex: 1 1 auto;
    min-width: 0;
    height: 100%;
    padding: 0 12px 0 0;
    border: 0;
    outline: none;
    background: transparent;
    color: var(--nav-dropdown-text);
    /* 16px keeps iOS Safari from zooming into the page on focus */
    font-size: 16px;
    text-overflow: ellipsis;
    -webkit-appearance: none;
    appearance: none;
}

.map-search-input::placeholder {
    color: var(--modal-muted);
    opacity: 1;
    font-size: 15px;
    text-overflow: ellipsis;
}

/* the bar has its own clear button */
.map-search-input::-webkit-search-cancel-button,
.map-search-input::-webkit-search-decoration {
    -webkit-appearance: none;
    appearance: none;
}

.map-search-results {
    /* --map-search-room is what the visible screen leaves under the bar, keyboard taken off */
    max-height: var(--map-search-room, calc(100dvh - var(--map-search-navbar, 56px) - 96px));
    overflow-y: auto;
    overscroll-behavior: contain;
    scrollbar-width: thin;
    scrollbar-color: var(--gd-scroll-thumb, rgba(108, 122, 137, 0.4)) transparent;
    background: var(--map-search-list-bg);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    border: 1px solid var(--nav-dropdown-border);
    border-top-color: transparent;
    border-radius: 0 0 16px 16px;
    box-shadow: 0 16px 30px rgba(15, 23, 42, 0.18);
}

.map-search-results[hidden] {
    display: none;
}

/* a wider screen has room to spare; a short list there reads better than one down to the bottom */
@media (min-width: 768px) {
    .map-search-results {
        max-height: min(420px, var(--map-search-room, calc(100dvh - var(--map-search-navbar, 56px) - 96px)));
    }
}

.map-search-option {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-height: 48px;
    padding: 8px 16px;
    border-top: 1px solid var(--nav-dropdown-border);
    cursor: pointer;
}

.map-search-option:first-child {
    border-top: 0;
}

.map-search-option.is-active {
    background-color: var(--nav-dropdown-hover-bg);
}

.map-search-empty {
    padding: 14px 16px;
    font-size: .875rem;
    color: var(--modal-muted);
}

/* ==========================================================================
   Map search results — one card per grave: which burial place it is, who lies
   in it and, where the cemetery publishes them, who holds it.
   ========================================================================== */

.map-search-card {
    line-height: 1.35;
}

.map-search-head {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: .875rem;
}

.map-search-place {
    flex: 1 1 auto;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-weight: 600;
}

.map-search-line {
    display: flex;
    align-items: baseline;
    gap: 6px;
    margin-top: 2px;
    font-size: .8rem;
    color: var(--modal-muted);
}

.map-search-names {
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.map-search-icon {
    flex: 0 0 14px;
    width: 14px;
    text-align: center;
    font-size: .75rem;
    opacity: .65;
}

.map-search-sep {
    margin: 0 5px;
    opacity: .5;
}

.map-search-dim {
    opacity: .75;
    font-weight: 400;
}

.map-search-more {
    margin-left: 6px;
    font-size: .72rem;
    opacity: .75;
}

.map-search-badge {
    flex: 0 0 auto;
    padding: 1px 7px;
    border-radius: 10px;
    font-size: .68rem;
    font-weight: 600;
    color: var(--modal-muted);
    background: var(--gd-surface-hover, rgba(127, 127, 127, .12));
    border: 1px solid var(--gd-border);
}

.map-search-badge-free {
    color: var(--gd-gold);
    border-color: var(--gd-gold);
}

/* the reason for the hit, in whichever line it stands */
.map-search-card strong {
    font-weight: 700;
    color: var(--gd-gold);
}
