/* =============================================
   Video Grid Widget v2 — Pixabay Style
   YouTube + Vimeo + Self-hosted
   ============================================= */

.hvwg-wrapper { width: 100%; }

.hvwg-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    width: 100%;
}

/* Each item */
.hvwg-item {
    position: relative;
    display: block;
    overflow: hidden;
    cursor: pointer;
    background: #111;
    border-radius: 8px;
}

/* Aspect-ratio box */
.hvwg-inner {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    overflow: hidden;
    border-radius: inherit;
}

/* Thumbnail bg */
.hvwg-thumb {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    border-radius: inherit;
    transition: opacity 0.35s ease, transform 0.45s ease;
    will-change: opacity, transform;
    z-index: 1;
}

/* Self-hosted video */
.hvwg-item video.hvwg-self-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    opacity: 0;
    transition: opacity 0.35s ease;
    z-index: 2;
}

/* iframe wrapper (YouTube / Vimeo) */
.hvwg-iframe-wrap {
    position: absolute;
    inset: -2px;
    z-index: 2;
    opacity: 0;
    transition: opacity 0.35s ease;
    pointer-events: none;
    border-radius: inherit;
    overflow: hidden;
    background: #000;
}

.hvwg-iframe-wrap iframe.hvwg-iframe {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
    pointer-events: none;
}

/* HOVER: show video/iframe, hide thumbnail */
.hvwg-item:hover video.hvwg-self-video,
.hvwg-item:hover .hvwg-iframe-wrap {
    opacity: 1;
}

.hvwg-item:hover .hvwg-thumb {
    opacity: 0;
}

/* Zoom */
.hvwg-item.hvwg-zoom:hover video.hvwg-self-video,
.hvwg-item.hvwg-zoom:hover .hvwg-thumb {
    transform: scale(1.05);
}


/* Hide native controls on hover-preview self-hosted videos */
.hvwg-item video.hvwg-self-video::-webkit-media-controls,
.hvwg-item video.hvwg-self-video::-webkit-media-controls-enclosure {
    display: none !important;
    -webkit-appearance: none;
}

.hvwg-item video.hvwg-self-video {
    controls: none;
}

/* Transparent hit area so preview stays non-interactive; controls only appear in popup */
.hvwg-preview-hitarea {
    position: absolute;
    inset: 0;
    z-index: 4;
    background: transparent;
}

/* Camera icon */
.hvwg-cam-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.45);
    padding: 10px;
    border-radius: 50%;
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
}

.hvwg-cam-icon svg {
    width: 22px;
    height: 22px;
    fill: #fff;
    display: block;
}

.hvwg-item:hover .hvwg-cam-icon {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.8);
}

/* Overlay */
.hvwg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,0.08);
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 5;
    pointer-events: none;
    border-radius: inherit;
}
.hvwg-item:hover .hvwg-overlay { opacity: 1; }

/* Title */
.hvwg-title-wrap {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 10px 14px;
    background: rgba(0,0,0,0.55);
    z-index: 7;
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.3s ease, transform 0.3s ease;
    pointer-events: none;
}
.hvwg-item:hover .hvwg-title-wrap { opacity: 1; transform: translateY(0); }

.hvwg-title {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.hvwg-link { display: block; text-decoration: none; color: inherit; }

.hvwg-placeholder {
    background: #f0f2f5;
    border: 2px dashed #b0b8c1;
    border-radius: 8px;
    padding: 30px;
    text-align: center;
    color: #6c757d;
    font-family: sans-serif;
}

@media (max-width: 1024px) { .hvwg-grid { grid-template-columns: repeat(2, 1fr); } }
@media (max-width: 600px)  { .hvwg-grid { grid-template-columns: 1fr; } }


/* =============================================
   Click Popup Video Modal
   ============================================= */
body.hvwg-modal-open {
    overflow: hidden;
}

.hvwg-modal {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px;
}

.hvwg-modal.is-open {
    display: flex;
}

.hvwg-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.78);
}

.hvwg-modal-dialog {
    position: relative;
    z-index: 2;
    width: min(1100px, 96vw);
    background: #000;
    border-radius: 14px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.45);
}

.hvwg-modal-video-wrap {
    position: relative;
    width: 100%;
    padding-bottom: 56.25%;
    background: #000;
    border-radius: 14px;
    overflow: hidden;
}

.hvwg-modal-iframe,
.hvwg-modal-self-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
    background: #000;
}

.hvwg-modal-close {
    position: absolute;
    top: -18px;
    right: -18px;
    width: 42px;
    height: 42px;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #111;
    font-size: 30px;
    line-height: 40px;
    cursor: pointer;
    z-index: 5;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
}

.hvwg-modal-error {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-family: sans-serif;
}

@media (max-width: 600px) {
    .hvwg-modal { padding: 14px; }
    .hvwg-modal-close {
        top: -12px;
        right: -8px;
        width: 36px;
        height: 36px;
        font-size: 26px;
        line-height: 34px;
    }
}
