/**
 * WC Product Video – Frontend Styles
 *
 * YouTube-style play button overlay + responsive video player wrapper.
 */

/* ------------------------------------------------------------------
 * Video Slide in Gallery
 * ----------------------------------------------------------------*/

.wcpv-video-slide {
    position: relative;
}

.wcpv-video-slide .wcpv-video-trigger {
    display: block;
    position: relative;
    cursor: pointer;
}

.wcpv-video-slide .wcpv-video-trigger img {
    display: block;
    width: 100%;
    height: auto;
}

/* ------------------------------------------------------------------
 * Play Button – YouTube-style (rounded rect SVG)
 * ----------------------------------------------------------------*/

.wcpv-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 68px;
    height: 48px;
    pointer-events: none;
    z-index: 2;
    transition: opacity 0.2s ease, transform 0.2s ease;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.3));
}

.wcpv-play-icon svg {
    display: block;
    width: 100%;
    height: 100%;
}

/* Background path of the rounded rectangle */
.wcpv-play-icon .wcpv-play-bg {
    fill: rgba(0, 0, 0, 0.75);
    transition: fill 0.2s ease;
}

/* Hover – red like YouTube */
.wcpv-video-trigger:hover .wcpv-play-bg {
    fill: #e52d27;
}

.wcpv-video-trigger:hover .wcpv-play-icon {
    transform: translate(-50%, -50%) scale(1.08);
}

/* Focus state – also red */
.wcpv-video-trigger:focus-visible .wcpv-play-bg {
    fill: #e52d27;
}

.wcpv-video-trigger:focus-visible .wcpv-play-icon {
    transform: translate(-50%, -50%) scale(1.08);
}

/* ------------------------------------------------------------------
 * Poster Placeholder (local video without custom thumbnail)
 * ----------------------------------------------------------------*/

.wcpv-poster-placeholder {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
}

/* ------------------------------------------------------------------
 * Video Player Wrapper (active state – replaces poster)
 * ----------------------------------------------------------------*/

.wcpv-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    overflow: hidden;
}

.wcpv-video-player {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.wcpv-video-slide.wcpv-playing {
    position: relative;
}

.wcpv-video-slide.wcpv-playing .wcpv-video-wrapper {
    z-index: 3;
}

/* ------------------------------------------------------------------
 * YouTube Shorts – vertical 9:16 aspect ratio
 *
 * Both the poster trigger and the video wrapper use the same explicit
 * width derived from max-height (500px × 9/16 = 281.25px) so they
 * render at identical dimensions.  A plain `width: auto` on a block
 * <div> resolves to 100 % of the parent, which broke the aspect ratio
 * and caused black bars; an explicit `min(calc(…), 100%)` fixes that.
 * ----------------------------------------------------------------*/

.wcpv-video-slide--shorts .wcpv-video-trigger {
    display: block;
    position: relative;
    width: min(calc(500px * 9 / 16), 100%);
    margin: 0 auto;
    cursor: pointer;
}

.wcpv-video-slide--shorts .wcpv-poster-placeholder {
    aspect-ratio: 9 / 16;
    width: 100%;
    background: #111;
}

.wcpv-shorts-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.15);
    border-top-color: #fff;
    border-radius: 50%;
    animation: wcpv-spin 0.8s linear infinite;
}

@keyframes wcpv-spin {
    to { transform: translate(-50%, -50%) rotate(360deg); }
}

.wcpv-video-wrapper--shorts {
    aspect-ratio: 9 / 16;
    width: min(calc(500px * 9 / 16), 100%);
    margin: 0 auto;
    background: #000;
    overflow: hidden;
}



/* ------------------------------------------------------------------
 * Responsive – Tablet
 * ----------------------------------------------------------------*/

@media (max-width: 768px) {
    .wcpv-play-icon {
        width: 56px;
        height: 40px;
    }
}

/* ------------------------------------------------------------------
 * Responsive – Mobile
 * ----------------------------------------------------------------*/

@media (max-width: 480px) {
    .wcpv-play-icon {
        width: 48px;
        height: 34px;
    }
}

/* ------------------------------------------------------------------
 * Accessibility
 * ----------------------------------------------------------------*/

.wcpv-video-trigger:focus {
    outline: 2px solid #e52d27;
    outline-offset: 2px;
}

.wcpv-video-trigger:focus:not(:focus-visible) {
    outline: none;
}

.wcpv-video-trigger:focus-visible {
    outline: 2px solid #e52d27;
    outline-offset: 2px;
}

/* ------------------------------------------------------------------
 * Video thumbnail v galérii – rovnaká veľkosť ako ostatné, vycentrovaný
 * ----------------------------------------------------------------*/

.woocommerce-product-gallery .flex-control-thumbs li.wcpv-thumb-has-video {
    position: relative;
    overflow: hidden;
    aspect-ratio: 1;
}

.woocommerce-product-gallery .flex-control-thumbs li.wcpv-thumb-has-video img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    display: block;
}

.woocommerce-product-gallery .flex-control-thumbs li.wcpv-thumb-has-video::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 28px;
    height: 20px;
    pointer-events: none;
    z-index: 2;
    background: url("data:image/svg+xml,%3Csvg viewBox='0 0 68 48' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M66.52 7.74c-.78-2.93-2.49-5.41-5.42-6.19C55.79.13 34 0 34 0S12.21.13 6.9 1.55c-2.93.78-4.63 3.26-5.42 6.19C.06 13.05 0 24 0 24s.06 10.95 1.48 16.26c.78 2.93 2.49 5.41 5.42 6.19C12.21 47.87 34 48 34 48s21.79-.13 27.1-1.55c2.93-.78 4.63-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z' fill='rgba(0,0,0,0.75)'/%3E%3Cpath d='M45 24L27 14v20' fill='%23fff'/%3E%3C/svg%3E") no-repeat center / contain;
    filter: drop-shadow(0 1px 4px rgba(0, 0, 0, 0.4));
    opacity: 0.5;
}

