/* ==========================================================================
   File: Tool/3d/engine/viewport.css
   KHALA STUDIO — SCREEN-SPACE SELECTION & CONSTANT-SIZE HANDLES
   ========================================================================== */

.threed-canvas-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #0e0e10;
    cursor: default;
}

.threed-artboard-container {
    position: absolute;
    top: 0;
    left: 0;
    transform-origin: 0 0;
    will-change: transform;
    transition: none !important;
}

.threed-artboard {
    position: relative;
    box-shadow: 0 30px 80px rgba(0, 0, 0, 0.9);
    overflow: hidden;
    background-size: cover;
    background-position: center;
    transition: none !important;
}

/* Marquee Drag Box */
.threed-marquee-box {
    position: absolute;
    background: rgba(10, 132, 255, 0.16);
    pointer-events: none;
    z-index: 9999;
    display: none;
    border-radius: 2px;
}

/* Shape Nodes inside Artboard */
.threed-shape-node {
    position: absolute;
    box-sizing: border-box;
    cursor: move;
    user-select: none;
    -webkit-user-select: none;
    -webkit-user-drag: none;
    touch-action: none;
    transition: none !important;
}

.threed-shape-node.smart-object-node {
    overflow: visible;
}

.threed-smart-obj-badge {
    position: absolute;
    bottom: 4px;
    right: 4px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 4px;
    padding: 2px;
    display: flex;
    pointer-events: none;
}

.threed-shape-node.text-node {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    outline: none;
    word-break: break-word;
}

.threed-shape-node img,
.threed-shape-node canvas {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
    -webkit-user-drag: none;
}

.threed-shape-triangle {
    width: 100%;
    height: 100%;
    clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
}

/* ⚡ Transform Overlay (Screen-Space Pixel Precision) */
.threed-transform-overlay {
    position: absolute;
    border: 1.5px solid #0A84FF;
    pointer-events: none !important;
    box-sizing: border-box;
    display: none;
    z-index: 10000;
    transition: none !important;
}

/* ⚡ 8 Control Handles — ទំហំថេរ 9px គ្រប់ Zoom Level ទាំងអស់ */
.threed-handle {
    position: absolute;
    width: 9px;
    height: 9px;
    background: #ffffff;
    border: 1.5px solid #0A84FF;
    border-radius: 2px;
    pointer-events: auto !important;
    transition: none !important;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
}

.threed-handle.nw { top: 0; left: 0; cursor: nwse-resize; }
.threed-handle.n  { top: 0; left: 50%; cursor: ns-resize; }
.threed-handle.ne { top: 0; left: 100%; cursor: nesw-resize; }
.threed-handle.e  { top: 50%; left: 100%; cursor: ew-resize; }
.threed-handle.se { top: 100%; left: 100%; cursor: nwse-resize; }
.threed-handle.s  { top: 100%; left: 50%; cursor: ns-resize; }
.threed-handle.sw { top: 100%; left: 0; cursor: nesw-resize; }
.threed-handle.w  { top: 50%; left: 0; cursor: ew-resize; }

/* ⚡ Top Rotation Pin — កម្ពស់ និងទំហំថេរស្អាតជានិច្ច */
.threed-rot-handle {
    position: absolute;
    top: -24px;
    left: 50%;
    width: 10px;
    height: 10px;
    background: #0A84FF;
    border: 1.5px solid #ffffff;
    border-radius: 50%;
    pointer-events: auto !important;
    cursor: grab;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    transition: none !important;
}

.threed-rot-line {
    position: absolute;
    top: -20px;
    left: 50%;
    width: 1.5px;
    height: 20px;
    background: #0A84FF;
    pointer-events: none;
    transform: translateX(-50%);
}

/* ⚡ Inward Corner Radius Handle */
.threed-radius-handle {
    position: absolute;
    width: 10px;
    height: 10px;
    background: #ffffff;
    border: 2px solid #0A84FF;
    border-radius: 50%;
    pointer-events: auto !important;
    cursor: crosshair;
    transform: translate(-50%, -50%);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    transition: none !important;
}

.threed-radius-handle.dragging {
    background: #0A84FF;
    border-color: #ffffff;
}

/* Context Menu */
.threed-context-menu {
    position: fixed;
    background: #232328;
    border-radius: 10px;
    padding: 6px;
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.7);
    z-index: 3000000;
    min-width: 190px;
    display: none;
    flex-direction: column;
}

.threed-context-item {
    padding: 8px 12px;
    font-size: 0.8125rem;
    color: #f1f3f4;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
}

.threed-context-item:active {
    background: #0A84FF;
    color: #ffffff;
}

.threed-context-divider {
    height: 1px;
    background: rgba(255, 255, 255, 0.06);
    margin: 4px 6px;
}