/* Block Mode — space handles, reorder handles, and visual feedback */

/* When SLide mode is active, suppress all touch scrolling through the
   entire zone so drag gestures aren't hijacked by the browser scroll. */
.sl-app[data-mode="mobile"] .sl-zone-body.slide-active {
    overflow: hidden !important;
    touch-action: none !important;
}

.sl-app[data-mode="mobile"] .sl-zone-body.slide-active * {
    touch-action: none !important;
}

.monaco-editor {
    --slide-font-size: 13px;
    --slide-line-height: 20px;
    --slide-gutter-pad: 2px;
    --slide-gutter-gap: 2px;
    --slide-space-col-width: 14px;
    --slide-delete-col-width: 14px;
    --slide-reorder-col-width: 14px;
    --slide-reorder-col-left: 32px;
    --slide-insert-width: 44px;
}

.block-mode-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: calc(var(--slide-reorder-col-left) - var(--slide-gutter-gap));
    height: 100%;
    z-index: 10;
    pointer-events: none;
    font-size: var(--slide-font-size);
}

/* Mobile gutter container for reorder handles — separate column right of block-mode-overlay */
.reorder-gutter-overlay {
    position: absolute;
    top: 0;
    left: var(--slide-reorder-col-left);
    width: var(--slide-reorder-col-width);
    height: 100%;
    z-index: 10;
    pointer-events: none;
    font-size: var(--slide-font-size);
}

.reorder-gutter-handle {
    position: absolute;
    left: 0;
    width: var(--slide-reorder-col-width);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    opacity: 0.35;
    transition: opacity 0.12s, background 0.12s, border-color 0.12s;
    border-radius: 4px;
    border: 1px solid transparent;
    user-select: none;
    touch-action: none;
    cursor: grab;
    background: transparent;
}

.reorder-gutter-handle:hover {
    opacity: 1;
    background: rgba(88, 166, 255, 0.1);
    border-color: rgba(88, 166, 255, 0.3);
}

