/**
 * xiaoten-footprintmap - Footprint Map Styles
 * Amap Only Version
 */

/* ==========================================================================
   1. AMap Overrides
   ========================================================================== */
.amap-logo, .amap-copyright {
    display: none !important;
}

/* Reset InfoWindow Styles */
.amap-info-content,
.amap-info-outer,
.amap-info-inner {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    padding: 0 !important;
}
.amap-info-sharp,
.amap-info-shadow {
    display: none !important;
}
.amap-scale-text,
.amap-scalecontrol {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* ==========================================================================
   2. Main Container
   ========================================================================== */
.footprint-map {
    width: 100%;
    min-height: 420px;
    border-radius: 12px;
    overflow: hidden;
    /* margin: 1.5rem 0; */
    border: 1px solid rgba(0, 0, 0, 0.05);
    position: relative;
    background: #fff;
    z-index: 1;
}

.footprint-map__canvas {
    width: 100%;
    height: 100%;
    outline: none;
}

/* Loading & Error States */
.footprint-map__loading,
.footprint-map__error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    font-size: 0.95rem;
    background: rgba(255, 255, 255, 0.92);
    color: #6b7886;
    z-index: 2;
    pointer-events: none;
}

.footprint-map__error {
    pointer-events: auto;
    color: #e74c3c;
}

.footprint-map:not(.footprint-map--loading) .footprint-map__loading {
    display: none;
}

/* Fullscreen Mode */
.footprint-map.is-fullscreen {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 99999 !important;
    margin: 0 !important;
    border-radius: 0 !important;
    background: #fff;
}

/* ==========================================================================
   3. UI Components: Filters
   ========================================================================== */
.footprint-map__filters {
    position: absolute;
    top: 6px;
    left: 6px;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 8px;
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.9);
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.12);
    z-index: 3;
    max-width: calc(100% - 24px);
}

.footprint-map__filter-btn {
    border: none;
    background: transparent;
    color: #333;
    font-size: 0.85rem;
    padding: 6px 12px;
    border-radius: 18px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.footprint-map__filter-btn:hover {
    background: rgba(0, 0, 0, 0.05);
}

.footprint-map__filter-btn.is-active {
    background: #111826;
    color: #fff;
}

@media (max-width: 640px) {
    .footprint-map__filters {
        max-height: 120px;
        overflow-y: auto;
        gap: 6px;
        border-radius: 12px;
        padding: 6px;
    }
}

/* ==========================================================================
   4. UI Components: Cluster Toggle
   ========================================================================== */
.footprint-map__cluster-toggle {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    user-select: none;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.footprint-map__cluster-toggle .toggle-label {
    font-weight: 500;
}

.footprint-map__cluster-toggle .toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
    outline: none;
    background: #06beb6;
    padding: 0;
}

.footprint-map__cluster-toggle .toggle-switch .toggle-knob {
    position: absolute;
    top: 2px;
    left: 22px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: left 0.3s;
}

.footprint-map__cluster-toggle .toggle-switch.is-off {
    background: #ccc;
}

.footprint-map__cluster-toggle .toggle-switch.is-off .toggle-knob {
    left: 2px;
}

/* [新增] Province Mask Toggle */
.footprint-map__province-toggle {
    position: absolute;
    bottom: 65px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 10;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    font-size: 13px;
    user-select: none;
    transition: all 0.3s;
    background: rgba(255, 255, 255, 0.95);
    color: #333;
}

.footprint-map__province-toggle .toggle-label {
    font-weight: 500;
}

.footprint-map__province-toggle .toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
    outline: none;
    background: #3388ff;
    padding: 0;
}

.footprint-map__province-toggle .toggle-switch .toggle-knob {
    position: absolute;
    top: 2px;
    left: 22px;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: left 0.3s;
}

.footprint-map__province-toggle .toggle-switch.is-off {
    background: #ccc;
}

.footprint-map__province-toggle .toggle-switch.is-off .toggle-knob {
    left: 2px;
}

/* ==========================================================================
   5. UI Components: Map Controls
   ========================================================================== */
.footprint-map-ctrls {
    position: absolute;
    z-index: 150;
    display: flex;
    flex-direction: column;
    gap: 8px;
    right: 20px;
    transition: all 0.3s ease;
}

.footprint-map-ctrls.is-desktop { top: 20px; }
.footprint-map-ctrls.is-mobile { bottom: 30px; }

