/* Circuit editor (CircuitSubmit page, wwwroot/js/circuiteditor.js) */

/* Layout: the map fills the height of the window, the panel beside it scrolls on its own and keeps its actions at the
   bottom, in view. On a phone, the map comes first and the panel follows, its actions stuck to the bottom. */
.ce-editor {
    display: flex;
    flex-direction: column;
}

.ce-map-frame {
    position: relative;
    height: 65vh;
    min-height: 22rem;
}

.ce-map {
    position: absolute;
    inset: 0;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: #20242c;
    touch-action: none;
}

/* What to do next, over the bottom of the map where the eyes are while drawing. */
.ce-map-hint {
    position: absolute;
    left: 50%;
    bottom: 1.75rem; /* Above the attribution of the map */
    z-index: 500;
    max-width: calc(100% - 2rem);
    transform: translateX(-50%);
    padding: 0.35rem 0.75rem;
    border-radius: 0.5rem;
    background: rgb(17 24 39 / 0.85);
    color: #fff;
    text-align: center;
    pointer-events: none;
}

.ce-map-hint:empty,
#ce-search-error:empty,
#ce-results:empty {
    display: none;
}

.ce-tabs {
    gap: 1.25rem;
    white-space: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
}

.ce-panel-footer {
    position: sticky;
    bottom: 0;
    z-index: 2;
    background: var(--card);
}

@media (min-width: 1024px) {
    .ce-editor {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 26rem;
        height: max(36rem, calc(100dvh - 11rem));
    }

    .ce-map-pane,
    .ce-panel {
        min-height: 0;
    }

    .ce-map-frame {
        flex: 1 1 auto;
        height: auto;
    }

    .ce-panel {
        display: flex;
        flex-direction: column;
    }

    .ce-panel-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto;
    }

    .ce-panel-footer {
        position: static;
    }
}

.ce-map.ce-placing {
    cursor: crosshair;
}

/* Timing lines */
.ce-line {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.5rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    cursor: pointer;
}

.ce-line.selected {
    border-color: var(--primary);
    box-shadow: 0 0 0 1px var(--primary);
}

.ce-swatch {
    flex: none;
    width: 1.4rem;
    height: 0.45rem;
    border: 1px solid #000;
}

.ce-line-text {
    display: grid;
    flex: 1 1 auto;
    min-width: 0;
    font-size: 0.875rem;
}

.ce-line-actions {
    display: flex;
    flex: none;
    gap: 0.125rem;
}

.ce-original-swatch {
    display: inline-block;
    width: 1.4rem;
    border-top: 4px dashed #111827;
    opacity: 0.7;
}

/* Handles on the map: a Leaflet marker of size 0, the visible dot centered on it. */
.ce-handle-anchor {
    background: none;
    border: none;
}

.ce-handle {
    position: absolute;
    left: -11px;
    top: -11px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--handle-color);
    border: 3px solid #000;
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.8);
    cursor: grab;
}

.ce-handle-corner {
    border-radius: 3px;
    background: rgba(255, 255, 255, 0.85);
}

.ce-handle-pending {
    background: #fff;
    border-color: var(--primary);
    animation: ce-pulse 1s ease-in-out infinite alternate;
}

@keyframes ce-pulse {
    from { transform: scale(0.8); }
    to { transform: scale(1.15); }
}

.ce-center {
    position: absolute;
    left: -16px;
    top: -16px;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-size: 18px;
    border: 2px solid #fff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
    cursor: grab;
}

/* Larger handles on a touch screen */
@media (pointer: coarse) {
    .ce-handle {
        left: -16px;
        top: -16px;
        width: 32px;
        height: 32px;
    }
}

.ce-map-label {
    font-weight: 600;
    padding: 0 0.3rem;
}

.ce-map-label-original {
    opacity: 0.75;
    font-weight: 400;
}

/* Track shape (trackeditor.js): the anchors of the edges, their handles, the ends and the width of a kerb */
.te-anchor {
    width: 10px;
    height: 10px;
    margin: -6px 0 0 -6px;
    background: #fff;
    border: 2px solid #111;
    box-sizing: content-box;
    cursor: move;
}

.te-anchor.selected {
    background: #ffd400;
}

.te-anchor.corner {
    transform: rotate(45deg);
}

.te-handle {
    width: 8px;
    height: 8px;
    margin: -5px 0 0 -5px;
    border-radius: 50%;
    background: #00c8ff;
    border: 2px solid #111;
    cursor: move;
}

.te-kerb-end {
    width: 10px;
    height: 10px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #dc1e1e;
    border: 2px solid #fff;
    cursor: ew-resize;
}

.te-kerb-width {
    width: 9px;
    height: 9px;
    margin: -6px 0 0 -6px;
    background: #fff;
    border: 2px solid #dc1e1e;
    cursor: ns-resize;
}

