/* =============================================================================
   CONSTERAPIA — VIDEO GALLERY SECTION
   Grid/slider layout, thumbnails, play button overlay, lightbox popup.
   ============================================================================= */

/* ---------------------------------------------------------------------------
   SECTION WRAPPER
   --------------------------------------------------------------------------- */
.video-gallery-section {
    padding: var(--space-section, 100px) 0;
    background: var(--bg-primary, #fffdf5);
}

/* ---------------------------------------------------------------------------
   GRID
   --------------------------------------------------------------------------- */
.vg-grid {
    display: grid;
    gap: 20px;
}
.vg-grid--cols-1 { grid-template-columns: 1fr; }
.vg-grid--cols-2 { grid-template-columns: repeat(2, 1fr); }
.vg-grid--cols-3 { grid-template-columns: repeat(3, 1fr); }
.vg-grid--cols-4 { grid-template-columns: repeat(4, 1fr); }

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

/* ---------------------------------------------------------------------------
   VIDEO ITEM (shared by grid and slider)
   --------------------------------------------------------------------------- */
.vg-item {
    border-radius: var(--border-radius-card, 16px);
    overflow: hidden;
    cursor: pointer;
    position: relative;
    background: #000;
    box-shadow: 0 4px 20px rgba(0,0,0,0.12);
    transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.vg-item:hover {
    transform: translateY(-5px);
    box-shadow: 0 12px 36px rgba(0,0,0,0.18);
}
.vg-item:focus-visible {
    outline: 3px solid var(--gold, #e5b720);
    outline-offset: 3px;
}

/* Thumbnail wrapper (maintains 16:9 ratio) */
.vg-thumb-wrap {
    position: relative;
    width: 100%;
    padding-top: 56.25%; /* 16:9 */
    overflow: hidden;
    background: #111;
}
.vg-thumb {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease, filter 0.3s ease;
}
.vg-item:hover .vg-thumb {
    transform: scale(1.04);
    filter: brightness(0.75);
}
.vg-thumb--placeholder {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #2c1a14 0%, #3e2723 100%);
    color: rgba(240,232,216,0.35);
}
.vg-thumb--placeholder svg {
    width: 48px;
    height: 48px;
}

/* Play icon overlay */
.vg-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(1);
    width: 64px;
    height: 64px;
    transition: transform 0.25s ease, opacity 0.2s ease;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.4));
    pointer-events: none;
}
.vg-item:hover .vg-play-icon {
    transform: translate(-50%, -50%) scale(1.12);
}

