/* Gallery Page Specific Styles */

/* Main Content */
main {
    max-width: var(--max-width);
    margin: 0 auto;
    padding: 60px var(--spacing);
}

.page-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 60px;
    gap: 40px;
}

.page-title {
    font-size: 32px;
    font-weight: 600;
    letter-spacing: -0.5px;
    margin: 0;
}

.cta-link {
    color: #9b9b9b;
    text-decoration: none;
    font-size: 16px;
    font-weight: 500;
    letter-spacing: 0.3px;
    transition: var(--transition);
    white-space: nowrap;
    padding: 12px 24px;
    border: 1px solid #9b9b9b;
    border-radius: 4px;
    background: transparent;
    display: inline-block;
}

.cta-link:hover {
    color: #ffffff;
    border-color: #9b9b9b;
    background: #9b9b9b;
    transform: translateY(-2px);
}

/* Gallery Grid */
.gallery {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 20px;
    width: 100%;
}

.gallery-item {
    position: relative;
    aspect-ratio: 1 / 1;
    overflow: hidden;
    background: #f9f9f9;
    border: 1px solid var(--color-border);
    border-radius: 4px;
    transition: var(--transition);
    cursor: pointer;
    min-width: 0; /* Wichtig für Grid-Items */
}

/* Description Card */
.gallery-item.description-card {
    background: #ffffff;
    cursor: default;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: stretch;
    padding: 0 50px;
    overflow: hidden;
    /* 
     * WICHTIG: Jedes neue Projekt beginnt immer in der linken Spalte
     * grid-column: 1 erzwingt, dass die Beschreibungskarte immer links startet,
     * auch wenn dadurch ein Leerraum in der rechten Spalte entsteht
     */
    grid-column: 1;
}

.description-card .description-text {
    background: #ffffff;
    display: block;
    position: relative;
    z-index: 2;
    flex-shrink: 0;
}

.description-card .description-text h3 {
    font-family: 'HelveticaNeueMedium', sans-serif;
    font-size: 50px;
    line-height: 0.68;
    color: #9b9b9b;
    text-align: left;
    font-weight: 500;
    letter-spacing: 0px;
    margin: 0;
}

.description-card .description-template {
    width: 100%;
    height: auto;
    min-height: 100px;
    margin-top: -5px;
    background-image: url('../images/describer_card_template.png');
    background-size: 100% auto;
    background-position: left top;
    background-repeat: no-repeat;
    position: relative;
    z-index: 1;
    flex-shrink: 0;
    padding-bottom: 30%;
}

.description-card:hover {
    transform: none;
    box-shadow: none;
    border-color: var(--color-border);
}

.gallery-item:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.08);
    border-color: var(--color-text-light);
}

.gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: var(--transition);
}

.gallery-item:hover img {
    transform: scale(1.05);
    filter: brightness(0.6);
}

/* Project Info Overlay */
.project-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 30px;
    opacity: 0;
    transition: var(--transition);
    pointer-events: none;
    text-align: center;
}

.gallery-item:hover .project-info {
    opacity: 1;
}

.project-info h3 {
    color: white;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 8px;
    letter-spacing: -0.3px;
}

.project-info .meta {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    font-weight: 400;
}

.project-info .kunde {
    color: #ffffff;
    font-size: 16px;
    font-weight: 400;
    margin-top: 4px;
}

/* Lightbox */
.lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    z-index: 2000;
    padding: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox.active {
    opacity: 1;
    visibility: visible;
}

.lightbox-content {
    position: relative;
    max-width: 70vw;
    max-height: 80vh;
    animation: fadeIn 0.3s ease;
}

.lightbox-images {
    position: relative;
    width: 100%;
    height: 100%;
}

.lightbox-image {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-width: 70vw;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    opacity: 0 !important;
    visibility: hidden;
    transition: opacity 0.6s ease-in-out, visibility 0.6s, transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: grab;
}

.lightbox.zoomed .lightbox-image {
    cursor: grab;
}

.lightbox.zoomed .lightbox-image:active {
    cursor: grabbing;
}

.lightbox-image.active {
    opacity: 1 !important;
    visibility: visible !important;
    z-index: 2;
}

/* ========================================
   DESKTOP LAYOUT
   Buttons: Links/Rechts neben dem Bild
   Counter: Über dem Bild
   Close: Rechts oben
   ======================================== */

.lightbox-close {
    position: fixed;
    top: 20px;
    right: 20px;
    background: transparent;
    color: var(--color-text);
    border: 2px solid var(--color-text);
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2001;
}

.lightbox-close:hover {
    background: var(--color-text);
    color: white;
    transform: rotate(90deg);
}

.lightbox-prev,
.lightbox-next {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: 2px solid rgba(255, 255, 255, 0.4);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 32px;
    line-height: 1;
    font-weight: bold;
    transition: all 0.3s ease;
    z-index: 2001;
    display: none;
    align-items: center;
    justify-content: center;
    user-select: none;
}

.lightbox-prev {
    left: 40px;
}

