/**
 * Sifency Distortion Widget — Stylesheet
 *
 * Handles: wrapper layout, canvas overlay, image/bg/object modes,
 * slice DOM strips, editor placeholder.
 *
 * @package  Sifency Addons
 * @version  1.0.0
 */

/* =========================================================================
   1. OUTER WRAPPER
   ========================================================================= */

.sifency-distortion {
    display: flex;
    width: 100%;
}

/* =========================================================================
   2. INNER WRAP — position context for canvas overlay
   ========================================================================= */

.sifency-distortion-wrap {
    position: relative;
    display: block;
    width: 100%;
    overflow: hidden;

    /* Sane defaults — Elementor controls override */
    min-height: 200px;
}

/* =========================================================================
   3. IMAGE MODE
   ========================================================================= */

.sifency-distortion-mode--image .sifency-distortion-image {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;

    /* Image is the base layer — sits below canvas */
    position: relative;
    z-index: 0;

    /* crossorigin required for canvas pixel access */
    user-select: none;
    pointer-events: none;
}

/* =========================================================================
   4. BACKGROUND MODE
   ========================================================================= */

.sifency-distortion-mode--background .sifency-distortion-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    z-index: 0;
}

/* =========================================================================
   5. OBJECT MODE
   ========================================================================= */

.sifency-distortion-mode--object .sifency-distortion-object {
    position: relative;
    width: 100%;
    height: 100%;
    z-index: 0;
}

/* Editor placeholder */
.sifency-distortion-object-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    min-height: 200px;
    background-color: rgba(0, 0, 0, 0.04);
    border: 2px dashed rgba(0, 0, 0, 0.15);
    border-radius: 4px;
    color: rgba(0, 0, 0, 0.4);
    font-size: 13px;
    font-family: inherit;
    font-style: italic;
    user-select: none;
    pointer-events: none;
}

/* =========================================================================
   6. CANVAS OVERLAY
   ========================================================================= */

.sifency-distortion-canvas {
    position: absolute;
    inset: 0;
    width: 100% !important;
    height: 100% !important;
    z-index: 2;

    /* Canvas sits on top of the image/bg/object */
    display: block;
    pointer-events: none;

    /* Default blend: normal. Elementor control overrides per-instance. */
    mix-blend-mode: normal;
}

/* =========================================================================
   7. SLICE EFFECT — DOM strips
   ========================================================================= */

.sifency-distortion-slices {
    position: absolute;
    inset: 0;
    z-index: 1;
    overflow: hidden;
}

.sifency-distortion-slice {
    position: absolute;
    background-repeat: no-repeat;

    /* GPU layer */
    will-change: transform;
    backface-visibility: hidden;
    transform: translateZ(0);
}

/* When slice effect is active, hide source image / bg (slices replace it) */
.sifency-distortion-effect--slice .sifency-distortion-image,
.sifency-distortion-effect--slice .sifency-distortion-bg {
    opacity: 0;
    pointer-events: none;
}

/* =========================================================================
   8. TRIGGER STATE CLASSES (added by JS)
   ========================================================================= */

.sifency-distortion-wrap.is-hovered .sifency-distortion-canvas {
    pointer-events: none;
    /* always non-interactive */
}

/* =========================================================================
   9. RESPONSIVE HELPERS
   ========================================================================= */

@media (max-width: 1024px) {
    .sifency-distortion-wrap {
        min-height: 160px;
    }
}

@media (max-width: 767px) {
    .sifency-distortion-wrap {
        min-height: 120px;
    }
}

/* =========================================================================
   10. ELEMENTOR EDITOR — preview helpers
   ========================================================================= */

.elementor-editor-active .sifency-distortion-canvas {
    /* Show a faint border in the editor so designers can see the canvas bounds */
    outline: 1px dashed rgba(0, 153, 255, 0.25);
}

.elementor-editor-active .sifency-distortion-slices {
    outline: 1px dashed rgba(0, 153, 255, 0.25);
}

/* =========================================================================
   11. RGB LAYER EFFECT — CSS channel composite
   ========================================================================= */

.sifency-distortion-rgb-wrap {
    position: absolute;
    inset: 0;
    overflow: hidden;
}

.sifency-distortion-rgb-layer {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    will-change: transform;
    /* GPU layer hint */
    transform: translateZ(0);
}

.sifency-distortion-rgb-g,
.sifency-distortion-rgb-b {
    mix-blend-mode: screen;
}