/**
 * Art on Tour
 * Name: Arthur Peter Lorenzen
 * Adresse: Bachtelstrasse 68, 8342 Wernetshausen, Schweiz
 * E-Mail: info@art-on-tour.ch
 * Web: www.art-on-tour.ch
 */

/* ======================================= */
/*   1. GRUNDLEGENDE LAYOUT-EINSTELLUNGEN  */
/* ======================================= */

/* 1.1 Container-Definitionen */
.container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    display: block; /* Safari: Global Flex-Container überschreiben */
}

/* 1.2 Detail-Container mit optimalem Abstand zum Header */
.detail-container {
    width: 100%;
    max-width: 100%;
    margin: 0 auto;
    padding: 0;
    margin-top: 5px !important; /* Exakt 5px Abstand zum Header */
    margin-bottom: var(--footer-height); /* Platz für fixen Footer */
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - var(--header-height) - var(--footer-height) - 5px);
}

/* Inline-Scroll Variante für Detailseite */
/* (entfernt) Inline-Scroll-Variante wurde zurückgebaut */

/* ======================================= */
/*   2. BILDER-GRID                        */
/* ======================================= */

/* 2.1 Grid-Layout für die Detailbilder */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr); /* Standardmäßig 2 Spalten (Mobilgeräte) */
    gap: 2px;
    width: 100%;
    padding: 0;
    margin: 0;
}

/* 2.2 Grid-Item */
.grid-item {
    position: relative;
    aspect-ratio: 1; /* Quadratisches Format */
    overflow: hidden;
    cursor: pointer;
}

/* 2.3 Responsive Grid-Spalten */
@media (min-width: 768px) {
    .detail-grid {
        grid-template-columns: repeat(3, 1fr); /* 3 Spalten für Querformat/Tablets */
    }
}

@media (min-width: 1200px) {
    .detail-grid {
        grid-template-columns: repeat(5, 1fr); /* 5 Spalten für große Bildschirme */
    }
}

/* 2.4 Bild im Grid */
.grid-image {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Bilder ausfüllen den Container */
    transition: transform 0.3s ease;
}

.grid-item:hover .grid-image {
    transform: scale(1.05); /* Leichter Zoom-Effekt beim Hover */
}

/* 2.5 Bildunterschrift (Optional) */
.grid-caption {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: rgba(0, 0, 0, 0.7);
    color: #fff;
    text-align: center;
    padding: 5px;
    font-size: 12px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.grid-item:hover .grid-caption {
    opacity: 1;
}

/* ======================================= */
/*   3. VOLLBILDMODUS                      */
/* ======================================= */

/* 3.1 Vollbild-Container */
.fullscreen-container {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.95);
    z-index: var(--z-index-fullscreen);
    display: none;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.fullscreen-container.active {
    display: flex;
    animation: fadeIn 0.3s ease forwards;
}

/* 3.2 Vollbild-Bild */
.fullscreen-image {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
}

/* 3.3 Vollbild-Steuerelemente */
.fullscreen-controls {
    position: fixed;
    bottom: 20px;
    left: 0;
    right: 0;
    display: flex;
    justify-content: center;
    padding: 10px;
    gap: 20px;
    z-index: calc(var(--z-index-fullscreen) + 1);
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: var(--border-radius); /* Eckig abgerundet statt rund */
}

/* 3.4 Steuerungsbuttons im Vollbildmodus */
.fullscreen-btn {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--border-radius); /* Eckig abgerundet statt rund */
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s;
}

.fullscreen-btn:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

.fullscreen-btn svg {
    width: 24px;
    height: 24px;
}

/* 3.5 Bildunterschrift im Vollbildmodus */
.fullscreen-caption {
    position: absolute;
    bottom: 80px;
    left: 0;
    right: 0;
    text-align: center;
    color: #fff;
    padding: 10px;
    font-size: 16px;
}

/* 3.6 Vollbild-Navigationsbuttons (alle unten) */
.fullscreen-nav {
    background-color: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: var(--border-radius); /* Eckig abgerundet statt rund */
    width: 44px;
    height: 44px;
    display: flex;
    justify-content: center;
    align-items: center;
    color: #fff;
    cursor: pointer;
    transition: background-color 0.3s;
}

.fullscreen-nav:hover {
    background-color: rgba(255, 255, 255, 0.4);
}

/* Entfernen der absoluten Positionierung der Navigationsbuttons */
.fullscreen-nav.prev,
.fullscreen-nav.next {
    position: static; /* Nicht absolut positioniert */
}

/* ======================================= */
/*   4. LADEANIMATION UND ÜBERGÄNGE        */
/* ======================================= */

/* 4.1 Fade-In-Animation */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 4.2 Zoom-Animation */
@keyframes zoomIn {
    from { transform: scale(0.9); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.fullscreen-image {
    animation: zoomIn 0.3s ease forwards;
}

/* 4.3 Ladeindikator */
.loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top: 4px solid var(--primary-color);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

/* ======================================= */
/*   5. RESPONSIVE OPTIMIERUNGEN           */
/* ======================================= */

/* 5.1 Mobile-Optimierungen */
@media (max-width: 480px) {
    .detail-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 Spalten für kleine Mobile */
        gap: 1px; /* Kleinerer Abstand */
    }
    
    .fullscreen-controls {
        bottom: 10px;
    }
    
    .fullscreen-btn,
    .fullscreen-nav {
        width: 36px;
        height: 36px;
    }
    
    .fullscreen-btn svg,
    .fullscreen-nav svg {
        width: 20px;
        height: 20px;
    }
}

/* 5.2 Touch-Optimierungen */
@media (pointer: coarse) {
    .fullscreen-btn,
    .fullscreen-nav {
        min-width: 44px; /* Minimale Größe für Touch-Ziele */
        min-height: 44px;
    }
}

/* 5.3 iOS-Anpassungen */
@supports (-webkit-touch-callout: none) {
    .fullscreen-controls {
        /* Sichere Positionierung auf iOS-Geräten */
        bottom: env(safe-area-inset-bottom, 20px);
    }
}

/* ======================================= */
/*   6. VERSTECKTE ELEMENTE IM FULLSCREEN  */
/* ======================================= */

/* 6.1 Versteckte Elemente bei aktivem Vollbildmodus */
body.fullscreen-active .header,
body.fullscreen-active .footer,
body.fullscreen-active .detail-grid:not(.fullscreen-grid) {
    display: none !important;
}

/* 6.2 Body-Styling im Vollbildmodus */
body.fullscreen-active {
    overflow: hidden;
    margin: 0;
    padding: 0;
    background-color: #000;
}

/* ======================================= */
/*   7. PERFORMANCE-OPTIMIERUNGEN          */
/* ======================================= */

/* 7.1 Hardware-Beschleunigung */
.grid-image,
.fullscreen-image,
.fullscreen-container,
.fullscreen-controls,
.fullscreen-nav {
    will-change: transform;
    transform: translateZ(0);
    backface-visibility: hidden;
}

/* 7.2 Smooth Scrolling deaktivieren im Fullscreen */
body.fullscreen-active {
    scroll-behavior: auto;
}

/* ======================================= */
/*   8. FEHLERMELDUNG                      */
/* ======================================= */

/* 8.1 Keine Bilder Fallback */
.no-images-message {
    text-align: center;
    padding: 40px var(--spacing-lg);
    background-color: var(--background-color);
    border-radius: var(--border-radius);
    margin: var(--spacing-lg) auto;
    max-width: 600px;
}

.no-images-message p {
    margin-bottom: var(--spacing-lg);
    font-size: 18px;
    color: var(--text-color-light);
}
