/* =========================================================================
   editor.css — SVG Editor styles
   Loaded ONLY by b-spline-gen pages (b-spline-gen/html/index.html and
   b-spline-gen/html/bspline_gen_palette.html). The SVG editor modal lives
   inside those pages and uses these tool/handle/keyboard styles plus
   responsive overrides for narrow viewports.
   ========================================================================= */

/* NOTE: The .ttf files under b-spline-gen/html/fonts/ are stamp assets
   loaded by opentype.js in editor-geometry.js, not CSS web fonts. The
   .symbol-key buttons further down rely on system font fallbacks
   (Segoe UI Symbol on Windows, Apple Color Emoji on macOS/iOS,
   Noto Sans Symbols on Linux). */

#svgEditorModal {
    z-index: 2000;
}

/* Native CAD Overhaul Modal Overlay */
.cad-modal-overlay {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background: rgba(0, 0, 0, 0.4);
    align-items: center;
    justify-content: center;
    z-index: 9999 !important;
}

.cad-modal-window.overhauled {
    box-shadow: none !important;
    border: none !important;
    background: #fdfdfd !important;
    border-radius: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    display: flex !important;
    flex-direction: column !important;
}

/* Tool Buttons */
.tool-btn {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    background: transparent;
    border: 1px solid transparent;
    padding: 0;
    outline: none;
}

.tool-btn:hover {
    background: #eee;
    color: #333;
}

.tool-btn.active {
    background: var(--cad-accent) !important;
    color: white !important;
    border-color: var(--cad-accent) !important;
}

#toolSelect .material-symbols-outlined {
    font-variation-settings: 'FILL' 1; /* Solid Black Cursor */
}

#toolNode .material-symbols-outlined {
    font-variation-settings: 'FILL' 0; /* Outline White Cursor */
}

.tool-btn .material-symbols-outlined {
    font-size: 20px;
}

/* Top View Canvas Scaling */
#svgEditorTopView {
    image-rendering: pixelated;
    image-rendering: crisp-edges;
    pointer-events: none;
    opacity: 0.85;
}

/* SVG Drawing Area */
#editorCanvasContainer {
    transition: padding-bottom 0.1s ease-out;
}

#editorSVGContainer {
    cursor: crosshair;
}

#editorSVGContainer.mode-select { cursor: default; }
#editorSVGContainer.mode-node { cursor: default; }

/* Handle/Node Styles */
.svg-handle {
    fill: #fff;
    stroke: var(--cad-accent);
    stroke-width: 0.5px;
}

.svg-handle:hover {
    fill: var(--cad-accent);
    stroke: #fff;
}

/* 2-STATE RESPONSIVE: NARROW MODE */
@media (max-width: 720px) {
    .cad-modal-window.overhauled {
        width: 100vw !important;
        height: 100vh !important;
        max-width: 100vw !important;
        max-height: 100vh !important;
        border-radius: 0 !important;
    }

    .cad-modal-body {
        flex-direction: column !important;
    }

    .editor-sidebar {
        width: 100% !important;
        height: auto !important;
        flex-direction: row !important;
        padding: 6px 12px !important;
        border-right: none !important;
        border-bottom: 1px solid var(--cad-border-standard) !important;
        justify-content: flex-start !important;
        overflow-x: auto !important;
        gap: 8px !important;
        white-space: nowrap !important;
    }

    .tool-divider {
        width: 1px !important;
        height: 20px !important;
        margin: 0 4px !important;
    }

    /* Properties Bar Stacking */
    .editor-toolbar-top {
        overflow-x: auto;
        padding: 0 8px !important;
        gap: 16px !important;
    }

    .editor-toolbar-top > div {
        flex-shrink: 0 !important;
    }
}

.tool-btn.active {
    background: #e5f3ff !important;
    color: #1a1a1a !important;
    border: 1px solid var(--cad-accent) !important;
    box-shadow: inset 0 1px 3px rgba(0,0,0,0.12) !important;
}

/* Ensure SVG icons stay dark and become bold when active */
.tool-btn.active svg {
    stroke: #1a1a1a !important;
    stroke-width: 2.5px !important;
}

