/* =============================================================================
   KE Video Gallery (ke-video-gallery) — v0.18.0
   Layouts: grid | masonry | carousel
   Info-Positionen: below | overlay | hover-reveal
   ============================================================================= */

/* ── Container ─────────────────────────────────────────────────────────────── */

.ke-video-gallery {
    --ke-vg-columns: 3;
    --ke-vg-aspect: 16/9;
    --ke-vg-gap: 20px;
}

/* ── Filter-Buttons ─────────────────────────────────────────────────────────── */

.ke-video-gallery__filters {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
    margin-bottom: 24px;
}

.ke-video-gallery__filter {
    display: inline-flex;
    align-items: center;
    padding: 7px 18px;
    background-color: #f0f0f0;
    color: #555555;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    line-height: 1.4;
    transition: background-color 0.2s ease, color 0.2s ease;
    white-space: nowrap;
}

.ke-video-gallery__filter:hover {
    background-color: #333333;
    color: #ffffff;
}

.ke-video-gallery__filter--active {
    background-color: #0073aa;
    color: #ffffff;
}

/* ── Grid ────────────────────────────────────────────────────────────────────── */

.ke-video-gallery__grid {
    display: grid;
    grid-template-columns: repeat(var(--ke-vg-columns, 3), 1fr);
    gap: var(--ke-vg-gap, 20px);
}

/* Masonry-Layout via CSS columns */
.ke-video-gallery--layout-masonry .ke-video-gallery__grid {
    display: block;
    column-count: var(--ke-vg-columns, 3);
    column-gap: var(--ke-vg-gap, 20px);
}

.ke-video-gallery--layout-masonry .ke-video-gallery__item {
    break-inside: avoid;
    margin-bottom: var(--ke-vg-gap, 20px);
}

/* Carousel-Layout: horizontales Scrollen */
.ke-video-gallery--layout-carousel .ke-video-gallery__grid {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    -webkit-overflow-scrolling: touch;
    gap: var(--ke-vg-gap, 20px);
    padding-bottom: 8px;
}

.ke-video-gallery--layout-carousel .ke-video-gallery__item {
    flex: 0 0 calc((100% - (var(--ke-vg-columns, 3) - 1) * var(--ke-vg-gap, 20px)) / var(--ke-vg-columns, 3));
    scroll-snap-align: start;
}

/* ── Gallery Item ────────────────────────────────────────────────────────────── */

.ke-video-gallery__item {
    position: relative;
    overflow: hidden;
    transition: opacity 0.25s ease;
}

.ke-video-gallery__item.ke-vg-item--hidden {
    opacity: 0;
    pointer-events: none;
}

.ke-video-gallery__item.ke-vg-item--visible {
    opacity: 1;
    pointer-events: auto;
}

/* ── Thumbnail ───────────────────────────────────────────────────────────────── */

.ke-video-gallery__thumbnail {
    display: block;
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    text-decoration: none;
    background-color: #111111;
    aspect-ratio: var(--ke-vg-aspect, 16/9);
}

.ke-video-gallery__thumbnail img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 8px;
    transition: transform 0.3s ease;
}

.ke-video-gallery__item:hover .ke-video-gallery__thumbnail img {
    transform: scale(1.04);
}

/* Placeholder wenn kein Thumbnail vorhanden */
.ke-video-gallery__thumb-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #1c1c1c 0%, #2d2d2d 100%);
}

/* ── Play-Button ─────────────────────────────────────────────────────────────── */

.ke-video-gallery__play-btn {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    align-items: center;
    justify-content: center;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-color: rgba(0, 0, 0, 0.55);
    color: #ffffff;
    font-size: 22px;
    transition: background-color 0.2s ease, transform 0.2s ease;
    pointer-events: none;
    z-index: 2;
}

.ke-video-gallery__play-btn svg {
    width: 28px;
    height: 28px;
    fill: currentColor;
    display: block;
}

.ke-video-gallery__item:hover .ke-video-gallery__play-btn {
    background-color: rgba(0, 0, 0, 0.8);
    transform: translate(-50%, -50%) scale(1.1);
}

