/**
 * Image Comparison Slider Styles
 *
 * Styles for the before/after image comparison component.
 *
 * @package Uit_Holland
 * @since 1.52.33
 */

/* Container */
.image-comparison {
    position: relative;
    overflow: hidden;
    cursor: ew-resize;
    user-select: none;
    -webkit-user-select: none;
    touch-action: pan-y pinch-zoom;
    border-radius: inherit;
}

.image-comparison:focus {
    outline: 2px solid #F29100;
    outline-offset: 2px;
}

.image-comparison:focus:not(:focus-visible) {
    outline: none;
}

.image-comparison:focus-visible {
    outline: 2px solid #F29100;
    outline-offset: 2px;
}

/* Image layers */
.comparison-before,
.comparison-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.comparison-before {
    z-index: 1;
}

.comparison-after {
    z-index: 2;
}

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

/* Make container respect aspect ratio of images (default) */
.image-comparison::before {
    content: '';
    display: block;
    padding-top: 66.67%; /* 3:2 aspect ratio - default fallback */
}

/* In service cards: fill the container height to match text column */
.category-image .image-comparison {
    height: 100%;
    min-height: 400px;
    max-width: 100%; /* Prevent overflow on mobile due to aspect-ratio + min-height */
}

.category-image .image-comparison::before {
    display: none; /* Remove aspect ratio constraint */
}

/* Handle */
.comparison-handle {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 4px;
    background: white;
    z-index: 10;
    transform: translateX(-50%);
    cursor: ew-resize;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
}

.handle-line {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    width: 3px;
    background: #F29100; /* uit-orange */
    transform: translateX(-50%);
}

.handle-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 48px;
    height: 48px;
    background: #F29100; /* uit-orange */
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.handle-button svg {
    width: 16px;
    height: 16px;
    color: white;
    flex-shrink: 0;
}

.handle-button svg:first-child {
    margin-right: -4px;
}

.handle-button svg:last-child {
    margin-left: -4px;
}

/* Hover and active states */
.image-comparison:hover .handle-button,
.image-comparison.is-dragging .handle-button {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
}

.image-comparison.is-dragging {
    cursor: grabbing;
}

/* Labels */
.comparison-label {
    position: absolute;
    bottom: 16px;
    padding: 8px 16px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    z-index: 5;
    pointer-events: none;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.comparison-label--before {
    left: 16px;
}

.comparison-label--after {
    right: 48px; /* Extra spacing for rounded corners (4rem = 64px) */
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .handle-button {
        width: 40px;
        height: 40px;
    }

    .handle-button svg {
        width: 14px;
        height: 14px;
    }

    .comparison-label {
        font-size: 10px;
        padding: 4px 8px;
        bottom: 24px; /* More offset to avoid rounded corner clipping */
    }

    .comparison-label--before {
        left: 12px;
    }

    .comparison-label--after {
        right: 12px;
    }

    /* Inside category-image with rounded corners (4rem = 64px) - need diagonal distance > 64px */
    /* Using bottom:50px + right:50px gives √(50²+50²) = 70.7px > 64px */
    .category-image .comparison-label {
        bottom: 50px;
    }

    .category-image .comparison-label--before {
        left: 20px;
    }

    .category-image .comparison-label--after {
        right: 50px;
    }
}

/* Very small screens */
@media (max-width: 400px) {
    .comparison-label {
        font-size: 9px;
        padding: 3px 6px;
    }

    /* Same diagonal calculation: √(48²+48²) = 67.9px > 64px */
    .category-image .comparison-label {
        bottom: 48px;
    }

    .category-image .comparison-label--before {
        left: 16px;
    }

    .category-image .comparison-label--after {
        right: 48px;
    }
}

/* Dark mode: keep orange styling */
@media (prefers-color-scheme: dark) {
    .handle-button {
        background: #F29100; /* Keep uit-orange in dark mode */
    }

    .handle-button svg {
        color: white;
    }
}

/* Animation for initial load */
@keyframes comparison-fade-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.image-comparison {
    animation: comparison-fade-in 0.3s ease-out;
}