.footprint-ctrl-btn {
    width: 32px;
    height: 32px;
    background: #fff;
    border-radius: 4px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.15);
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #555;
    transition: background 0.2s, color 0.2s;
    padding: 0;
}

.footprint-ctrl-btn:hover {
    background: #f5f5f5;
    color: #000;
}

.footprint-ctrl-btn svg {
    width: 18px;
    height: 18px;
    fill: currentColor;
}

/* ==========================================================================
   6. Markers
   ========================================================================== */
.footprint-marker {
    display: block;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.25);
    cursor: pointer;
}

.footprint-marker--sunset { background: linear-gradient(135deg, #ffb347, #ff6f61); }
.footprint-marker--ocean  { background: linear-gradient(135deg, #06beb6, #48b1bf); }
.footprint-marker--violet { background: linear-gradient(135deg, #a18cd1, #fbc2eb); }
.footprint-marker--forest { background: linear-gradient(135deg, #5ee7df, #39a37c); }
.footprint-marker--amber  { background: linear-gradient(135deg, #f6d365, #fda085); }
.footprint-marker--citrus { background: linear-gradient(135deg, #fdfb8f, #a1ffce); }

/* ==========================================================================
   7. Popup (InfoWindow)
   ========================================================================== */
.footprint-popup {
    width: 260px;
    max-width: calc(100vw - 16px);
    font-size: .95rem;
    line-height: 1.5;
    background: rgba(255, 255, 255, .9);
    color: #111826;
    padding: 12px 14px;
    caret-color: transparent;
}

.footprint-popup h4 {
    margin: 0 0 .35rem;
    font-size: 1rem;
    font-weight: 600;
}

.footprint-popup p {
    margin: 0 0 .35rem;
    font-size: .9rem;
}

.footprint-popup__meta {
    font-size: .78rem;
    color: #6b7886;
    margin-bottom: .25rem;
}

.footprint-popup__tags {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: .35rem;
}

.footprint-popup__tag {
    font-size: .75rem;
    padding: 2px 6px;
    border-radius: 6px;
    background: rgba(17, 24, 38, 0.08);
    color: #111826;
}

.footprint-popup__links {
    margin: 0 0 .35rem;
}

.footprint-popup__link {
    font-size: .82rem;
    padding: 4px 12px;
    border-radius: 18px;
    background: rgba(17, 24, 38, 0.08);
    color: inherit;
    text-decoration: none;
    display: inline-block;
    transition: background .2s;
}

.footprint-popup__link:hover {
    background: rgba(17, 24, 38, 0.16);
}

.footprint-popup__photos {
    position: relative;
    margin-top: .5rem;
}

.footprint-popup__track {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    padding-bottom: 4px;
}

.footprint-popup__track::-webkit-scrollbar {
    height: 4px;
}

.footprint-popup__track::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 999px;
}

.footprint-popup__slide {
    flex: 0 0 120px;
    scroll-snap-align: start;
    margin: 0 !important;
}

.footprint-popup__slide {
    position: relative;
}

.footprint-popup__slide img {
    width: 120px;
    height: 90px;
    border-radius: 8px;
    object-fit: cover;
    cursor: zoom-in;
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.footprint-popup__slide img.loaded {
    opacity: 1;
}

/* 图片加载指示器 */
.footprint-popup__slide-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    margin-top: -15px;
    margin-left: -15px;
    width: 30px;
    height: 30px;
    border: 3px solid rgba(0, 0, 0, 0.1);
    border-top-color: rgba(0, 0, 0, 0.4);
    border-radius: 50%;
    animation: footprint-spinner 0.8s linear infinite;
    pointer-events: none;
}

@keyframes footprint-spinner {
    to { transform: rotate(360deg); }
}

/* 强制图片为块级，避免 inline 图片在不同平台产生基线/空白差异 */
.footprint-popup__slide img { display: block; }

/* 兼容性回退：部分旧版 iOS/浏览器对 flex gap 存在差异，使用 margin-right 作为回退
   并用 @supports 避免在支持 gap 的浏览器产生双重间距 */
.footprint-popup__slide { margin-right: 8px; }
.footprint-popup__slide:last-child { margin-right: 0; }
@supports (gap: 8px) {
    .footprint-popup__slide { margin-right: 0; }
}

.footprint-popup__photos-btn {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(17, 24, 38, 0.7);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 2;
}

.footprint-popup__photos-btn--prev { left: 4px; }
.footprint-popup__photos-btn--next { right: 4px; }

/* ==========================================================================
   8. Photo Viewer
   ========================================================================== */
.footprint-photo-viewer {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.7);
    z-index: 100000 !important;
    opacity: 0;
    pointer-events: none;
    transition: opacity .2s ease;
}

.footprint-photo-viewer.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.footprint-photo-viewer__dialog {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footprint-photo-viewer__dialog img {
    max-width: 90vw;
    max-height: 85vh;
    box-shadow: 0 5px 20px rgba(0,0,0,0.5);
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.footprint-photo-viewer__dialog img.loaded {
    opacity: 1;
}

/* 灯箱查看器加载指示器 */
.footprint-photo-viewer__loader {
    position: absolute;
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: rgba(255, 255, 255, 0.8);
    border-radius: 50%;
    animation: footprint-spinner 0.8s linear infinite;
}

.footprint-photo-viewer__close {
    position: absolute;
    top: -40px;
    right: 0;
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(0,0,0,0.5);
    color: #fff;
    border-radius: 50%;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.footprint-photo-viewer__prev,
.footprint-photo-viewer__next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    background: rgba(0,0,0,0.45);
    color: #fff;
    border-radius: 50%;
    font-size: 1.25rem;
    cursor: pointer;
    z-index: 10002;
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.footprint-photo-viewer__prev { left: -60px; }
.footprint-photo-viewer__next { right: -60px; }

.footprint-photo-viewer__prev:hover,
.footprint-photo-viewer__next:hover {
    background: rgba(0,0,0,0.6);
}

.footprint-photo-viewer-open {
    overflow: hidden;
}

@media (max-width: 768px) {
    .footprint-photo-viewer__prev { left: 10px; }
    .footprint-photo-viewer__next { right: 10px; }
    .footprint-photo-viewer__close { top: 10px; right: 10px; z-index: 10; }
    .footprint-popup { width: 220px; }
    .footprint-popup__slide img { width: 100px; height: 80px; }
}

/* ==========================================================================
   9. Dark Mode
   ========================================================================== */
.dark .footprint-map {
    border-color: rgba(255, 255, 255, 0.1);
    background: #1a1a1a;
}
.dark .footprint-map.is-fullscreen { background: #1a1a1a; }
.dark .footprint-map__loading,
.dark .footprint-map__error { background: rgba(0, 0, 0, 0.6); color: #999; }
.dark .footprint-map__filters { background: rgba(33, 35, 40, 0.85); box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35); }
.dark .footprint-map__filter-btn { color: #999; }
.dark .footprint-map__filter-btn.is-active { background: #f7f7f7; color: #111; }
.dark .footprint-map__cluster-toggle { background: rgba(40, 40, 40, 0.95); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); color: #e0e0e0; }
.dark .footprint-map__cluster-toggle .toggle-switch.is-off { background: #555; }
.dark .footprint-map__province-toggle { background: rgba(40, 40, 40, 0.95); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4); color: #e0e0e0; }
.dark .footprint-map__province-toggle .toggle-switch.is-off { background: #555; }
.dark .footprint-ctrl-btn { background: #282828; color: #ccc; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.4); }
.dark .footprint-ctrl-btn:hover { background: #333; color: #fff; }
.dark .footprint-marker { border-color: rgba(0, 0, 0, 0.35); }
.dark .footprint-popup { background: rgba(33, 35, 40, .85); color: rgba(255, 255, 255, 0.92); }
.dark .footprint-popup__meta { color: #999; }
.dark .footprint-popup__tag { background: rgba(255, 255, 255, 0.14); color: #f5f5f5; }
.dark .footprint-popup__link { background: rgba(255, 255, 255, 0.14); }
.dark .footprint-popup__link:hover { background: rgba(255, 255, 255, 0.2); }
.dark .footprint-popup__track::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.28); }
.dark .footprint-popup__photos-btn { background: rgba(255, 255, 255, 0.8); color: #111; }
.dark .footprint-popup__slide-loader { border-color: rgba(255, 255, 255, 0.2); border-top-color: rgba(255, 255, 255, 0.6); }
.dark .amap-scale-text { color: #e0e0e0 !important; }