/* ========================================
   Before/After Slider
   ======================================== */

/* Some themes add borders/outlines to block wrappers; keep it clean by default. */
.wp-block-blockenberg-before-after,
.wp-block-blockenberg-before-after .bkbg-ba-wrap {
    border: 0;
    outline: 0;
}

.bkbg-ba-wrap {
    --bkbg-ba-pos: 50%;
    --bkbg-ba-radius: 12px;
    --bkbg-ba-handle-size: 44px;
    --bkbg-ba-handle-bg: #007cba;
    --bkbg-ba-handle-color: #ffffff;
    --bkbg-ba-line-color: rgba(255, 255, 255, 0.95);
    --bkbg-ba-line-width: 2px;

    --bkbg-ba-label-bg: rgba(0, 0, 0, 0.55);
    --bkbg-ba-label-color: #ffffff;
    --bkbg-ba-label-size: 13px;
    --bkbg-ba-label-radius: 6px;

    --bkbg-ba-min-height: 260px;

    width: 100%;
}

.bkbg-ba-aspect {
    width: 100%;
}

.bkbg-ba-inner {
    position: relative;
    width: 100%;
    min-height: var(--bkbg-ba-min-height);
    border-radius: var(--bkbg-ba-radius);
    overflow: hidden;
    background: #f3f4f6;
    user-select: none;
    touch-action: none;
}

.bkbg-ba-wrap.has-shadow .bkbg-ba-inner {
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.12);
}

.bkbg-ba-layer {
    position: absolute;
    inset: 0;
}

.bkbg-ba-layer img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

/* After overlay */
.bkbg-ba-after {
    /* Keep the layer full-size and clip it instead of resizing it,
       so the image never stretches while the slider moves. */
    clip-path: inset(0 0 0 0);
}

.bkbg-ba-wrap.is-horizontal .bkbg-ba-after {
    clip-path: inset(0 calc(100% - var(--bkbg-ba-pos)) 0 0);
}

.bkbg-ba-wrap.is-vertical .bkbg-ba-after {
    clip-path: inset(0 0 calc(100% - var(--bkbg-ba-pos)) 0);
}

/* Divider line + handle */
.bkbg-ba-divider {
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
    right: 0;
    pointer-events: auto;
}

.bkbg-ba-wrap.is-horizontal .bkbg-ba-divider {
    top: 0;
    bottom: 0;
    left: calc(var(--bkbg-ba-pos) - (var(--bkbg-ba-line-width) / 2));
    width: var(--bkbg-ba-line-width);
    right: auto;
}

.bkbg-ba-wrap.is-vertical .bkbg-ba-divider {
    left: 0;
    right: 0;
    top: calc(var(--bkbg-ba-pos) - (var(--bkbg-ba-line-width) / 2));
    height: var(--bkbg-ba-line-width);
    bottom: auto;
}

.bkbg-ba-divider::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--bkbg-ba-line-color);
    pointer-events: none;
}

.bkbg-ba-handle {
    position: absolute;
    left: 50%;
    top: 50%;
    width: var(--bkbg-ba-handle-size);
    height: var(--bkbg-ba-handle-size);
    transform: translate(-50%, -50%);
    cursor: grab;
}

.bkbg-ba-handle-surface {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
    transition: transform 160ms ease;
}

.bkbg-ba-handle-anim {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bkbg-ba-handle-bg);
    color: var(--bkbg-ba-handle-color);
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18);
}

