/* Media lightbox — a small "expand to see it clearly" affordance for the
   figures, videos and 3D models inside a rendered manuscript.
   Self-contained: it decorates whatever media is already on the page and adds
   a full-screen overlay. It does not change how the media is stored or
   sanitised — only how the reader can enlarge it.

   Scoped to .media-lightbox-on so it only acts where the page opts in. */

/* The button sits over the top-right of each media object. */
.media-lightbox-on .media-expandable {
    position: relative;
    display: inline-block;
    max-width: 100%;
}

/* A video or 3D model is an iframe laid absolutely over a box whose height is
   its padding (the aspect ratio). Inline-block shrinks that box to its content,
   which is nothing: zero wide, and the video or model was not there at all. */
.media-lightbox-on .inserted-video-content-wrapper.media-expandable {
    display: block;
    width: 100%;
}

.media-expand-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    display: inline-flex;
    align-items: center;
    gap: 0.35em;
    padding: 0.35rem 0.6rem;
    border: 0;
    border-radius: 6px;
    background: rgba(17, 24, 39, 0.72);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    line-height: 1;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.15s ease, background 0.15s ease;
    backdrop-filter: blur(2px);
}

.media-expandable:hover .media-expand-btn,
.media-expand-btn:focus-visible {
    opacity: 1;
}

/* On touch screens there is no hover, so keep it visible. */
@media (hover: none) {
    .media-expand-btn { opacity: 1; }
}

.media-expand-btn:hover {
    background: rgba(17, 24, 39, 0.9);
}

.media-expand-btn svg {
    width: 14px;
    height: 14px;
    fill: currentColor;
}

/* The overlay. */
.media-lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3vmin;
    background: rgba(10, 14, 22, 0.85);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.18s ease;
}

.media-lightbox.open {
    opacity: 1;
    pointer-events: auto;
}

.media-lightbox__stage {
    max-width: 96vw;
    max-height: 92vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-lightbox__stage img,
.media-lightbox__stage video {
    max-width: 96vw;
    max-height: 92vh;
    width: auto;
    height: auto;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

/* Videos and 3D-model iframes want a large 16:9 (or 4:3) box. */
.media-lightbox__stage iframe {
    width: 90vw;
    height: 84vh;
    border: 0;
    border-radius: 4px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    background: #000;
}

.media-lightbox__close {
    position: absolute;
    top: 14px;
    right: 16px;
    width: 40px;
    height: 40px;
    border: 0;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.14);
    color: #fff;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.media-lightbox__close:hover {
    background: rgba(255, 255, 255, 0.28);
}

.media-lightbox__hint {
    position: absolute;
    bottom: 16px;
    left: 0;
    right: 0;
    text-align: center;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.8rem;
}

/* Keep the page from scrolling behind an open overlay. */
body.media-lightbox-open {
    overflow: hidden;
}
