/* ==========================================================
   IMAGE LIGHTBOX — site-wide component
   Markup: handbook_lightbox_image() in inc/lightbox.php.
   Script: assets/js/lightbox.js (loaded only on pages that use it).

   handbook-lightbox__trigger          framed image button
   handbook-lightbox__trigger--plain   same, without the frame
   handbook-lightbox__expand           "Click to expand" text button
   handbook-lightbox                   the dialog
   ========================================================== */

/* Lightbox trigger / expand affordance on each image figure. */

.handbook-lightbox__trigger {
    display: block;
    width: 100%;
    padding: 1px;
    border: 1px solid var(--handbook-grey-725);
    background: none;
    cursor: zoom-in;
    overflow: hidden;
    border-radius: 5px;
}

.handbook-lightbox__trigger--plain {
    padding: 0;
    border: 0;
}

.handbook-lightbox__trigger img {
    transition: transform 200ms ease;
    transform-origin: center;
}

@media (hover: hover) and (prefers-reduced-motion: no-preference) {
    .handbook-lightbox__trigger:hover img {
        transform: scale(1.025);
    }
}

.handbook-lightbox__trigger:focus-visible,
.handbook-lightbox__expand:focus-visible {
    outline: 2px solid #17a5aa;
    outline-offset: 3px;
}

.handbook-lightbox__expand {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    margin: 9px 0 0 auto;
    padding: 3px 0;
    background: transparent;
    border: 0;
    color: var(--handbook-grey-375);
    font: inherit;
    font-size: 12px;
    cursor: pointer;
}

.handbook-lightbox__expand:hover {
    color: var(--handbook-white);
}


/* Dialog
---------------------------------------------------------- */

.handbook-lightbox {
    position: fixed;
    inset: 0;
    z-index: 2147483647;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(0, 0, 0, .94);
    color: var(--handbook-grey-100);
    box-sizing: border-box;
}

.handbook-lightbox[hidden] {
    display: none !important;
}

.handbook-lightbox__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 100%;
    max-height: 100%;
    width: 100%;
}

.handbook-lightbox__image {
    display: block;
    max-width: calc(100vw - 110px);
    max-height: calc(100dvh - 170px);
    width: auto;
    height: auto;
    object-fit: contain;
}

.handbook-lightbox__caption {
    margin: 16px auto 0;
    max-width: min(760px, 90vw);
    text-align: center;
    color: var(--handbook-grey-275);
    font-size: 13px;
    line-height: 1.5;
    white-space: pre-wrap;
}

.handbook-lightbox__counter {
    margin-top: 10px;
    color: var(--handbook-grey-375);
    font-size: 24px;
    font-variant-numeric: tabular-nums;
}

.handbook-lightbox__close,
.handbook-lightbox__prev,
.handbook-lightbox__next {
    position: absolute;
    border: 0;
    background: rgba(40, 40, 40, .8);
    color: var(--handbook-white);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: grid;
    place-items: center;
    cursor: pointer;
    font-size: 25px;
    line-height: 1;
}

.handbook-lightbox__close {
    top: 15px;
    right: 15px;
}

.handbook-lightbox__prev {
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.handbook-lightbox__next {
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
}

.handbook-lightbox__prev[hidden],
.handbook-lightbox__next[hidden] {
    display: none !important;
}

.handbook-lightbox button:focus-visible {
    outline: 2px solid #17a5aa;
    outline-offset: 3px;
}

@media (max-width: 600px) {
    .handbook-lightbox {
        padding: 12px;
    }

    .handbook-lightbox__image {
        max-width: calc(100vw - 70px);
        max-height: calc(100dvh - 155px);
    }

    .handbook-lightbox__prev {
        left: 3px;
    }

    .handbook-lightbox__next {
        right: 3px;
    }
}