/* ── Dauer-Badge ─────────────────────────────────────────────────────────────── */

.ke-video-gallery__duration {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 2px 6px;
    background-color: rgba(0, 0, 0, 0.7);
    color: #ffffff;
    font-size: 12px;
    font-weight: 600;
    border-radius: 3px;
    line-height: 1.5;
    /* v0.23.10: z-index 4 > Overlay (3), damit Dauer im Overlay-Modus sichtbar bleibt. */
    z-index: 4;
    pointer-events: none;
}

/* ── Info-Leiste unterhalb (below) ───────────────────────────────────────────── */

.ke-video-gallery__info {
    padding: 8px 4px 4px;
}

.ke-video-gallery__title {
    margin: 0;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.35;
    /* v0.23.10: KEINE color-Regel im Basis-CSS. Farbe kommt ausschließlich vom
       Widget-Control `title_color` (Default im PHP: #1a1a1a). Damit ist die
       Widget-Regel die einzige color-Quelle → User-Style greift immer. */
}

/* ── Info-Overlay (overlay + hover-reveal) ───────────────────────────────────── */

.ke-video-gallery__info-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 16px 12px 10px;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.75) 0%, rgba(0, 0, 0, 0) 100%);
    z-index: 3;
}

/* v0.23.10: :where()-Fallback (Spezifität 0) — nur aktiv, wenn weder
   title_color noch overlay_title_color gesetzt sind. Stellt Lesbarkeit
   auf dem dunklen Gradient-Overlay sicher (Default #ffffff). */
:where(.ke-video-gallery__info-overlay .ke-video-gallery__title) {
    color: #ffffff;
}

.ke-video-gallery__info-overlay .ke-video-gallery__title {
    font-size: 14px;
}

/* Overlay: immer sichtbar */
.ke-video-gallery--info-overlay .ke-video-gallery__info-overlay {
    opacity: 1;
}

/* Hover-Reveal: einblenden bei Hover */
.ke-video-gallery--info-hover-reveal .ke-video-gallery__info-overlay {
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ke-video-gallery--info-hover-reveal .ke-video-gallery__item:hover .ke-video-gallery__info-overlay {
    opacity: 1;
}

/* ── Fallback-Modal (ke-vg-modal) ────────────────────────────────────────────── */

.ke-vg-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
}

.ke-vg-modal--open {
    display: flex;
    align-items: center;
    justify-content: center;
}

.ke-vg-modal__backdrop {
    position: absolute;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.88);
    cursor: pointer;
}

.ke-vg-modal__inner {
    position: relative;
    width: 90vw;
    max-width: 960px;
    z-index: 1;
}

.ke-vg-modal__close {
    position: absolute;
    top: -40px;
    right: 0;
    background: none;
    border: none;
    color: #ffffff;
    font-size: 22px;
    line-height: 1;
    cursor: pointer;
    padding: 6px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.ke-vg-modal__close:hover {
    opacity: 1;
}

.ke-vg-modal__player {
    position: relative;
    width: 100%;
    aspect-ratio: 16/9;
    background-color: #000000;
    border-radius: 6px;
    overflow: hidden;
}

.ke-vg-modal__iframe,
.ke-vg-modal__video {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border: none;
    border-radius: 6px;
}

/* ── Responsive ──────────────────────────────────────────────────────────────── */

@media (max-width: 1024px) {
    .ke-video-gallery--layout-masonry .ke-video-gallery__grid {
        column-count: 2;
    }
}

@media (max-width: 767px) {
    .ke-video-gallery__grid {
        grid-template-columns: repeat(1, 1fr);
    }

    .ke-video-gallery--layout-masonry .ke-video-gallery__grid {
        column-count: 1;
    }

    .ke-video-gallery--layout-carousel .ke-video-gallery__item {
        flex: 0 0 85%;
    }

    .ke-vg-modal__inner {
        width: 95vw;
    }

    .ke-vg-modal__close {
        top: -36px;
        font-size: 20px;
    }
}