.reorder-gutter-handle.dragging {
    opacity: 1;
    cursor: grabbing;
    background: rgba(88, 166, 255, 0.2);
    border-color: var(--accent, #58a6ff);
}

.reorder-gutter-handle .reorder-handle-dot {
    background: var(--accent, #58a6ff);
}

/* --- Space handles (gutter) --- */

.block-handle {
    position: absolute;
    left: var(--slide-gutter-pad);
    width: var(--slide-space-col-width);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: max(1px, calc(var(--slide-font-size) * 0.12));
    pointer-events: auto;
    opacity: 0.35;
    transition: opacity 0.12s, background 0.12s, box-shadow 0.12s;
    border-radius: 4px;
    border: 1px solid transparent;
    user-select: none;
    touch-action: none;
    cursor: ns-resize;
    background: transparent;
}

.block-handle:hover {
    opacity: 1;
    background: var(--bg-tertiary, rgba(255, 255, 255, 0.08));
    border-color: var(--border-primary, rgba(255, 255, 255, 0.12));
}

.block-handle.dragging {
    opacity: 1;
    background: rgba(210, 153, 34, 0.2);
    border-color: var(--console-warn, #d29922);
    box-shadow: 0 0 4px rgba(210, 153, 34, 0.3);
}

.block-handle-dot {
    width: max(3px, calc(var(--slide-font-size) * 0.26));
    height: max(3px, calc(var(--slide-font-size) * 0.26));
    border-radius: 50%;
    background: var(--text-muted, #6e7681);
    transition: background 0.12s;
    flex-shrink: 0;
}

.block-handle:hover .block-handle-dot {
    background: var(--text-primary, #c9d1d9);
}

.block-handle.dragging .block-handle-dot {
    background: var(--console-warn, #d29922);
}

/* --- Delete mark handles (gutter, next to space handle) --- */

.delete-handle {
    position: absolute;
    left: calc(var(--slide-gutter-pad) + var(--slide-space-col-width) + var(--slide-gutter-gap));
    width: var(--slide-delete-col-width);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    opacity: 0.2;
    transition: opacity 0.12s, color 0.12s;
    user-select: none;
    touch-action: none;
    cursor: pointer;
    color: var(--text-muted, #6e7681);
    font-size: max(10px, calc(var(--slide-font-size) * 0.8));
    line-height: 1;
}

.delete-handle:hover {
    opacity: 0.8;
    color: var(--console-error, #f85149);
}

.delete-handle.marked {
    opacity: 1;
    color: var(--console-error, #f85149);
}

/* Lines marked for deletion with /// */
.block-mode-marked-line {
    background: rgba(248, 81, 73, 0.06);
}

.block-mode-marked-text {
    text-decoration: line-through;
    opacity: 0.4;
}

/* 2x3 dot grid inside reorder handles */
.reorder-handle-grip {
    display: grid;
    grid-template-columns: repeat(2, max(3px, calc(var(--slide-font-size) * 0.26)));
    grid-template-rows: repeat(3, max(3px, calc(var(--slide-font-size) * 0.26)));
    gap: max(1px, calc(var(--slide-font-size) * 0.12));
}

.reorder-handle-dot {
    width: max(3px, calc(var(--slide-font-size) * 0.26));
    height: max(3px, calc(var(--slide-font-size) * 0.26));
    border-radius: 50%;
    background: var(--text-muted, #6e7681);
    transition: background 0.12s;
}

/* --- Monaco decorations --- */

/* Block highlight on reorder handle hover — visible rounded-rect effect */
.block-mode-highlight {
    background: rgba(88, 166, 255, 0.08);
    border-left: 3px solid rgba(88, 166, 255, 0.4);
}

/* Source block during drag */
.block-mode-drag-source {
    background: rgba(88, 166, 255, 0.12);
    border-left: 3px solid var(--accent, #58a6ff);
}

/* Reorder drop target indicator */
.block-mode-reorder-indicator {
    border-top: 2px solid var(--accent, #58a6ff);
}

/* --- Insert handles (+ buttons on blank lines, spans all 3 gutter columns) --- */

.insert-handle {
    position: absolute;
    left: var(--slide-gutter-pad);
    width: var(--slide-insert-width);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: auto;
    opacity: 0.5;
    transition: opacity 0.12s, background 0.12s, color 0.12s, box-shadow 0.12s;
    border-radius: 6px;
    user-select: none;
    touch-action: none;
    cursor: pointer;
    background: rgba(63, 185, 80, 0.08);
    color: var(--console-log, #3fb950);
    font-size: max(13px, calc(var(--slide-font-size) * 1.1));
    font-weight: 700;
    line-height: 1;
}

.insert-handle:hover {
    opacity: 1;
    background: rgba(63, 185, 80, 0.18);
    box-shadow: 0 0 0 1px rgba(63, 185, 80, 0.35);
}

.insert-handle.dragging {
    opacity: 1;
    background: rgba(63, 185, 80, 0.25);
    box-shadow: 0 0 6px rgba(63, 185, 80, 0.4);
    color: var(--console-log, #3fb950);
}

/* --- Insert option grid (absolutely positioned on document.body) --- */

.insert-grid {
    position: fixed;
    display: flex;
    flex-direction: row;
    gap: 2px;
    padding: 4px;
    background: var(--bg-secondary, #252526);
    border: 1px solid var(--border-primary, rgba(255, 255, 255, 0.12));
    border-radius: 6px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    z-index: 10000;
    white-space: nowrap;
    font-size: var(--slide-font-size);
}

.insert-grid-col {
    display: flex;
    flex-direction: column;
    min-width: 80px;
}

.insert-grid-header {
    padding: 2px 8px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted, #6e7681);
    text-align: center;
    user-select: none;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    margin-bottom: 2px;
}

.insert-grid-cell {
    padding: 3px 10px;
    font-size: 11px;
    color: var(--text-secondary, #8b949e);
    border-radius: 3px;
    cursor: pointer;
    transition: background 0.08s, color 0.08s;
    user-select: none;
    touch-action: none;
    text-align: center;
}

.insert-grid-cell:hover,
.insert-grid-cell.active {
    background: rgba(63, 185, 80, 0.15);
    color: var(--console-log, #3fb950);
}

.insert-grid-cell.empty {
    pointer-events: none;
    visibility: hidden;
}

/* --- Insert inline code preview (on the actual blank line) --- */

.insert-preview {
    pointer-events: none;
    white-space: pre;
    font-style: italic;
    opacity: 0.45;
    color: var(--console-log, #3fb950);
    line-height: inherit;
}

.insert-preview-more {
    font-size: 0.85em;
    opacity: 0.7;
}

/* --- Placeholder inline decoration (styles the actual /*type*/ text in the editor) --- */

.placeholder-inline {
    border: 1px dashed rgba(210, 153, 34, 0.35);
    border-radius: 3px;
    cursor: grab;
}

.placeholder-var-inline {
    border: 1px dashed rgba(88, 166, 255, 0.4);
    border-radius: 3px;
    cursor: grab;
}

/* --- Literal inline decoration (styles existing float/int literals in the editor) --- */

.literal-inline {
    border-bottom: 1px dashed rgba(139, 148, 158, 0.35);
    cursor: ew-resize;
}

/* --- Variable inline decoration (styles known typed variable usages) --- */

.variable-inline {
    border-bottom: 1px dotted rgba(88, 166, 255, 0.4);
    cursor: grab;
}

.variable-decl-inline {
    border-bottom: 1px dashed rgba(63, 185, 80, 0.55);
    border-radius: 2px;
    cursor: grab;
}

/* --- Placeholder/literal hit areas (transparent overlays for pointer events) --- */

.placeholder-hit-container {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
}

.placeholder-hit {
    position: absolute;
    pointer-events: auto;
    cursor: grab;
    border-radius: 3px;
    transition: background 0.1s;
    touch-action: none;
    user-select: none;
}

.placeholder-hit:hover {
    background: rgba(210, 153, 34, 0.1);
}

.placeholder-hit.literal-hit {
    cursor: ew-resize;
}

.placeholder-hit.literal-hit:hover {
    background: rgba(139, 148, 158, 0.1);
}

.placeholder-hit.variable-hit {
    cursor: grab;
}

.placeholder-hit.variable-hit:hover {
    background: rgba(88, 166, 255, 0.1);
}

.placeholder-hit.variable-decl-hit {
    cursor: grab;
}

.placeholder-hit.variable-decl-hit:hover {
    background: rgba(63, 185, 80, 0.12);
}

/* --- Placeholder floating menu (phase 1: float/int up-menu) --- */

.placeholder-menu {
    position: fixed;
    display: flex;
    flex-direction: row;
    min-width: auto;
    max-width: none;
    max-height: none;
    overflow: visible;
    z-index: 10001;
    pointer-events: auto;
}

.placeholder-menu-item {
    padding: 4px 10px;
    border-radius: 4px;
    color: var(--text-secondary, #8b949e);
    font-size: 11px;
    line-height: 1.3;
    white-space: nowrap;
    cursor: pointer;
    user-select: none;
    touch-action: none;
}

.placeholder-menu-item:hover,
.placeholder-menu-item.active {
    background: rgba(88, 166, 255, 0.16);
    color: var(--accent, #58a6ff);
}

/* Toggle button active state */
.v2-block-mode-btn.active {
    background: var(--accent, #58a6ff) !important;
    color: var(--bg-primary, #1e1e1e) !important;
    opacity: 1 !important;
}
