/* 河南省市县地图 - 交互浏览工具 */
.tool-content {
    box-shadow: var(--card-shadow);
    border: 1px solid var(--border-color);
    padding: 0.2em;
    border-radius: .6em;
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 1em;
}

/* 悬浮工具条：浮在地图左上角，不占文档流、不挤压地图高度 */
.map-toolbar {
    position: absolute;
    right: 12px;
    top: 12px;
    z-index: 7;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100% - 24px);
    font-size: 14px;
    cursor: default;
    touch-action: auto;
    user-select: auto;
    -webkit-user-select: auto;
}

/* 与右侧操作按钮共用同一阴影变量，浮层控件不额外叠加投影 */
.map-toolbar > * {
    box-shadow: var(--button-shadow, 0 1px 3px rgba(0, 0, 0, .08));
}

.map-toolbar select {
    min-width: 120px;
    height: 32px;
    padding: 0 30px 0 10px;
    color: var(--text-color);
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath d='M2 4l4 4 4-4' fill='none' stroke='%23888' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 10px center;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
    appearance: none;
    -webkit-appearance: none;
    cursor: pointer;
    font-family: inherit;
    font-size: 13px;
    box-shadow: var(--button-shadow, 0 1px 3px rgba(0, 0, 0, .08));
}

.map-toolbar select:focus,
.map-toolbar select:focus-visible {
    outline: none;
}

/* 地图视口 */
.map-box {
    position: relative;
    overflow: hidden;
    width: 100%;
    height: clamp(380px, 68vh, 760px);
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    /* 首屏先显示内联的极低分辨率占位图（约 230 字节），矢量图加载完成后移除 */
    background: #fff url("data:image/webp;base64,UklGRuIAAABXRUJQVlA4INYAAADwBgCdASooACYAPtFUpEyoJKOiONScAQAaCWQAyQfUdxSVWHwATZQFHK4SQ5PxT2g/Nr2TE4LMqZPLEwcnlIhAAP76EKJ2JD/qTdoVqjVTSzbRcEQBcMbjl9ggwodu5n9O2l3XDtbHBnToWApy4IDKkK15ZXh9tTSL8l4w1aHjMpdJwUbphxD4GlJ7mnMvbSrYcqzg8W3Tqa/HONK9V6ICWRvUyb1AxGtN0bN3EwObQixckkh2lcTLX+HL87oDTMZkSliHXCM9acgzVewjCSce3zGAAAAA") center / contain no-repeat;
    /* 外层 .tool-content 已是卡片外框，这里不再重复描边 */
    cursor: grab;
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    outline: none;
}

/* 矢量图已就绪：撤掉占位图，避免图片白边处透出模糊背景 */
.map-box.is-ready {
    background-image: none;
}

.map-box:focus-visible {
    box-shadow: inset 0 0 0 2px var(--primary-color, rgb(60, 44, 255));
}

.map-box.is-dragging {
    cursor: grabbing;
}

.map-box > img {
    position: absolute;
    left: 0;
    top: 0;
    display: block;
    width: auto;
    height: auto;
    max-width: none;
    margin: 0;
    padding: 0;
    transform-origin: 0 0;
    /* 不设置 will-change：部分浏览器会把 SVG 提升为固定分辨率的合成层，
       导致放大后文字发虚。transform 本身已由浏览器优化，无需提前提升图层。 */
    pointer-events: none; /* 指针事件统一由视口接管，避免拖拽时选中图片 */
    user-select: none;
    -webkit-user-drag: none;
}

.map-box > img.is-animating {
    transition: transform .28s cubic-bezier(.22, .61, .36, 1);
}

/* 右侧操作按钮 */
.map-operate {
    position: absolute;
    right: 14px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 5;
    margin: 0;
    padding: 0;
}

.map-operate span {
    display: flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    width: 30px;
    height: 30px;
    background-color: #fff;
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 6px;
    box-shadow: var(--button-shadow, 0 1px 3px rgba(0, 0, 0, .08));
    line-height: unset;
    cursor: pointer;
    transition: background-color .18s, transform .12s, box-shadow .18s;
}

.map-operate span:hover {
    background-color: #f0f1ff;
    box-shadow: 0 2px 8px rgba(60, 44, 255, .16);
}

.map-operate span:active {
    transform: scale(.92);
}

.map-operate span:focus-visible {
    outline: 2px solid var(--primary-color, rgb(60, 44, 255));
    outline-offset: 2px;
}

.map-operate span svg {
    width: 14px;
    height: 14px;
    color: #666;
    pointer-events: none;
}

.map-operate span:hover svg,
.map-operate span.is-active svg {
    color: var(--primary-color, rgb(60, 44, 255));
}

/* 缩放比例：与下拉框同排同高，随悬浮工具条浮在地图上层 */
.map-scale {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    height: 32px;
    min-width: 66px;
    padding: 0 8px;
    color: #555;
    background: #fff;
    border: 1px solid var(--border-color, #e5e5e5);
    border-radius: 6px;
    font-size: 13px;
    line-height: 1;
    font-variant-numeric: tabular-nums;
    white-space: nowrap;
    user-select: none;
    box-shadow: var(--button-shadow, 0 1px 3px rgba(0, 0, 0, .08));
}

.map-toast {
    position: absolute;
    left: 50%;
    bottom: 16px;
    z-index: 6;
    max-width: 80%;
    padding: 7px 14px;
    color: #fff;
    background: rgba(28, 30, 40, .86);
    border-radius: 6px;
    font-size: 13px;
    white-space: nowrap;
    opacity: 0;
    transform: translate(-50%, 8px);
    transition: opacity .2s, transform .2s;
    pointer-events: none;
}

.map-toast.is-visible {
    opacity: 1;
    transform: translate(-50%, 0);
}

/* 全屏（原生 Fullscreen API + 降级方案）
   注意：浏览器不认识的伪类不能与其它选择器写在同一组，
   否则整条规则会被丢弃，因此这里拆成独立规则。 */
#map:fullscreen,
#map:-webkit-full-screen {
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
}

.map-box.is-fullscreen {
    position: fixed;
    inset: 0;
    z-index: 9999;
    width: 100vw;
    height: 100vh;
    max-width: none;
    max-height: none;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    background: #fff;
    overflow: hidden;
}

body.map-fullscreen-lock {
    overflow: hidden;
}

#map:fullscreen .map-operate,
#map:-webkit-full-screen .map-operate {
    right: 28px;
}

.map-box.is-fullscreen .map-operate {
    right: 28px;
}

@media (max-width: 768px) {
    .tool-content {
        padding: .8em !important;
        box-shadow: unset;
    }

    .map-box {
        height: min(66vh, 560px);
        min-height: 340px;
    }

    .map-toolbar {
        left: 8px;
        top: 8px;
        gap: 6px;
    }

    .map-toolbar select {
        width: 118px;
        min-width: 118px;
    }

    .map-scale {
        flex: none;
        font-size: 13px;
    }

    .map-operate {
        right: 10px;
        gap: 5px;
    }

    .map-operate span {
        width: 28px;
        height: 28px;
    }

    .operate-buttons .btn {
        line-height: 32px !important;
        height: 32px !important;
        padding: 0 8px !important;
    }

    .btn {
        height: 32px;
    }

    .input-textarea {
        min-height: 200px;
    }
}