/* Property Groups Visibility - Unified Model */
.property-group.hidden {
    display: none !important;
}

.editor-properties-pane {
    display: flex !important; /* Managed by group visibility now */
}

/* Status Item (Snap) Active Style */
.status-item.active {
    color: var(--cad-accent) !important;
    text-shadow: 0 0 4px rgba(6, 150, 215, 0.3);
}

.status-item:hover {
    color: #333 !important;
}

/* Restore Glyph hover style */
#editorSymbolKeyboardGrid div:hover,
.symbol-key:hover {
    background: var(--cad-accent-hover) !important;
    color: white !important;
}

.symbol-key {
    background: white;
    border: 1px solid #eee;
    border-radius: 4px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    cursor: pointer;
    transition: all 0.1s ease;
    margin: 1px;
    /* System fallbacks for special symbols as suggested by user */
    font-family: "Segoe UI Symbol", "Apple Color Emoji", "Noto Sans Symbols", "Segoe UI", Tahoma, sans-serif;
}

.symbol-key:active {
    background: var(--cad-accent) !important;
    transform: translateY(1px);
}

/* Stepper styles */
.stepper-container input::-webkit-outer-spin-button,
.stepper-container input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* =========================================================================
   ===== Mobile ===== (editor-specific narrow viewport overrides,
   originally editor-mobile.css)
   ========================================================================= */
@media (max-width: 720px) {
    #svgEditorModal .modal-window>div:nth-child(2) {
        flex-direction: column;
    }

    #editorCanvasContainer {
        padding-inline: var(--mobile-dynamic-padding, 0px);
        transition: padding 0.05s linear;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        flex: 1 1 auto;
        min-height: 0;
        height: 100%;
        overflow: hidden;
    }

    #editorSVGContainer {
        width: auto !important;
        max-width: 100%;
        margin: 0 auto;
        flex: 1 1 auto;
        min-height: 0;
        height: auto;
        min-width: 0 !important;
    }

    .editor-symbol-keyboard {
        position: relative !important;
        bottom: auto !important;
        left: auto !important;
        right: auto !important;
        width: 100vw !important;
        max-width: 100vw !important;
        margin-inline: calc(var(--mobile-dynamic-padding, 0px) * -1);
        flex-shrink: 0;
        box-shadow: none;
        border-top: 1px solid var(--border);
        border-left: none;
        border-right: none;
        border-radius: 0;
        touch-action: none;
        z-index: 100;
    }

    .editor-sidebar {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        padding: 8px 8px;
        border-right: none;
        border-bottom: 1px solid var(--border);
        background: var(--surface);
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        justify-content: flex-start;
        align-items: center;
        gap: 6px;
        overflow-x: auto;
        overflow-y: hidden;
        white-space: nowrap;
        -webkit-overflow-scrolling: touch;
        touch-action: pan-x;
    }

    .editor-sidebar .tool-btn {
        width: 38px;
        height: 38px;
        flex: 0 0 auto;
        padding: 6px;
    }

    .editor-toolbar-top {
        padding: 8px 10px;
        gap: 8px;
    }

    .editor-properties-panel {
        width: 100%;
        max-width: none;
        justify-content: space-between;
    }

    .editor-properties-pane,
    .property-row {
        width: 100%;
        justify-content: space-between;
    }

    .property-select,
    .property-number {
        min-width: 90px;
        height: 30px;
    }

    .property-row {
        flex-wrap: wrap;
    }

    .editor-symbol-keyboard-header {
        flex-wrap: wrap;
        justify-content: space-between;
        gap: 8px;
    }

    .editor-symbol-keyboard-actions {
        margin-left: auto;
    }
}

