/*
 * components/video.css
 * Video component and YouTube facade.
 * Migrated verbatim from the live site (sources: video.css, video/youtube.css).
 */

/* video.css */
.wmc_video {
    --pointOfInterest: var(--wmd_mediaPointOfInterest);
    --videoPlayButtonSizeDesktop: 0px;
    --videoPlayButtonSize: var(--videoPlayButtonSizeDesktop);
    --mediaOpacity: 1;
}

.wmc_video > .wml {
}

.wmc_video .wms_overlay {
    width: 100%;
    height: 100%;
    position: absolute;
    pointer-events: none;
    z-index: 1;
    background-color: var(--colorOverlay);
}

@media all and (width < 1040px) {
    --videoPlayButtonSizeTablet: var(--videoPlayButtonSizeDesktop);
    --videoPlayButtonSize: var(--videoPlayButtonSizeTablet);
}

@media all and (width < 650px) {
    --videoPlayButtonSizeMobile: var(--videoPlayButtonSizeDesktop);
    --videoPlayButtonSize: var(--videoPlayButtonSizeMobile);
}


/* Video Popup Modal Styles */
.wmc_video__video-popup {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    z-index: 5100; /* TODO - z-index management on the live page, currently sticky have 5000 z-index value */
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
}

.wmc_video__video-popup.active {
    display: flex;
    align-items: center;
    justify-content: center;
    animation: videoPopupFadeIn 0.3s ease;
}

@keyframes videoPopupFadeIn {
    from {
        opacity: 0;
        backdrop-filter: blur(0px);
        -webkit-backdrop-filter: blur(0px);
    }
    to {
        opacity: 1;
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
    }
}

.wmc_video__video-popup-content {
    position: relative;
    max-width: 800px;
    max-height: 90vh;
    width: 100%;
    background: #000;
    border-radius: 25px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.7);
    animation: videoPopupScaleIn 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    overflow: hidden;
    aspect-ratio: 16 / 9;
}

@keyframes videoPopupScaleIn {
    from {
        transform: scale(0.85) translateY(20px);
        opacity: 0;
    }
    to {
        transform: scale(1) translateY(0);
        opacity: 1;
    }
}

.wmc_video__video-popup-player {
    width: 100%;
    height: 100%;
    min-height: 350px;
    display: block;
}

.wmc_video__video-popup-player iframe {
    border-radius: 12px;
    width: 100%;
    height: 100%;
}

.wmc_video__video-popup-player video {
    border-radius: 12px;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.wmc_video__video-popup-close {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.8);
    color: white;
    font-size: 20px;
    cursor: pointer;
    z-index: 5101; /* TODO - z-index management on the live page, currently sticky have 5000 z-index value */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.wmc_video__video-popup-close > svg {
    height: 18px;
    width: 18px;
    fill: currentColor;
    transition: transform 0.2s ease;
}

.wmc_video__video-popup-close:hover {
    background: rgba(255, 255, 255, 0.95);
    color: #333;
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.6);
}

.wmc_video__video-popup-close:hover > svg {
    transform: rotate(90deg);
}

.wmc_video__video-popup-close:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Loading State */
.wmc_video__video-popup-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.9);
    color: white;
    border-radius: 12px;
    z-index: 10;
}

.wmc_video__loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top: 3px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin-bottom: 20px;
}

@keyframes spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

.wmc_video__video-popup-loading p {
    margin: 0;
    font-size: 16px;
    font-weight: 500;
    opacity: 0.9;
}

/* Error State */
.wmc_video__video-popup-error {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(20, 20, 20, 0.95);
    color: white;
    border-radius: 12px;
    z-index: 10;
}

.wmc_video__error-content {
    text-align: center;
    padding: 40px;
}

.wmc_video__error-content p {
    margin: 0 0 20px 0;
    font-size: 16px;
    color: #ff6b6b;
}

.wmc_video__retry-btn {
    background: #007bff;
    color: white;
    border: none;
    border-radius: 8px;
    padding: 12px 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.wmc_video__retry-btn:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.3);
}

.wmc_video__retry-btn:focus {
    outline: 2px solid #007bff;
    outline-offset: 2px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .wmc_video__video-popup-content {
        width: 95vw;
        max-width: 95vw;
        margin: 20px;
        max-height: 85vh;
    }

    .wmc_video__video-popup-player {
        min-height: 200px;
    }

    .wmc_video__video-popup-close {
        top: 8px;
        right: 8px;
        width: 35px;
        height: 35px;
    }

    .wmc_video__video-popup-close > svg {
        height: 15px;
        width: 15px;
    }
}

