/* Screenshot annotation editor popup (opened by the map camera button) */

.map-screenshot-editor {
    position: fixed;
    inset: 0;
    z-index: 100001;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 6, 4, 0.78);
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

.map-screenshot-editor.is-open {
    display: flex;
}

.mse-dialog {
    display: flex;
    flex-direction: column;
    min-width: 0;
    max-width: min(1240px, 100%);
    max-height: 100%;
    background: var(--panel);
    border: 2px solid var(--border-strong);
    box-shadow: 6px 6px 0 #000000;
}

@media (prefers-reduced-motion: no-preference) {
    .map-screenshot-editor.is-open .mse-dialog {
        animation: mse-pop 0.18s ease-out;
    }

    @keyframes mse-pop {
        from { transform: translateY(10px) scale(0.985); opacity: 0; }
        to { transform: none; opacity: 1; }
    }
}

.mse-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    border-bottom: 2px solid var(--border);
    background: var(--panel-dark);
}

.mse-title {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-display);
    font-size: 1.15rem;
    font-weight: 800;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--accent);
    white-space: nowrap;
}

.mse-subtitle {
    color: var(--muted);
    font-size: 0.72rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
}

.mse-close {
    margin-left: auto;
}

/* Square hard-shadow buttons for tools, undo/redo, and the header close. */

.mse-tool,
.mse-close {
    width: 36px;
    height: 36px;
    flex: 0 0 auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-deep);
    border: 2px solid var(--border);
    color: var(--text);
    font-size: 0.9rem;
    cursor: pointer;
    border-radius: 0;
    box-shadow: var(--shadow-s);
    transition: all 0.12s ease;
}

.mse-tool:hover:not(:disabled),
.mse-close:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
    transform: translate(-1px, -1px);
    box-shadow: var(--shadow-m);
}

.mse-tool:active:not(:disabled),
.mse-close:active {
    transform: translate(1px, 1px);
    box-shadow: var(--shadow-xs);
}

.mse-tool.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #141414;
}

.mse-tool.is-active:hover:not(:disabled) {
    color: #141414;
}

.mse-tool:disabled {
    opacity: 0.4;
    cursor: default;
    box-shadow: none;
    transform: none;
}

.mse-tool[data-tool="arrow"] i {
    transform: rotate(-45deg);
}

.mse-toolbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 16px;
    padding: 10px 16px;
    border-bottom: 2px solid var(--border);
}

.mse-tools,
.mse-swatches,
.mse-sizes,
.mse-dashes,
.mse-history {
    display: flex;
    align-items: center;
    gap: 6px;
}

.mse-history {
    margin-left: auto;
}

.mse-swatch {
    width: 22px;
    height: 22px;
    padding: 0;
    border: 2px solid var(--border);
    cursor: pointer;
    border-radius: 0;
    box-shadow: var(--shadow-xs);
    transition: all 0.12s ease;
}

.mse-swatch:hover {
    transform: translate(-1px, -1px);
    box-shadow: var(--shadow-s);
}

.mse-swatch.is-active {
    border-color: var(--text);
    outline: 2px solid var(--accent);
    outline-offset: 1px;
}

.mse-size,
.mse-dash {
    width: 30px;
    height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: var(--panel-deep);
    border: 2px solid var(--border);
    color: var(--text);
    cursor: pointer;
    border-radius: 0;
    box-shadow: var(--shadow-s);
    transition: all 0.12s ease;
}

.mse-size:hover,
.mse-dash:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
    transform: translate(-1px, -1px);
    box-shadow: var(--shadow-m);
}

.mse-size.is-active,
.mse-dash.is-active {
    background: var(--accent);
    border-color: var(--accent);
    color: #141414;
}

.mse-size-dot {
    display: block;
    background: currentColor;
}

.mse-size-dot-s { width: 4px; height: 4px; }
.mse-size-dot-m { width: 8px; height: 8px; }
.mse-size-dot-l { width: 12px; height: 12px; }

.mse-dash-sample {
    display: block;
    width: 16px;
    border-top: 3px solid currentColor;
}

.mse-dash-sample-dashed {
    border-top-style: dashed;
}

.mse-canvas-wrap {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
    padding: 16px;
    background: var(--panel-deep);
    overflow: hidden;
}

.mse-canvas {
    display: block;
    max-width: 100%;
    max-height: min(62vh, 900px);
    width: auto;
    height: auto;
    border: 2px solid var(--border);
    box-shadow: var(--shadow-m);
    cursor: crosshair;
    touch-action: none;
    transform-origin: center center;
}

