/**
 * Comparison Slider CSS
 */

/* CSS Custom Properties for easy customization */
.bricks-comparison-slider {
    --handle-color: #ffffff;
    --handle-size: 40px;
    --text-color: #ffffff;
    --text-background: rgba(0, 0, 0, 0.7);
    --aspect-ratio-padding: 56.25%;
    --transition-duration: 0.3s;
    --handle-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

/* Main container */
.bricks-comparison-slider {
    position: relative;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

/* Comparison container with aspect ratio */
.comparison-container {
    position: relative;
    width: 100%;
    height: 0;
    padding-bottom: var(--aspect-ratio-padding);
    cursor: pointer;
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}

/* Image layers */
.image-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.comparison-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
    user-select: none;
    -webkit-user-drag: none;
}

/* Before layer (full width background) */
.before-layer-full {
    z-index: 1;
}

/* After layer with clip-path (overlaid and clipped) */
.after-layer {
    z-index: 2;
    will-change: clip-path;
}

/* Image labels */
.image-label {
    position: absolute;
    top: 16px;
    padding: 8px 12px;
    background: var(--text-background);
    color: var(--text-color);
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s ease;
}

.before-label {
    left: 16px;
}

.after-label {
    right: 16px;
}

/* Handle */
.comparison-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 2px;
    cursor: ew-resize;
    z-index: 10;
    transform: translateX(-50%);
    transition: transform var(--transition-duration) cubic-bezier(0.4, 0, 0.2, 1);
}

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

.comparison-handle:focus {
    outline: 2px solid var(--handle-color);
    outline-offset: 4px;
}

.comparison-handle.dragging {
    transition: none;
}

/* Handle line */
.handle-line {
    width: 2px;
    height: 100%;
    background: var(--handle-color);
    position: relative;
    box-shadow: var(--handle-shadow);
}

.handle-line::before {
    content: '';
    position: absolute;
    top: 0;
    left: -1px;
    right: -1px;
    bottom: 0;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 1px;
}

/* Handle circle */
.handle-circle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--handle-size);
    height: var(--handle-size);
    transform: translate(-50%, -50%);
    background: var(--handle-color);
    border-radius: 50%;
    box-shadow: var(--handle-shadow);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.comparison-handle:hover .handle-circle {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.comparison-handle.dragging .handle-circle {
    transform: translate(-50%, -50%) scale(1.2);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.5);
}

/* Handle arrows */
.handle-arrow {
    position: absolute;
    width: 0;
    height: 0;
    opacity: 0.8;
}

.handle-arrow-left {
    left: 30%;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-right: 6px solid #333;
    transform: translateX(-50%);
}

.handle-arrow-right {
    right: 30%;
    border-top: 4px solid transparent;
    border-bottom: 4px solid transparent;
    border-left: 6px solid #333;
    transform: translateX(50%);
}

/* Body class when dragging to prevent text selection */
.comparison-slider-dragging {
    user-select: none !important;
    -webkit-user-select: none !important;
    -moz-user-select: none !important;
    -ms-user-select: none !important;
}

.comparison-slider-dragging * {
    cursor: ew-resize !important;
}

/* Responsive design */
@media (max-width: 768px) {
    .bricks-comparison-slider {
        --handle-size: 36px;
    }
    
    .image-label {
        font-size: 12px;
        padding: 6px 10px;
        top: 12px;
    }
    
    .before-label {
        left: 12px;
    }
    
    .after-label {
        right: 12px;
    }
}

@media (max-width: 480px) {
    .bricks-comparison-slider {
        --handle-size: 32px;
    }
    
    .image-label {
        font-size: 11px;
        padding: 4px 8px;
        top: 8px;
    }
    
    .before-label {
        left: 8px;
    }
    
    .after-label {
        right: 8px;
    }
    
    .handle-arrow-left {
        border-right-width: 5px;
        border-top-width: 3px;
        border-bottom-width: 3px;
    }
    
    .handle-arrow-right {
        border-left-width: 5px;
        border-top-width: 3px;
        border-bottom-width: 3px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .bricks-comparison-slider {
        --handle-color: #000000;
        --text-background: rgba(255, 255, 255, 0.9);
        --text-color: #000000;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .bricks-comparison-slider {
        --transition-duration: 0s;
    }
    
    .comparison-handle,
    .handle-circle,
    .after-layer {
        transition: none !important;
    }
}

/* Dark theme support */
@media (prefers-color-scheme: dark) {
    .bricks-comparison-slider {
        --handle-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    }
}

/* Print styles */
@media print {
    .bricks-comparison-slider {
        break-inside: avoid;
    }
    
    .comparison-handle {
        display: none;
    }
    
    .after-layer {
        clip-path: none !important;
        opacity: 0.5;
    }
}