/* Map page */
.map-page {
    width: 100%;
    padding: 32px 0 48px;
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 32px;
}

.map-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--color-text-muted);
    padding: 0 60px;
}

.map-breadcrumbs a {
    color: var(--color-text-muted);
    text-decoration: none;
}

.map-breadcrumbs a:hover {
    border-bottom: 1px solid var(--color-text-secondary);
}

.map-breadcrumbs__sep {
    color: var(--color-text-muted);
}

.breadcrumbs-item__active {
    color: var(--color-text-primary);
    text-decoration: underline;
}

.map-page__content {
    max-width: 1750px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    align-items: start;
    gap: 32px;
}

.map-page-title {
    text-transform: uppercase;
    align-self: center;
}

.map-layout {
    display: grid;
    grid-template-columns: minmax(0, 1fr) 375px;
    gap: 108px;
    align-items: start;
}

.map-canvas-wrap {
    background: var(--color-bg-warm-gray);
    border-radius: 16px;
    padding: 16px;
    min-height: 520px;
}

.map-canvas {
    position: relative;
    width: 100%;
    overflow: auto;
    border-radius: 12px;
    background: #fff;
}

.map-canvas-loading {
    padding: 48px 24px;
    text-align: center;
    color: var(--color-text-secondary);
}

.map-stack {
    position: relative;
    width: 100%;
    max-width: 100%;
}

.map-base {
    display: block;
    width: 100%;
    height: auto;
    user-select: none;
    -webkit-user-drag: none;
}

.map-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.map-route-layer {
    pointer-events: none;
}

.map-route-path {
    fill: none;
    stroke: #76231B;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.map-route-chevron {
    fill: none;
    stroke: #9C3327;
    stroke-linecap: round;
    stroke-linejoin: round;
}

@media (max-width: 678px) {
    .map-route-path {
        stroke-width: 1;
        vector-effect: non-scaling-stroke;
    }
}

.map-route-path-glow {
    display: none;
}

.map-route-start {
    pointer-events: none;
}

.map-route-start__circle {
    fill: #9C3327;
}

.map-route-end {
    fill: #76231B;
}

.map-route-label {
    fill: var(--color-text-primary);
    font-family: var(--font-sans, 'Montserrat', sans-serif);
    font-size: 28px;
    font-weight: 600;
}

.map-toast {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 300;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    width: min(360px, calc(100vw - 32px));
    padding: 14px 14px 14px 12px;
    background: #FBEDEB;
    border: 1px solid #E8A39A;
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(22, 20, 18, 0.08);
}

.map-toast[hidden] {
    display: none !important;
}

.map-toast__icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #9C3327;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.map-toast__content {
    flex: 1;
    min-width: 0;
}

.map-toast__title {
    margin: 0 0 4px;
    color: #9C3327;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
}

.map-toast__text {
    margin: 0;
    color: #9C3327;
    font-size: 13px;
    line-height: 1.4;
    opacity: 0.9;
}

.map-toast__close {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    border: 0;
    background: transparent;
    color: #B8AEA2;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.map-toast__close:hover {
    color: #76231B;
}

.map-route-panel {
    background: var(--color-bg-warm-gray);
    border: 1px solid var(--color-border-light);
    padding: 28px 24px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    position: sticky;
    top: 24px;
}

.map-route-panel__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.map-route-panel__title {
    margin: 0;
    font-weight: 600;
    color: var(--color-text-primary);
}