.lightbox-next {
    right: 40px;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(0, 0, 0, 0.75);
    border-color: rgba(255, 255, 255, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-counter {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: transparent;
    color: rgba(150, 150, 150, 0.9);
    border: 1px solid rgba(150, 150, 150, 0.9);
    padding: 10px 20px;
    border-radius: 25px;
    font-size: 15px;
    font-weight: 600;
    z-index: 2001;
    display: none;
    white-space: nowrap;
    text-align: center;
    letter-spacing: 1px;
}

/* Loading State */
.gallery-item.loading {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

@keyframes fadeIn {
    from { 
        opacity: 0; 
        transform: scale(0.98); 
    }
    to { 
        opacity: 1; 
        transform: scale(1); 
    }
}

/* ========================================
   MOBILE PORTRAIT (Skyscraper)
   Buttons: Unter dem Bild (Reihe: zurück, counter, vor)
   Close: Rechts oben
   ======================================== */
@media (max-width: 768px) and (orientation: portrait) {
    main {
        padding: 40px 20px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: flex-start;
        margin-bottom: 40px;
        gap: 20px;
    }
    
    .page-title {
        font-size: 24px;
    }
    
    .cta-link {
        font-size: 15px;
    }
    
    .gallery {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .gallery-item.description-card {
        padding: 0 20px;
    }
    
    .description-card .description-text h3 {
        font-size: 32px;
    }
    
    .description-card .description-template {
        min-height: 60px;
        padding-bottom: 25%;
    }
    
    /* Lightbox Mobile Portrait */
    .lightbox {
        padding: 0;
        flex-direction: column;
    }
    
    .lightbox-content {
        max-width: 100vw;
        max-height: calc(100vh - 100px);
        margin-bottom: 100px;
    }
    
    .lightbox-image {
        max-width: 95vw;
        max-height: calc(100vh - 120px);
    }
    
    /* Close Button: Rechts oben */
    .lightbox-close {
        top: 15px;
        right: 15px;
        width: 48px;
        height: 48px;
        font-size: 24px;
    }
    
    /* Navigation Buttons: Unter dem Bild - GRÖßER und HÖHER */
    .lightbox-prev,
    .lightbox-next {
        position: fixed;
        bottom: 80px;
        top: auto;
        transform: none;
        width: 70px;
        height: 70px;
        font-size: 36px;
        background: rgba(0, 0, 0, 0.7);
    }
    
    .lightbox-prev {
        left: 30px;
    }
    
    .lightbox-next {
        right: 30px;
    }
    
    .lightbox-prev:hover,
    .lightbox-next:hover {
        transform: none;
        background: rgba(0, 0, 0, 0.85);
    }
    
    /* Counter: Mittig - AUF GLEICHER HÖHE WIE BUTTONS */
    .lightbox-counter {
        position: fixed;
        bottom: 80px;
        top: auto;
        left: 50%;
        transform: translateX(-50%);
        background: transparent;
        color: rgba(150, 150, 150, 0.9);
        border: 1px solid rgba(150, 150, 150, 0.9);
        padding: 12px 24px;
        border-radius: 30px;
        font-size: 18px;
        font-weight: 700;
        text-align: center;
        letter-spacing: 1px;
    }
}

/* ========================================
   MOBILE LANDSCAPE
   Buttons: Links/Rechts neben dem Bild
   Counter: Ausgeblendet
   Close: Rechts oben
   ======================================== */
@media (max-width: 926px) and (orientation: landscape), 
       (max-height: 500px) and (orientation: landscape) {
    .gallery {
        grid-template-columns: 1fr !important;
        gap: 15px;
    }
    
    .gallery-item.description-card {
        padding: 0 15px;
    }
    
    .description-card .description-text h3 {
        font-size: 28px;
    }
    
    .description-card .description-template {
        min-height: 50px;
        padding-bottom: 20%;
    }
    
    /* Lightbox Mobile Landscape */
    .lightbox {
        padding: 0;
    }
    
    .lightbox-content {
        max-width: 85vw;
        max-height: 85vh;
    }
    
    .lightbox-image {
        max-width: 85vw;
        max-height: 85vh;
    }
    
    /* Close Button: Rechts oben */
    .lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    /* Navigation Buttons: Links/Rechts neben dem Bild */
    .lightbox-prev,
    .lightbox-next {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        width: 45px;
        height: 45px;
        font-size: 26px;
        background: rgba(0, 0, 0, 0.6);
    }
    
    .lightbox-prev {
        left: 10px;
    }
    
    .lightbox-next {
        right: 10px;
    }
    
    .lightbox-prev:hover,
    .lightbox-next:hover {
        transform: translateY(-50%) scale(1.05);
    }
    
    /* Counter: Ausgeblendet im Landscape */
    .lightbox-counter {
        display: none !important;
    }
}

/* Sehr kleine Screens */
@media (max-width: 480px) and (orientation: portrait) {
    .gallery {
        grid-template-columns: 1fr;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 65px;
        height: 65px;
        font-size: 32px;
        bottom: 70px;
    }
    
    .lightbox-prev {
        left: 20px;
    }
    
    .lightbox-next {
        right: 20px;
    }
    
    .lightbox-counter {
        font-size: 16px;
        font-weight: 700;
        padding: 10px 20px;
        bottom: 70px;
        background: transparent;
        border: 1px solid rgba(150, 150, 150, 0.9);
        color: rgba(150, 150, 150, 0.9);
        text-align: center;
        letter-spacing: 1px;
    }
}

