/* Casa Library — Photo lightbox + multi-photo picker (shared by admin and frontend) */

/* Clickable cover on book cards */
.cl-book-cover.cl-has-photos {
    position: relative;
    cursor: zoom-in;
}

.cl-book-cover.cl-has-photos:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: -2px;
}

.cl-photo-count {
    position: absolute;
    right: 6px;
    bottom: 6px;
    padding: 2px 7px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.65);
    color: #fff;
    font-size: 12px;
    line-height: 1.5;
    pointer-events: none;
}

/* Lightbox */
.cl-lightbox {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 100100; /* above .cl-modal (99999) and the WP admin bar */
    background: rgba(0, 0, 0, 0.92);
}

.cl-lightbox.cl-lb-open {
    display: block;
}

.cl-lb-stage {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 48px 64px;
    box-sizing: border-box;
    overflow: auto;
}

.cl-lb-img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    cursor: zoom-in;
    user-select: none;
}

/* Zoomed: photo at its real size, scroll/drag around it */
.cl-lb-zoomed .cl-lb-stage {
    display: block;
    padding: 0;
}

.cl-lb-zoomed .cl-lb-img {
    max-width: none;
    max-height: none;
    margin: auto;
    display: block;
    cursor: zoom-out;
}

.cl-lb-btn {
    position: absolute;
    z-index: 1;
    border: 0;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    padding: 0;
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 30px;
    line-height: 44px;
    text-align: center;
    cursor: pointer;
}

.cl-lb-btn:hover,
.cl-lb-btn:focus-visible {
    background: rgba(255, 255, 255, 0.3);
}

.cl-lb-close {
    top: 12px;
    right: 12px;
}

.cl-lb-prev,
.cl-lb-next {
    top: 50%;
    transform: translateY(-50%);
}

.cl-lb-prev {
    left: 12px;
}

.cl-lb-next {
    right: 12px;
}

.cl-lb-single .cl-lb-prev,
.cl-lb-single .cl-lb-next,
.cl-lb-zoomed .cl-lb-prev,
.cl-lb-zoomed .cl-lb-next {
    display: none;
}

.cl-lb-counter {
    position: absolute;
    bottom: 14px;
    left: 0;
    right: 0;
    text-align: center;
    color: #ddd;
    font-size: 14px;
    pointer-events: none;
}

@media (max-width: 600px) {
    .cl-lb-stage {
        padding: 56px 8px;
    }

    .cl-lb-prev,
    .cl-lb-next {
        top: auto;
        bottom: 8px;
        transform: none;
    }
}

/* Photo picker in the book modal */
.cl-field-hint {
    margin: 0 0 6px;
    color: #666;
    font-size: 12px;
}

.cl-gallery-picker {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
}

.cl-gallery-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.cl-gallery-list:empty {
    display: none;
}

.cl-gallery-thumb {
    position: relative;
    width: 72px;
    height: 72px;
    border: 2px solid #ddd;
    border-radius: 4px;
    overflow: hidden;
    background: #f5f5f5;
    cursor: pointer;
}

.cl-gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.cl-gallery-thumb.cl-is-cover {
    border-color: #2271b1;
    cursor: default;
}

.cl-gallery-cover-badge {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: #2271b1;
    color: #fff;
    font-size: 10px;
    line-height: 16px;
    text-align: center;
    text-transform: uppercase;
}

.cl-gallery-remove {
    position: absolute;
    top: 2px;
    right: 2px;
    width: 20px;
    height: 20px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    cursor: pointer;
}

.cl-gallery-remove:hover {
    background: #b32d2e;
}
