/**
 * @package     J2Commerce
 * @subpackage  Plugin.J2Commerce.AppVideodisplay
 *
 * @copyright   (C)2024-2026 J2Commerce, LLC <https://www.j2commerce.com>
 * @license     GNU General Public License version 2 or later; see LICENSE.txt
 */

/* ------------------------------------------------------------------ */
/* Video Display plugin — storefront styles                            */
/* ------------------------------------------------------------------ */

#j2commerce-videodisplay {
    container-type: inline-size;
}

/* Shared embed wrapper */
.j2c-videodisplay iframe,
.j2c-videodisplay video {
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    border-radius: 4px;
}

/* ------------------------------------------------------------------ */
/* Grid mode                                                           */
/* ------------------------------------------------------------------ */

.j2c-videodisplay--grid .j2c-video-caption {
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.875rem;
}

/* ------------------------------------------------------------------ */
/* Scroller (Swiper) mode                                              */
/* ------------------------------------------------------------------ */

.j2c-videoswiper .swiper {
    width: 100%;
}

.j2c-videoswiper .swiper-slide {
    box-sizing: border-box;
}

/* Spotlight: big centered card with peeking neighbors */
.j2c-videoswiper--spotlight .swiper-slide {
    width: min(1152px, 80vw);
    height: auto;
}

.j2c-videoswiper .j2c-video-caption {
    margin-top: 0.5rem;
    margin-bottom: 0;
    font-size: 0.875rem;
    text-align: center;
}

/* Poster-thumbnail link (scroller mode) */
.j2c-video-poster {
    position: relative;
    display: block;
    overflow: hidden;
    border-radius: 6px;
    text-decoration: none;
}

.j2c-video-poster img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.j2c-video-poster:hover img {
    transform: scale(1.02);
}

/* Play button overlay */
.j2c-video-playbtn {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 3.5rem;
    color: #fff;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.6);
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.j2c-video-poster:hover .j2c-video-playbtn {
    opacity: 0.75;
}

/* ------------------------------------------------------------------ */
/* Alternating mode                                                    */
/* ------------------------------------------------------------------ */

.j2c-videodisplay--alternating .j2c-videodisplay-row {
    margin-bottom: 2rem;
}

.j2c-videodisplay--alternating .j2c-video-text {
    /* Prevent stray margins from WYSIWYG output clipping flex container */
    overflow: hidden;
}

.j2c-videodisplay--alternating .j2c-video-text :first-child {
    margin-top: 0;
}

.j2c-videodisplay--alternating .j2c-video-text :last-child {
    margin-bottom: 0;
}

/* ------------------------------------------------------------------ */
/* Admin: provider badge on URL field                                  */
/* ------------------------------------------------------------------ */

.j2c-video-provider-badge {
    display: inline-block;
    padding: 2px 8px;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 3px;
    background: #e9ecef;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    vertical-align: middle;
    margin-inline-start: 6px;
}

.j2c-video-provider-badge--youtube {
    background: #ff0000;
    color: #fff;
}

.j2c-video-provider-badge--vimeo {
    background: #1ab7ea;
    color: #fff;
}

.j2c-video-provider-badge--html5 {
    background: #e44d26;
    color: #fff;
}

/* ------------------------------------------------------------------ */
/* Image items                                                         */
/* ------------------------------------------------------------------ */

/* Spotlight slides are sized for 16:9 video; image slides take the section's width, not the viewport's */
.j2c-videoswiper--spotlight .swiper-slide.j2c-media-slide--image {
    width: min(360px, 70vw);
    width: min(360px, 70cqi);
}

/* Focus ring drawn inside the link: the scroller clips anything outside the slide.
   White outer band plus black inner band, so one of them contrasts with any photo. */
.j2c-video-poster:focus-visible {
    outline: 3px solid #fff;
    outline-offset: -3px;
}

.j2c-video-poster:focus-visible::after {
    content: "";
    position: absolute;
    inset: 3px;
    border: 2px solid #000;
    pointer-events: none;
}

/* Carousel controls: Swiper's A11y module makes arrows and dots focusable. Two-tone rings (white + black) so one
   band contrasts with any photo; drawn inside the clipped .swiper box. */
.j2c-videoswiper .swiper-button-next:focus-visible,
.j2c-videoswiper .swiper-button-prev:focus-visible {
    outline: 2px solid #fff;
    outline-offset: -2px;
    box-shadow: inset 0 0 0 4px #000;
}

.j2c-videoswiper .swiper-pagination-bullet:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
    box-shadow: 0 0 0 2px #000;
}

/* Dots on a 24px pitch (WCAG 2.5.8 target spacing) */
.j2c-videoswiper {
    --swiper-pagination-bullet-horizontal-gap: 8px;
}

/* Autoplay pause/play control (WCAG 2.2.2) */
.j2c-videoswiper-toggle {
    display: block;
    min-height: 24px;
    margin: 0 auto 0.5rem;
    padding: 0.25rem 0.75rem;
    border: 1px solid currentColor;
    border-radius: 0.25rem;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 0.875rem;
    cursor: pointer;
}

.j2c-videoswiper-toggle:focus-visible {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}
