/* Prevent image selection and dragging */
img {
    user-select: none;
    pointer-events: none;
}

/* Container for the slider */
.slider-container {
    position: relative;
    width: 100%;
    max-width: 500px;
    height: 200px;
    margin: 20px 0;
    overflow: hidden;
}

/* The before-after image area */
.before-after-slider {
    position: relative;
    width: 100%;
    height: 100%;
}

/* Stack the images */
.slider-before,
.slider-after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* Ensure the 'before' image is fully visible by default */
.slider-before {
    z-index: 1;
    visibility: visible;
}

/* Initially, show only the right half of the 'after' image */
.slider-after {
    z-index: 2;
    clip-path: inset(0 50% 0 0); /* Initially hide the left half of the after image */
}

/* The vertical bar */
.slider-bar {
    position: absolute;
    top: 0;
    left: 50%; /* Center the bar horizontally */
    width: 2px; /* Thin vertical bar */
    height: 100%; /* Full height of the slider container */
    background-color: rgba(0, 0, 0, 0.8); /* Bar color */
    transform: translateX(-50%); /* Center the bar exactly */
    z-index: 2; /* Ensure the bar is behind the handle but above the images */
}

/* The handle: Curved for decoration */
.slider-handle {
    position: absolute;
    top: 50%; /* Center vertically */
    left: 50%; /* Center horizontally initially */
    width: 30px; /* Width of the oval handle */
    height: 100px; /* Height of the oval handle */
    background-color: rgba(255, 255, 255, 0.8); /* Slight transparency */
    border: 2px solid rgba(0, 0, 0, 0.8); /* Border for handle visibility */
    border-radius: 50px / 100px; /* Creates a vertical curved oval shape */
    transform: translate(-50%, -50%); /* Center the handle properly */
    cursor: ew-resize;
    z-index: 3; /* Ensure the handle is on top of the bar and images */
}

/* Optional: Handle hover effect */
.slider-handle:hover {
    background-color: rgba(255, 255, 255, 0.9);
}

/* Sparkle effect for slider handle */
.sparkle {
    position: absolute;
    width: 6px;
    height: 6px;
    background: radial-gradient(circle, rgba(255,255,255,0.9), rgba(255,215,0,0.6));
    border-radius: 50%;
    opacity: 1;
    animation: sparkle-fade-move 0.3s ease-out forwards;
    pointer-events: none;
    z-index: 5;
}

@keyframes sparkle-fade-move {
    0% {
        opacity: 1;
        transform: translate(0, 0) scale(1.2);
    }
    100% {
        opacity: 0;
        transform: translate(var(--dx), var(--dy)) scale(0.4);
    }
}
