/*
 * Modern Mobile-Optimized Gallery System
 * State-of-the-art picture presentation with touch gestures, lazy loading, and performance optimization
 */

/* ==========================================================================
   ACCESSIBILITY & SCREEN READER SUPPORT
   ========================================================================== */

.sr-only {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    padding: 0 !important;
    margin: -1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
    white-space: nowrap !important;
    border: 0 !important;
}

/* ==========================================================================
   MODERN GALLERY CONTAINER
   ========================================================================== */

.heidmark-modern-gallery {
    width: 100%;
    position: relative;
    background: linear-gradient(135deg, #FFF8DC 0%, #F4A460 100%);
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.1);
    overflow: hidden;
    margin: 20px 0;
}

.gallery-main-container {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
}

/* ==========================================================================
   MAIN IMAGE DISPLAY
   ========================================================================== */

.gallery-main-image {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: 12px;
    opacity: 0;
    transform: scale(1.05);
    transition: opacity 0.6s cubic-bezier(0.4, 0, 0.2, 1),
                transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-main-image:hover,
.gallery-main-image.transitioning {
    will-change: opacity, transform;
}

.gallery-main-image.active {
    opacity: 1;
    transform: scale(1);
    will-change: auto;
}

.gallery-main-image.next {
    transform: translateX(100%) scale(1.05);
}

.gallery-main-image.prev {
    transform: translateX(-100%) scale(1.05);
}

/* Image overlay with information */
.gallery-image-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.7));
    color: white;
    padding: 30px 20px 20px;
    transform: translateY(100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.heidmark-modern-gallery:hover .gallery-image-overlay,
.gallery-image-overlay.show {
    transform: translateY(0);
}

.gallery-image-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin-bottom: 8px;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.gallery-image-description {
    font-size: 0.9rem;
    opacity: 0.9;
    line-height: 1.4;
}

/* ==========================================================================
   MODERN NAVIGATION CONTROLS
   ========================================================================== */

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    backdrop-filter: blur(10px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
}

.gallery-nav:hover {
    background: rgba(255, 255, 255, 1);
    transform: translateY(-50%) scale(1.1);
    box-shadow: 0 6px 25px rgba(0, 0, 0, 0.15);
}

.gallery-nav-prev {
    left: 15px;
}

.gallery-nav-next {
    right: 15px;
}

.gallery-nav::before {
    content: '';
    width: 12px;
    height: 12px;
    border-top: 2px solid #8B4513;
    border-right: 2px solid #8B4513;
    transform: rotate(-135deg);
    margin-right: 2px;
}

.gallery-nav-next::before {
    transform: rotate(45deg);
    margin-right: 0;
    margin-left: 2px;
}

/* ==========================================================================
   MOBILE-OPTIMIZED THUMBNAIL GRID
   ========================================================================== */

.gallery-thumbnails {
    padding: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
}

.gallery-thumbnail-container {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(80px, 1fr));
    gap: 12px;
    max-width: 100%;
    overflow-x: auto;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding: 8px 0;
}

.gallery-thumbnail-container::-webkit-scrollbar {
    display: none;
}

.gallery-thumbnail {
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    border: 3px solid transparent;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.gallery-thumbnail:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
}

.gallery-thumbnail.active {
    border-color: #D2691E;
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(210, 105, 30, 0.3);
}

.gallery-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.gallery-thumbnail:hover img {
    transform: scale(1.1);
}

