/* ── compare.css — Swipe / Side-by-side compare mode ── */

/* ─── Secondary map container ─── */
#map-compare {
    position: fixed;
    inset: 0;
    z-index: 1;          /* just above #map (z-index 0) */
    pointer-events: auto;
}

/* ─── Swipe mode: clip both maps ─── */
body.compare-swipe #map {
    clip-path: inset(0 var(--compare-clip-right, 50%) 0 0);
}
body.compare-swipe #map-compare {
    clip-path: inset(0 0 0 var(--compare-clip-left, 50%));
}

/* ─── Side-by-side mode ─── */
body.compare-sbs #map {
    clip-path: inset(0 50% 0 0);
}
body.compare-sbs #map-compare {
    clip-path: inset(0 0 0 50%);
}
body.compare-sbs #compare-divider {
    left: 50% !important;
    pointer-events: none;
}
body.compare-sbs #compare-divider .compare-handle {
    display: none;
}

/* ─── Divider line + handle ─── */
#compare-divider {
    position: fixed;
    top: var(--topbar-h);
    bottom: 0;
    left: 50%;
    width: 4px;
    margin-left: -2px;
    z-index: 790;        /* below timeline (800) */
    cursor: ew-resize;
    touch-action: none;
    user-select: none;
}
#compare-divider::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--accent);
    opacity: 0.85;
    border-radius: 2px;
}
/* Wider invisible hit area */
#compare-divider::after {
    content: '';
    position: absolute;
    top: 0; bottom: 0;
    left: -14px;
    width: 32px;
}

.compare-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 40px;
    background: var(--surface);
    border: 2px solid var(--accent);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 3px;
    pointer-events: none;
}
.compare-handle::before,
.compare-handle::after {
    content: '';
    display: block;
    width: 2px;
    height: 14px;
    border-radius: 1px;
    background: var(--accent);
    opacity: 0.6;
}

/* ─── Layer name labels on each side ─── */
.compare-label {
    position: fixed;
    top: calc(var(--topbar-h) + 10px);
    z-index: 850;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    padding: 5px 12px;
    font-size: 12px;
    font-family: var(--font-body);
    color: var(--text-1);
    box-shadow: var(--shadow-sm);
    pointer-events: none;
    max-width: 240px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.compare-label--left {
    left: 12px;
}
.compare-label--right {
    right: 12px;
}

/* ─── Compare floating panel ─── */
#compare-panel {
    position: fixed;
    top: calc(var(--topbar-h) + 10px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 900;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 12px;
    min-width: 440px;
}

.compare-section {
    display: flex;
    align-items: center;
    gap: 6px;
}

.compare-section label {
    font-weight: 600;
    color: var(--text-2);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.compare-select {
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-1);
    font-size: 12px;
    min-width: 120px;
    max-width: 160px;
    cursor: pointer;
}
.compare-select:focus {
    outline: 2px solid var(--accent);
    outline-offset: -1px;
}

/* Separator between left/right selectors */
.compare-sep {
    width: 1px;
    height: 24px;
    background: var(--border);
    flex-shrink: 0;
}

/* Mode toggle pill (swipe / side-by-side) */
.compare-mode-pill {
    display: flex;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    overflow: hidden;
}
.compare-mode-btn {
    padding: 4px 10px;
    font-size: 11px;
    background: var(--surface-2);
    color: var(--text-2);
    border: none;
    cursor: pointer;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.compare-mode-btn + .compare-mode-btn {
    border-left: 1px solid var(--border);
}
.compare-mode-btn.is-active {
    background: var(--accent);
    color: #fff;
}
.compare-mode-btn:hover:not(.is-active) {
    background: var(--border);
}

/* Swap + Exit buttons */
.compare-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px 8px;
    border: 1px solid var(--border);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    color: var(--text-1);
    font-size: 12px;
    cursor: pointer;
    transition: background 0.15s;
    gap: 4px;
}
.compare-btn:hover {
    background: var(--border);
}
.compare-btn--exit {
    border-color: var(--red-border);
    color: var(--red);
}
.compare-btn--exit:hover {
    background: var(--red-lt);
}

/* ─── Body-level transition for smooth mode switch ─── */
body.compare-swipe #map,
body.compare-swipe #map-compare,
body.compare-sbs #map,
body.compare-sbs #map-compare {
    transition: clip-path 0.05s linear;
}
