/*
 * 文章图片灯箱。所有规则均限定在 .zclb 内，避免污染父主题。
 */

body.zclb-open {
    overflow: hidden !important;
}

body.single-post .article-content .wp-posts-content img[data-zclb-ready] {
    cursor: zoom-in;
}

.zclb[hidden] {
    display: none !important;
}

.zclb {
    --zclb-color: #333333;
    --zclb-muted-color: rgba(51, 51, 51, 0.62);
    --zclb-overlay: rgba(255, 255, 255, 0.9);
    --zclb-tool-surface: rgba(51, 51, 51, 0.06);
    --zclb-focus: var(--focus-color, var(--theme-color, #f04494));
    --zclb-tool-hover: var(--focus-color-opacity1, rgba(240, 68, 148, 0.1));
    --zclb-tool-active: var(--focus-color-opacity3, rgba(240, 68, 148, 0.3));
    --zclb-shadow: 0 24px 70px rgba(31, 41, 55, 0.18);
    position: fixed;
    inset: 0;
    z-index: 100100;
    overflow: hidden;
    color: var(--zclb-color);
    font-family: inherit;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.22s ease, visibility 0.22s ease;
    isolation: isolate;
    -webkit-tap-highlight-color: transparent;
}

.zclb,
.zclb * {
    box-sizing: border-box;
}

.zclb.is-open,
.zclb.is-closing {
    visibility: visible;
}

.zclb.is-open {
    opacity: 1;
    pointer-events: auto;
    cursor: default;
}

.zclb.is-closing {
    opacity: 0;
    pointer-events: none;
}

.zclb__backdrop {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: var(--zclb-overlay);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
}

.zclb button {
    min-width: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 0;
    box-shadow: none;
    color: inherit;
    background: transparent;
    font: inherit;
    line-height: 1;
    text-shadow: none;
    -webkit-appearance: none;
    appearance: none;
}

.zclb button:focus-visible {
    outline: 2px solid var(--zclb-focus);
    outline-offset: -3px;
}

.zclb__toolbar {
    position: absolute;
    inset: 8px 8px auto;
    z-index: 8;
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
    transition: opacity 0.15s ease, transform 0.22s ease;
}

.zclb__tool-group {
    display: flex;
    align-items: center;
    min-height: 48px;
    overflow: hidden;
    border-radius: 48px;
    background: var(--zclb-tool-surface);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    pointer-events: auto;
}

.zclb__tool,
.zclb__nav {
    display: inline-flex !important;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    flex: 0 0 48px;
    cursor: pointer !important;
    pointer-events: auto !important;
    opacity: 1;
    transition: color 0.15s ease, background-color 0.15s ease, opacity 0.15s ease, transform 0.15s ease;
}

.zclb__tool:hover,
.zclb__nav:hover {
    color: var(--zclb-focus);
    background: var(--zclb-tool-hover);
}

.zclb__tool:active,
.zclb__nav:active {
    transform: scale(0.92);
}

.zclb__tool[aria-pressed="true"] {
    color: var(--zclb-focus);
    background: var(--zclb-tool-active);
}

.zclb__tool svg,
.zclb__nav svg {
    display: block;
    width: 24px;
    height: 24px;
    overflow: visible;
    fill: none;
    stroke: currentColor;
    stroke-width: 1.5;
    stroke-linecap: round;
    stroke-linejoin: round;
    pointer-events: none;
}

.zclb__nav svg {
    width: 26px;
    height: 26px;
    stroke-width: 2.5;
    filter: drop-shadow(1px 1px 1px rgba(24, 24, 27, 0.35));
}

.zclb__tool[data-zclb-action="flip-x"] svg,
.zclb__tool[data-zclb-action="flip-y"] svg {
    stroke-width: 1.3;
}

.zclb__tool[data-zclb-action="slideshow"] {
    position: relative;
    overflow: hidden;
    isolation: isolate;
}

.zclb__tool[data-zclb-action="slideshow"] svg g:last-child,
.zclb__tool[data-zclb-action="fullscreen"] svg g:last-child {
    display: none;
}

.zclb__tool[data-zclb-action="slideshow"][aria-pressed="true"] svg g:first-child,
.zclb__tool[data-zclb-action="fullscreen"][aria-pressed="true"] svg g:first-child {
    display: none;
}

.zclb__tool[data-zclb-action="slideshow"][aria-pressed="true"] svg g:last-child,
.zclb__tool[data-zclb-action="fullscreen"][aria-pressed="true"] svg g:last-child {
    display: initial;
}

.zclb__progress {
    position: absolute;
    inset: 0;
    z-index: -1;
    background: currentColor;
    opacity: 0.2;
    transform: scaleX(0);
    transform-origin: left;
    pointer-events: none;
}

.zclb__tool[data-zclb-action="slideshow"][aria-pressed="true"] .zclb__progress {
    animation: zclb-progress 3s linear infinite;
}

.zclb__counter {
    min-width: 48px;
    padding: 0 13px 0 5px;
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    text-align: center;
    white-space: nowrap;
}

.zclb__stage {
    position: absolute;
    inset: 64px 58px 112px;
    z-index: 3;
    overflow: hidden;
    touch-action: none;
    user-select: none;
}

.zclb__layer {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    opacity: 1;
    transform: translate3d(0, 0, 0);
    will-change: transform, opacity;
}

.zclb__layer--current,
.zclb__media {
    pointer-events: auto;
}

.zclb__layer--preview {
    visibility: hidden;
    opacity: 0;
    pointer-events: none;
}

.zclb__media {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    border-radius: var(--main-radius, 8px);
    box-shadow: var(--zclb-shadow);
    cursor: zoom-in;
    transform: translate3d(0, 0, 0) rotate(0deg) scale(1, 1);
    transform-origin: center;
    transition: transform 0.85s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.2s ease;
    will-change: transform;
}

.zclb__media::after {
    content: "";
    position: absolute;
    inset: 0;
    border: 1px solid rgba(255, 255, 255, 0.72);
    border-radius: inherit;
    pointer-events: none;
}

.zclb__media.is-zoomed {
    cursor: grab;
}

.zclb__media.is-dragging {
    cursor: grabbing;
    transition: none;
}

.zclb__image {
    display: block;
    width: auto;
    height: auto;
    max-width: calc(100vw - 124px) !important;
    max-height: calc(100vh - 184px) !important;
    max-height: calc(100dvh - 184px) !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: inherit !important;
    box-shadow: none !important;
    object-fit: contain;
    pointer-events: none;
    -webkit-user-drag: none;
    user-select: none;
}

.zclb.is-opening .zclb__layer--current .zclb__media {
    animation: zclb-open-image 0.2s ease 0.1s backwards;
}

.zclb__loader {
    position: absolute;
    left: 50%;
    top: 50%;
    width: 36px;
    height: 36px;
    margin: -18px 0 0 -18px;
    border: 3px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.15s ease;
    animation: zclb-spin 0.72s linear infinite;
}

.zclb.is-loading .zclb__loader {
    opacity: 0.45;
}

.zclb__error {
    position: absolute;
    left: 50%;
    top: 50%;
    display: none;
    padding: 10px 16px;
    border-radius: 999px;
    color: var(--zclb-color);
    background: var(--zclb-tool-surface);
    transform: translate(-50%, -50%);
    white-space: nowrap;
}

.zclb.has-error .zclb__error {
    display: block;
}

.zclb__nav {
    position: absolute;
    top: 50%;
    z-index: 7;
    width: 50px;
    height: 50px;
    border-radius: 50% !important;
    transform: translateY(-50%);
}

.zclb__nav:active {
    transform: translateY(-50%) scale(0.92);
}

.zclb__nav[data-zclb-direction="prev"] {
    left: 8px;
}

.zclb__nav[data-zclb-direction="next"] {
    right: 8px;
}

.zclb.is-single .zclb__nav,
.zclb.is-single [data-zclb-action="slideshow"],
.zclb.is-single [data-zclb-action="thumbs"] {
    display: none !important;
}

.zclb__caption {
    position: absolute;
    left: 50%;
    bottom: 92px;
    z-index: 6;
    max-width: min(760px, calc(100% - 80px));
    padding: 6px 12px;
    border-radius: 999px;
    color: var(--zclb-muted-color);
    background: var(--zclb-tool-surface);
    font-size: 13px;
    line-height: 1.45;
    text-align: center;
    transform: translateX(-50%);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    transition: opacity 0.2s ease, bottom 0.35s cubic-bezier(0.23, 1, 0.32, 1);
}

.zclb__caption:empty {
    display: none;
}

.zclb.thumbs-hidden .zclb__caption,
.zclb.is-single .zclb__caption {
    bottom: 22px;
}

.zclb__thumbs {
    position: absolute;
    inset: auto 0 8px;
    z-index: 7;
    display: block;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-padding-inline: 12px;
    scrollbar-width: none;
    transition: transform 0.35s cubic-bezier(0.23, 1, 0.32, 1), opacity 0.2s ease;
}

.zclb__thumbs-track {
    display: flex;
    justify-content: center;
    gap: 8px;
    width: max-content;
    min-width: 100%;
    padding: 8px 12px 4px;
}

.zclb__thumbs::-webkit-scrollbar {
    display: none;
}

.zclb__thumbs.is-hidden,
.zclb.is-single .zclb__thumbs {
    opacity: 0;
    transform: translateY(92px);
    pointer-events: none;
}

.zclb__thumb {
    position: relative;
    width: 96px !important;
    height: 72px !important;
    flex: 0 0 96px;
    padding: 3px !important;
    overflow: hidden;
    border: 2px solid transparent !important;
    border-radius: 5px !important;
    background: transparent !important;
    opacity: 0.52;
    cursor: pointer;
    transition: opacity 0.2s ease, border-color 0.2s ease, transform 0.15s ease;
}

.zclb__thumb:hover,
.zclb__thumb[aria-current="true"] {
    opacity: 1;
}

.zclb__thumb[aria-current="true"] {
    border-color: var(--zclb-focus) !important;
}

.zclb__thumb img {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none !important;
    max-height: none !important;
    margin: 0 !important;
    border: 0 !important;
    border-radius: 2px !important;
    object-fit: cover;
    pointer-events: none;
}

.zclb.is-idle .zclb__toolbar,
.zclb.is-idle .zclb__nav {
    opacity: 0;
    pointer-events: none;
}

.zclb.is-idle .zclb__toolbar {
    transform: translateY(-8px);
}

/* 子比夜间模式是运行时切换 body.dark-theme，无需重新初始化灯箱。 */
body.dark-theme .zclb {
    --zclb-color: rgba(255, 255, 255, 0.78);
    --zclb-muted-color: rgba(255, 255, 255, 0.62);
    --zclb-overlay: rgba(18, 19, 22, 0.88);
    --zclb-tool-surface: rgba(255, 255, 255, 0.08);
    --zclb-focus: var(--focus-color, var(--theme-color, #f04494));
    --zclb-tool-hover: var(--focus-color-opacity1, rgba(240, 68, 148, 0.1));
    --zclb-tool-active: var(--focus-color-opacity3, rgba(240, 68, 148, 0.3));
    --zclb-shadow: 0 24px 70px rgba(0, 0, 0, 0.52);
    color-scheme: dark;
}

body.dark-theme .zclb__media::after {
    border-color: rgba(255, 255, 255, 0.15);
}

@keyframes zclb-open-image {
    from {
        opacity: 0;
        transform: translateY(16px) scale(0.975);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes zclb-progress {
    from { transform: scaleX(0); }
    to { transform: scaleX(1); }
}

@keyframes zclb-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 700px), (max-height: 578px) {
    .zclb__toolbar {
        justify-content: center;
    }

    .zclb__toolbar-middle {
        order: 3;
        margin-inline: auto;
    }

    .zclb__stage {
        inset: 118px 36px 94px;
    }

    .zclb__image {
        max-width: calc(100vw - 76px) !important;
        max-height: calc(100vh - 218px) !important;
        max-height: calc(100dvh - 218px) !important;
    }

    .zclb__caption {
        bottom: 70px;
        max-width: calc(100% - 34px);
    }

    .zclb.thumbs-hidden .zclb__caption,
    .zclb.is-single .zclb__caption {
        bottom: 14px;
    }

    .zclb__thumb {
        width: 64px !important;
        height: 48px !important;
        flex-basis: 64px;
    }

    .zclb__nav {
        width: 44px;
        height: 44px;
    }

    .zclb__nav[data-zclb-direction="prev"] {
        left: 0;
    }

    .zclb__nav[data-zclb-direction="next"] {
        right: 0;
    }
}

@media (max-width: 430px) {
    .zclb__tool-group,
    .zclb__tool {
        min-height: 42px;
        height: 42px;
    }

    .zclb__tool {
        width: 42px;
        flex-basis: 42px;
    }

    .zclb__tool svg {
        width: 22px;
        height: 22px;
    }

    .zclb__counter {
        min-width: 40px;
        padding-right: 10px;
        font-size: 12px;
    }

    .zclb__stage {
        inset: 112px 26px 82px;
    }

    .zclb__image {
        max-width: calc(100vw - 56px) !important;
        max-height: calc(100vh - 198px) !important;
        max-height: calc(100dvh - 198px) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    .zclb,
    .zclb *,
    .zclb *::before,
    .zclb *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}
