/* Camera panes use one SVG viewBox for every host. The viewport owns clipping;
   the camera panel fills it without centering or introducing a second scroll range. */
.map-camera-viewport {
    position: relative;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
    touch-action: auto;
    cursor: grab;
}

#map-viewport.map-camera-viewport,
#watch-map-viewport.map-camera-viewport,
#map-panel.map-camera-viewport {
    display: block;
    overflow: hidden;
}

#map-panel.map-camera-viewport {
    padding: 0;
    transform: none;
    transition: none;
}

.map-camera-viewport:focus-visible {
    outline: 2px solid var(--accent, #7bdff2);
    outline-offset: 2px;
}

.map-camera-viewport.is-map-dragging,
.map-camera-viewport.is-dragging {
    cursor: grabbing;
}

.map-camera-viewport.map-camera-touch-enabled[data-map-ready] {
    touch-action: none;
}

.map-camera-panel {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    min-width: 0;
    min-height: 0;
    overflow: hidden;
    box-sizing: border-box;
}

#map-viewport > #map-panel.map-camera-panel,
#watch-map-viewport > #watch-mermaid-panel.map-camera-panel,
#map-panel.map-camera-viewport > #map-camera-panel.map-camera-panel {
    display: block;
    padding: 0;
    transform: none;
    transform-origin: center center;
    transition: none;
    flex: none;
}

#watch-mermaid-panel.map-camera-panel {
    max-height: none;
    overflow: hidden;
}

.map-camera-panel > svg.map-camera-svg {
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    max-height: none;
}

.map-camera-panel > .map-fallback {
    box-sizing: border-box;
    height: 100%;
    margin: 0;
    padding: 0.5rem;
    overflow: auto;
}

.map-camera-toolbar {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.5rem;
}

.map-camera-toolbar [data-map-action] {
    min-width: 2.75rem;
    min-height: 2.5rem;
    padding: 0.4rem 0.75rem;
    border: 1px solid var(--border);
    border-radius: 999px;
    background: var(--bg);
    color: var(--text);
    font-family: inherit;
    font-size: 0.8rem;
    line-height: 1;
    cursor: pointer;
    touch-action: manipulation;
}

.map-camera-toolbar [data-map-action]:hover:not(:disabled),
.map-camera-toolbar [data-map-action][aria-pressed="true"] {
    border-color: var(--accent);
    color: var(--accent);
}

.map-camera-toolbar [data-map-action]:disabled {
    cursor: not-allowed;
    opacity: 0.58;
}

.map-camera-toolbar [data-map-action]:focus-visible {
    outline: 2px solid var(--accent, #7bdff2);
    outline-offset: 2px;
}

.map-camera-toolbar [data-map-zoom] {
    min-width: 4.5rem;
    text-align: center;
    font-variant-numeric: tabular-nums;
}

.map-camera-help {
    margin: 0;
    color: var(--dim, #aab5c0);
    font-size: 0.78rem;
    line-height: 1.45;
}

/* Render generations away from the visible host, then move only the winning SVG
   into its camera panel. visibility:hidden keeps Mermaid's measured layout alive. */
.map-render-stage {
    position: fixed;
    top: 0;
    left: -100000px;
    width: 1000px;
    max-width: none;
    min-height: 1px;
    overflow: hidden;
    visibility: hidden;
    pointer-events: none;
    contain: layout style paint;
    z-index: -1;
}

.map-render-stage svg {
    display: block;
    width: 100%;
    height: auto;
}

@media (max-width: 720px) {
    .map-camera-toolbar {
        gap: 0.35rem;
    }

    .map-camera-toolbar [data-map-action] {
        min-width: 2.65rem;
        min-height: 2.65rem;
        padding-inline: 0.55rem;
    }

    .map-camera-toolbar [data-map-zoom] {
        min-width: 3.75rem;
    }
}

/* The camera changes SVG coordinates directly, so it has no motion animation. */
@media (prefers-reduced-motion: reduce) {
    .map-camera-panel,
    .map-camera-panel > svg.map-camera-svg {
        scroll-behavior: auto;
        transition: none;
    }
}