.map-route-panel__close {
    display: none;
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    margin: -8px -8px -8px 0;
    border: 0;
    background: transparent;
    color: var(--color-text-muted);
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.map-route-panel__close:hover {
    color: var(--color-text-primary);
}

.map-route-fab {
    display: none;
}

.map-route-backdrop {
    display: none;
}

.map-select {
    position: relative;
}

.map-select__trigger {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 56px;
    padding: 16px;
    border: 1px solid var(--color-border-dark);
    background: #fff;
    color: var(--color-text-muted);
    font: inherit;
    font-size: 15px;
    line-height: 18px;
    cursor: pointer;
    text-align: left;
    transition: border-color .2s, color .2s, opacity .2s;
}

.map-select.is-filled .map-select__trigger {
    color: var(--color-text-primary);
}

.map-select.is-open .map-select__trigger {
    border-color: var(--color-accent-mustard);
}

.map-select.is-disabled .map-select__trigger {
    background: var(--color-bg-warm-gray);
    color: var(--color-text-muted);
    cursor: not-allowed;
    opacity: 0.72;
}

.map-select__chevron {
    display: inline-flex;
    color: var(--color-text-muted);
    transition: transform .2s;
}

.map-select.is-open .map-select__chevron {
    transform: rotate(180deg);
}

.map-select__dropdown {
    position: absolute;
    left: 0;
    right: 0;
    top: calc(100%);
    z-index: 20;
    border: 1px solid var(--color-border-light);
    background-color: var(--color-bg-main);
    box-shadow: 0 12px 28px rgba(22, 20, 18, 0.08);
    overflow: hidden;
}

.map-select__search {
    border-bottom: 1px solid var(--color-border-light);
    height: 48px;
    display: flex;
    align-items: center;
    gap: 9px;
    padding: 0 12px;
}

.map-select__search-input {
    width: 100%;
    border: none;
    outline: none;
    padding: 10px 12px;
    font: inherit;
    font-size: 14px;
    background: var(--color-bg-main);
}

.map-select__search-input::-webkit-search-decoration,
.map-select__search-input::-webkit-search-cancel-button,
.map-select__search-input::-webkit-search-results-button,
.map-select__search-input::-webkit-search-results-decoration {
    -webkit-appearance: none;
    appearance: none;
    display: none;
}

.map-select__search-input::-ms-clear {
    display: none;
    width: 0;
    height: 0;
}

.map-select__search-input:focus {
    border-color: var(--color-accent-mustard);
}

.map-select__list {
    list-style: none;
    margin: 0;
    padding: 0 0 12px;
    max-height: 240px;
    overflow-y: auto;
}

.map-select__option {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    width: 100%;
    padding: 12px 32px;
    border: 0;
    background: transparent;
    text-align: left;
    font: inherit;
    font-size: 16px;
    color: var(--color-text-primary);
    cursor: pointer;
}

.map-select__option-name {
    min-width: 0;
}

.map-select__option-pavilion {
    flex-shrink: 0;
    color: var(--color-text-secondary);
    font-size: 14px;
}

.map-select__option:hover,
.map-select__option.is-active {
    background: var(--color-bg-warm-gray);
}

.map-select__empty {
    padding: 14px;
    color: var(--color-text-muted);
    font-size: 14px;
}

.map-route-button {
    width: 100%;
    min-height: 48px;
    border: 0;
    background: var(--color-accent-terracotta);
    color: #fff;
    font: inherit;
    font-size: var(--text-button-size, 15px);
    font-weight: var(--text-button-weight, 400);
    cursor: pointer;
    transition: background-color .2s, opacity .2s;
}

.map-route-button:hover:not(:disabled) {
    background: var(--color-accent-terracotta-hover);
}

.map-route-button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.map-route-button--reset {
    background: transparent;
    border: 1px solid #161412;
    color: #161412;
}

.map-route-button--reset:hover:not(:disabled) {
    background: transparent;
    border-color: #514940;
    color: #514940;
}

.map-route-hint {
    margin: 0;
    color: var(--color-text-secondary);
    line-height: 1.45;
}

@media (max-width: 1800px) {
    .map-page__content {
        max-width: calc(100svw - 32px);
    }

    .map-layout {
        gap: 32px;
    }
}

@media (max-width: 1024px) {
    .map-page {
        padding: 20px 20px 48px;
    }

    .map-breadcrumbs {
        padding: 0;
    }

    .map-layout {
        grid-template-columns: 1fr;
        gap: 24px;
        width: 100%;
    }

    .map-route-panel {
        position: static;
    }

    .map-canvas {
        max-height: none;
    }
}

@media (max-width: 768px) {
    body.site-body:has(.map-page) {
        overflow: hidden;
        height: 100%;
        height: 100dvh;
    }

    body.site-body:has(.map-page) .site-footer {
        display: none;
    }

    .map-page {
        --map-header-h: 72px;
        height: calc(100dvh - var(--map-header-h));
        max-height: calc(100dvh - var(--map-header-h));
        padding: 10px 12px calc(72px + env(safe-area-inset-bottom, 0px));
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
        align-items: stretch;
        overflow: hidden;
    }

    .map-breadcrumbs {
        flex-shrink: 0;
        padding: 0;
    }

    .map-page__content {
        flex: 1;
        min-height: 0;
        gap: 8px;
        width: 100%;
        max-width: none;
        align-items: stretch;
        display: flex;
        flex-direction: column;
    }

    .map-page-title {
        flex-shrink: 0;
        font-size: clamp(22px, 6vw, 28px);
        line-height: 1.15;
        text-align: center;
        padding: 0 8px;
        margin: 0;
    }

    .map-layout {
        flex: 1;
        min-height: 0;
        gap: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .map-canvas-wrap {
        flex: 1;
        min-height: 0;
        padding: 8px;
        border-radius: 12px;
        width: 100%;
        display: flex;
        flex-direction: column;
    }

    .map-canvas {
        flex: 1;
        min-height: 0;
        max-height: none;
        height: auto;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .map-stack {
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .map-route-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        left: 16px;
        right: 16px;
        bottom: calc(16px + env(safe-area-inset-bottom, 0px));
        z-index: 40;
        min-height: 52px;
        border: 0;
        background: var(--color-accent-terracotta);
        color: #fff;
        font: inherit;
        font-size: 15px;
        cursor: pointer;
        box-shadow: 0 10px 28px rgba(22, 20, 18, 0.18);
    }

    .map-route-fab:hover {
        background: var(--color-accent-terracotta-hover);
    }

    .map-route-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 200;
        background: rgba(126, 117, 107, 0.75);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition: opacity .25s, visibility .25s;
    }

    .map-route-backdrop.is-open {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .map-route-backdrop[hidden] {
        display: block !important;
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
    }

    .map-route-panel {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 201;
        max-height: min(88dvh, calc(100dvh - 16px));
        margin: 0;
        padding: 12px 16px calc(20px + env(safe-area-inset-bottom, 0px));
        border: 0;
        border-radius: 16px 16px 0 0;
        background: var(--color-bg-main);
        box-shadow: 0 -12px 40px rgba(22, 20, 18, 0.16);
        overflow: auto;
        -webkit-overflow-scrolling: touch;
        transform: translateY(110%);
        transition: transform .28s ease;
        gap: 14px;
    }

    .map-route-panel::before {
        content: '';
        display: block;
        width: 40px;
        height: 4px;
        margin: 0 auto 8px;
        border-radius: 999px;
        background: #D9D2C8;
    }

    .map-route-panel.is-open {
        transform: translateY(0);
    }

    .map-route-panel__close {
        display: inline-flex;
    }

    .map-select__dropdown {
        position: static;
        box-shadow: none;
        border-color: var(--color-border-light);
        margin-top: 0;
    }

    .map-select__list {
        max-height: min(36vh, 260px);
    }

    .map-select__option {
        padding: 12px 16px;
        font-size: 15px;
    }

    .map-toast {
        top: 12px;
        right: 12px;
        left: 12px;
        width: auto;
        z-index: 300;
    }

    body.map-route-modal-open {
        overflow: hidden;
    }
}

@media (max-width: 440px) {
    .map-page {
        padding: 8px 10px calc(64px + env(safe-area-inset-bottom, 0px));
        gap: 6px;
    }

    .map-breadcrumbs {
        font-size: 13px;
        gap: 6px;
    }

    .map-page-title {
        font-size: 22px;
    }

    .map-canvas-wrap {
        padding: 6px;
        border-radius: 10px;
    }

    .map-route-fab {
        left: 12px;
        right: 12px;
        bottom: calc(12px + env(safe-area-inset-bottom, 0px));
        min-height: 48px;
        font-size: 14px;
    }

    .map-route-panel {
        padding: 10px 12px calc(16px + env(safe-area-inset-bottom, 0px));
        gap: 12px;
        max-height: calc(100dvh - 12px);
    }

    .map-select__trigger {
        min-height: 48px;
        padding: 12px;
        font-size: 14px;
    }

    .map-route-button {
        min-height: 44px;
        font-size: 14px;
    }
}
