/* 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 — Einheitliches 4-Spalten-Raster für alle Zeilen */
.gallery-grid {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.gallery-row {
    display: grid;
    gap: 15px;
    grid-template-columns: repeat(4, 1fr);
}

.gallery-row .gallery-item {
    width: 100%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.gallery-row .gallery-item img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* Portrait in gemischten Reihen: gleiche Höhe wie Landscape (mit Gap-Korrektur) */
.gallery-row .gallery-item.matched-portrait {
    aspect-ratio: 0.73;
}

/* Vertikale Trennlinien – nur noch zwischen zwei Portraits (mittig im Gap) */
.gallery-row .gallery-item:not(:first-child)::before {
    content: '';
    position: absolute;
    top: 12%;
    height: 76%;
    width: 1px;
    background: rgba(0, 0, 0, 0.25);
    pointer-events: none;
    display: none;
}
.gallery-row .gallery-item.portrait + .gallery-item.portrait::before {
    display: block;
    left: -8px;
}

/* Portraits in Landscape-Zeilen: an den äußeren Rand rücken */
.gallery-row.row-landscape-left .gallery-item.portrait:nth-child(2) img,
.gallery-row.row-landscape-right .gallery-item.portrait:nth-child(1) img,
.gallery-row.row-mixed-2 .gallery-item.portrait img {
    object-position: left center;
}
.gallery-row.row-landscape-left .gallery-item.portrait:nth-child(3) img,
.gallery-row.row-landscape-right .gallery-item.portrait:nth-child(2) img {
    object-position: right center;
}

/* === Spaltenbelegung pro Reihentyp === */

/* Landscape links: 🌅 in Spalte 1–2, 📷 in 3, 📷 in 4 */
.gallery-row.row-landscape-left .gallery-item.landscape {
    grid-column: 1 / 3;
}

/* Landscape rechts: 📷 in 1, 📷 in 2, 🌅 in Spalte 3–4 */
.gallery-row.row-landscape-right .gallery-item.landscape {
    grid-column: 3 / 5;
}

/* Gemischt 2: 🌅 in Spalte 1–2, 📷 in 3 (Spalte 4 leer) */
.gallery-row.row-mixed-2 .gallery-item.landscape {
    grid-column: 1 / 3;
}
.gallery-row.row-mixed-2 .gallery-item.portrait {
    grid-column: 3 / 4;
}

/* Landscape allein: zentriert in Spalte 2–3 */
.gallery-row.row-solo-landscape .gallery-item.landscape {
    grid-column: 2 / 4;
}

/* Portrait-Paar: nebeneinander in Spalte 2–3 */
.gallery-row.row-portrait-pair .gallery-item.portrait:first-child {
    grid-column: 2 / 3;
}
.gallery-row.row-portrait-pair .gallery-item.portrait:last-child {
    grid-column: 3 / 4;
}

/* Portrait allein: zentriert in Spalte 2 */
.gallery-row.row-solo-portrait .gallery-item.portrait {
    grid-column: 2 / 3;
}

@media (max-width: 700px) {
    .gallery-row .gallery-item {
        grid-column: 1 / -1 !important;
    }
    .gallery-row .gallery-item.matched-portrait {
        aspect-ratio: auto;
    }
    .gallery-row .gallery-item.portrait + .gallery-item.portrait::before {
        display: none;
    }
}

/* =============================================
   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;
    }
}

/* 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; }

/* Static Pages (Impressum, Datenschutz) – Overflow auf Mobile verhindern */
.static-page {
    overflow-wrap: break-word;
    word-break: break-word;
}
.static-page a {
    overflow-wrap: break-word;
    word-break: break-all;
}

/* 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; }