@media (max-width: 480px) {
    .wmc_video__video-popup-content {
        width: 98vw;
        margin: 10px;
        border-radius: 8px;
    }

    .wmc_video__video-popup-player,
    .wmc_video__video-popup-player iframe,
    .wmc_video__video-popup-player video {
        border-radius: 8px;
    }

    .wmc_video__video-popup-loading {
        border-radius: 8px;
    }

    .wmc_video__loading-spinner {
        width: 40px;
        height: 40px;
        margin-bottom: 15px;
    }

    .wmc_video__video-popup-loading p {
        font-size: 14px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: more) {
    .wmc_video__video-popup {
        background: rgba(0, 0, 0, 0.95);
    }

    .wmc_video__video-popup-close {
        background: white;
        color: black;
        border: 2px solid black;
    }

    .wmc_video__video-popup-close:hover {
        background: black;
        color: white;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .wmc_video__video-popup.active {
        animation: none;
    }

    .wmc_video__video-popup-content {
        animation: videoPopupFadeIn 0.2s ease;
    }

    .wmc_video__video-popup-close > svg {
        transition: none;
    }

    .wmc_video__video-popup-close:hover > svg {
        transform: none;
    }

    .wmc_video__loading-spinner {
        animation: none;
        border: 3px solid #007bff;
        border-top: 3px solid rgba(255, 255, 255, 0.3);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .wmc_video__video-popup-error {
        background: rgba(10, 10, 10, 0.95);
    }

    .wmc_video__error-content p {
        color: #ff8a8a;
    }
}

/* Print styles (hide popup when printing) */
@media print {
    .wmc_video__video-popup {
        display: none !important;
    }
}

/* video/youtube.css */
.wmc_video {
    &:not(.wmcM_videoShowPlay) lite-youtube > .lyt-playbtn {
        display: none !important;
    }

    lite-youtube {
        background-color: #000;
        position: relative;
        display: block;
        contain: content;
        background-position: center center;
        background-size: cover;
        cursor: pointer;
        width: 100%;
        height: 100%;
    }

    /* gradient */
    lite-youtube::before {
        content: attr(data-title);
        display: block;
        position: absolute;
        top: 0;
        /* Pixel-perfect port of YT's gradient PNG, using https://github.com/bluesmoon/pngtocss plus optimizations */
        background-image: linear-gradient(180deg, rgb(0 0 0 / 67%) 0%, rgb(0 0 0 / 54%) 14%, rgb(0 0 0 / 15%) 54%, rgb(0 0 0 / 5%) 72%, rgb(0 0 0 / 0%) 94%);
        height: 99px;
        width: 100%;
        font-family: "YouTube Noto", Roboto, Arial, Helvetica, sans-serif;
        color: hsl(0deg 0% 93.33%);
        text-shadow: 0 0 2px rgba(0, 0, 0, .5);
        font-size: 18px;
        padding: 25px 20px;
        overflow: hidden;
        white-space: nowrap;
        text-overflow: ellipsis;
        box-sizing: border-box;
    }

    lite-youtube:hover::before {
        color: white;
    }

    /* responsive iframe with a 16:9 aspect ratio
        thanks https://css-tricks.com/responsive-iframes/
    */
    lite-youtube::after {
        content: "";
        display: block;
        padding-bottom: calc(100% / (16 / 9));
    }
    lite-youtube > iframe {
        width: 100%;
        height: 100%;
        position: absolute;
        top: 0;
        left: 0;
        border: 0;
        opacity: var(--mediaOpacity);
    }

    /* play button */
    lite-youtube > .lyt-playbtn {
        display: block;
        /* Make the button element cover the whole area for a large hover/click target… */
        width: 100%;
        height: 100%;
        /* …but visually it's still the same size */
        background: no-repeat center / var(--videoPlayButtonSize) calc(var(--videoPlayButtonSize) * 48 / 68);
        /* YT's actual play button svg */
        background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 68 48"><path 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.64-3.26 5.42-6.19C67.94 34.95 68 24 68 24s-.06-10.95-1.48-16.26z" fill="red"/><path d="M45 24 27 14v20" fill="white"/></svg>');
        position: absolute;
        cursor: pointer;
        z-index: 1;
        filter: grayscale(100%);
        transition: filter .1s cubic-bezier(0, 0, 0.2, 1);
        border: 0;
    }

    lite-youtube:hover > .lyt-playbtn,
    lite-youtube .lyt-playbtn:focus {
        filter: none;
    }

    /* Post-click styles */
    lite-youtube.lyt-activated {
        cursor: unset;
    }
    lite-youtube.lyt-activated::before,
    lite-youtube.lyt-activated > .lyt-playbtn {
        opacity: 0;
        pointer-events: none;
    }

    .lyt-visually-hidden {
        clip: rect(0 0 0 0);
        clip-path: inset(50%);
        height: 1px;
        overflow: hidden;
        position: absolute;
        white-space: nowrap;
        width: 1px;
    }
}
