/**
 * Gallery Pro - Frontend Styles
 * 
 * Uses Ensemble Unified CSS Variables for theme compatibility
 * Supports images and videos (YouTube, Vimeo, Self-hosted)
 * 
 * @package Ensemble
 * @subpackage Addons/Gallery Pro
 * @since 3.0.0
 */

/* ==========================================================================
   CSS Variables - Unified System

/* ==========================================================================
   CSS Variables Note
   ==========================================================================
   Uses --ensemble-* Designer variables directly.
   Dark/Light mode handled by Designer system.
   See CSS-ARCHITECTURE.md for variable reference.
   ========================================================================== */


/* ==========================================================================
   Base Gallery Styles
   ========================================================================== */

.es-gallery {
    width: 100%;
    margin: 0 auto;
}

.es-gallery-section {
    margin-bottom: 2rem;
}

.es-gallery-section .es-section-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    font-size: 1.25rem;
    font-weight: var(--ensemble-button-weight, 600);
    color: var(--ensemble-text, #1a202c);
}

.es-gallery-section .es-section-title .dashicons {
    opacity: 0.7;
}

.es-gallery-section .es-gallery-count {
    font-size: 0.875rem;
    font-weight: var(--ensemble-body-weight, 400);
    color: var(--ensemble-text-secondary, #718096);
}

/* ==========================================================================
   Grid Layout
   ========================================================================== */

.es-gallery-grid .es-gallery-items {
    display: grid;
    grid-template-columns: repeat(var(--ensemble-gallery-columns, 4), 1fr);
    gap: var(--ensemble-grid-gap, 16px);
}

@media (max-width: 1024px) {
    .es-gallery-grid .es-gallery-items {
        grid-template-columns: repeat(min(var(--ensemble-gallery-columns, 4), 3), 1fr);
    }
}

@media (max-width: 768px) {
    .es-gallery-grid .es-gallery-items {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .es-gallery-grid .es-gallery-items {
        grid-template-columns: 1fr;
    }
}

/* ==========================================================================
   Masonry Layout
   ========================================================================== */

.es-gallery-masonry .es-masonry-grid {
    column-count: var(--ensemble-gallery-columns, 4);
    column-gap: var(--ensemble-grid-gap, 16px);
}

.es-gallery-masonry .es-masonry-item {
    break-inside: avoid;
    margin-bottom: var(--ensemble-grid-gap, 16px);
}

@media (max-width: 1024px) {
    .es-gallery-masonry .es-masonry-grid {
        column-count: 3;
    }
}

@media (max-width: 768px) {
    .es-gallery-masonry .es-masonry-grid {
        column-count: 2;
    }
}

@media (max-width: 480px) {
    .es-gallery-masonry .es-masonry-grid {
        column-count: 1;
    }
}

/* ==========================================================================
   Justified Layout (10.10.2026)
   Gab es bisher nicht: jedes Bild stand allein in voller Breite. Jede Zeile
   hat jetzt dieselbe Hoehe, die Bilder behalten ihr Seitenverhaeltnis.
   --es-ratio (Breite / Hoehe) setzt das Template je Bild; daraus die
   Grundbreite, flex-grow fuellt die Zeile auf. Der <i>-Abstandshalter
   (padding-bottom = Hoehe in % der Breite) gibt die Hoehe vor.
   Zeilenhoehe anpassbar ueber --ensemble-justified-row-height.
   ========================================================================== */

.es-gallery-justified .es-gallery-justified-container {
    display: flex;
    flex-wrap: wrap;
    gap: var(--ensemble-grid-gap, 16px);
}

.es-gallery-justified .es-gallery-justified-item {
    position: relative;
    flex-basis: calc(var(--es-ratio, 1.333) * var(--ensemble-justified-row-height, 240px));
    overflow: hidden;
    border-radius: var(--ensemble-radius, 8px);
}

.es-gallery-justified .es-gallery-justified-item > i,
.es-gallery-justified .es-gallery-justified-item > a > i {
    display: block;
}

.es-gallery-justified .es-gallery-justified-item .es-gallery-image-wrapper {
    position: absolute;
    inset: 0;
    aspect-ratio: auto;
}

.es-gallery-justified .es-gallery-justified-item:hover .es-gallery-overlay {
    opacity: 1;
}

.es-gallery-justified .es-gallery-justified-item:hover .es-gallery-image {
    transform: scale(1.05);
}

.es-gallery-justified .es-gallery-justified-spacer {
    flex-basis: 0;
    height: 0;
}

@media (max-width: 768px) {
    .es-gallery-justified {
        --ensemble-justified-row-height: 170px;
    }
}

@media (max-width: 480px) {
    .es-gallery-justified {
        --ensemble-justified-row-height: 130px;
    }
}

/* ==========================================================================
   Carousel Layout
   ========================================================================== */

.es-gallery-carousel {
    position: relative;
}

.es-gallery-carousel .es-gallery-swiper {
    overflow: hidden;
    border-radius: var(--ensemble-radius, 8px);
}

.es-gallery-carousel .swiper-slide {
    height: auto;
}

.es-gallery-carousel .es-gallery-image-wrapper {
    aspect-ratio: 16 / 9;
}

.es-gallery-carousel .es-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Carousel Navigation */
.es-gallery-carousel .swiper-button-prev,
.es-gallery-carousel .swiper-button-next {
    color: var(--ensemble-button-text, #ffffff);
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    transition: var(--ensemble-transition, all 0.3s ease);
}

.es-gallery-carousel .swiper-button-prev:hover,
.es-gallery-carousel .swiper-button-next:hover {
    background: var(--ensemble-primary, #667eea);
}

.es-gallery-carousel .swiper-button-prev::after,
.es-gallery-carousel .swiper-button-next::after {
    font-size: var(--ensemble-lg-size, 18px);
}

.es-gallery-carousel .swiper-pagination-bullet {
    background: var(--ensemble-text-secondary, #718096);
    opacity: 0.5;
}

.es-gallery-carousel .swiper-pagination-bullet-active {
    background: var(--ensemble-primary, #667eea);
    opacity: 1;
}

/* ==========================================================================
   Filmstrip Layout
   ========================================================================== */

.es-gallery-filmstrip .es-filmstrip-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.es-gallery-filmstrip .es-filmstrip-track {
    flex: 1;
    overflow: hidden;
}

.es-gallery-filmstrip .es-filmstrip-items {
    display: flex;
    gap: var(--ensemble-grid-gap, 16px);
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 4px 0;
}

.es-gallery-filmstrip .es-filmstrip-items::-webkit-scrollbar {
    display: none;
}

.es-gallery-filmstrip .es-filmstrip-item {
    flex: 0 0 auto;
    width: 180px;
    scroll-snap-align: start;
}

.es-gallery-filmstrip .es-gallery-image-wrapper {
    aspect-ratio: 4 / 3;
}

.es-gallery-filmstrip .es-filmstrip-nav {
    flex-shrink: 0;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ensemble-card-bg, #ffffff);
    border: 1px solid var(--ensemble-card-border, #e2e8f0);
    border-radius: 50%;
    cursor: pointer;
    transition: var(--ensemble-transition, all 0.3s ease);
}

.es-gallery-filmstrip .es-filmstrip-nav:hover {
    background: var(--ensemble-primary, #667eea);
    border-color: var(--ensemble-primary, #667eea);
    color: var(--ensemble-button-text, #ffffff);
}

.es-gallery-filmstrip .es-filmstrip-nav svg {
    width: 20px;
    height: 20px;
}

/* ==========================================================================
   Gallery Item Styles
   ========================================================================== */

.es-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: var(--ensemble-radius, 8px);
    background: var(--ensemble-card-bg, #ffffff);
}

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

.es-gallery-image-wrapper {
    position: relative;
    overflow: hidden;
    background: var(--ensemble-card-border, #e2e8f0);
}

.es-gallery-grid .es-gallery-image-wrapper {
    aspect-ratio: 1;
}

.es-gallery-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform var(--ensemble-transition, all 0.3s ease);
}

.es-gallery-item:hover .es-gallery-image {
    transform: scale(1.05);
}

/* Image Overlay */
.es-gallery-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    opacity: 0;
    transition: opacity var(--ensemble-transition, all 0.3s ease);
}

.es-gallery-item:hover .es-gallery-overlay {
    opacity: 1;
}

.es-gallery-zoom-icon {
    width: 32px;
    height: 32px;
    color: var(--ensemble-button-text, #ffffff);
}

/* ==========================================================================
   Video Item Styles
   ========================================================================== */

.es-gallery-item-video .es-gallery-image-wrapper {
    aspect-ratio: 16 / 9;
}

.es-gallery-grid .es-gallery-item-video .es-gallery-image-wrapper {
    aspect-ratio: 16 / 9;
}

.es-gallery-video-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #1a1a1a 0%, #333333 100%);
}

.es-gallery-video-placeholder svg {
    width: 48px;
    height: 48px;
    color: rgba(255, 255, 255, 0.5);
}

.es-gallery-video-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(to top, rgba(0,0,0,0.6) 0%, transparent 50%);
    transition: background var(--ensemble-transition, all 0.3s ease);
}

.es-gallery-item:hover .es-gallery-video-overlay {
    background: rgba(0, 0, 0, 0.5);
}

.es-gallery-play-button {
    width: 64px;
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--ensemble-primary, #667eea);
    border-radius: 50%;
    transition: var(--ensemble-transition, all 0.3s ease);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.es-gallery-play-button svg {
    width: 28px;
    height: 28px;
    color: var(--ensemble-button-text, #ffffff);
    margin-left: 4px; /* Visual centering for play icon */
}

.es-gallery-item:hover .es-gallery-play-button {
    transform: scale(1.1);
}

.es-gallery-play-button-small {
    width: 40px;
    height: 40px;
}

.es-gallery-play-button-small svg {
    width: 18px;
    height: 18px;
    margin-left: 2px;
}

/* Video Provider Badge */
.es-gallery-video-provider {
    position: absolute;
    bottom: 8px;
    right: 8px;
    padding: 4px 8px;
    font-size: var(--ensemble-xs-size, 12px);
    font-weight: var(--ensemble-button-weight, 600);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--ensemble-button-text, #ffffff);
    background: rgba(0, 0, 0, 0.7);
    border-radius: var(--ensemble-badge-radius, 4px);
}

.es-provider-youtube {
    background: #ff0000;
}

.es-provider-vimeo {
    background: #1ab7ea;
}

/* ==========================================================================
   Caption Styles
   ========================================================================== */

.es-gallery-caption {
    padding: 12px;
    background: var(--ensemble-card-bg, #ffffff);
}

.es-gallery-caption-title {
    display: block;
    font-weight: var(--ensemble-button-weight, 600);
    font-size: 0.875rem;
    color: var(--ensemble-text, #1a202c);
    margin-bottom: 4px;
}

.es-gallery-caption-text {
    display: block;
    font-size: 0.8125rem;
    color: var(--ensemble-text-secondary, #718096);
    line-height: 1.4;
}

.es-gallery-caption-source {
    display: block;
    font-size: 0.75rem;
    color: var(--ensemble-primary, #667eea);
    margin-top: 4px;
}

/* ==========================================================================
   Counter Styles
   ========================================================================== */

.es-gallery-counter {
    display: flex;
    gap: 1rem;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--ensemble-card-border, #e2e8f0);
    font-size: 0.8125rem;
    color: var(--ensemble-text-secondary, #718096);
}

/* Bis 05.09.2026 standen hier zwei Emoji als `content`. Emoji im CSS ersetzt
   WordPress nicht — sie kamen also als bunte Systemzeichen und passten weder
   zum Linien-Icon-Set des Plugins noch zu Fabians Vorgabe, keine Emoji zu
   verwenden. Jetzt zwei kleine Zeichnungen als Maske: sie nehmen die Textfarbe
   an (`currentColor`) und laden nichts nach. */
.es-gallery-count-images::before,
.es-gallery-count-videos::before {
    content: '';
    display: inline-block;
    width: 1em;
    height: 1em;
    margin-right: .4em;
    vertical-align: -.14em;
    background-color: currentColor;
    -webkit-mask-repeat: no-repeat;
    mask-repeat: no-repeat;
    -webkit-mask-position: center;
    mask-position: center;
    -webkit-mask-size: contain;
    mask-size: contain;
}

.es-gallery-count-images::before {
    -webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='2'/><circle cx='9' cy='10' r='2'/><path d='m4 18 5-4 3 2 4-3 4 3'/></svg>");
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='5' width='18' height='14' rx='2'/><circle cx='9' cy='10' r='2'/><path d='m4 18 5-4 3 2 4-3 4 3'/></svg>");
}

.es-gallery-count-videos::before {
    -webkit-mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='6' width='13' height='12' rx='2'/><path d='m16 10 5-3v10l-5-3z'/></svg>");
    mask-image: url("data:image/svg+xml,<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23000' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'><rect x='3' y='6' width='13' height='12' rx='2'/><path d='m16 10 5-3v10l-5-3z'/></svg>");
}

/* ==========================================================================
   GLightbox Customizations
   ========================================================================== */

.glightbox-clean .gslide-title {
    font-family: inherit;
    font-weight: var(--ensemble-button-weight, 600);
}

.glightbox-clean .gslide-description {
    font-family: inherit;
}

/* Video in Lightbox */
.glightbox-clean .gvideo-wrapper {
    max-width: 100%;
}

.glightbox-clean .gvideo-wrapper video {
    max-height: 80vh;
}

/* ==========================================================================
   Responsive Adjustments
   ========================================================================== */

@media (max-width: 768px) {
    .es-gallery {
        --ensemble-grid-gap: 12px;
    }
    
    .es-gallery-play-button {
        width: 48px;
        height: 48px;
    }
    
    .es-gallery-play-button svg {
        width: 22px;
        height: 22px;
    }
    
    .es-gallery-carousel .swiper-button-prev,
    .es-gallery-carousel .swiper-button-next {
        width: 32px;
        height: 32px;
    }
    
    .es-gallery-carousel .swiper-button-prev::after,
    .es-gallery-carousel .swiper-button-next::after {
        font-size: var(--ensemble-small-size, 14px);
    }
    
    .es-gallery-filmstrip .es-filmstrip-item {
        width: 140px;
    }
}

@media (max-width: 480px) {
    .es-gallery-caption {
        padding: 10px;
    }
    
    .es-gallery-caption-title {
        font-size: 0.8125rem;
    }
    
    .es-gallery-caption-text {
        font-size: 0.75rem;
    }
    
    .es-gallery-filmstrip .es-filmstrip-nav {
        display: none;
    }
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
    .es-gallery-video-overlay,
    .es-gallery-overlay,
    .es-gallery-counter,
    .es-filmstrip-nav,
    .swiper-button-prev,
    .swiper-button-next,
    .swiper-pagination {
        display: none !important;
    }
    
    .es-gallery-grid .es-gallery-items {
        grid-template-columns: repeat(3, 1fr);
    }
}


/* ==========================================================================
   LIGHTBOX THEMES
   Added for theme selection support (dark/light/minimal)
   ========================================================================== */

/* Dark Theme (default) - no changes needed, GLightbox default is dark */
.glightbox-glightbox-dark .goverlay {
    background: rgba(0, 0, 0, 0.92);
}

.glightbox-glightbox-dark .gslide-title,
.glightbox-glightbox-dark .gslide-desc {
    color: #fff;
}

/* Light Theme */
.glightbox-glightbox-light .goverlay {
    background: rgba(255, 255, 255, 0.95);
}

.glightbox-glightbox-light .gslide-title,
.glightbox-glightbox-light .gslide-desc {
    color: var(--ensemble-text, #1a1a1a);
}

.glightbox-glightbox-light .gnext,
.glightbox-glightbox-light .gprev,
.glightbox-glightbox-light .gclose {
    background: rgba(0, 0, 0, 0.08);
    color: var(--ensemble-text, #1a1a1a);
}

.glightbox-glightbox-light .gnext:hover,
.glightbox-glightbox-light .gprev:hover,
.glightbox-glightbox-light .gclose:hover {
    background: rgba(0, 0, 0, 0.15);
}

.glightbox-glightbox-light .glightbox-counter {
    color: var(--ensemble-text, #1a1a1a);
}

/* Minimal Theme */
.glightbox-glightbox-minimal .goverlay {
    background: rgba(0, 0, 0, 0.98);
}

.glightbox-glightbox-minimal .gslide-title,
.glightbox-glightbox-minimal .gslide-desc,
.glightbox-glightbox-minimal .glightbox-counter {
    display: none !important;
}

.glightbox-glightbox-minimal .gnext,
.glightbox-glightbox-minimal .gprev {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.glightbox-glightbox-minimal .gcontainer:hover .gnext,
.glightbox-glightbox-minimal .gcontainer:hover .gprev {
    opacity: 1;
}

.glightbox-glightbox-minimal .gclose {
    opacity: 0.5;
}

.glightbox-glightbox-minimal .gclose:hover {
    opacity: 1;
}