.bkbg-ba-handle-hover {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bkbg-ba-wrap.has-handle-hover .bkbg-ba-handle:hover .bkbg-ba-handle-surface {
    transform: scale(var(--bkbg-ba-handle-hover-scale));
}

.bkbg-ba-wrap:active .bkbg-ba-handle {
    cursor: grabbing;
}

.bkbg-ba-handle.is-circle {
    border-radius: 999px;
}

.bkbg-ba-handle.is-square {
    border-radius: 10px;
}

.bkbg-ba-handle.is-circle .bkbg-ba-handle-anim {
    border-radius: 999px;
}

.bkbg-ba-handle.is-square .bkbg-ba-handle-anim {
    border-radius: 10px;
}

.bkbg-ba-handle-icon {
    font-size: var(--bkbg-ba-handle-icon-size);
    width: var(--bkbg-ba-handle-icon-size);
    height: var(--bkbg-ba-handle-icon-size);
    line-height: 1;
}

.bkbg-ba-handle-img {
    width: var(--bkbg-ba-handle-icon-size);
    height: var(--bkbg-ba-handle-icon-size);
    object-fit: contain;
    display: block;
    filter: drop-shadow(0 1px 1px rgba(0,0,0,0.18));
}

/* Handle hover animations */
.bkbg-ba-wrap.has-handle-anim .bkbg-ba-handle-anim {
    animation-duration: var(--bkbg-ba-handle-anim-dur);
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* Do not animate while hovering/dragging the handle */
.bkbg-ba-wrap.has-handle-anim .bkbg-ba-handle:hover .bkbg-ba-handle-anim,
.bkbg-ba-wrap.has-handle-anim .bkbg-ba-handle:active .bkbg-ba-handle-anim {
    animation-play-state: paused;
}

.bkbg-ba-wrap.has-handle-anim.is-handle-anim-pulse .bkbg-ba-handle-anim {
    animation-name: bkbgBaPulse;
}

.bkbg-ba-wrap.has-handle-anim.is-handle-anim-wiggle .bkbg-ba-handle-anim {
    animation-name: bkbgBaWiggle;
}

.bkbg-ba-wrap.has-handle-anim.is-handle-anim-bounce .bkbg-ba-handle-anim {
    animation-name: bkbgBaBounce;
}

.bkbg-ba-wrap.has-handle-anim.is-handle-anim-glow .bkbg-ba-handle-anim {
    animation-name: bkbgBaGlow;
}

@keyframes bkbgBaPulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.08); }
}

@keyframes bkbgBaWiggle {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-10deg); }
    75% { transform: rotate(10deg); }
}

@keyframes bkbgBaBounce {
    0%, 100% { transform: translateY(0) scale(1); }
    40% { transform: translateY(-8px) scale(1.04); }
    60% { transform: translateY(3px) scale(0.98); }
}

@keyframes bkbgBaGlow {
    0%, 100% { box-shadow: 0 10px 24px rgba(0, 0, 0, 0.18); }
    50% { box-shadow: 0 14px 34px rgba(0, 0, 0, 0.22), 0 0 0 10px rgba(255,255,255,0.12); }
}

/* Labels */
.bkbg-ba-labels {
    position: absolute;
    left: 0;
    right: 0;
    display: flex;
    justify-content: space-between;
    padding: 14px;
    pointer-events: none;
    z-index: 2;
}

.bkbg-ba-labels.is-top {
    top: 0;
}

.bkbg-ba-labels.is-bottom {
    bottom: 0;
}

.bkbg-ba-label {
    background: var(--bkbg-ba-label-bg);
    color: var(--bkbg-ba-label-color);
    font-size: var(--bkbg-ba-label-size);
    font-weight: 600;
    padding: 6px 10px;
    border-radius: var(--bkbg-ba-label-radius);
    max-width: 48%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Accessible range input (covers the whole slider) */
.bkbg-ba-range {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: ew-resize;
    pointer-events: none;
}

.bkbg-ba-wrap.is-vertical .bkbg-ba-range {
    cursor: ns-resize;
}

/* ========================================
   Editor UI
   ======================================== */

.editor-styles-wrapper .bkbg-ba-inner {
    outline: 1px dashed rgba(0, 124, 186, 0.2);
    outline-offset: -1px;
}

.editor-styles-wrapper .bkbg-ba-inner:hover {
    outline-color: rgba(0, 124, 186, 0.4);
}

.bkbg-ba-empty-inner {
    background: #f8fafc;
}

.bkbg-ba-empty-grid {
    position: absolute;
    inset: 0;
    display: grid;
    grid-template-columns: 1fr 1fr;
}

.bkbg-ba-empty-panel {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 18px;
    text-align: center;
    color: #334155;
}

.bkbg-ba-empty-panel.is-before {
    border-right: 1px dashed rgba(0, 0, 0, 0.18);
}

.bkbg-ba-empty-panel-title {
    font-weight: 800;
    font-size: 14px;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    color: rgba(15, 23, 42, 0.75);
}

.bkbg-ba-empty-copy {
    font-weight: 600;
    color: rgba(15, 23, 42, 0.7);
}

.bkbg-ba-empty-thumb {
    width: min(320px, 90%);
    height: 140px;
    object-fit: cover;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.12);
    background: #fff;
}

