/**
 * KS LP Image — Block Styles
 */

.kslp-image-block {
    position: relative;
    width: 100%;
    box-sizing: border-box;
}

.kslp-image-container {
    display: flex;
    flex-direction: column;
    width: 100%;
    box-sizing: border-box;
}

.kslp-align-left .kslp-image-container {
    align-items: flex-start;
}

.kslp-align-center .kslp-image-container {
    align-items: center;
}

.kslp-align-right .kslp-image-container {
    align-items: flex-end;
}

.kslp-image-grid-wrap {
    display: grid;
    width: 100%;
    box-sizing: border-box;
}

.kslp-single-image-wrap {
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
    position: relative;
}

.kslp-image-holder {
    margin: 0;
    padding: 0;
    position: relative;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
    background-clip: padding-box;
}

.kslp-image-holder img {
    display: block;
    width: 100%;
    height: auto;
    max-width: 100%;
    box-sizing: border-box;
    transition: filter 0.2s ease, opacity 0.2s ease;
    -webkit-backface-visibility: hidden;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.kslp-image-link {
    display: block;
    position: relative;
    text-decoration: none;
    line-height: 0;
    overflow: hidden;
    border-radius: inherit;
}

.kslp-image-lightbox-trigger {
    cursor: zoom-in;
}

.kslp-image-lightbox-badge {
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(15, 23, 42, 0.65);
    color: #ffffff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.25s ease, transform 0.25s ease, background-color 0.2s ease;
    backdrop-filter: blur(4px);
    pointer-events: none;
}

.kslp-image-lightbox-trigger:hover .kslp-image-lightbox-badge {
    opacity: 1;
    transform: scale(1);
    background: rgba(15, 23, 42, 0.85);
}

/* Lightbox Navigation (Next & Prev) */
.kslp-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 54px;
    height: 54px;
    background: rgba(15, 23, 42, 0.68);
    color: #ffffff;
    border: 1.5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 1000002;
    transition: background-color 0.2s ease, transform 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.45);
    padding: 0;
    margin: 0;
    line-height: 1;
    outline: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.kslp-lightbox-nav svg {
    width: 32px;
    height: 32px;
    display: block;
    pointer-events: none;
    transition: transform 0.15s ease;
}

.kslp-lightbox-prev {
    left: 24px;
}

.kslp-lightbox-next {
    right: 24px;
}

.kslp-lightbox-nav:hover {
    background: rgba(255, 255, 255, 0.35);
    border-color: rgba(255, 255, 255, 0.75);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 26px rgba(0, 0, 0, 0.65);
    color: #ffffff;
}

.kslp-lightbox-prev:hover svg {
    transform: translateX(-2.5px);
}

.kslp-lightbox-next:hover svg {
    transform: translateX(2.5px);
}

.kslp-lightbox-nav:active {
    transform: translateY(-50%) scale(0.94);
    background: rgba(255, 255, 255, 0.45);
}

@media (max-width: 640px) {
    .kslp-lightbox-nav {
        width: 44px;
        height: 44px;
    }
    .kslp-lightbox-nav svg {
        width: 24px;
        height: 24px;
    }
    .kslp-lightbox-prev {
        left: 10px;
    }
    .kslp-lightbox-next {
        right: 10px;
    }
}

.kslp-image-caption {
    font-size: 13.5px;
    line-height: 1.5;
    color: #64748b;
    margin-top: 8px;
    text-align: center;
    font-style: italic;
}

/* Hover Caption Bottom */
.kslp-caption-hover {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    margin: 0;
    padding: 28px 16px 12px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.82) 0%, rgba(0, 0, 0, 0.45) 60%, transparent 100%);
    color: #ffffff;
    font-size: 13.5px;
    line-height: 1.4;
    text-align: center;
    font-style: normal;
    box-sizing: border-box;
    opacity: 0;
    visibility: hidden;
    transform: translateY(8px);
    transition: opacity 0.28s ease, transform 0.28s ease, visibility 0.28s ease;
    pointer-events: none;
    z-index: 2;
    border-bottom-left-radius: inherit;
    border-bottom-right-radius: inherit;
}

