/* css/components/image-compare.css */

.image-compare {
    position: relative;
    width: 100%;
    padding-bottom: 100%;
    /* Square Aspect Ratio (1:1) fixed per user request */
    overflow: hidden;
    border-radius: var(--radius-large);
    isolation: isolate;
    background: var(--surface-2);
    /* Placeholder background */

    /* Touch Interaction Polish */
    cursor: ew-resize;
    touch-action: pan-y;
    /* Allows vertical scroll, reserves horizontal for slider */
    -webkit-tap-highlight-color: transparent;
}

/* Base Image (Past/Before) - Visible by default */
.image-compare__before {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 1;
}

/* Overlay Image (Future/After) - Clipped via clip-path */
.image-compare__after {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    pointer-events: none;
    z-index: 2;

    /* Initial state: 50% revealed */
    clip-path: polygon(0 0, 50% 0, 50% 100%, 0 100%);
    transition: clip-path 0.1s ease-out;
    /* Smooth follow */
}

/* The Slider Input (Invisible interactable layer) */
.image-compare__slider {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 4;
    /* Topmost interaction layer */
    opacity: 0;
    cursor: ew-resize;
    /* East-West resize cursor */
    margin: 0;
    touch-action: pan-y;
    /* Allow vertical scroll, block horizontal for slider */
}

/* The Visual Handle (Line + Circle) */
.image-compare__handle {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 50%;
    /* Sync with clip-path via JS */
    width: 2px;
    background: rgba(255, 255, 255, 0.6);
    pointer-events: none;
    z-index: 3;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
    transition: left 0.1s ease-out;
    /* Match clip-path transition */
}

.image-compare__handle::after {
    content: "";
    /* Use arrows instead of text */
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 56px;
    height: 56px;

    /* Glassmorphism Luxury */
    background: rgba(255, 255, 255, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);

    border-radius: 50%;

    /* Double border effect for premium look */
    box-shadow:
        0 8px 32px rgba(61, 48, 37, 0.15),
        inset 0 0 0 1px rgba(255, 255, 255, 0.8),
        inset 0 0 0 2px rgba(255, 255, 255, 0.2);

    /* Arrows (SVG) + Full Height Line (Gradient) */
    background-image:
        url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%233d3025' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M8 17l-5-5 5-5'/%3E%3Cpath d='M16 7l5 5-5 5'/%3E%3C/svg%3E"),
        linear-gradient(to right, transparent calc(50% - 0.75px), rgba(61, 48, 37, 0.2) calc(50% - 0.75px), rgba(61, 48, 37, 0.2) calc(50% + 0.75px), transparent calc(50% + 0.75px));

    background-position: center, center;
    background-repeat: no-repeat, no-repeat;
    background-size: 22px, 100% 100%;

    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), background-color 0.2s;
}

/* Performance: Disable transitions during drag to prevent stuttering */
.image-compare.is-dragging .image-compare__handle,
.image-compare.is-dragging .image-compare__after {
    transition: none !important;
}

/* Hover Effect - Tactile feedback */
.image-compare:hover .image-compare__handle::after {
    background-color: rgba(255, 255, 255, 0.55);
    transform: translate(-50%, -50%) scale(1.1);
}

.image-compare__slider:active~.image-compare__handle::after,
.image-compare.is-dragging .image-compare__handle::after {
    /* Maintain active state on drag */
    transform: translate(-50%, -50%) scale(0.95);
    background-color: rgba(255, 255, 255, 0.7);
}

/* Labels (Optional) */
.image-compare__label {
  position: absolute;
  top: 20px;
  padding: var(--space-1) var(--space-2);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    font-size: var(--type-eyebrow);
    border-radius: 999px;
    text-transform: uppercase;
    letter-spacing: var(--track-eyebrow);
    pointer-events: none;
    z-index: 3;
    backdrop-filter: blur(4px);
}

.image-compare__label--before {
    right: 20px;
}

.image-compare__label--after {
    left: 20px;
}

.image-compare__label--single {
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}
