/* ══════════════════════════════════════════════════════════════════
   CODERIX VIDEO GALLERY — .cxvg- prefix
   ══════════════════════════════════════════════════════════════════ */

.cxvg-wrapper {
    position: relative;
}

/* ── Grid layouts (Tile / Mosaic / Masonry) ─────────────────────── */
.cxvg-grid {
    --cxvg-cols: 3;
    display: grid;
    grid-template-columns: repeat(var(--cxvg-cols), 1fr);
    gap: 20px;
}

/* Mosaic — first item spans 2x2 to create visual hierarchy */
.cxvg-grid-mosaic {
    grid-auto-rows: 160px;
}
.cxvg-grid-mosaic .cxvg-item {
    aspect-ratio: auto;
    height: 100%;
}
.cxvg-grid-mosaic .cxvg-item:first-child {
    grid-column: span 2;
    grid-row: span 2;
}

/* Masonry — CSS columns so items keep their own natural aspect ratio
   at varying heights instead of being cropped to a uniform grid cell. */
.cxvg-grid-masonry {
    display: block;
    column-count: var(--cxvg-cols);
    column-gap: 20px;
}
.cxvg-grid-masonry .cxvg-item {
    aspect-ratio: auto;
    break-inside: avoid;
    margin-bottom: 20px;
}
/* The base .cxvg-thumb rule is `position:absolute; inset:0`, which only
   works when .cxvg-item already has a height (normally from aspect-ratio).
   Masonry removes that aspect-ratio on purpose — each card's height is
   supposed to come from its own image instead — so the thumb needs to be
   a normal in-flow element here instead, or .cxvg-item never gets a real
   height at all (inset:0 pins top+bottom regardless of `height:auto`,
   so the previous override here did nothing — this was the actual bug).
   The overlay/play button/caption stay absolutely positioned as normal,
   now correctly relative to a .cxvg-item that has a real height again. */
.cxvg-grid-masonry .cxvg-thumb {
    position: relative;
    inset: auto;
    height: auto;
    display: block;
}

/* ── The video card itself (shared by grid + slideshow + film) ──── */
.cxvg-item {
    position: relative;
    aspect-ratio: 16 / 9;
    overflow: hidden;
    border-radius: 14px;
    background: #0c0f14;
    cursor: pointer;
}

.cxvg-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.6s ease;
    display: block;
}
.cxvg-item:hover .cxvg-thumb { transform: scale(1.06); }

.cxvg-hover-video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.35s ease;
}
.cxvg-item.cxvg-preview-playing .cxvg-hover-video { opacity: 1; }
.cxvg-item.cxvg-preview-playing .cxvg-thumb { opacity: 0; }

.cxvg-overlay {
    position: absolute;
    inset: 0;
    background: rgba(10,15,25,0.28);
    transition: background 0.3s ease;
    pointer-events: none;
}
.cxvg-item.cxvg-preview-playing .cxvg-overlay { background: rgba(10,15,25,0.05); }

.cxvg-play {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    transform: translate(-50%, -50%);
    border: none;
    border-radius: 50%;
    background: #ffffff;
    color: #1B2430;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(0,0,0,0.25);
    transition: background 0.25s ease, transform 0.25s ease, color 0.25s ease;
    z-index: 3;
}
/* The icon is a fixed-size 24x24 SVG (see widget.php play_icon()) using
   fill="currentColor" — it always follows this button's own `color`
   property, which is exactly what the Icon Color / Icon Color (Hover)
   controls set. No separate sizing or fill rule needed here. */
.cxvg-play svg { display: block; flex-shrink: 0; }

/* Hover animations */
.cxvg-item:hover .cxvg-play { transform: translate(-50%, -50%) scale(1.08); }
.cxvg-wrapper[data-play-hover="1"] .cxvg-item.cxvg-preview-playing .cxvg-play { opacity: 0; pointer-events: none; }

.cxvg-play::before {
    content: '';
    position: absolute;
    inset: -14px;
    border-radius: 50%;
    border: 2px solid rgba(255,255,255,0.7);
    opacity: 0;
    transform: scale(0.8);
}
.cxvg-item:hover .cxvg-play.cxvg-anim-pulse::before {
    animation: cxvg-pulse-ring 1.4s ease-out infinite;
}
@keyframes cxvg-pulse-ring {
    0%   { opacity: 0.9; transform: scale(0.8); }
    70%  { opacity: 0;   transform: scale(1.5); }
    100% { opacity: 0;   transform: scale(1.5); }
}

.cxvg-duration {
    position: absolute;
    right: 10px;
    bottom: 10px;
    z-index: 3;
    background: rgba(0,0,0,0.65);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 5px;
    letter-spacing: 0.02em;
}

.cxvg-caption {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 3;
    padding: 28px 16px 14px;
    background: linear-gradient(to top, rgba(0,0,0,0.75), rgba(0,0,0,0));
    pointer-events: none;
}
.cxvg-title {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    line-height: 1.3;
}

