.site-plan-viewer {
    background: #fff;
    isolation: isolate;
    position: relative;
    width: 100%;
}

.site-plan-viewer__stage {
    aspect-ratio: var(--site-plan-ratio, 16 / 10);
    /* Leaves room for the site header and the toolbar, so the whole plan fits on one screen */
    max-height: calc(100vh - 190px);
    overflow: hidden;
    position: relative;
    width: 100%;
}

.site-plan-viewer__toolbar {
    align-items: center;
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 16px;
    position: relative;
    z-index: 1100;
}

.site-plan-viewer__zones {
    display: flex;
    flex: 1 1 auto;
    flex-wrap: wrap;
    gap: 6px;
}

.site-plan-viewer__zones button {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #0f3d3e;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    padding: 7px 14px;
    white-space: nowrap;
}

.site-plan-viewer__zones button:hover,
.site-plan-viewer__zones button:focus-visible {
    background: #0f6b6b;
    border-color: #0f6b6b;
    color: #fff;
}

.site-plan-viewer__search {
    flex: 0 1 280px;
    margin: 0;
    position: relative;
}

.site-plan-viewer__search input {
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: 999px;
    color: #111827;
    font-size: 16px;
    height: 38px;
    line-height: 1.2;
    padding: 0 16px;
    width: 100%;
}

.site-plan-viewer__results {
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.14);
    left: 0;
    list-style: none;
    margin: 6px 0 0;
    max-height: 300px;
    overflow: auto;
    padding: 6px;
    position: absolute;
    right: 0;
    top: 100%;
}

.site-plan-viewer__results li {
    color: #6b7280;
    font-size: 14px;
    list-style: none;
    margin: 0;
    padding: 6px 10px;
}

.site-plan-viewer__results li:has(button) {
    padding: 0;
}

.site-plan-viewer__results button {
    background: none;
    border: 0;
    border-radius: 6px;
    color: #111827;
    cursor: pointer;
    display: block;
    font-size: 14px;
    padding: 8px 10px;
    text-align: left;
    width: 100%;
}

.site-plan-viewer__results button:hover,
.site-plan-viewer__results button:focus-visible {
    background: #eef6f6;
}

/* Hollow, so the printed lot code stays readable inside the ring */
.site-plan-viewer__marker {
    border: 4px solid #f59e0b;
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9), inset 0 0 0 2px rgba(255, 255, 255, 0.9);
}

/* The editor wraps a pasted shortcode in a paragraph, which leaves an empty one above the map */
p:empty:has(+ .site-plan-viewer) {
    display: none;
}

.site-plan-viewer__map,
.site-plan-viewer__preview {
    height: 100%;
    inset: 0;
    position: absolute;
    width: 100%;
}

.site-plan-viewer__map {
    z-index: 1;
}

/* Leaflet's stylesheet loads later, so this needs the extra specificity */
.site-plan-viewer .site-plan-viewer__map {
    background: transparent;
}

/* Width, left and margin-top come from the shortcode and match the map's opening view */
.site-plan-viewer__preview {
    height: auto;
    inset: 0 auto auto;
    max-width: none;
}

/* Theme content styles must not resize map tiles */
.site-plan-viewer .leaflet-container img,
.site-plan-viewer .leaflet-tile {
    height: auto;
    margin: 0;
    max-height: none;
    max-width: none;
}

.site-plan-viewer__hint {
    background: rgba(0, 0, 0, 0.7);
    border-radius: 6px;
    bottom: 16px;
    color: #fff;
    font-size: 14px;
    left: 50%;
    padding: 6px 14px;
    pointer-events: none;
    position: absolute;
    transform: translateX(-50%);
    white-space: nowrap;
    z-index: 1000;
}

.site-plan-viewer__fullscreen {
    align-items: center;
    display: flex !important;
    justify-content: center;
}

/* Filled and bigger than the zoom buttons, so older visitors spot it (buyer's request) */
.site-plan-viewer .leaflet-bar a.site-plan-viewer__fullscreen {
    background: #0f6b6b;
    color: #fff;
    height: 36px;
    width: 36px;
}

.site-plan-viewer .leaflet-bar a.site-plan-viewer__fullscreen:hover,
.site-plan-viewer .leaflet-bar a.site-plan-viewer__fullscreen:focus-visible {
    background: #0b5252;
    color: #fff;
}

.site-plan-viewer__fullscreen svg {
    height: 22px;
    stroke-width: 3;
    width: 22px;
}

.site-plan-viewer--fullscreen,
.site-plan-viewer:fullscreen {
    display: flex;
    flex-direction: column;
    height: 100%;
    width: 100%;
}

.site-plan-viewer--fullscreen .site-plan-viewer__stage,
.site-plan-viewer:fullscreen .site-plan-viewer__stage {
    aspect-ratio: auto;
    flex: 1 1 auto;
    max-height: none;
    min-height: 0;
}

/* iPhone Safari has no element fullscreen, so fill the viewport instead */
.site-plan-viewer--fullscreen {
    height: 100dvh;
    inset: 0;
    position: fixed;
    width: 100vw;
    z-index: 99999;
}

html.site-plan-viewer-locked,
html.site-plan-viewer-locked body {
    overflow: hidden;
}

/* The plan is short on phones, so keep the controls from covering it */
@media (max-width: 576px) {
    .site-plan-viewer__toolbar {
        padding: 8px;
    }

    .site-plan-viewer__zones {
        flex-wrap: nowrap;
        overflow-x: auto;
        scrollbar-width: none;
    }

    .site-plan-viewer__search {
        flex: 1 1 100%;
    }

    .site-plan-viewer .leaflet-touch .leaflet-bar a {
        height: 26px;
        line-height: 26px;
        width: 26px;
    }

    .site-plan-viewer .leaflet-top .leaflet-control {
        margin-right: 6px;
        margin-top: 6px;
    }

    .site-plan-viewer .leaflet-touch .leaflet-bar a.site-plan-viewer__fullscreen {
        height: 34px;
        line-height: 34px;
        width: 34px;
    }

    /* A gap under the search box, so the plan does not start right against it (buyer's request) */
    .site-plan-viewer:not(.site-plan-viewer--fullscreen):not(:fullscreen) .site-plan-viewer__stage {
        margin-top: 28px;
    }
}
