/*
 * Lightbox
 *
 * Loaded only on pages with `lightbox: true` in their front matter.
 * Markup is produced by layouts/_default/_markup/render-image.html
 * and layouts/partials/head/custom.html; behaviour lives in js/lightbox.js.
 */

/* -------------------------------------------------------------------------
 * Thumbnails (in-content)
 * ---------------------------------------------------------------------- */

.lightbox-thumb {
    position: relative;
    display: inline-block;
    max-width: 100%;
    margin: 0 0.5em 0.5em 0;
    padding: 4px;
    border: solid 1px #e0e0e0;
    border-radius: 5px;
    background-color: #fff;
    line-height: 0;
    vertical-align: top;
    cursor: zoom-in;
    transition: border-color 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.lightbox-thumb:hover,
.lightbox-thumb:focus-visible {
    border-color: #fac70d;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
}

.lightbox-thumb:focus-visible {
    outline: solid 2px #fac70d;
    outline-offset: 2px;
}

.lightbox-thumb img {
    display: block;
    width: auto;
    height: auto;
    max-width: 100%;
    max-height: 180px;
    border-radius: 3px;
}

/* Magnifier badge, so it is obvious the thumbnail expands. */
.lightbox-thumb::after {
    content: '';
    position: absolute;
    right: 8px;
    bottom: 8px;
    width: 26px;
    height: 26px;
    border-radius: 3px;
    background-color: rgba(0, 0, 0, 0.55);
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='10.5' cy='10.5' r='6.5'/%3E%3Cpath d='M10.5 7.5v6M7.5 10.5h6M15.5 15.5L21 21'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    background-size: 16px 16px;
    opacity: 0.75;
    transition: opacity 0.2s ease-in-out;
    pointer-events: none;
}

.lightbox-thumb:hover::after,
.lightbox-thumb:focus-visible::after {
    opacity: 1;
}

@media screen and (max-width: 736px) {
    .lightbox-thumb img {
        max-height: 130px;
    }
}

/* -------------------------------------------------------------------------
 * Overlay
 * ---------------------------------------------------------------------- */

body.lightbox-open {
    overflow: hidden;
}

.lightbox-overlay {
    position: fixed;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    z-index: 11000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3.5em 1em 1em;
    background-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease-in-out, visibility 0.2s;
}

.lightbox-overlay.is-open {
    opacity: 1;
    visibility: visible;
}

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

.lightbox-image {
    width: auto;
    height: auto;
    max-width: 90vw;
    max-height: 78vh;
    border-radius: 3px;
    background-color: #fff;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    flex-shrink: 0;
    max-width: 90vw;
    margin-top: 1em;
    color: #fff;
    font-size: 0.9em;
    line-height: 1.5;
    text-align: center;
}

.lightbox-caption:empty {
    display: none;
}

.lightbox-counter {
    position: absolute;
    top: 1em;
    left: 1em;
    color: #fff;
    font-size: 0.85em;
    letter-spacing: 0.05em;
    opacity: 0.7;
}

/* Buttons */

.lightbox-overlay button {
    position: absolute;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 3px;
    background-color: rgba(255, 255, 255, 0.1);
    background-repeat: no-repeat;
    background-position: center;
    background-size: 24px 24px;
    color: transparent;
    font-size: 0;
    cursor: pointer;
    transition: background-color 0.2s ease-in-out;
}

.lightbox-overlay button:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

.lightbox-overlay button:focus-visible {
    outline: solid 2px #fac70d;
    outline-offset: 2px;
}

.lightbox-close {
    top: 1em;
    right: 1em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round'%3E%3Cpath d='M6 6l12 12M18 6L6 18'/%3E%3C/svg%3E");
}

.lightbox-prev,
.lightbox-next {
    top: 50%;
    margin-top: -22px;
}

.lightbox-prev {
    left: 1em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M15 4L7 12l8 8'/%3E%3C/svg%3E");
}

.lightbox-next {
    right: 1em;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23fff' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M9 4l8 8-8 8'/%3E%3C/svg%3E");
}

/* Hidden when there is only a single image on the page. */
.lightbox-overlay.is-single .lightbox-prev,
.lightbox-overlay.is-single .lightbox-next,
.lightbox-overlay.is-single .lightbox-counter {
    display: none;
}

@media screen and (max-width: 736px) {
    .lightbox-overlay {
        padding: 3.5em 0.5em 0.5em;
    }

    .lightbox-image {
        max-width: 96vw;
        max-height: 70vh;
    }

    .lightbox-prev,
    .lightbox-next {
        top: auto;
        bottom: 0.5em;
        margin-top: 0;
    }

    .lightbox-prev {
        left: 0.5em;
    }

    .lightbox-next {
        right: 0.5em;
    }
}

@media (prefers-reduced-motion: reduce) {
    .lightbox-thumb,
    .lightbox-thumb::after,
    .lightbox-overlay,
    .lightbox-overlay button {
        transition: none;
    }
}
