/* The reader's picture and video windows (js/lightbox-photoswipe.js, PhotoSwipe 5). */
/* On opaque black (bgOpacity 1): the book page does not show behind, a picture's own black edge melts into it */
.bi-pswp {
    --pswp-bg: #000;
    --pswp-icon-color: #ccc;
}

.bi-pswp .pswp__button[hidden],
.bi-pswp .pswp__bi-caption[hidden],
.bi-pswp .pswp__bi-thumbs-panel[hidden] {
    display: none;
}

/* Bar: one rounded box of 36px buttons at the top right, its bottom at 44px where the picture
   starts. The counter and the loading circle sit outside it. */
.bi-pswp .pswp__top-bar {
    top: 4px;
    right: 4px;
    left: auto;
    width: auto;
    max-width: calc(100% - 8px);
    height: auto;
    padding: 2px;
    border-radius: 10px;
    background: rgba(24, 24, 24, 0.85);
    box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.08), 0 2px 10px rgba(0, 0, 0, 0.35);
    z-index: 3;
    /* A click between two buttons stays in the box (through it, it would close the window) */
    pointer-events: auto !important;
}

.bi-pswp .pswp__top-bar .pswp__button {
    width: 36px;
    height: 36px;
    margin: 0;
    padding: 0;
    border-radius: 8px;
    background-color: transparent;
    color: #e6e6e6;
    opacity: 1;
    font-size: 17px;
    line-height: 36px;
    text-align: center;
    transition: background-color 0.15s, color 0.15s;
}

.bi-pswp .pswp__top-bar .pswp__button:hover {
    background-color: rgba(255, 255, 255, 0.14);
    color: #fff;
}

.bi-pswp .pswp__top-bar .pswp__button:focus {
    outline: 2px solid #2563eb;
    outline-offset: -2px;
}

.bi-pswp .pswp__top-bar .pswp__button:focus:not(:focus-visible) {
    outline: none;
}

/* Thumbnails on */
.bi-pswp .pswp__top-bar .pswp__button[aria-pressed="true"] {
    background-color: rgba(255, 255, 255, 0.18);
    color: #fff;
}

/* Arrow to previous / next resource without target (first / last in the book),
   disabled by AmmiNavigator.refreshButtons(). */
.bi-pswp .pswp__top-bar .pswp__button:disabled,
.bi-pswp .pswp__top-bar .pswp__button:disabled:hover {
    opacity: 0.35;
    background-color: transparent;
    cursor: default;
}

/* Close, set apart by a thin line */
.bi-pswp .pswp__top-bar .pswp__button--close {
    margin-left: 7px;
    overflow: visible;
}

.bi-pswp .pswp__top-bar .pswp__button--close::before {
    content: "";
    position: absolute;
    top: 8px;
    bottom: 8px;
    left: -5px;
    width: 1px;
    background: rgba(255, 255, 255, 0.2);
}

/* The icons (lightbox-photoswipe.js ICONS), centred in their button */
.bi-pswp .bi-pswp-icn {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    pointer-events: none;
}

.bi-pswp .pswp__counter {
    position: fixed;
    top: 10px;
    left: 8px;
    height: 28px;
    margin: 0;
    padding: 0 12px;
    border-radius: 14px;
    background: rgba(24, 24, 24, 0.85);
    font-size: 13px;
    font-variant-numeric: tabular-nums;
    line-height: 28px;
    color: #e6e6e6;
    text-shadow: none;
    opacity: 1;
}

.bi-pswp .pswp__preloader {
    position: fixed;
    top: 50%;
    left: 50%;
    margin: -30px 0 0 -25px;
}

.bi-pswp .pswp__button--bi-transcript[aria-expanded="true"],
.bi-pswp .pswp__button--bi-transcript[aria-expanded="true"]:hover {
    background-color: #2563eb;
    color: #fff;
}

/* Side arrows of the gallery: dark circle, visible over light pictures. They stay on touch
   screens too, as the visible way to the other pictures. */
.bi-pswp .pswp__button--arrow {
    width: 48px;
    height: 48px;
    margin-top: -24px;
    border-radius: 50%;
    background: rgba(24, 24, 24, 0.75);
    color: #e6e6e6;
    opacity: 1;
    transition: background-color 0.15s, color 0.15s;
}

.bi-pswp .pswp__button--arrow:hover {
    background: rgba(24, 24, 24, 0.95);
    color: #fff;
}

.bi-pswp.pswp--touch .pswp__button--arrow {
    visibility: visible;
}

.bi-pswp .pswp__button--arrow .bi-pswp-icn {
    width: 26px;
    height: 26px;
    margin: -13px 0 0 -13px;
}

