/* ============================================================
   Image Comparator for Elementor — Frontend CSS
   ============================================================ */

/* ── Reset & base ─────────────────────────────────────── */
.ice-comparator *,
.ice-comparator *::before,
.ice-comparator *::after {
    box-sizing: border-box;
}

/* ── Wrapper ──────────────────────────────────────────── */
.ice-comparator {
    position: relative;
    width: 100%;
    height: 480px;
    overflow: hidden;
    cursor: col-resize;
    user-select: none;
    -webkit-user-select: none;
    /* none: o JS cancela o scroll durante drag via preventDefault() */
    touch-action: none;
    display: block;
    background: #111;
    /* Isola repaints internos do resto da página */
    isolation: isolate;
}

/* Orientação vertical */
.ice-comparator.ice-vertical {
    cursor: row-resize;
}

/* ── Imagens ──────────────────────────────────────────── */
.ice-comparator .ice-img-base,
.ice-comparator .ice-img-overlay {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    pointer-events: none;
    max-width: none;
    margin: 0;
    padding: 0;
    border: none;
}

/* Overlay: clipping dinâmico via JS */
.ice-comparator .ice-img-overlay {
    clip-path: inset(0 50% 0 0);
    /* Sinaliza ao browser só o que vai mudar — evita over-promotion */
    will-change: clip-path;
}
.ice-comparator.ice-vertical .ice-img-overlay {
    clip-path: inset(0 0 50% 0);
}

/* ── Linha divisória ──────────────────────────────────── */
.ice-comparator .ice-divider {
    position: absolute;
    top: 0;
    left: 0;           /* posição base; o JS aplica transform */
    width: 2px;
    height: 100%;
    background-color: #fff;
    pointer-events: none;
    z-index: 10;
    /* transform: compositor puro, zero reflow */
    will-change: transform;
    transform: translateX(calc(50% * 1 - 50%)); /* placeholder; JS define */
}

.ice-comparator.ice-vertical .ice-divider {
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    will-change: transform;
}

/* ── Handle ───────────────────────────────────────────── */
.ice-comparator .ice-handle {
    position: absolute;
    top: 0;            /* base; o JS move via transform */
    left: 0;
    z-index: 20;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background-color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: grab;
    /* Apenas transform e box-shadow — compositor puro */
    transition: box-shadow 0.15s ease;
    box-shadow: 0 2px 12px rgba(0,0,0,0.4), 0 0 0 2px rgba(255,255,255,0.2);
    will-change: transform;
    pointer-events: none;
    outline: none;
}

.ice-comparator:active .ice-handle,
.ice-comparator.ice-dragging .ice-handle {
    cursor: grabbing;
    box-shadow: 0 4px 20px rgba(0,0,0,0.5), 0 0 0 3px rgba(255,255,255,0.35);
}

/* Ícone SVG padrão */
.ice-comparator .ice-handle svg {
    width: 18px;
    height: 18px;
    pointer-events: none;
    stroke: #000;
    fill: none;
    flex-shrink: 0;
}

/* Ícone Elementor/FA */
.ice-comparator .ice-handle .ice-handle-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    line-height: 1;
}

/* ── Estilos de handle ────────────────────────────────── */

/* Barra */
.ice-comparator.ice-handle-style-bar .ice-handle {
    width: 32px;
    height: 60px;
    border-radius: 4px;
}
.ice-comparator.ice-vertical.ice-handle-style-bar .ice-handle {
    width: 60px;
    height: 32px;
}

/* Minimalista: sem handle, só a linha */
.ice-comparator.ice-handle-style-minimal .ice-handle {
    opacity: 0;
    pointer-events: none;
}

/* ── Rótulos ──────────────────────────────────────────── */
.ice-comparator .ice-label {
    position: absolute;
    z-index: 15;
    font-size: 12px;
    font-weight: 600;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    padding: 4px 10px;
    border-radius: 3px;
    pointer-events: none;
    line-height: 1.4;
    max-width: 45%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Posição: base (padrão) */
.ice-comparator.ice-label-pos-bottom .ice-label-before { bottom: 14px; left: 14px; }
.ice-comparator.ice-label-pos-bottom .ice-label-after  { bottom: 14px; right: 14px; }

/* Posição: topo */
.ice-comparator.ice-label-pos-top .ice-label-before { top: 14px; left: 14px; }
.ice-comparator.ice-label-pos-top .ice-label-after  { top: 14px; right: 14px; }

/* Posição: centro */
.ice-comparator.ice-label-pos-middle .ice-label-before {
    top: 50%;
    left: 14px;
    transform: translateY(-50%);
}
.ice-comparator.ice-label-pos-middle .ice-label-after {
    top: 50%;
    right: 14px;
    transform: translateY(-50%);
}

/* Orientação vertical: rótulos no topo/baixo */
.ice-comparator.ice-vertical .ice-label-before { top: 14px; left: 14px; bottom: auto; right: auto; }
.ice-comparator.ice-vertical .ice-label-after  { bottom: 14px; left: 14px; top: auto; right: auto; }

/* Cores padrão dos rótulos */
.ice-comparator .ice-label-before {
    background-color: rgba(0,0,0,0.5);
    color: #fff;
}
.ice-comparator .ice-label-after {
    background-color: rgba(0,0,0,0.5);
    color: #fff;
}

/* ── Acessibilidade: foco via teclado ─────────────────── */
.ice-comparator:focus-within .ice-handle {
    box-shadow: 0 0 0 3px #4a90d9, 0 2px 12px rgba(0,0,0,0.4);
}

/* ── Responsivo ───────────────────────────────────────── */
@media (max-width: 767px) {
    .ice-comparator {
        height: 280px;
        cursor: default;
    }
    .ice-comparator .ice-handle {
        width: 38px;
        height: 38px;
    }
    .ice-comparator .ice-label {
        font-size: 10px;
        padding: 3px 7px;
    }
}

@media (max-width: 480px) {
    .ice-comparator {
        height: 220px;
    }
}
