/* AB Media Gallery widget */

/*
 * Take the full width available, like Elementor's own Video widget.
 * Otherwise, in a container that centres its contents, the widget is only as wide as its text
 * and preview bar, so an item with no title or description shrinks.
 * A Width set on the widget's Advanced tab still wins over this.
 */
.e-con .elementor-widget-ab_random_video {
    width: 100%;
}

.ab-rvw-center {
    text-align: center;
}

.ab-rvw-center .ab-rvw-container {
    margin-left: auto;
    margin-right: auto;
}

.ab-rv-title {
    margin-bottom: 5px;
    font-weight: bold;
}

.ab-rv-description {
    margin-top: 5px;
}

.ab-rv-button .elementor-button {
    display: inline-block;
}

.ab-rvw-gallery .ab-rvw-item[hidden] {
    display: none !important;
}

/* The image or movie box. Its shape comes from the widget's Shape setting. */
.ab-rvw-container {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
}

.ab-rvw-ratio-4-3 .ab-rvw-container { aspect-ratio: 4 / 3; }
.ab-rvw-ratio-3-2 .ab-rvw-container { aspect-ratio: 3 / 2; }
.ab-rvw-ratio-1-1 .ab-rvw-container { aspect-ratio: 1 / 1; }
.ab-rvw-ratio-auto .ab-rvw-container { aspect-ratio: auto; }

.ab-rvw-container > .ab-rvw-media {
    position: absolute;
    top: 0;
    left: 0;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    object-fit: cover;
}

/* Each image's own shape */
.ab-rvw-ratio-auto .ab-rvw-container > img.ab-rvw-media,
.ab-rvw-ratio-auto .ab-rvw-container > video.ab-rvw-media {
    position: static;
    height: auto;
}

/* YouTube is always 16:9 */
.ab-rvw-ratio-auto .ab-rvw-container > .ab-rvw-youtube {
    position: relative;
    aspect-ratio: 16 / 9;
}

.ab-rvw-youtube .ab-rvw-youtube-poster,
.ab-rvw-youtube iframe,
.ab-rvw-youtube .ab-rvw-youtube-cover {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    margin: 0;
    border: 0;
}

.ab-rvw-youtube .ab-rvw-youtube-poster {
    object-fit: cover;
}

.ab-rvw-youtube .ab-rvw-youtube-cover {
    z-index: 2;
}

.ab-rvw-zoom {
    cursor: zoom-in;
}

/* Preview bar */

.ab-rvw-gallery .ab-rvw-thumbs {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-top: 12px;
}

/* The longer selectors stop theme and Elementor button styles from changing the previews */
.ab-rvw-gallery .ab-rvw-thumbs button.ab-rvw-thumb {
    position: relative;
    flex: 0 0 auto;
    width: 80px;
    height: 60px;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 4px;
    background: #f0f0f0;
    box-shadow: none;
    color: #333;
    line-height: 1;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
}

.ab-rvw-gallery .ab-rvw-thumbs button.ab-rvw-thumb:hover {
    opacity: 1;
}

.ab-rvw-gallery .ab-rvw-thumbs button.ab-rvw-thumb[aria-pressed="true"] {
    border-color: #333;
    opacity: 1;
}

.ab-rvw-gallery .ab-rvw-thumbs button.ab-rvw-thumb:focus-visible {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.ab-rvw-gallery .ab-rvw-thumbs .ab-rvw-thumb img,
.ab-rvw-gallery .ab-rvw-thumbs .ab-rvw-thumb video {
    display: block;
    width: 100% !important;
    height: 100% !important;
    max-width: none;
    margin: 0;
    border-radius: 0;
    box-shadow: none;
    object-fit: cover;
    pointer-events: none;
}

/* Play symbol over movie and YouTube previews */
.ab-rvw-gallery .ab-rvw-thumb-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 24px;
    height: 24px;
    margin: -12px 0 0 -12px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.65);
    pointer-events: none;
}

.ab-rvw-gallery .ab-rvw-thumb-play::after {
    content: "";
    position: absolute;
    top: 7px;
    left: 9px;
    border-style: solid;
    border-width: 5px 0 5px 8px;
    border-color: transparent transparent transparent #fff;
}

/* Full size view */

html.ab-rvw-lightbox-open {
    overflow: hidden;
}

dialog.ab-rvw-lightbox {
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    max-width: 100%;
    max-height: 100%;
    margin: 0;
    padding: 0;
    border: 0;
    background: rgba(0, 0, 0, 0.92);
    overflow: hidden;
}

/* Only when open, or the closed pop-up would show */
dialog.ab-rvw-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Shown at its real size, shrunk only if it is bigger than the screen */
dialog.ab-rvw-lightbox .ab-rvw-lightbox-content img,
dialog.ab-rvw-lightbox .ab-rvw-lightbox-content video {
    display: block;
    width: auto;
    height: auto;
    max-width: 95vw;
    max-height: 88vh;
    margin: 0;
}

dialog.ab-rvw-lightbox .ab-rvw-lightbox-content img.ab-rvw-lightbox-svg {
    width: 95vw;
    height: 88vh;
    object-fit: contain;
}

/* YouTube has no size of its own, so it is as big as fits at 16:9 */
dialog.ab-rvw-lightbox .ab-rvw-lightbox-content iframe {
    display: block;
    width: min(95vw, calc(88vh * 16 / 9));
    height: auto;
    aspect-ratio: 16 / 9;
    border: 0;
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-close,
dialog.ab-rvw-lightbox button.ab-rvw-lightbox-nav {
    position: absolute;
    min-width: 0;
    min-height: 0;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 50%;
    box-shadow: none;
    color: #fff;
    cursor: pointer;
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-close {
    top: 8px;
    right: 8px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.15);
    font-size: 28px;
    line-height: 40px;
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Left and right arrows, only when the widget has more than one item */
dialog.ab-rvw-lightbox button.ab-rvw-lightbox-nav {
    display: none;
    top: 50%;
    width: 48px;
    height: 48px;
    margin-top: -24px;
    padding-bottom: 6px;
    background: rgba(90, 90, 90, 0.65);
    font-size: 36px;
    line-height: 42px;
}

dialog.ab-rvw-lightbox.ab-rvw-lightbox-multi button.ab-rvw-lightbox-nav {
    display: block;
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-nav:hover {
    background: rgba(130, 130, 130, 0.85);
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-prev {
    left: 8px;
}

dialog.ab-rvw-lightbox button.ab-rvw-lightbox-next {
    right: 8px;
}

/* On wider screens, leave room so the arrows don't cover the image or movie */
@media (min-width: 601px) {
    dialog.ab-rvw-lightbox.ab-rvw-lightbox-multi .ab-rvw-lightbox-content img,
    dialog.ab-rvw-lightbox.ab-rvw-lightbox-multi .ab-rvw-lightbox-content video {
        max-width: calc(100vw - 128px);
    }

    dialog.ab-rvw-lightbox.ab-rvw-lightbox-multi .ab-rvw-lightbox-content img.ab-rvw-lightbox-svg {
        width: calc(100vw - 128px);
    }

    dialog.ab-rvw-lightbox.ab-rvw-lightbox-multi .ab-rvw-lightbox-content iframe {
        width: min(calc(100vw - 128px), calc(88vh * 16 / 9));
    }
}
