/**
 * ExploreXR Draggable Styles
 * 
 * Styles for the draggable model viewer functionality
 */

/* Ensure model-viewer always fills the draggable container.
   ExploreXR's shortcode may set explicit px inline styles; these
   percentage values override them so resizing works correctly. */
.explorexr-draggable-container model-viewer {
    width: 100% !important;
    height: 100% !important;
    display: block;
}

/* Draggable container */
.explorexr-draggable-container {
    position: relative;
    display: inline-block;
    transition: box-shadow 0.2s ease;
}

.explorexr-draggable-container.is-dragging {
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    cursor: move;
    z-index: 10000 !important;
}

/* Drag handle base styles */
.explorexr-drag-handle {
    position: absolute;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    cursor: move;
    z-index: 10;
    border-radius: 4px;
    user-select: none;
    transition: all 0.2s ease;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
}

.explorexr-drag-handle:hover {
    background: rgba(0, 0, 0, 0.9);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    transform: scale(1.05);
}

.explorexr-drag-handle:active {
    background: rgba(0, 0, 0, 1);
    transform: scale(0.95);
}

/* Handle positions */
.explorexr-drag-handle-top-left {
    top: 10px;
    left: 10px;
}

.explorexr-drag-handle-top-right {
    top: 10px;
    right: 10px;
}

.explorexr-drag-handle-bottom-left {
    bottom: 10px;
    left: 10px;
}

.explorexr-drag-handle-bottom-right {
    bottom: 10px;
    right: 10px;
}

/* Prevent text selection while dragging */
.explorexr-draggable-container.is-dragging,
.explorexr-draggable-container.is-dragging * {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Model viewer adjustments when draggable */
model-viewer[data-draggable="true"] {
    position: relative;
}

/* Touch device optimizations */
@media (pointer: coarse) {
    .explorexr-drag-handle {
        width: 50px;
        height: 50px;
        font-size: 24px;
    }
}

/* Animation for handle appearance */
@keyframes handleFadeIn {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.explorexr-drag-handle {
    animation: handleFadeIn 0.3s ease;
}

/* Mobile responsive adjustments */
@media (max-width: 768px) {
    .explorexr-drag-handle {
        width: 44px;
        height: 44px;
        font-size: 22px;
    }
    
    .explorexr-drag-handle-top-left,
    .explorexr-drag-handle-top-right,
    .explorexr-drag-handle-bottom-left,
    .explorexr-drag-handle-bottom-right {
        top: 5px;
        right: 5px;
        bottom: 5px;
        left: 5px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .explorexr-drag-handle {
        background: black;
        border: 2px solid white;
    }
    
    .explorexr-drag-handle:hover {
        background: white;
        color: black;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .explorexr-drag-handle {
        transition: none;
        animation: none;
    }
    
    .explorexr-draggable-container {
        transition: none;
    }
}

/* Print styles - hide drag handle when printing */
@media print {
    .explorexr-drag-handle {
        display: none !important;
    }
}

/* ===================================================================
   Custom icon support
   =================================================================== */
.explorexr-drag-handle-custom-icon {
    width: 24px;
    height: 24px;
    object-fit: contain;
    pointer-events: none;
    display: block;
}

/* ===================================================================
   Resize Handles
   =================================================================== */

/* Base resize handle */
.explorexr-resize-handle {
    position: absolute;
    width: 20px;
    height: 20px;
    background: rgba(0, 0, 0, 0.65);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    z-index: 10;
    border-radius: 3px;
    user-select: none;
    transition: background 0.15s ease, transform 0.15s ease;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.4);
    pointer-events: auto;
    line-height: 1;
}

.explorexr-resize-handle:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

.explorexr-resize-handle:active {
    background: rgba(0, 0, 0, 1);
    transform: scale(0.95);
}

/* Whole-container resize — bottom-right corner */
.explorexr-resize-handle-container {
    bottom: 6px;
    right: 6px;
    cursor: nwse-resize;
    width: 22px;
    height: 22px;
    font-size: 14px;
}

/* Height-only resize — bottom-center edge */
.explorexr-resize-handle-height {
    bottom: 6px;
    left: 50%;
    transform: translateX(-50%);
    cursor: ns-resize;
    width: 32px;
    height: 16px;
}

.explorexr-resize-handle-height:hover {
    transform: translateX(-50%) scale(1.1);
}

.explorexr-resize-handle-height:active {
    transform: translateX(-50%) scale(0.95);
}

/* Width-only resize — right-center edge */
.explorexr-resize-handle-width {
    right: 6px;
    top: 50%;
    transform: translateY(-50%);
    cursor: ew-resize;
    width: 16px;
    height: 32px;
}

.explorexr-resize-handle-width:hover {
    transform: translateY(-50%) scale(1.1);
}

.explorexr-resize-handle-width:active {
    transform: translateY(-50%) scale(0.95);
}

/* Container while actively resizing */
.explorexr-draggable-container.is-resizing {
    outline: 2px dashed rgba(0, 115, 170, 0.6);
    outline-offset: -2px;
    user-select: none;
    -webkit-user-select: none;
}

.explorexr-draggable-container.is-resizing * {
    pointer-events: none;
    user-select: none;
    -webkit-user-select: none;
}

/* Ensure resize handles stay interactive during resize */
.explorexr-draggable-container.is-resizing .explorexr-resize-handle {
    pointer-events: none; /* disable during resize to avoid interference */
}

/* Minimum size guardrail via CSS */
.explorexr-draggable-container {
    min-width: 100px;
    min-height: 100px;
}

/* Touch device — bigger resize handles */
@media (pointer: coarse) {
    .explorexr-resize-handle {
        width: 28px;
        height: 28px;
        font-size: 14px;
    }
    .explorexr-resize-handle-height {
        width: 44px;
        height: 22px;
    }
    .explorexr-resize-handle-width {
        width: 22px;
        height: 44px;
    }
}

/* Hide resize handles when printing */
@media print {
    .explorexr-resize-handle {
        display: none !important;
    }
}