.kslp-image-holder:hover .kslp-caption-hover,
.kslp-image-holder:focus-within .kslp-caption-hover {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

/* Lightbox Modal */
.kslp-lightbox-overlay,
.kslp-image-lightbox-overlay {
    position: fixed;
    inset: 0;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    background: rgba(0, 0, 0, 0.92);
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    padding: 24px;
    box-sizing: border-box;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    cursor: zoom-out;
}

.kslp-lightbox-overlay.is-active,
.kslp-image-lightbox-overlay.is-active {
    display: flex;
}

.kslp-lightbox-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    background: #000000;
    color: #ffffff;
    margin: 0;
    font-size: 18px;
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    padding: 12px 20px;
    box-sizing: border-box;
    border-bottom-left-radius: 8px;
    border-bottom-right-radius: 8px;
    max-height: 40%;
    overflow-y: auto;
    word-break: break-word;
    cursor: default;
    z-index: 10;
}

.kslp-lightbox-content {
    max-width: 90vw;
    max-height: 78vh;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: default;
}

.kslp-lightbox-img-wrap {
    position: relative;
    display: inline-block;
    max-width: 100%;
    max-height: 78vh;
    line-height: 0;
    overflow: hidden;
    border-radius: 8px;
}

.kslp-lightbox-content img,
.kslp-lightbox-img-wrap img,
.kslp-image-lightbox-overlay img {
    max-width: 90vw;
    max-height: 78vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    border-radius: 8px;
    box-shadow: 0 25px 60px -12px rgba(0, 0, 0, 0.7);
    transform: scale(0.96);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.kslp-lightbox-overlay.is-active img,
.kslp-image-lightbox-overlay.is-active img {
    transform: scale(1);
}

.kslp-lightbox-close {
    position: absolute;
    top: 20px;
    right: 24px;
    background: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    border: none;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    font-size: 28px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
    z-index: 1000002;
}

.kslp-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: scale(1.08);
}

@media (max-width: 767px) {
    /* Mobile Trim Odd Image (-1 agar layout 2 kolom seimbang) */
    .kslp-image-grid-wrap.has-mobile-trim-odd > .is-mobile-trim-odd,
    .kslp-image-grid-wrap.has-mobile-trim-odd > .kslp-image-holder.is-mobile-trim-odd,
    .kslp-image-grid-wrap.has-mobile-trim-odd > .kslp-mask-filter-wrap.is-mobile-trim-odd,
    .kslp-image-grid-wrap.has-mobile-trim-odd:not([data-kslp-has-pagination="true"]) > :not(:only-child):nth-child(odd):last-child {
        display: none !important;
    }

    .kslp-lightbox-close {
        top: 14px;
        right: 14px;
        width: 38px;
        height: 38px;
        font-size: 24px;
    }
    .kslp-lightbox-caption {
        font-size: 16px;
        padding: 10px 16px;
        line-height: 1.4;
    }
    .kslp-lightbox-content,
    .kslp-lightbox-img-wrap,
    .kslp-lightbox-content img,
    .kslp-lightbox-img-wrap img {
        max-height: 72vh;
        max-width: 94vw;
    }
}

/* Editor Interactive Canvas UI */
.block-editor-page .kslp-caption-hover,
.editor-styles-wrapper .kslp-caption-hover,
.block-editor-block-list__layout .kslp-caption-hover {
    pointer-events: auto !important;
    opacity: 1 !important;
    visibility: visible !important;
    transform: none !important;
    cursor: text !important;
    user-select: text !important;
    -webkit-user-select: text !important;
}

.editor-styles-wrapper .kslp-caption-hover [data-rich-text-placeholder]::after,
.editor-styles-wrapper .kslp-caption-hover .block-editor-rich-text__editable:empty::before {
    color: rgba(255, 255, 255, 0.75) !important;
    opacity: 0.85 !important;
}

.kslp-grid-item-actions button,
.kslp-single-image-actions button {
    transition: transform 0.15s ease, background-color 0.15s ease !important;
}

.kslp-grid-item-actions button:hover,
.kslp-single-image-actions button:hover {
    background-color: rgba(255, 255, 255, 0.25) !important;
    transform: scale(1.08) !important;
}

.kslp-image-grid-add-slot:hover {
    border-color: #0284c7 !important;
    background-color: #f0f9ff !important;
}

/* Pagination & Load More */
.kslp-image-pagination {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 24px;
    width: 100%;
    box-sizing: border-box;
}

.kslp-image-pagination-center {
    justify-content: center;
}

.kslp-image-pagination-left {
    justify-content: flex-start;
}