/* Inspector */
.bkbg-ba-media-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
}

.bkbg-ba-media-title {
    font-size: 12px;
    font-weight: 600;
    color: #334155;
    margin-bottom: 6px;
}

.bkbg-ba-media-thumb {
    width: 100%;
    height: 90px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.1);
    margin-bottom: 8px;
}

.bkbg-ba-media-placeholder {
    width: 100%;
    height: 90px;
    border-radius: 8px;
    border: 1px dashed rgba(0,0,0,0.2);
    background: rgba(0,0,0,0.03);
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 8px;
    color: rgba(0,0,0,0.6);
    font-size: 12px;
}

.bkbg-ba-color-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
}

.bkbg-ba-color-btn {
    width: 30px;
    height: 30px;
    border-radius: 999px;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,0.12);
    cursor: pointer;
}

/* ========================================
   Handle icon picker (editor)
   ======================================== */

.bkbg-ba-icon-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-top: 10px;
    position: relative;
}

.bkbg-ba-icon-popover-anchor {
    position: absolute;
    width: 0;
    height: 0;
    overflow: visible;
    right: 0;
    top: 0;
}

.bkbg-ba-icon-row-label {
    font-size: 13px;
}

.bkbg-ba-icon-picker-btn {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    border: 1px solid rgba(0,0,0,0.12);
    background: #fff;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

.bkbg-ba-icon-picker-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.bkbg-ba-icon-btn-img {
    width: 22px;
    height: 22px;
    object-fit: contain;
}

.bkbg-ba-icon-btn-none {
    font-size: 11px;
    font-weight: 700;
    color: rgba(0,0,0,0.6);
}

.bkbg-ba-icon-popover .components-popover__content {
    padding: 0;
}

.bkbg-ba-icon-picker-modal {
    width: 360px;
    max-width: 70vw;
}

.bkbg-ba-icon-picker-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 12px 8px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}

.bkbg-ba-icon-picker-header h3 {
    margin: 0;
    font-size: 14px;
}

.bkbg-ba-icon-actions {
    display: flex;
    gap: 8px;
    padding: 12px 12px 0;
}

.bkbg-ba-icon-search {
    padding: 8px 12px 0;
}

.bkbg-ba-dashicons-grid {
    padding: 12px;
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 6px;
    max-height: 280px;
    overflow: auto;
}

.bkbg-ba-dashicon-btn {
    width: 34px;
    height: 34px;
    border-radius: 8px;
    border: 1px solid rgba(0,0,0,0.08);
    background: #fff;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.bkbg-ba-dashicon-btn.is-active {
    border-color: rgba(0, 124, 186, 0.85);
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.18);
}

.bkbg-ba-dashicon-btn .dashicons {
    font-size: 18px;
    width: 18px;
    height: 18px;
}

.bkbg-ba-media-panel {
    padding: 12px;
}

.bkbg-ba-current-media {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 10px;
}

.bkbg-ba-current-media img {
    width: 56px;
    height: 56px;
    object-fit: contain;
    background: #fff;
    border: 1px solid rgba(0,0,0,0.12);
    border-radius: 10px;
}

.bkbg-ba-media-hint {
    margin: 10px 0 0;
    font-size: 12px;
    color: rgba(0,0,0,0.6);
}