/* Thumbnail loading state */
.gallery-thumbnail.loading {
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                linear-gradient(-45deg, #f0f0f0 25%, transparent 25%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px;
    animation: thumbnail-loading 1.5s ease-in-out infinite;
}

@keyframes thumbnail-loading {
    0%, 100% { background-position: 0 0, 0 10px; }
    50% { background-position: 20px 0, 20px 10px; }
}

/* ==========================================================================
   TOUCH GESTURE INDICATORS
   ========================================================================== */

.gallery-touch-indicator {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 8px 12px;
    font-size: 0.8rem;
    color: #8B4513;
    font-weight: 500;
    opacity: 0;
    animation: touch-hint 3s ease-in-out 2s;
    pointer-events: none;
}

@keyframes touch-hint {
    0%, 90%, 100% { opacity: 0; }
    10%, 80% { opacity: 1; }
}

.gallery-touch-indicator::before {
    content: '👈 👉 ';
    margin-right: 4px;
}

/* ==========================================================================
   MOBILE RESPONSIVENESS
   ========================================================================== */

@media (max-width: 768px) {
    .gallery-main-container {
        height: 280px;
    }

    .gallery-nav {
        width: 44px;
        height: 44px;
        font-size: 14px;
    }

    .gallery-nav-prev {
        left: 10px;
    }

    .gallery-nav-next {
        right: 10px;
    }

    .gallery-thumbnails {
        padding: 16px;
    }

    .gallery-thumbnail-container {
        grid-template-columns: repeat(auto-fit, minmax(60px, 1fr));
        gap: 8px;
    }

    .gallery-image-overlay {
        padding: 20px 16px 16px;
    }

    .gallery-image-title {
        font-size: 1rem;
    }

    .gallery-image-description {
        font-size: 0.85rem;
    }

    .gallery-touch-indicator {
        top: 16px;
        right: 16px;
        padding: 6px 10px;
        font-size: 0.7rem;
    }

    /* Enable smoother touch scrolling */
    .gallery-thumbnail-container {
        -webkit-overflow-scrolling: touch;
        scroll-behavior: smooth;
    }
}

@media (max-width: 480px) {
    .gallery-main-container {
        height: 240px;
        border-radius: 12px;
    }

    .gallery-thumbnail-container {
        grid-template-columns: repeat(auto-fit, minmax(50px, 1fr));
        gap: 6px;
    }

    .gallery-nav {
        width: 40px;
        height: 40px;
    }

    .gallery-nav::before {
        width: 10px;
        height: 10px;
    }
}

/* ==========================================================================
   PERFORMANCE OPTIMIZATIONS
   ========================================================================== */

/* GPU acceleration for smooth animations - only when needed */
.gallery-nav:hover,
.gallery-thumbnail:hover,
.gallery-image-overlay:hover,
.gallery-main-image.transitioning {
    will-change: transform;
}

/* Reset will-change after animations complete */
.gallery-nav,
.gallery-thumbnail,
.gallery-image-overlay,
.gallery-main-image {
    will-change: auto;
    backface-visibility: hidden;
}

/* Reduce animations for users who prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
    .gallery-main-image,
    .gallery-nav,
    .gallery-thumbnail,
    .gallery-image-overlay {
        transition: none;
        animation: none;
    }

    .gallery-touch-indicator {
        display: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .gallery-nav {
        background: #ffffff;
        border: 2px solid #000000;
    }

    .gallery-nav::before {
        border-color: #000000;
    }

    .gallery-thumbnail.active {
        border-color: #000000;
    }

    .gallery-image-overlay {
        background: rgba(0, 0, 0, 0.9);
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .heidmark-modern-gallery {
        background: linear-gradient(135deg, #2a2a2a 0%, #3a3a3a 100%);
    }

    .gallery-thumbnails {
        background: rgba(42, 42, 42, 0.9);
    }

    .gallery-nav {
        background: rgba(42, 42, 42, 0.9);
        color: #ffffff;
    }

    .gallery-nav::before {
        border-color: #ffffff;
    }

    .gallery-touch-indicator {
        background: rgba(42, 42, 42, 0.9);
        color: #ffffff;
    }
}

/* ==========================================================================
   LOADING STATES
   ========================================================================== */

.gallery-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    background: linear-gradient(45deg, #f0f0f0 25%, transparent 25%);
    background-size: 40px 40px;
    animation: gallery-loading 2s ease-in-out infinite;
}

@keyframes gallery-loading {
    0%, 100% { background-position: 0 0; }
    50% { background-position: 40px 0; }
}

.gallery-loading::after {
    content: '🍯 Lädt Galerie...';
    font-size: 1.1rem;
    color: #8B4513;
    font-weight: 500;
    text-align: center;
}

/* ==========================================================================
   FULLSCREEN MODE (BONUS FEATURE)
   ========================================================================== */

.gallery-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-fullscreen.active {
    opacity: 1;
    visibility: visible;
}

.gallery-fullscreen img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.gallery-fullscreen-close {
    position: absolute;
    top: 20px;
    right: 20px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.gallery-fullscreen-close:hover {
    background: #ffffff;
    transform: scale(1.1);
}

.gallery-fullscreen-close::before {
    content: '✕';
    color: #333;
}