.bi-pswp .pswp__button--arrow--prev {
    left: 8px;
    left: calc(8px + env(safe-area-inset-left));
}

.bi-pswp .pswp__button--arrow--next {
    right: 8px;
    right: calc(8px + env(safe-area-inset-right));
}

/* Video window: the player fills its black box (letterboxed) */
.bi-pswp .bi-pswp-video {
    width: 100%;
    height: 100%;
    background: #000;
}

.bi-pswp .bi-pswp-video video {
    display: block;
    width: 100%;
    height: 100%;
    background: #000;
}

/* Caption: title, attribution and AI voice label, over the bottom of the picture */
.bi-pswp .pswp__bi-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1;
    padding: 75px 44px 25px;
    padding-bottom: max(25px, env(safe-area-inset-bottom));
    background: linear-gradient(0deg, rgba(0, 0, 0, .85) 0, rgba(0, 0, 0, .3) 50%, rgba(0, 0, 0, .15) 65%,
        rgba(0, 0, 0, .075) 75.5%, rgba(0, 0, 0, .037) 82.85%, rgba(0, 0, 0, .019) 88%, transparent);
    color: #eee;
    font-size: 16px;
    font-weight: bold;
    line-height: 1.5;
    text-align: center;
    pointer-events: none;
}

.bi-pswp--gallery .pswp__bi-caption {
    font-size: 20px;
}

.bi-pswp .pswp__bi-caption a,
.bi-pswp .pswp__bi-caption button {
    pointer-events: auto;
    position: relative;
}

/* Thumbnails of a gallery: a column on the right (active one in the UI blue) */
.bi-pswp .pswp__bi-thumbs-panel {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    z-index: 2;
    width: 212px;
    box-sizing: border-box;
    padding: 2px 2px 4px;
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    background: #ddd;
}

.bi-pswp .bi-pswp-thumb {
    position: relative;
    float: left;
    width: 100px;
    height: 75px;
    max-width: calc(50% - 4px);
    margin: 2px;
    padding: 0;
    border: 0;
    background-color: rgba(0, 0, 0, .1);
    background-position: 50%;
    background-repeat: no-repeat;
    background-size: cover;
    cursor: pointer;
}

.bi-pswp .bi-pswp-thumb::before {
    content: "";
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    border: 4px solid #2563eb;
    opacity: 0;
    transition: opacity .2s;
}

.bi-pswp .bi-pswp-thumb.is-active::before {
    opacity: 1;
}

.bi-pswp .bi-pswp-thumb:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

.bi-pswp .bi-pswp-thumb:focus:not(:focus-visible) {
    outline: none;
}

/* The bar and the caption stay left of the thumbnails */
.bi-pswp--thumbs .pswp__top-bar {
    right: 216px;
    max-width: calc(100% - 220px);
}

.bi-pswp--thumbs .pswp__bi-caption {
    right: 212px;
}

.bi-pswp--thumbs .pswp__button--arrow--next {
    right: 220px;
}

@media (max-width: 640px) {
    /* Larger touch buttons; the box (8 + 60 + 8 px) wraps when they do not fit */
    .bi-pswp .pswp__top-bar {
        top: 8px;
        right: 8px;
        max-width: calc(100% - 16px);
        flex-wrap: wrap;
        padding: 6px;
        border-radius: 12px;
    }

    .bi-pswp--thumbs .pswp__top-bar {
        right: 220px;
        max-width: calc(100% - 228px);
    }

    .bi-pswp .pswp__top-bar .pswp__button {
        width: 48px;
        height: 48px;
        border-radius: 9px;
        line-height: 48px;
    }

    .bi-pswp .pswp__top-bar .bi-pswp-icn {
        width: 22px;
        height: 22px;
        margin: -11px 0 0 -11px;
    }

    .bi-pswp .pswp__top-bar .pswp__button--close::before {
        top: 12px;
        bottom: 12px;
    }

    /* Centred on the bar box */
    .bi-pswp .pswp__counter {
        top: 22px;
        height: 32px;
        border-radius: 16px;
        line-height: 32px;
    }

    .bi-pswp .pswp__bi-caption {
        padding-left: 12px;
        padding-right: 12px;
    }
}

@media (max-width: 576px) {
    .bi-pswp .pswp__bi-thumbs-panel {
        width: 110px;
    }

    .bi-pswp .bi-pswp-thumb {
        max-width: calc(100% - 10px);
    }

    .bi-pswp--thumbs .pswp__bi-caption {
        right: 110px;
    }

    .bi-pswp--thumbs .pswp__top-bar {
        right: 118px;
        max-width: calc(100% - 126px);
    }

    .bi-pswp--thumbs .pswp__button--arrow--next {
        right: 118px;
    }
}
