html:not(.has-map) .map-only,
.has-map .no-map-only {
    display: none;
}

.map-shell__map {
    display: none;
}

.map-shell__top {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: var(--space-4);
    padding: var(--space-4);
}

.map-shell__panel {
    padding: 0 var(--space-4) var(--space-7);
}

.map-shell__panel .zn-panel {
    max-width: 40rem;
}

.map-shell__error {
    margin-bottom: var(--space-2);
    padding: var(--space-3) var(--space-4);
    background: var(--surface);
    color: var(--text);
    font-size: 15px;
    line-height: 22px;
    border-radius: var(--radius-control);
    box-shadow: 0 0 0 1px var(--line);
}

.map-shell__controls {
    display: grid;
    justify-items: start;
    gap: var(--space-2);
}

.map-zoom,
.floor-switch {
    display: inline-flex;
    padding: 4px;
    border-radius: var(--radius-control);
    background: var(--surface);
    box-shadow: 0 0 0 1px var(--line);
}

.map-zoom__button,
.floor-switch__button {
    display: inline-grid;
    place-items: center;
    min-width: 44px;
    min-height: 44px;
    padding: 0 var(--space-3);
    border: 0;
    border-radius: 9px;
    background: transparent;
    color: var(--ink);
    font-family: var(--font-text);
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
}

.floor-switch__button[aria-pressed='true'] {
    background: var(--ink);
    color: var(--page);
}

.map-credit {
    padding: 2px var(--space-2);
    border-radius: 6px;
    background: var(--surface);
    color: var(--muted);
    font-size: 12px;
    line-height: 18px;
}

.map-credit a {
    color: inherit;
}

.has-map body {
    overflow: hidden;
}

.has-map .map-shell__map {
    position: fixed;
    inset: 0;
    display: block;
}

.has-map .map-shell__top {
    position: fixed;
    top: var(--space-5);
    left: var(--space-5);
    z-index: 2;
    width: max-content;
    max-width: calc(100vw - 408px - 3 * var(--space-5));
    padding: 0;
}

.has-map .map-shell__controls {
    position: fixed;
    bottom: var(--space-5);
    left: var(--space-5);
    z-index: 1;
    max-width: calc(100vw - 408px - 3 * var(--space-5));
}

.has-map .map-shell__panel {
    position: fixed;
    top: var(--space-5);
    right: var(--space-5);
    bottom: var(--space-5);
    z-index: 2;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    width: 408px;
    padding: 0;
    pointer-events: none;
}

.has-map .language-nav {
    padding: 4px;
    border-radius: var(--radius-chip);
    background: var(--page);
}

.has-map .map-shell__top .zn-search__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

.has-map .map-shell__panel > * {
    pointer-events: auto;
}

.has-map .map-shell__panel .zn-panel {
    max-height: 100%;
    overflow-y: auto;
    overscroll-behavior: contain;
}

.has-map .maplibregl-canvas:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: -2px;
}

@media (width >= 48rem) {
    .zn-panel__expand {
        display: none;
    }
}

@media (width < 48rem) {
    .has-map .map-shell__top {
        top: var(--space-3);
        right: var(--space-4);
        left: var(--space-4);

        /* The suggestion list opens over the sheet: the header that holds it must be drawn above the sheet. */
        z-index: 3;
        gap: var(--space-2);
        width: auto;
        max-width: none;
    }

    .has-map .zn-wordmark {
        font-size: 24px;
    }

    .has-map .palette-status {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        white-space: nowrap;
    }

    .has-map .map-shell__controls {
        right: var(--space-4);
        bottom: calc(40vh + var(--space-3));
        left: var(--space-4);
        display: flex;
        flex-wrap: wrap;
        align-items: flex-end;
        max-width: none;
    }

    /* The floor switch shares the row of the zoom buttons, its labels wrapping inside their 44px buttons: on a phone 667px tall, controls of three rows no longer reach up under the search field. */
    .has-map .floor-switch {
        flex: 1 1 0;
        min-width: 0;
        max-width: max-content;
    }

    .has-map .floor-switch__button {
        flex: 1 1 auto;
        padding: 0 var(--space-2);
        line-height: 18px;
        text-align: center;
    }

    .has-map .map-shell__panel {
        inset: auto 0 0;
        width: auto;
        max-height: 40vh;
    }

    .has-map .map-shell__panel .zn-panel {
        max-width: none;
        padding: var(--space-5) var(--space-4) var(--space-4);
        border-radius: var(--radius-panel) var(--radius-panel) 0 0;
        box-shadow: var(--shadow-sheet);
    }

    /* The expanded sheet stops 11.5rem from the top: the header, with the wordmark, the language links on a second row and the search field, ends at 11rem on a phone. */
    .has-map .map-shell__panel:has(.zn-panel--expanded) {
        max-height: calc(100vh - 11.5rem);
    }

    .has-map .map-shell__error {
        margin-inline: var(--space-4);
    }

    .has-map .zn-panel:not(.zn-panel--expanded) .zn-panel__more {
        display: none;
    }

    .has-map .intro__title {
        font-size: 26px;
        line-height: 30px;
    }

    .has-map .zn-legend {
        width: 100%;
        padding: var(--space-2) var(--space-3);
    }

    .has-map .zn-legend .zn-word--small {
        font-size: 14px;
        line-height: 20px;
    }
}

/* On a screen under 48rem wide and 30rem tall, a small phone held sideways, the header with its search field, the controls and a sheet of 40vh do not fit: with 24vh the field no longer hides the zoom and floor controls. Wider screens in landscape keep their own layout. */
@media (width < 48rem) and (height < 30rem) {
    .has-map .map-shell__controls {
        bottom: calc(24vh + var(--space-3));
    }

    .has-map .map-shell__panel {
        max-height: 24vh;
    }
}