/* ══════════════════════════════════════════════════════════════════
   SLIDESHOW / FILM STRIP
   ══════════════════════════════════════════════════════════════════ */
.cxvg-slideshow, .cxvg-film {
    position: relative;
}

.cxvg-slide-main {
    position: relative;
    width: 100%;
    height: 480px;
    border-radius: 14px;
    overflow: hidden;
}

.cxvg-slide {
    position: absolute;
    inset: 0;
    opacity: 0;
    transition: opacity 0.55s ease;
    pointer-events: none;
}
.cxvg-slide.cxvg-active { opacity: 1; pointer-events: auto; }
.cxvg-slide .cxvg-item { width: 100%; height: 100%; border-radius: 0; aspect-ratio: auto; }

.cxvg-mode-slide .cxvg-slide {
    opacity: 1;
    transform: translateX(100%);
    transition: transform 0.55s ease;
}
.cxvg-mode-slide .cxvg-slide.cxvg-active { transform: translateX(0); }

.cxvg-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: rgba(0,0,0,0.4);
    color: #fff;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 6;
    opacity: 0.85;
    transition: opacity 0.2s ease, background 0.2s ease;
}
.cxvg-arrow:hover { opacity: 1; background: rgba(0,0,0,0.65); }
.cxvg-arrow-prev { left: 14px; }
.cxvg-arrow-next { right: 14px; }
.cxvg-arrow:disabled { opacity: 0.3; cursor: not-allowed; }

.cxvg-dots {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 16px;
}
.cxvg-dot {
    width: 9px;
    height: 9px;
    border-radius: 50%;
    border: none;
    background: rgba(0,0,0,0.2);
    cursor: pointer;
    padding: 0;
}
.cxvg-dot.cxvg-active { background: #1B2430; }

.cxvg-filmstrip {
    display: flex;
    gap: 10px;
    margin-top: 14px;
    overflow-x: auto;
    scrollbar-width: thin;
    padding-bottom: 4px;
}
.cxvg-film-thumb {
    flex: 0 0 auto;
    width: 100px;
    height: 64px;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    padding: 0;
    cursor: pointer;
    opacity: 0.55;
    transition: opacity 0.2s ease, border-color 0.2s ease;
}
.cxvg-film-thumb img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cxvg-film-thumb.cxvg-active { opacity: 1; border-color: #E63946; }

.cxvg-counter {
    position: absolute;
    z-index: 6;
    background: rgba(0,0,0,0.55);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    padding: 6px 12px;
    border-radius: 20px;
    pointer-events: none;
}
.cxvg-counter--top-left     { top: 12px;    left: 12px; }
.cxvg-counter--top-right    { top: 12px;    right: 12px; }
.cxvg-counter--bottom-left  { bottom: 12px; left: 12px; }
.cxvg-counter--bottom-right { bottom: 12px; right: 12px; }

.cxvg-progress {
    position: absolute;
    left: 0; right: 0; bottom: 0;
    height: 3px;
    background: rgba(255,255,255,0.25);
    z-index: 6;
    overflow: hidden;
}
.cxvg-progress-fill { height: 100%; width: 0%; background: #E63946; }

/* ══════════════════════════════════════════════════════════════════
   LIGHTBOX
   ══════════════════════════════════════════════════════════════════ */
.cxvg-lightbox {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: none;
    align-items: center;
    justify-content: center;
}
.cxvg-lightbox.cxvg-lb-open { display: flex; }

.cxvg-lb-overlay {
    position: absolute;
    inset: 0;
    background: rgba(6,8,12,0.94);
}

.cxvg-lb-inner {
    position: relative;
    width: min(92vw, 1100px);
    max-height: 88vh;
    z-index: 1;
}

.cxvg-lb-stage {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 30px 80px rgba(0,0,0,0.5);
}
.cxvg-lb-stage video,
.cxvg-lb-stage iframe {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: 0;
    display: block;
}

.cxvg-lb-btn {
    position: absolute;
    top: -48px;
    width: 40px;
    height: 40px;
    border: none;
    background: transparent;
    color: #fff;
    font-size: 26px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
}
.cxvg-lb-close      { right: 0; }
.cxvg-lb-fullscreen  { right: 48px; font-size: 18px; }
.cxvg-lb-btn:hover { opacity: 0.7; }

/* ── Responsive ───────────────────────────────────────────────────── */
@media (max-width: 900px) {
    .cxvg-grid-masonry { column-count: min(var(--cxvg-cols), 2); }
}
@media (max-width: 768px) {
    .cxvg-play { width: 52px; height: 52px; }
    .cxvg-arrow { width: 36px; height: 36px; font-size: 13px; }
    .cxvg-lb-inner { width: 96vw; }
    .cxvg-lb-btn { top: -40px; }
}
@media (max-width: 480px) {
    .cxvg-grid, .cxvg-grid-masonry { grid-template-columns: 1fr !important; column-count: 1 !important; }
    .cxvg-film-thumb { width: 76px; height: 50px; }
    .cxvg-counter { font-size: 11px; padding: 4px 10px; }
}