/* Type badge (YouTube, Vimeo, Live) */
.vg-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.4px;
    padding: 3px 8px;
    border-radius: 4px;
    color: #fff;
    pointer-events: none;
}
.vg-badge--yt   { background: #cc0000; }
.vg-badge--vm   { background: #1ab7ea; }
.vg-badge--live { background: #e53935; animation: vgPulseLive 1.6s infinite; }
@keyframes vgPulseLive {
    0%, 100% { box-shadow: 0 0 0 0 rgba(229,57,53,0.4); }
    50%       { box-shadow: 0 0 0 6px rgba(229,57,53,0); }
}

/* Item caption */
.vg-item__caption {
    padding: 12px 16px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary, #4e342e);
    background: #fff;
    border-top: 1px solid rgba(0,0,0,0.05);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ---------------------------------------------------------------------------
   SLIDER
   --------------------------------------------------------------------------- */
.vg-slider {
    position: relative;
    overflow: hidden;
    border-radius: var(--border-radius-card, 16px);
}
.vg-slider__track {
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    will-change: transform;
}
.vg-slider__slide {
    flex: 0 0 100%;
    min-width: 0;
}

/* Arrows */
.vg-slider__arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 44px;
    height: 44px;
    background: rgba(0,0,0,0.6);
    border: none;
    border-radius: 50%;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 5;
    transition: background 0.2s, transform 0.2s;
}
.vg-slider__arrow:hover { background: var(--gold, #e5b720); transform: translateY(-50%) scale(1.08); }
.vg-slider__arrow--prev { left: 14px; }
.vg-slider__arrow--next { right: 14px; }

/* Dots */
.vg-slider__dots {
    position: absolute;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 7px;
    z-index: 5;
}
.vg-slider__dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(255,255,255,0.5);
    border: none;
    cursor: pointer;
    transition: background 0.2s, transform 0.2s;
    padding: 0;
}
.vg-slider__dot.active {
    background: var(--gold, #e5b720);
    transform: scale(1.3);
}

/* ---------------------------------------------------------------------------
   LIGHTBOX / POPUP
   --------------------------------------------------------------------------- */
.vg-lightbox {
    /* Reset browser dialog styles */
    border: none;
    padding: 0;
    margin: auto;
    background: transparent;
    max-width: 100vw;
    max-height: 100vh;
    width: 100%;
    height: 100%;
}

/* Backdrop */
.vg-lightbox::backdrop {
    background: rgba(0,0,0,0.88);
    backdrop-filter: blur(6px);
}

.vg-lightbox[open] {
    display: flex;
    align-items: center;
    justify-content: center;
}
.vg-lightbox[open] .vg-lightbox__inner {
    animation: vgLightboxIn 0.28s cubic-bezier(0.25,0.46,0.45,0.94);
}
@keyframes vgLightboxIn {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: none; }
}

.vg-lightbox__inner {
    position: relative;
    width: min(92vw, 1080px);
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Close button */
.vg-lightbox__close {
    position: absolute;
    top: -44px;
    right: 0;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: 1px solid rgba(255,255,255,0.3);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
    z-index: 10;
}
.vg-lightbox__close:hover { background: rgba(255,255,255,0.3); }

/* Player area */
.vg-lightbox__player {
    width: 100%;
    aspect-ratio: 16 / 9;
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    box-shadow: 0 24px 80px rgba(0,0,0,0.6);
}

/* Embedded iframe/video */
.vg-embed-frame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}
.vg-native-player {
    width: 100%;
    height: 100%;
    background: #000;
    display: block;
}

/* Title under player */
.vg-lightbox__title {
    margin-top: 14px;
    font-size: 15px;
    font-weight: 600;
    color: rgba(255,255,255,0.85);
    text-align: center;
    max-width: 700px;
}

/* Loading spinner (while AJAX fetch) */
.vg-loading {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #000;
    border-radius: 12px;
}
.vg-loading::after {
    content: '';
    width: 42px;
    height: 42px;
    border: 3px solid rgba(229,183,32,0.3);
    border-top-color: var(--gold, #e5b720);
    border-radius: 50%;
    animation: vgSpin 0.8s linear infinite;
}
@keyframes vgSpin { to { transform: rotate(360deg); } }

/* Vimeo fallback thumb fetch */
.vg-vimeo-loading .vg-thumb {
    filter: brightness(0.4);
}

/* ---------------------------------------------------------------------------
   ENTRY ANIMATIONS (applied via JS based on admin setting)
   --------------------------------------------------------------------------- */
.vg-grid .vg-item { opacity: 0; }
.vg-grid .vg-item.vg-visible { opacity: 1; }

.vg-grid .vg-item.vg-anim-fadeIn    { animation: vgFadeIn    0.5s ease both; }
.vg-grid .vg-item.vg-anim-slideUp   { animation: vgSlideUp   0.5s ease both; }
.vg-grid .vg-item.vg-anim-zoomIn    { animation: vgZoomIn    0.5s ease both; }
.vg-grid .vg-item.vg-anim-none      { opacity: 1; }

@keyframes vgFadeIn  { from { opacity: 0; }                             to { opacity: 1; } }
@keyframes vgSlideUp { from { opacity: 0; transform: translateY(40px); } to { opacity: 1; transform: none; } }
@keyframes vgZoomIn  { from { opacity: 0; transform: scale(0.88); }     to { opacity: 1; transform: none; } }

@media (prefers-reduced-motion: reduce) {
    .vg-grid .vg-item { animation: none !important; opacity: 1 !important; }
}

/* ---------------------------------------------------------------------------
   RESPONSIVE
   --------------------------------------------------------------------------- */
@media (max-width: 767px) {
    .vg-lightbox__inner { width: 100vw; max-height: 100vh; border-radius: 0; }
    .vg-lightbox__player { border-radius: 0; }
    .vg-lightbox__close { top: 8px; right: 8px; }
    .vg-slider__arrow { width: 36px; height: 36px; }
    .vg-play-icon { width: 48px; height: 48px; }
}
