/*
 * Marketing Sux Before / After v1.9.0
 * v1.9.0 hardens image sizing against Elementor core's `.elementor img { height: auto; }`
 * rule. The widget now wins that cascade explicitly so images fill the CSS-native
 * aspect-ratio frame and object-fit: cover can crop them correctly in both single
 * and comparison modes.
 */
.elementor-widget-marketing_sux_before_after,
.elementor-widget-marketing_sux_before_after > .elementor-widget-container {
    min-width: 0;
    max-width: 100%;
}

.msux-ba {
    --msux-ba-position: 50%;
    --msux-ba-ratio-setting: auto;
    --msux-ba-aspect-ratio: auto; /* legacy generated CSS fallback */
    --msux-ba-natural-aspect-ratio: 4 / 3;
    --msux-ba-frame-ratio-desktop: var(--msux-ba-natural-aspect-ratio);
    --msux-ba-frame-ratio-tablet: var(--msux-ba-frame-ratio-desktop);
    --msux-ba-frame-ratio-mobile: var(--msux-ba-frame-ratio-tablet);
    --msux-ba-radius: 0px;
    --msux-ba-divider-color: #fff;
    --msux-ba-divider-width: 3px;
    --msux-ba-handle-size: 44px;
    --msux-ba-handle-icon-size: 18px;
    --msux-ba-handle-icon-color: var(--msux-ba-divider-color);
    --msux-ba-handle-background: rgba(0, 0, 0, .35);
    --msux-ba-handle-border-width: 2px;
    --msux-ba-label-color: #fff;
    --msux-ba-label-background: rgba(0, 0, 0, .55);
    --msux-ba-label-radius: 999px;

    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    aspect-ratio: var(--msux-ba-frame-ratio-desktop, var(--msux-ba-natural-aspect-ratio));
    overflow: hidden;
    border-radius: var(--msux-ba-radius);
    box-sizing: border-box;
    isolation: isolate;
    line-height: 0;
    cursor: ew-resize;
    touch-action: pan-y pinch-zoom;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

@media (max-width: 1024px) {
    .msux-ba {
        aspect-ratio: var(--msux-ba-frame-ratio-tablet, var(--msux-ba-frame-ratio-desktop, var(--msux-ba-natural-aspect-ratio)));
    }
}

@media (max-width: 767px) {
    .msux-ba {
        aspect-ratio: var(--msux-ba-frame-ratio-mobile, var(--msux-ba-frame-ratio-tablet, var(--msux-ba-frame-ratio-desktop, var(--msux-ba-natural-aspect-ratio))));
    }
}

.msux-ba--single {
    cursor: default;
    touch-action: auto;
}

.msux-ba--single .msux-ba__image--before {
    z-index: 1;
}

/* Dedicated clipping layer. This avoids making the reveal clip responsible for
 * the card's rounded corners and hardens Safari/iOS clipping. */
.msux-ba__clip {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
    border-radius: inherit;
    clip-path: inset(0 round var(--msux-ba-radius));
    -webkit-mask-image: -webkit-radial-gradient(white, black);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.msux-ba__image {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    min-width: 0;
    object-fit: cover;
    object-position: center;
    border-radius: 0 !important;
    user-select: none;
    -webkit-user-drag: none;
    pointer-events: none;
}

/* Elementor core ships `.elementor img { height: auto; max-width: 100%; }`,
 * which has higher specificity than `.msux-ba__image`. Force the media layer
 * to fill the ratio frame so object-fit: cover owns the crop geometry. */
.elementor .elementor-widget-marketing_sux_before_after .msux-ba__image {
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
}

.msux-ba__image--before {
    z-index: 1;
}

.msux-ba__after-wrap {
    position: absolute;
    inset: 0;
    z-index: 2;
    overflow: hidden;
    border-radius: 0 !important;
    clip-path: inset(0 calc(100% - var(--msux-ba-position)) 0 0);
    transform: translateZ(0);
    backface-visibility: hidden;
}

.msux-ba__image--after {
    z-index: 1;
}

.msux-ba__divider {
    position: absolute;
    z-index: 4;
    top: 0;
    bottom: 0;
    left: var(--msux-ba-position);
    width: var(--msux-ba-divider-width);
    transform: translateX(-50%);
    background-color: var(--msux-ba-divider-color);
    pointer-events: none;
    box-sizing: border-box;
}

.msux-ba__handle {
    position: absolute;
    top: 50%;
    left: 50%;
    width: var(--msux-ba-handle-size);
    height: var(--msux-ba-handle-size);
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    transform: translate(-50%, -50%);
    box-sizing: border-box;
    border-style: solid;
    border-width: var(--msux-ba-handle-border-width);
    border-color: var(--msux-ba-divider-color);
    border-radius: 999px;
    background-color: var(--msux-ba-handle-background);
    color: var(--msux-ba-handle-icon-color);
    line-height: 0;
    pointer-events: none;
}

.msux-ba__handle-icon {
    width: var(--msux-ba-handle-icon-size);
    height: var(--msux-ba-handle-icon-size);
    min-width: 0;
    min-height: 0;
    max-width: none;
    max-height: none;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 auto;
    overflow: visible;
    line-height: 0;
    color: inherit;
    pointer-events: none;
}

.msux-ba__handle-icon svg {
    display: block;
    width: 100% !important;
    height: 100% !important;
    min-width: 0 !important;
    min-height: 0 !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    padding: 0 !important;
    fill: currentColor;
    color: inherit;
    overflow: visible;
}

.msux-ba__handle-icon i {
    display: block;
    width: auto;
    height: auto;
    margin: 0;
    padding: 0;
    font-size: var(--msux-ba-handle-icon-size);
    line-height: 1;
    color: inherit;
}

.msux-ba__label {
    position: absolute;
    z-index: 3;
    top: 14px;
    max-width: 42%;
    padding: 7px 10px;
    overflow: hidden;
    border-radius: var(--msux-ba-label-radius);
    background-color: var(--msux-ba-label-background);
    color: var(--msux-ba-label-color);
    line-height: 1;
    font-size: 12px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .04em;
    text-overflow: ellipsis;
    white-space: nowrap;
    pointer-events: none;
    box-sizing: border-box;
}

.msux-ba__label--before { left: 14px; }
.msux-ba__label--after { right: 14px; }

.msux-ba:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 3px;
}

/* Tablet and phone safety. The widget remains entirely controlled by its
 * parent width and does not introduce its own min-content width. */
@media (max-width: 1024px) {
    .msux-ba__label {
        top: 12px;
        padding: 6px 9px;
    }

    .msux-ba__label--before { left: 12px; }
    .msux-ba__label--after { right: 12px; }
}

@media (max-width: 767px) {
    .msux-ba {
        width: 100%;
        max-width: 100%;
    }

    .msux-ba__label {
        top: 10px;
        max-width: 40%;
        padding: 5px 8px;
    }

    .msux-ba__label--before { left: 10px; }
    .msux-ba__label--after { right: 10px; }

}

/* Elementor editor should remain easy to select while controls are adjusted. */
.elementor-editor-active .msux-ba {
    touch-action: auto;
}

.msux-ba__editor-notice {
    padding: 16px;
    border: 1px dashed #b8b8b8;
    border-radius: 6px;
    background: #fafafa;
    color: #444;
    line-height: 1.4;
    font-size: 13px;
}

/* Before / After Gallery: direct Project query, no Elementor Loop Grid wrappers. */
.msux-ba-gallery {
    --msux-ba-gallery-columns: 4;
    --msux-ba-gallery-gap: 24px;
    display: grid;
    grid-template-columns: repeat(var(--msux-ba-gallery-columns), minmax(0, 1fr));
    gap: var(--msux-ba-gallery-gap);
    width: 100%;
    max-width: 100%;
    min-width: 0;
    height: auto;
    align-items: start;
}

.msux-ba-gallery__item {
    display: block;
    width: 100%;
    min-width: 0;
    height: auto;
}

.msux-ba-gallery__item .msux-ba {
    width: 100%;
    max-width: 100%;
    aspect-ratio: 1 / 1;
}

.msux-ba-gallery .msux-ba__label {
    font-family: var(--e-global-typography-primary-font-family, Montserrat), Sans-serif;
    font-weight: var(--e-global-typography-primary-font-weight, 700);
    line-height: var(--e-global-typography-primary-line-height, 1.2);
}

@media (max-width: 1024px) {
    .msux-ba-gallery {
        --msux-ba-gallery-columns: 2;
    }
}

@media (max-width: 767px) {
    .msux-ba-gallery {
        --msux-ba-gallery-columns: 1;
    }
}
