/* Compare Img - Frontend Styles */

.cwp-wrap {
    position: relative;
    width: 100%;
    overflow: hidden;
    border-radius: 8px;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    /* Only claim the touch axis this slider actually drags along.
       A horizontal slider still lets the browser handle vertical
       panning natively (e.g. scrolling past it, or a parent carousel's
       own swipe) — touch-action:none would block that entirely. */
    touch-action: pan-y;
}

.cwp-wrap[data-direction="vertical"] { touch-action: pan-x; cursor: row-resize; }
.cwp-wrap[data-mode="hover"]         { cursor: crosshair; }

/* ---- BACKGROUND (AFTER image) ---- */
.cwp-back {
    position: absolute;
    inset: 0;
}
.cwp-back img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    max-width: none !important;
    max-height: none !important;
    pointer-events: none;
}

/* ---- CLIP (BEFORE image) ---- */
.cwp-clip {
    position: absolute;
    top: 0;
    left: 0;
    width: 50%;
    height: 100%;
    overflow: hidden;
}
.cwp-wrap[data-direction="vertical"] .cwp-clip {
    width: 100%;
    height: 50%;
}

/* clip image must stay full wrap size — JS sets this */
.cwp-clip-img {
    display: block;
    position: absolute;
    top: 0;
    left: 0;
    /* width/height set by JS to match wrap dimensions */
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    object-fit: cover;
    pointer-events: none;
}

/* ---- DIVIDER LINE ---- */
.cwp-divider {
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 100%;
    background: rgba(255,255,255,0.85);
    transform: translateX(-50%);
    pointer-events: none;
    z-index: 5;
}
.cwp-wrap[data-direction="vertical"] .cwp-divider {
    top: 50%;
    left: 0;
    width: 100%;
    height: 2px;
    transform: translateY(-50%);
}

/* ---- HANDLE BUTTON ---- */
.cwp-handle {
    position: absolute;
    top: 50%;
    left: 50%;
    min-width: 44px;
    height: 44px;
    padding: 0 12px;
    border-radius: 22px;
    transform: translate(-50%, -50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    color: #fff;
    pointer-events: none;
    box-shadow: 0 2px 10px rgba(0,0,0,0.25);
    z-index: 10;
    white-space: nowrap;
}

/* icon-only = perfect circle */
.cwp-handle:not(:has(.cwp-handle-text)) {
    width: 44px;
    padding: 0;
    border-radius: 50%;
}

.cwp-icon {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}

.cwp-handle-text {
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.04em;
    line-height: 1;
}

/* ---- LABELS ---- */
.cwp-label {
    position: absolute;
    top: 12px;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    background: rgba(0,0,0,0.4);
    padding: 5px 10px;
    border-radius: 4px;
    pointer-events: none;
    z-index: 10;
    backdrop-filter: blur(4px);
}
.cwp-label-before { left: 12px; }
.cwp-label-after  { right: 12px; }

.cwp-wrap[data-direction="vertical"] .cwp-label-before {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}
.cwp-wrap[data-direction="vertical"] .cwp-label-after {
    top: auto;
    bottom: 12px;
    right: auto;
    left: 50%;
    transform: translateX(-50%);
}

/* ---- MOBILE ---- */
@media (max-width: 768px) {
    .cwp-wrap { cursor: default; }
    .cwp-handle { min-width: 40px; height: 40px; border-radius: 20px; }
}

/* ---- CONTAIN MODE (no crop, shows full image) ---- */
.cwp-wrap[data-fit="contain"] .cwp-back img,
.cwp-wrap[data-fit="contain"] .cwp-clip-img {
    object-fit: contain !important;
    background: #000; /* letterbox color — client can override */
}

.cwp-wrap[data-fit="contain"] .cwp-back {
    background: #000;
}

/* ---- OBJECT POSITION (controls which part of image shows when cover mode) ---- */
.cwp-wrap[data-position="top center"]    .cwp-back img,
.cwp-wrap[data-position="top center"]    .cwp-clip-img { object-position: top center; }

.cwp-wrap[data-position="bottom center"] .cwp-back img,
.cwp-wrap[data-position="bottom center"] .cwp-clip-img { object-position: bottom center; }

.cwp-wrap[data-position="left center"]   .cwp-back img,
.cwp-wrap[data-position="left center"]   .cwp-clip-img { object-position: left center; }

.cwp-wrap[data-position="right center"]  .cwp-back img,
.cwp-wrap[data-position="right center"]  .cwp-clip-img { object-position: right center; }

/* ---- STATIC MODE (no reveal, just 50/50 split) ---- */
.cwp-wrap[data-mode="static"] {
    cursor: default;
}
/* in static mode the clip stays at 50% (set inline) and has no handle */
.cwp-wrap[data-mode="static"] .cwp-handle,
.cwp-wrap[data-mode="static"] .cwp-divider {
    display: none;
}
/* labels stay visible in static mode */
.cwp-wrap[data-mode="static"] .cwp-label-before { left:  12px; }
.cwp-wrap[data-mode="static"] .cwp-label-after  { right: 12px; }