.kslp-image-pagination-right {
    justify-content: flex-end;
}

.kslp-page-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    user-select: none;
    box-sizing: border-box;
}

.kslp-page-btn:hover:not(.is-disabled):not(.is-active) {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}

.kslp-page-btn.is-active {
    background: #0b8e36;
    color: #ffffff;
    border-color: transparent;
    box-shadow: 0 3px 10px rgba(11, 142, 54, 0.28);
    cursor: default;
}

.kslp-page-btn.is-disabled {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

.kslp-load-more-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 26px;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.4;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #f1f5f9;
    color: #334155;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    outline: none;
    box-sizing: border-box;
}

.kslp-load-more-btn:hover:not(.is-disabled) {
    background: #e2e8f0;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.kslp-load-more-btn.is-disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.kslp-page-indicator {
    font-size: 14px;
    color: #64748b;
    margin: 0 10px;
    font-weight: 500;
}

.kslp-current-page-num {
    color: #0f172a;
    font-weight: 700;
}

/* AJAX Chunk Loading & Animation */
.kslp-chunk-fade-in {
    animation: kslpChunkFadeIn 0.35s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes kslpChunkFadeIn {
    from {
        opacity: 0;
        transform: translateY(12px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.kslp-load-more-btn.is-loading,
.kslp-page-btn.is-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.8;
}

.kslp-load-more-btn.is-loading::after,
.kslp-page-btn.is-loading::after {
    content: '';
    display: inline-block;
    width: 14px;
    height: 14px;
    margin-left: 8px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: kslpChunkSpin 0.6s linear infinite;
    vertical-align: middle;
}

@keyframes kslpChunkSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ====================================================
   IMAGE MASK & MORPH SYSTEM
   ==================================================== */

.kslp-image-holder.has-image-mask {
    border-radius: 0 !important;
    background-color: transparent !important;
    border: none !important;
}

.kslp-image-holder.has-image-mask img {
    border-radius: 0 !important;
}

/* Morph Animations (GPU Accelerated) */
.kslp-mask-morph {
    will-change: transform;
}

/* 1. Fluid Morph: gentle organic breathing & transformation */
@keyframes kslpMaskFluid {
    0%, 100% {
        transform: scale(1) rotate(0deg);
    }
    25% {
        transform: scale(1.025, 0.975) rotate(1.5deg);
    }
    50% {
        transform: scale(0.975, 1.03) rotate(-1deg);
    }
    75% {
        transform: scale(1.02, 0.98) rotate(1deg);
    }
}

.kslp-mask-morph--fluid {
    animation-name: kslpMaskFluid;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* 2. Breathing Pulse */
@keyframes kslpMaskPulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
}

.kslp-mask-morph--pulse {
    animation-name: kslpMaskPulse;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* 3. Organic Wobble */
@keyframes kslpMaskWobble {
    0%, 100% {
        transform: translate3d(0, 0, 0) rotate(0deg);
    }
    20% {
        transform: translate3d(-3px, 2px, 0) rotate(-1.5deg);
    }
    40% {
        transform: translate3d(3px, -2px, 0) rotate(1.5deg);
    }
    60% {
        transform: translate3d(-2px, -2px, 0) rotate(-1deg);
    }
    80% {
        transform: translate3d(2px, 1px, 0) rotate(1deg);
    }
}

.kslp-mask-morph--wobble {
    animation-name: kslpMaskWobble;
    animation-timing-function: ease-in-out;
    animation-iteration-count: infinite;
}

/* 4. Slow Continuous Rotation */
@keyframes kslpMaskRotate {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.kslp-mask-morph--rotate {
    animation-name: kslpMaskRotate;
    animation-timing-function: linear;
    animation-iteration-count: infinite;
}

/* Morph Speeds */
.kslp-mask-speed--slow {
    animation-duration: 14s;
}

.kslp-mask-speed--normal {
    animation-duration: 8s;
}

.kslp-mask-speed--fast {
    animation-duration: 4.5s;
}

/* Mask Filter Wrapper (Shadow, Emboss, Stroke) */
.kslp-mask-filter-wrap {
    display: block;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    box-sizing: border-box;
}

.kslp-mask-filter-wrap.has-morph {
    will-change: transform, filter;
}

.kslp-mask-svg-filter-def {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    pointer-events: none;
    visibility: hidden;
}
