/* Content image zoom lightbox — body text images plus the book cover thumbnail. */

/* Affordance only. The text containers are marked with [data-content-zoom]
   (Content detail: .content-html/.content-summary — Books reader: .bf-html); the book
   cover thumbnail (.bf-landing__cover img) opts into the same lightbox. Site chrome
   (header logo, footer) never matches. */
[data-content-zoom] img,
.bf-landing__cover img {
    cursor: zoom-in;
}

.czoom {
    --czoom-pad: clamp(.75rem, 2.5vw, 1.5rem);
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity .26s ease, visibility .26s ease;
}

.czoom.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

.czoom__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .9);
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
}

.czoom__stage {
    position: relative;
    z-index: 1;
    box-sizing: border-box;
    width: 100%;
    height: 100%;
    max-height: 100vh;
    max-height: 100dvh;
    padding: var(--czoom-pad);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: .7rem;
    outline: none;
    overflow: hidden;
}

.czoom__figure {
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: .55rem;
    max-width: 100%;
}

.czoom__frame {
    position: relative;
    flex: 0 0 auto;
    width: 280px;
    height: 200px;
    max-width: 92vw;
    max-height: 82vh;
    background: rgba(0, 0, 0, .25);
    border-radius: 4px;
    overflow: hidden;
    box-shadow:
        0 0 0 1px rgba(255, 255, 255, .06),
        0 12px 40px rgba(0, 0, 0, .55);
    touch-action: none;
    cursor: default;
}

.czoom__frame.is-zoomed { cursor: grab; }
.czoom__frame.is-dragging { cursor: grabbing; }

.czoom__img {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: contain;
    border: 0;
    transform-origin: center center;
    opacity: 0;
    transition: opacity .28s ease, transform .18s ease;
    will-change: transform, opacity;
    user-select: none;
    -webkit-user-drag: none;
}

.czoom__img.is-ready { opacity: 1; }

.czoom__frame.is-dragging .czoom__img {
    transition: opacity .28s ease;
}

.czoom__caption {
    margin: 0;
    max-width: min(40rem, 92vw);
    color: rgba(255, 255, 255, .92);
    font-size: clamp(.85rem, 2.2vw, .95rem);
    font-weight: 500;
    line-height: 1.45;
    text-align: center;
    word-break: break-word;
}

.czoom__caption[hidden] { display: none !important; }

.czoom__tools {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: .5rem;
}

.czoom__btn {
    appearance: none;
    border: 0;
    background: rgba(20, 20, 20, .5);
    color: rgba(255, 255, 255, .95);
    width: 2.7rem;
    height: 2.7rem;
    border-radius: 999px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .3);
    -webkit-backdrop-filter: blur(6px);
    backdrop-filter: blur(6px);
    -webkit-tap-highlight-color: transparent;
    transition: background .18s ease, color .18s ease, opacity .18s ease;
    z-index: 2;
}

.czoom__btn:hover { background: rgba(0, 0, 0, .62); color: #fff; }

.czoom__btn:focus-visible {
    outline: 2px solid rgba(255, 255, 255, .7);
    outline-offset: 2px;
}

.czoom__btn:disabled {
    opacity: .35;
    cursor: default;
    pointer-events: none;
}

.czoom__btn .bi {
    font-size: 1.2rem;
    line-height: 1;
    pointer-events: none;
}

.czoom__btn--close {
    position: absolute;
    top: var(--czoom-pad);
    inset-inline-end: var(--czoom-pad);
}

body.czoom-open {
    position: fixed;
    inset-inline: 0;
    width: 100%;
    overflow: hidden;
}

@media (max-width: 480px) {
    .czoom__btn {
        width: 2.5rem;
        height: 2.5rem;
    }
    .czoom__frame {
        max-height: 74vh;
    }
}

@media (prefers-reduced-motion: reduce) {
    .czoom,
    .czoom__img {
        transition: none !important;
    }
}