/* A kerb being placed: a cross instead of the hand */
.te-placing .leaflet-grab,
.te-placing .leaflet-interactive {
    cursor: crosshair;
}

/* 3D scene (sceneeditor.js): the tools as a row of icons, the properties of the selection only, the handles on the map */
.se-tools {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.se-tool {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 2.125rem;
    height: 2.125rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
    background: var(--background);
    color: var(--foreground);
}

.se-tool:hover {
    background: var(--accent);
}

.se-tool:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 1px;
}

.se-tool[aria-pressed="true"] {
    border-color: var(--primary);
    background: var(--primary);
    color: var(--primary-foreground);
}

.se-tool svg,
.se-icon {
    width: 1.125rem;
    height: 1.125rem;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.8;
    stroke-linecap: round;
    stroke-linejoin: round;
}

/* The mode buttons: the chosen one looks pressed */
.kt-toggle-group [aria-pressed="true"] {
    background: var(--accent);
    color: var(--accent-foreground);
    font-weight: 600;
}

.se-props {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    padding: 0.75rem;
    border: 1px solid var(--border);
    border-radius: 0.5rem;
}

.se-props.hidden {
    display: none;
}

.se-fields {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.5rem 0.75rem;
}

.se-fields label {
    display: flex;
    flex-direction: column;
    gap: 0.2rem;
    min-width: 0;
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.se-fields .se-wide {
    grid-column: 1 / -1;
}

.se-fields label.se-check {
    flex-direction: row;
    align-items: center;
    gap: 0.5rem;
    color: var(--foreground);
}

.se-fields input[type="color"] {
    width: 100%;
    height: 2rem;
    padding: 0.15rem;
    border: 1px solid var(--input);
    border-radius: 0.375rem;
    background: var(--background);
}

.se-swatch,
.se-legend {
    display: inline-block;
    flex: none;
    width: 0.8rem;
    height: 0.8rem;
    border-radius: 0.2rem;
}

.se-swatch-orthophoto { background: linear-gradient(135deg, #6b7c4a, #a39a7a); }
.se-swatch-buildings { background: #94a3b8; }
.se-swatch-trees { background: #22c55e; }
.se-swatch-hedges { background: #84cc16; }
.se-swatch-barriers { background: #f43f5e; }
.se-swatch-markings { background: #f8fafc; border: 1px solid #94a3b8; }
.se-swatch-props { background: #a855f7; }
.se-swatch-ground { background: #d6b98c; }
.se-swatch-relief { border: 2px dashed #eab308; }

.se-legend {
    width: 1.4rem;
    height: 0;
    border-radius: 0;
    border-top: 3px solid;
}

.se-legend-generated { border-top-color: #e2e8f0; border-top-width: 2px; }
.se-legend-changed { border-top-color: #fb923c; border-top-style: dashed; }
.se-legend-manual { border-top-color: #22d3ee; }

.se-issue {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
}

/* Handles of the selected object: move (the centre), size (a corner), turn, a point of a line */
.se-handle {
    width: 12px;
    height: 12px;
    margin: -7px 0 0 -7px;
    border-radius: 50%;
    background: #ffd400;
    border: 2px solid #111;
    cursor: move;
}

.se-handle.se-vertex {
    width: 9px;
    height: 9px;
    margin: -6px 0 0 -6px;
    border-radius: 2px;
    background: #fff;
}

.se-handle.se-middle {
    width: 7px;
    height: 7px;
    margin: -5px 0 0 -5px;
    background: rgb(255 255 255 / 0.55);
    border-width: 1px;
    cursor: copy;
}

.se-handle.se-size {
    border-radius: 2px;
    background: #fff;
    cursor: nwse-resize;
}

.se-handle.se-turn {
    background: #22d3ee;
    cursor: grab;
}

.se-handle.se-first {
    background: #22d3ee;
    cursor: pointer;
}

@media (pointer: coarse) {
    .se-handle {
        width: 22px;
        height: 22px;
        margin: -12px 0 0 -12px;
    }

    .se-tool {
        width: 2.5rem;
        height: 2.5rem;
    }
}

.se-drawing .leaflet-grab,
.se-drawing .leaflet-interactive {
    cursor: crosshair;
}

/* While the 3D scene tab is open, the proposal of the circuit (its comment, its buttons, its hint) is out of the way */
.ce-editor.se-active .ce-panel-footer,
.ce-editor.se-active #ce-hint {
    display: none;
}

@media (max-width: 640px) {
    #se-hint {
        bottom: 2.5rem;
        font-size: 0.75rem;
        line-height: 1.1rem;
    }
}

/* Field left empty by people (CircuitSubmit, without an account): off screen, not display:none, which some robots skip */
.ce-trap {
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}
