/*
 * parts/media.php: a looping video in a block's media slot. The inline aspect-ratio (the
 * image's size, else 16:9) reserves the box before the video loads; the block's image
 * class (also on the video) sets width, radius and any fixed height.
 */

:where(.rm-media__video) {
    display: block;
    max-width: 100%;
    height: auto;
    object-fit: cover;
}

:where(.rm-media__video:not([width])) {
    width: 100%;
}

/*
 * parts/media.php with `once`: the video plays once and stays on its last frame; a round
 * replay button sits in its bottom-right corner (44px touch target, hidden until
 * assets/js/media.js runs). It is quieter while the video plays.
 */
:where(.rm-media-once) {
    position: relative;
    display: block;
}

.rm-media-once__replay {
    position: absolute;
    right: 14px;
    bottom: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--rm-black);
    color: var(--rm-white);
    box-shadow: 0 6px 16px -6px rgba(41, 41, 41, .45);
    cursor: pointer;
    opacity: .9;
    transition: opacity .2s, transform .2s;
}

.rm-media-once__replay[hidden] {
    display: none;
}

.rm-media-once__replay svg {
    width: 20px;
    height: 20px;
}

.rm-media-once.is-playing .rm-media-once__replay {
    opacity: .45;
}

.rm-media-once__replay:hover,
.rm-media-once__replay:focus-visible {
    opacity: 1;
    transform: scale(1.06);
}

.rm-media-once__replay:focus-visible {
    outline: 2px solid var(--rm-blurple);
    outline-offset: 3px;
}

@media (prefers-reduced-motion: reduce) {
    .rm-media-once__replay {
        transition: none;
    }

    .rm-media-once__replay:hover,
    .rm-media-once__replay:focus-visible {
        transform: none;
    }
}

/*
 * parts/media.php with a motif: a lavender box with the image's aspect ratio holding the
 * canvas assets/js/motifs.js draws on. The fallback image shows only without scripts
 * (html.rm-js is set in the head, so a hidden lazy fallback is never fetched).
 */
:where(.rm-motif) {
    position: relative;
    display: block;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
    border-radius: 24px;
    background: var(--rm-lavender);
}

.rm-motif canvas {
    position: absolute;
    inset: 0;
    display: block;
    width: 100%;
    height: 100%;
}

.rm-motif__fallback {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.rm-js .rm-motif__fallback {
    display: none;
}
