/* Minimalist Reset & Base */
* { margin: 0; padding: 0; box-sizing: border-box; }
body { 
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background-color: #fff;
    color: #000;
    line-height: 1.6;
}

/* Navigation */
header {
    position: fixed;
    top: 0; width: 100%;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    transition: transform 0.3s ease, background 0.3s ease;
    z-index: 1000;
    border-bottom: 1px solid #000;
}
header.nav-hidden { transform: translateY(-100%); }

.page-title {
    text-align: center;
    font-size: 1.05rem;
    font-weight: 500;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
}
.page-title.visible { opacity: 1; }

nav { justify-self: end; }
nav a { text-decoration: none; color: #000; margin-left: 20px; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px; }
header .logo { font-weight: bold; letter-spacing: 2px; font-size: 0.7rem; line-height: 1.15; text-decoration: none; color: #000; display: inline-block; }

/* Layouts */
.container { padding: 100px 20px 40px 20px; max-width: 1400px; margin: 0 auto; }

/* Landing Page Gallery — CSS Grid (bündig, lückenlos) */
.gallery-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    grid-auto-flow: dense;
}

.gallery-grid .gallery-item {
    width: 100%;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.gallery-grid .gallery-item img {
    width: 100%;
    height: auto;
    display: block;
}

.gallery-grid .gallery-item.landscape {
    grid-column: span 2;
}

.gallery-grid .gallery-item.solo {
    grid-column: 1 / -1;
}

@media (max-width: 1000px) {
    .gallery-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

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

/* =============================================
   Mobile Navigation (≤600px)
   ============================================= */
@media (max-width: 600px) {
    header {
        grid-template-columns: 1fr auto;
        padding: 15px;
    }
    .page-title {
        display: none;
    }
    nav {
        justify-self: end;
    }
    .container {
        padding-top: 70px;
    }
    .collection-header {
        padding-top: 15px;
    }
}

@media (max-width: 600px) {
    .gallery-grid {
        grid-template-columns: 1fr;
    }
    .gallery-grid .gallery-item.landscape {
        grid-column: span 1;
    }
}

/* Collection Detail & Admin Grid (6-Column System) */
.collection-images-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 15px;
}

.collection-images-grid .gallery-item {
    grid-column: span 2; /* Portrait Slot */
    width: 100%;
    aspect-ratio: 2 / 3;
}

.collection-images-grid .gallery-item.landscape {
    grid-column: span 3; /* Landscape Slot */
    aspect-ratio: 3 / 2;
}

.collection-images-grid .gallery-item.full-width {
    grid-column: span 6; /* Solo / Cover */
    aspect-ratio: auto;
}

.collection-images-grid .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    background: #fff;
}

.collection-images-grid .stacked-group {
    grid-column: span 2;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Schließt oben und unten bündig ab */
    aspect-ratio: 2 / 3; /* Gleiche Höhe wie ein Portrait-Bild */
    gap: 7px;
}

.collection-images-grid .stacked-group .gallery-item {
    aspect-ratio: auto;
    flex: 0 1 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 0;
}

.collection-images-grid .stacked-group .gallery-item:last-child {
    justify-content: flex-end; /* Drückt das untere Bild ganz nach unten */
}

.collection-images-grid .stacked-group .gallery-item img {
    height: auto;
    width: 100%;
    object-fit: contain;
    background: none;
    margin: 0;
    display: block;
}

.collection-images-grid .stacked-group .stacked-divider {
    width: 75%;
    height: 1px;
    background: rgba(0, 0, 0, 0.2);
    margin: 0 auto;
    flex-shrink: 0;
}

/* Common Gallery Styles */
.gallery-item {
    cursor: pointer;
    transition: transform 0.3s ease;
}
.gallery-item:hover img { transform: scale(1.015); }

.stacked-group {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gallery-grid .stacked-group {
    flex-grow: var(--group-ratio, 1);
    width: calc(350px * var(--group-ratio, 1));
}

.stacked-group .gallery-item {
    width: 100% !important;
    flex: 1;
}

@media (max-width: 900px) {
    .collection-images-grid { grid-template-columns: repeat(4, 1fr); }
    .collection-images-grid .gallery-item.landscape { grid-column: span 2; }
}

@media (max-width: 600px) {
    .collection-images-grid { grid-template-columns: 1fr; }
    .collection-images-grid .gallery-item, 
    .collection-images-grid .gallery-item.landscape, 
    .collection-images-grid .gallery-item.full-width {
        grid-column: span 1;
        aspect-ratio: auto;
    }
    .collection-images-grid .gallery-item img {
        height: auto;
        display: block;
    }
    .collection-images-grid .stacked-group {
        aspect-ratio: auto;
        grid-column: span 1;
        gap: 10px;
    }
    .collection-images-grid .stacked-group .gallery-item {
        aspect-ratio: auto;
    }
    .stacked-divider {
        display: none;
    }
}

/* Collections Overview Page */
.collections-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 40px;
}
@media (max-width: 600px) { .collections-grid { grid-template-columns: 1fr; } }

.collection-card {
    text-decoration: none;
    color: #000;
    border: 1px solid #000;
    padding: 12px;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 10px;
    gap: 10px;
}

.card-header h3 {
    text-transform: uppercase;
    font-size: 1.1rem;
    margin: 0 0 4px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.card-date {
    font-size: 0.85rem;
    opacity: 0.55;
    white-space: nowrap;
}

.card-cover-wrapper {
    width: 100%;
    background: none;
    display: block;
    overflow: visible;
    margin-top: 8px;
}

.card-cover-fit {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.subgroup-row {
    display: grid;
    gap: 10px;
    padding: 10px 0 0 0;
    background: none;
}

.subgroup-row.three-portrait {
    grid-template-columns: repeat(3, 1fr);
    align-items: start;
}

.subgroup-row.single-landscape {
    grid-template-columns: 1fr;
}

.subgroup-row img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
}

.collection-card:hover img {
    transform: none;
}

@media (max-width: 600px) {
    .subgroup-row {
        display: none;
    }
}

.collection-header { margin-bottom: 40px; border-bottom: 1px solid #000; padding: 50px 0 10px 0; }
.collection-header h1 { font-size: 2.5rem; text-transform: uppercase; }
.collection-header .date { font-scale: 0.8rem; opacity: 0.6; }
#viewer {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #fff; z-index: 2000; display: none;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
}
#viewer.active { display: block; }

.viewer-image-container {
    height: 100vh; width: 100%;
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    scroll-snap-align: start;
    padding: 40px;
}
.viewer-image-container img {
    max-width: 100%; max-height: 85vh;
    border: 20px solid #fff; /* Thick white frame */
    box-shadow: 0 0 0 1px #000; /* Thin black outline to see edge on white */
    object-fit: contain;
}

/* Navigation Arrow in Viewer
.viewer-back-arrow {
    position: fixed;
    top: 30px;
    left: 30px;
    z-index: 2100;
    text-decoration: none;
    color: #000;
    font-size: 2.5rem;
    opacity: 0.5;
    transition: opacity 0.3s;
    line-height: 1;
    cursor: pointer;
    background: rgba(255,255,255,0.5);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
}
.viewer-back-arrow:hover {
    opacity: 1;
    background: rgba(255,255,255,0.8);
}
*/

.viewer-description { text-align: center; margin-top: 20px; font-size: 1rem; }

/* Mobile Viewer (< 768px) – natürliche Bildgröße wie in Sammlungsansicht, kein Rahmen */
@media (max-width: 767px) {
    .viewer-image-container {
        height: 100dvh;
        padding: 0 10px;
    }
    .viewer-image-container img {
        border: none;
        box-shadow: none;
        max-height: 100dvh;
        width: 100%;
        height: auto;
    }
}

/* Footer */
footer { padding: 40px 20px; text-align: center; border-top: 1px solid #eee; font-size: 0.8rem; opacity: 0.5; transition: opacity 0.3s; }
footer a { color: #000; text-decoration: none; margin: 0 10px; }

/* Admin Page Fixes */
.admin-container { padding-top: 100px; }