@media (max-width: 700px) {
    #svgEditorHeader {
        flex-direction: row;
        align-items: center !important;
        justify-content: space-between;
        padding: 12px 10px;
        gap: 12px;
        width: 100%;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    #svgEditorHeader h3 {
        margin: 0;
    }

    #svgEditorHeader>div {
        width: auto;
        margin-left: 0 !important;
        justify-content: space-between;
        min-width: 0;
        flex: 0 0 auto;
        display: flex;
        align-items: center;
    }

    .editor-toolbar-top {
        flex-wrap: nowrap;
        gap: 8px;
        padding: 10px 10px 10px 8px;
        height: auto;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scroll-snap-type: x proximity;
        align-items: center;
        white-space: nowrap;
    }

    .editor-toolbar-top > * {
        flex: 0 0 auto;
        scroll-snap-align: start;
        min-width: 0;
    }

    /* Prevent the layout spacer from forcing a second row on mobile */
    .editor-toolbar-top > div[style*="flex:1"] {
        flex: 0 0 auto !important;
        width: auto !important;
    }

    #svgEditorHeader > div:last-child {
        gap: 4px;
    }

    #svgEditorHeader > div:last-child > button {
        min-width: 0 !important;
        width: auto !important;
        padding: 4px 8px !important;
        height: 30px !important;
        font-size: 11px !important;
        line-height: 1 !important;
    }

    #svgEditorHeader > div:last-child > button.btn-primary.btn-xs {
        padding: 4px 10px !important;
    }

    #svgEditorHeader > div:last-child > button,
    #svgEditorHeader > div:last-child > button.btn-secondary,
    #svgEditorHeader > div:last-child > button.btn-primary {
        flex: 0 0 auto !important;
    }

    .editor-properties-panel {
        display: flex;
        flex: 1 1 auto;
        min-width: 0;
        gap: 12px;
        align-items: center;
        flex-wrap: nowrap;
        overflow-x: auto;
    }

    .editor-properties-pane {
        display: none;
        align-items: center;
        gap: 12px;
        min-width: 0;
        flex-wrap: nowrap;
    }

    .editor-properties-pane.active {
        display: flex;
    }

    .property-row {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        flex-wrap: nowrap;
        min-width: 0;
    }

    .property-label {
        font-size: 11px;
        opacity: 0.75;
        white-space: nowrap;
        min-width: 0;
    }

    .property-select,
    .property-number,
    .property-range {
        font: 13px/1.4 Arial, sans-serif;
        border: 1px solid var(--border);
        border-radius: 8px;
        background: var(--surface);
        color: var(--text);
        outline: none;
        transition: border-color 0.16s ease, box-shadow 0.16s ease;
    }

    .property-select {
        min-width: 120px;
        height: 32px;
        padding: 0 10px;
    }

    .property-number {
        width: 50px;
        min-width: 50px;
        height: 32px;
        padding: 0 8px;
        text-align: center;
    }

    .property-range {
        min-width: 140px;
        max-width: 220px;
        height: 24px;
    }

    .stepper-group {
        display: inline-flex;
        align-items: center;
        gap: 4px;
    }

    .stepper-btn {
        width: 30px;
        height: 30px;
        border-radius: 8px;
        border: 1px solid var(--border);
        background: var(--surface2);
        color: var(--text);
        cursor: pointer;
        font-size: 16px;
        line-height: 1;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        transition: background 0.16s ease, border-color 0.16s ease;
    }

    .stepper-btn:hover {
        background: var(--surface);
        border-color: rgba(0,0,0,0.12);
    }

    .editor-action-btn {
        height: 32px;
        min-width: 84px;
    }

    .editor-layer-group {
        display: inline-flex;
        align-items: center;
        gap: 10px;
        padding-left: 12px;
        border-left: 1px solid var(--border);
        margin-left: 12px;
        white-space: nowrap;
    }

    .property-note {
        font-size: 12px;
        opacity: 0.75;
    }

    #editorStrokeGroup,
    #editorFontGroup {
        width: auto;
        justify-content: flex-start;
    }

    #editorStrokeWidthSlider {
        flex: 1;
        margin-right: 12px;
    }

    .editor-sidebar {
        width: 56px;
        min-width: 56px;
        padding: 10px 6px;
    }

    .tool-btn {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-width: 40px;
        width: 40px;
        height: 40px;
        padding: 6px;
        border-radius: 10px;
    }
}
