/**
 * Sleek Compare - Frontend Styles
 * A lightweight before/after image comparison slider
 *
 * CSS Variables for theming:
 * --sleek-handle-color: Handle and line color (default: #fff)
 * --sleek-handle-size: Handle circle diameter (default: 44px)
 * --sleek-label-bg: Label background (default: rgba(0,0,0,0.6))
 * --sleek-label-color: Label text color (default: #fff)
 * --sleek-border-radius: Container border radius (default: 0)
 */

.sleek-compare {
    --sleek-handle-color: #ffffff;
    --sleek-handle-size: 44px;
    --sleek-label-bg: rgba(0, 0, 0, 0.6);
    --sleek-label-color: #ffffff;
    --sleek-border-radius: 0;

    position: relative;
    overflow: hidden;
    border-radius: var(--sleek-border-radius);
    user-select: none;
    touch-action: pan-y pinch-zoom;
    cursor: ew-resize;
}

.sleek-compare:focus {
    outline: 2px solid #0073aa;
    outline-offset: 2px;
}

.sleek-compare img {
    display: block;
    width: 100%;
    height: auto;
    max-width: none;
    pointer-events: none;
}

/* Before image container - clips to reveal after */
.sleek-compare__before {
    position: absolute;
    top: 0;
    left: 0;
    right: 0; /* Full width, clip-path controls visible area */
    bottom: 0;
    z-index: 2;
    clip-path: inset(0 50% 0 0); /* JS updates the right inset value */
}

/* Before image fills the container same as after */
.sleek-compare__before img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left center;
}

/* After image - sits behind */
.sleek-compare__after {
    position: relative;
    z-index: 1;
}

.sleek-compare__after img {
    display: block;
    width: 100%;
    height: auto;
}

/* Labels */
.sleek-compare__label {
    position: absolute;
    bottom: 16px;
    padding: 6px 12px;
    background: var(--sleek-label-bg);
    color: var(--sleek-label-color);
    font-size: 14px;
    font-weight: 500;
    line-height: 1;
    border-radius: 4px;
    pointer-events: none;
    z-index: 5;
}

.sleek-compare__label--before {
    left: 16px;
}

.sleek-compare__label--after {
    right: 16px;
}

/* Handle */
.sleek-compare__handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    margin-left: -2px;
    z-index: 10;
    display: flex;
    flex-direction: column;
    align-items: center;
    pointer-events: none;
}

.sleek-compare__handle-line {
    flex: 1;
    width: 3px;
    background: var(--sleek-handle-color);
    box-shadow: 0 0 4px rgba(0, 0, 0, 0.3);
}

.sleek-compare__handle-circle {
    flex-shrink: 0;
    width: var(--sleek-handle-size);
    height: var(--sleek-handle-size);
    background: var(--sleek-handle-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    pointer-events: auto;
    cursor: ew-resize;
}

.sleek-compare__handle-circle svg {
    width: 16px;
    height: 16px;
    color: #333;
    flex-shrink: 0;
}

/* Interaction states */
.sleek-compare--dragging {
    cursor: ew-resize;
}

.sleek-compare--dragging .sleek-compare__handle-circle {
    transform: scale(1.1);
    transition: transform 0.1s ease;
}

/* Smooth handle movement except when dragging */
.sleek-compare:not(.sleek-compare--dragging) .sleek-compare__handle,
.sleek-compare:not(.sleek-compare--dragging) .sleek-compare__before {
    transition: left 0.1s ease-out, clip-path 0.1s ease-out;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .sleek-compare .sleek-compare__handle,
    .sleek-compare .sleek-compare__before {
        transition: none !important;
    }
}

/* Mobile touch target size */
@media (max-width: 768px) {
    .sleek-compare {
        --sleek-handle-size: 48px;
    }

    .sleek-compare__label {
        font-size: 12px;
        padding: 4px 8px;
        bottom: 12px;
    }

    .sleek-compare__label--before {
        left: 12px;
    }

    .sleek-compare__label--after {
        right: 12px;
    }
}
