/*
 * BTH Lighting — Before/After Widget
 * Responsive stage height is established by the base image itself.
 */

.bthlew-before-after,
.bthlew-before-after * {
    box-sizing: border-box;
}


/* =========================================================
   MAIN STAGE
========================================================= */

.bthlew-before-after {
    --bthlew-position: 50%;
    --bthlew-image-ratio: 1280 / 570;
    --bthlew-compare-accent: #f5b41b;
    --bthlew-label-bg: rgba(5, 7, 9, .72);

    position: relative;
    display: block;

    width: 100%;
    max-width: 100%;

    /* IMPORTANT:
       Height is now created naturally by the AFTER image.
       Do not force a fixed height here.
    */
    height: auto;
    min-height: 0;

    overflow: hidden;
    border-radius: 28px;
    background: #050505;

    user-select: none;
    isolation: isolate;
}


/* =========================================================
   AFTER / NIGHT IMAGE
   This image establishes the actual stage height.
========================================================= */

.bthlew-before-after .bthlew-after-image {
    position: relative !important;
    z-index: 1;

    display: block !important;

    width: 100% !important;
    max-width: 100% !important;

    /*
     * IMPORTANT:
     * Keep height AUTO so the original image ratio
     * determines the wrapper height.
     */
    height: auto !important;

    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;
    border-radius: 0 !important;

    object-fit: contain !important;
    object-position: center center !important;

    background: #050505;
}


/* =========================================================
   BEFORE / DAY CLIPPING LAYER
========================================================= */

.bthlew-before-clip {
    position: absolute;
    z-index: 2;

    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    width: 100%;
    height: 100%;

    overflow: hidden;

    clip-path: inset(
        0
        calc(100% - var(--bthlew-position))
        0
        0
    );
}


/* =========================================================
   BEFORE / DAY IMAGE
========================================================= */

.bthlew-before-after .bthlew-before-image {
    position: absolute !important;

    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    left: 0 !important;

    display: block !important;

    width: 100% !important;
    max-width: none !important;

    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;
    border-radius: 0 !important;

    object-fit: contain !important;
    object-position: center center !important;

    background: #050505;
}


/* =========================================================
   LABELS
========================================================= */

.bthlew-compare-label {
    position: absolute;
    z-index: 4;

    top: 22px;

    display: inline-flex;
    align-items: center;

    min-height: 30px;

    margin: 0;
    padding: 8px 12px;

    color: #fff;

    font-size: 12px;
    font-weight: 800;
    line-height: 1;
    letter-spacing: .1em;

    white-space: nowrap;

    border: 1px solid rgba(255, 255, 255, .16);
    border-radius: 999px;

    background: var(--bthlew-label-bg);

    -webkit-backdrop-filter: blur(8px);
    backdrop-filter: blur(8px);

    pointer-events: none;
}


.bthlew-before-label {
    left: 22px;
}


.bthlew-after-label {
    right: 22px;
}


/* =========================================================
   CENTER DIVIDER
========================================================= */

.bthlew-compare-divider {
    position: absolute;
    z-index: 5;

    top: 0;
    bottom: 0;

    left: var(--bthlew-position);

    width: 2px;

    background: var(--bthlew-compare-accent);

    box-shadow:
        0 0 18px
        color-mix(
            in srgb,
            var(--bthlew-compare-accent),
            transparent 45%
        );

    transform: translateX(-50%);

    pointer-events: none;
}


/* =========================================================
   DIVIDER HANDLE
========================================================= */

.bthlew-compare-divider span {
    position: absolute;

    top: 50%;
    left: 50%;

    display: grid;

    width: 52px;
    height: 52px;

    place-items: center;

    color: #17110e;

    font-size: 21px;
    line-height: 1;

    border: 2px solid #fff;
    border-radius: 50%;

    background: var(--bthlew-compare-accent);

    box-shadow: 0 10px 28px rgba(0, 0, 0, .3);

    transform: translate(-50%, -50%);
}


/* =========================================================
   RANGE INPUT
========================================================= */

.bthlew-compare-range {
    position: absolute;
    z-index: 6;

    top: 0;
    right: 0;
    bottom: 0;
    left: 0;

    display: block;

    width: 100%;
    height: 100%;

    margin: 0;
    padding: 0;

    opacity: 0;

    cursor: ew-resize;
}


/* =========================================================
   TABLET
========================================================= */

@media (max-width: 1024px) {

    .bthlew-before-after {
        width: 100%;
        max-width: 100%;
        height: auto;
    }


    /*
     * Keep base image in normal flow.
     * This prevents stage collapse on tablet.
     */
    .bthlew-before-after .bthlew-after-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }


    /*
     * Day image always exactly follows
     * the height created by Night image.
     */
    .bthlew-before-after .bthlew-before-image {
        width: 100% !important;
        height: 100% !important;
        max-width: none !important;

        object-fit: contain !important;
        object-position: center center !important;
    }
}


/* =========================================================
   MOBILE
========================================================= */

@media (max-width: 700px) {

    .bthlew-before-after {
        width: 100%;
        max-width: 100%;

        height: auto;

        border-radius: 18px;
    }


    /*
     * Night image creates full mobile stage height.
     */
    .bthlew-before-after .bthlew-after-image {
        position: relative !important;

        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;

        object-fit: contain !important;
        object-position: center center !important;
    }


    /*
     * Day image fills exactly that same stage.
     */
    .bthlew-before-after .bthlew-before-image {
        position: absolute !important;

        width: 100% !important;
        max-width: none !important;
        height: 100% !important;

        object-fit: contain !important;
        object-position: center center !important;
    }


    .bthlew-compare-label {
        top: 14px;

        min-height: 26px;

        padding: 7px 9px;

        font-size: 10px;
    }


    .bthlew-before-label {
        left: 14px;
    }


    .bthlew-after-label {
        right: 14px;
    }


    .bthlew-compare-divider span {
        width: 44px;
        height: 44px;

        font-size: 18px;
    }
}


/* =========================================================
   VERY SMALL MOBILE
========================================================= */

@media (max-width: 480px) {

    .bthlew-compare-label {
        top: 10px;

        min-height: 24px;

        padding: 6px 8px;

        font-size: 9px;

        letter-spacing: .07em;
    }


    .bthlew-before-label {
        left: 10px;
    }


    .bthlew-after-label {
        right: 10px;
    }


    .bthlew-compare-divider span {
        width: 40px;
        height: 40px;

        font-size: 16px;
    }
}


/* =========================================================
   REDUCED MOTION
========================================================= */

@media (prefers-reduced-motion: reduce) {

    .bthlew-before-clip,
    .bthlew-compare-divider {
        transition: none !important;
    }
}