/* ==========================================================================
   Lightbox

   The full-size view, with prev/next, a caption, a count, Escape and a
   focus trap. Shared, because two blocks now open one: the Gallery, where
   it started, and Image & Text when its gallery is set to enlarge on
   click.

   It was inside the Gallery block's stylesheet and its view.js. Both only
   load when that block is on the page, so an Image & Text gallery on a
   page without one had a dialog and no rules to draw it. Moving it here
   also means the two cannot drift: there is one lightbox, and a change to
   it is a change to both.

   The markup a block has to print, and the attributes each trigger
   carries, are described in assets/js/lightbox.js.
   ========================================================================== */

.ssb-lightbox {
    position: fixed;
    inset: 0;
    z-index: 1200;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ssb-lightbox[hidden] {
    display: none;
}

.ssb-lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .92);
}

.ssb-lightbox-panel {
    /*
     * The panel is the full size of the dialog and sits over the backdrop,
     * so a click on the dark area around the picture landed on the panel
     * and the dialog did not close. Letting the pointer through here sends
     * those clicks to the backdrop, which is a close trigger; the parts
     * that are actually controls take it back below.
     */
    pointer-events: none;

    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    padding: var(--space-xl) calc(44px + var(--space-md) * 2);
    color: var(--color-light);
}

.ssb-lightbox-figure {
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
}

.ssb-lightbox-img {
    display: block;
    max-width: 100%;
    max-height: calc(100vh - 10rem);
    width: auto;
    height: auto;
    object-fit: contain;
}

.ssb-lightbox-caption {
    max-width: 60ch;
    margin-top: var(--space-sm);
    font-size: 0.875rem;
    text-align: center;

    /* The same caption the grid shows, so it breaks the same way. */
    white-space: pre-line;
}

.ssb-lightbox-close,
.ssb-lightbox-arrow {
    position: absolute;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    background: none;
    border: 0;
    color: var(--color-light);
    cursor: pointer;
}

.ssb-lightbox-close {
    top: var(--space-sm);
    right: var(--space-sm);
    font-size: 2rem;
    line-height: 1;
}

.ssb-lightbox-arrow {
    top: 50%;
    font-size: 1.5rem;
    transform: translateY(-50%);
}

.ssb-lightbox-arrow--prev {
    left: var(--space-md);
}

.ssb-lightbox-arrow--next {
    right: var(--space-md);
}

.ssb-lightbox-close:hover,
.ssb-lightbox-close:focus-visible,
.ssb-lightbox-arrow:hover,
.ssb-lightbox-arrow:focus-visible {
    color: var(--color-highlight, var(--color-light));
}

.ssb-lightbox-close:focus-visible,
.ssb-lightbox-arrow:focus-visible {
    outline: 2px solid currentColor;
}

.ssb-lightbox-count {
    position: absolute;
    bottom: var(--space-sm);
    left: 50%;
    margin: 0;
    font-size: 0.8125rem;
    letter-spacing: 0.1em;
    transform: translateX(-50%);
    opacity: .75;
}

body.ssb-lightbox-open {
    overflow: hidden;
}

@media (max-width: 599px) {

    .ssb-lightbox-panel {
        padding: var(--space-xl) var(--space-sm);
    }

    .ssb-lightbox-arrow {
        top: auto;
        bottom: var(--space-sm);
        transform: none;
    }

}


/*
 * The pieces inside the panel, which the rule above let the pointer fall
 * through. The picture is listed so that clicking it does not close the
 * dialog -- the dark area around it is what closes.
 */
.ssb-lightbox-figure,
.ssb-lightbox-close,
.ssb-lightbox-arrow,
.ssb-lightbox-count {
    pointer-events: auto;
}
