/*
 * Video thumbnails and the player they open.
 *
 * A video post drew a grey "View Media" button on the post page and an empty
 * card in the feed. It now draws the picture, with a play badge over it, and
 * pressing it opens the player here instead of sending the reader to
 * youtube.com in a new tab.
 */

/* ---------------------------------------------- the thumbnail, as a button */

.wz-vthumb {
    position: relative;
    display: block;
    width: 100%;
    padding: 0;
    border: 0;
    border-radius: 12px;
    overflow: hidden;
    background: #0b1222;
    cursor: pointer;
    line-height: 0;
}

.wz-vthumb__img {
    display: block;
    width: 100%;
    height: auto;
    /* YouTube's hqdefault is 480x360 with black bars for a 16:9 video, and a
       tall white frame for a Short. Cropping to 16:9 keeps a row of cards the
       same height whichever kind was posted. */
    aspect-ratio: 16 / 9;
    object-fit: cover;
}

.wz-vthumb__play {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(11, 18, 34, .72);
    color: #fff;
    font-size: 22px;
    transition: background .15s, transform .15s;
    pointer-events: none;
}

.wz-vthumb:hover .wz-vthumb__play,
.wz-vthumb:focus-visible .wz-vthumb__play {
    background: #c4302b;
    transform: translate(-50%, -50%) scale(1.06);
}

.wz-vthumb:focus-visible {
    outline: 3px solid #1d4ed8;
    outline-offset: 2px;
}

/* The play triangle sits a shade right of centre, because its own bounding
   box is wider than the shape inside it. */
.wz-vthumb__play .fa-play { margin-left: 4px; }

/* ------------------------------------------------------------ the player */

.wz-video {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(6, 12, 26, .88);
}

.wz-video[hidden] { display: none; }

.wz-video__inner {
    position: relative;
    width: 100%;
    max-width: 900px;
}

.wz-video__frame {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    border: 0;
    border-radius: 14px;
    background: #000;
    box-shadow: 0 30px 80px rgba(0, 0, 0, .55);
}

.wz-video__close {
    position: absolute;
    top: -46px;
    right: 0;
    width: 38px;
    height: 38px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid rgba(255, 255, 255, .28);
    border-radius: 10px;
    background: rgba(255, 255, 255, .12);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
}

.wz-video__close:hover { background: rgba(255, 255, 255, .24); }

.wz-video__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

/* The page behind must not scroll while the player is up. */
body.wz-video-open { overflow: hidden; }

@media (max-width: 575.98px) {
    .wz-video { padding: 16px; }

    /* On a phone there is no room above the player for the close button, so
       it sits on the player itself. */
    .wz-video__close {
        top: 8px;
        right: 8px;
        background: rgba(6, 12, 26, .72);
        border-color: rgba(255, 255, 255, .38);
    }

    .wz-vthumb__play { width: 52px; height: 52px; font-size: 18px; }
}