/* Zoom controls floated over the canvas corner */

.mse-zoom {
    position: absolute;
    right: 12px;
    bottom: 12px;
    z-index: 4;
    display: flex;
    align-items: center;
    gap: 3px;
    padding: 3px;
    background: rgba(13, 12, 10, 0.88);
    border: 2px solid var(--border);
    box-shadow: var(--shadow-s);
}

.mse-zoom button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    background: var(--panel-deep);
    border: 1px solid var(--border);
    border-radius: 0;
    color: var(--text);
    font-size: 0.72rem;
    cursor: pointer;
    transition: all 0.12s ease;
}

.mse-zoom button:hover {
    border-color: var(--accent);
    color: var(--accent-strong);
}

.mse-zoom .mse-zoom-level {
    width: auto;
    min-width: 48px;
    background: transparent;
    border-color: transparent;
    color: var(--muted);
    font-family: var(--font-ui);
    font-size: 0.68rem;
    font-weight: 800;
    letter-spacing: 0.04em;
}

.mse-zoom .mse-zoom-level:hover {
    color: var(--accent);
    border-color: transparent;
}

/* Inline input for the text tool, floated over the click point. Resizable
   sideways: the box width becomes the committed text's wrap width. */
.mse-text-input {
    position: absolute;
    display: none;
    z-index: 3;
    min-width: 170px;
    width: 240px;
    max-width: min(520px, 78%);
    min-height: 1.6em;
    padding: 4px 8px;
    background: rgba(10, 9, 8, 0.88);
    border: 2px dashed var(--accent);
    border-radius: 0;
    color: var(--text);
    font-family: var(--font-ui);
    font-weight: 800;
    line-height: 1.25;
    outline: none;
    resize: horizontal;
    overflow: hidden;
}

.mse-text-input.is-visible {
    display: block;
}

.mse-footer {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px 14px;
    padding: 12px 16px;
    border-top: 2px solid var(--border);
    background: var(--panel-dark);
}

.mse-hint {
    color: var(--muted);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.04em;
    text-transform: uppercase;
}

.mse-actions {
    margin-left: auto;
    display: flex;
    gap: 10px;
}

.mse-actions .btn {
    font-size: 0.88rem;
    min-height: 2.35em;
}

/* Mobile: the editor takes the whole screen, the toolbar collapses into one
   horizontally scrollable row, and the canvas flexes into what remains. */
@media (max-width: 768px) {
    .map-screenshot-editor {
        padding: 0;
    }

    .mse-dialog {
        width: 100%;
        height: 100%;
        max-width: none;
        max-height: none;
        border: 0;
        box-shadow: none;
    }

    .mse-header {
        padding: 8px 10px;
    }

    .mse-title {
        font-size: 1rem;
    }

    .mse-subtitle,
    .mse-hint {
        display: none;
    }

    /* Compact wrapped rows: every control stays on screen, nothing clips. */
    .mse-toolbar {
        justify-content: center;
        gap: 6px 10px;
        padding: 6px 8px;
    }

    .mse-tools,
    .mse-swatches,
    .mse-sizes,
    .mse-dashes,
    .mse-history {
        flex: 0 0 auto;
        gap: 4px;
    }

    .mse-history {
        margin-left: 0;
    }

    .mse-tool,
    .mse-close {
        width: 31px;
        height: 31px;
        font-size: 0.78rem;
        box-shadow: var(--shadow-xs);
    }

    .mse-size,
    .mse-dash {
        width: 25px;
        height: 31px;
        box-shadow: var(--shadow-xs);
    }

    .mse-swatch {
        width: 19px;
        height: 19px;
    }

    .mse-size-dot-s { width: 3px; height: 3px; }
    .mse-size-dot-m { width: 6px; height: 6px; }
    .mse-size-dot-l { width: 10px; height: 10px; }

    .mse-dash-sample {
        width: 12px;
        border-top-width: 2px;
    }

    .mse-canvas-wrap {
        flex: 1 1 auto;
        min-height: 0;
        padding: 8px;
    }

    .mse-canvas {
        max-width: 100%;
        max-height: 100%;
    }

    .mse-zoom {
        right: 8px;
        bottom: 8px;
    }

    .mse-footer {
        padding: 8px 10px;
        gap: 8px;
    }

    .mse-actions {
        margin-left: 0;
        width: 100%;
        gap: 8px;
    }

    .mse-actions .btn {
        flex: 1 1 0;
        font-size: 0.8rem;
        min-height: 2.5em;
    }
}
