/*
 * Galerie-Startseite (ab 1.16.0, ADR-086) – Stile der bisherigen index.html von pioch.me, unverändert übernommen.
 * Neu am Ende nur: .gallery-empty und .footer-sep (vorher als style-Attribut bzw. gar nicht vorhanden).
 */
:root {
    --bg: #020202;
    --text: #e8e8e8;
    --card: #0a0a0a;
    --muted: #888;
    --accent: #999;
}
[data-theme="light"] {
    --bg: #f9f9f9;
    --text: #111;
    --card: #ffffff;
    --muted: #555;
    --accent: #333;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    transition: background .45s, color .45s;
}

/* ── Header ── */
.header {
    position: relative;
    padding: clamp(30px,8vw,50px) 5% clamp(20px,5vw,40px);
    max-width: 1820px;
    margin: 0 auto;
}
.theme-switch-wrapper {
    position: absolute;
    top: clamp(20px,5vw,50px); left: 5%;
    display: flex; align-items: center; gap: 8px;
    font-size: clamp(0.8rem,2.5vw,0.92rem);
    color: var(--muted); z-index: 10;
}
.theme-label { min-width: 45px; text-align: center; transition: color 0.3s; }
.theme-label.active { color: var(--text); font-weight: 500; }
.theme-slider {
    position: relative;
    width: clamp(50px,10vw,64px); height: clamp(24px,5vw,30px);
    background: var(--card); border-radius: 999px;
    cursor: pointer; transition: background 0.3s;
}
.theme-slider::before {
    content: "";
    position: absolute;
    top: 3px; left: 3px;
    width: clamp(18px,4vw,24px); height: clamp(18px,4vw,24px);
    background: var(--accent); border-radius: 50%;
    transition: transform 0.28s ease;
}
[data-theme="light"] .theme-slider::before {
    transform: translateX(clamp(26px,5vw,34px));
}
.title-block {
    text-align: right;
    max-width: calc(100% - 10px);
    margin-left: auto;
    padding-right: calc(5% + 10px);
}
.header h1 {
    font-size: clamp(1.5rem,8vw,6.2rem);
    font-weight: 200;
    letter-spacing: clamp(0.1em,1.5vw,0.48em);
    text-transform: uppercase;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.subtitle {
    font-size: clamp(0.9rem,3vw,1.18rem);
    color: var(--muted); letter-spacing: 0.09em; margin-top: 8px;
}
.bio {
    font-size: clamp(0.78rem,2vw,0.92rem);
    color: var(--muted);
    letter-spacing: 0.04em;
    margin-top: 10px;
    line-height: 1.7;
}
.bio em {
    color: var(--text);
    font-style: normal;
}
.bio .sep { margin: 0 8px; opacity: 0.25; }

.total-count {
    font-size: clamp(0.7rem,2vw,0.82rem);
    color: #444; letter-spacing: 0.06em; margin-top: 4px;
}

/* ── Staggered fade-in für Galerie-Items ── */
.gallery-item {
    opacity: 0;
    transform: translateY(16px);
    animation: itemReveal 0.55s ease forwards;
}
@keyframes itemReveal {
    to { opacity: 1; transform: translateY(0); }
}
/* Verzögerung gestaffelt, max 600ms damit es nicht zu lang dauert */
.gallery-item:nth-child(1)  { animation-delay: 0.03s; }
.gallery-item:nth-child(2)  { animation-delay: 0.06s; }
.gallery-item:nth-child(3)  { animation-delay: 0.09s; }
.gallery-item:nth-child(4)  { animation-delay: 0.12s; }
.gallery-item:nth-child(5)  { animation-delay: 0.15s; }
.gallery-item:nth-child(6)  { animation-delay: 0.18s; }
.gallery-item:nth-child(7)  { animation-delay: 0.21s; }
.gallery-item:nth-child(8)  { animation-delay: 0.24s; }
.gallery-item:nth-child(9)  { animation-delay: 0.27s; }
.gallery-item:nth-child(10) { animation-delay: 0.30s; }
.gallery-item:nth-child(n+11) { animation-delay: 0.35s; }

/* ── Kategorie-Filter ── */
.filter-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 5% 32px;
    max-width: 1820px;
    margin: 0 auto;
    flex-wrap: wrap;
}
.filter-btn {
    background: transparent;
    border: 1px solid var(--card);
    color: var(--muted);
    font-family: inherit;
    font-size: 0.78rem;
    letter-spacing: 0.1em;
    text-transform: uppercase;
    padding: 7px 16px;
    border-radius: 999px;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex; align-items: center; gap: 6px;
}
.filter-btn:hover {
    border-color: var(--accent);
    color: var(--text);
}
.filter-btn.active {
    background: var(--text);
    border-color: var(--text);
    color: var(--bg);
}
.filter-btn .badge {
    font-size: 0.65rem;
    opacity: 0.6;
    min-width: 18px;
}
.filter-btn.active .badge { opacity: 0.7; }

/* Filter-Übergangsanimation */
.masonry-grid.filtering .gallery-item {
    animation: fadeOut 0.2s ease forwards;
}
@keyframes fadeOut { to { opacity: 0; transform: scale(0.97); } }

/* ── Gallery ── */
#gallery { opacity: 1; }
#gallery.visible { opacity: 1; }
.gallery-wrapper { max-width: 1820px; margin: 0 auto; }

/* ══ ALL-Filter: gemischtes Masonry ══ */
.masonry-grid {
    display: grid;
    grid-gap: 10px;
    padding: 0 5% 100px;
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-flow: dense;
    grid-auto-rows: 200px;
}

/* Portrait braucht mehr Höhe damit es nicht gequetscht wirkt */
.masonry-grid .gallery-item.portrait   { grid-row: span 2; }
.masonry-grid .gallery-item.widescreen { grid-column: span 2; }
.masonry-grid .gallery-item.landscape  { grid-row: span 1; }

/* Key-Varianten für "all"-Modus */
.masonry-grid[data-filter="all"] .gallery-item.key           { grid-column: span 2; grid-row: span 2; }
.masonry-grid[data-filter="all"] .gallery-item.key-landscape { grid-column: span 3; grid-row: span 2; }
.masonry-grid[data-filter="all"] .gallery-item.key-portrait  { grid-column: span 2; grid-row: span 3; }

/* ══ PORTRAIT-Filter ══ */
.masonry-grid[data-filter="portrait"] {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    grid-auto-rows: 380px;   /* Hoch genug für echtes Hochformat */
}
.masonry-grid[data-filter="portrait"] .gallery-item {
    grid-column: span 1;
    grid-row: span 1;
}

/* ══ LANDSCAPE-Filter ══ */
.masonry-grid[data-filter="landscape"] {
    grid-template-columns: repeat(auto-fill, minmax(440px, 1fr));
    grid-auto-rows: 320px;
}
.masonry-grid[data-filter="landscape"] .gallery-item {
    grid-column: span 1;
    grid-row: span 1;
}

/* ══ WIDESCREEN-Filter ══ */
.masonry-grid[data-filter="widescreen"] {
    grid-template-columns: repeat(auto-fill, minmax(500px, 1fr));
    grid-auto-rows: 300px;
}
.masonry-grid[data-filter="widescreen"] .gallery-item {
    grid-column: span 1;
    grid-row: span 1;
}

/* ══ MOBILE (≤ 600px) ══ */
@media (max-width: 600px) {
    /* ALL */
    .masonry-grid {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 160px;
    }
    .masonry-grid .gallery-item.portrait {
        grid-column: span 1;
        grid-row: span 2;       /* Hochformat: 2 Zeilen hoch */
    }
    .masonry-grid .gallery-item.landscape,
    .masonry-grid .gallery-item.widescreen {
        grid-column: span 2;    /* Quer/Wide: volle Breite */
        grid-row: span 1;
    }
    /* Key auf Mobile ignorieren */
    .masonry-grid[data-filter="all"] .gallery-item.key,
    .masonry-grid[data-filter="all"] .gallery-item.key-landscape,
    .masonry-grid[data-filter="all"] .gallery-item.key-portrait {
        grid-column: unset;
        grid-row: unset;
    }
    .masonry-grid[data-filter="all"] .gallery-item.portrait.key,
    .masonry-grid[data-filter="all"] .gallery-item.portrait.key-portrait {
        grid-column: span 1; grid-row: span 2;
    }
    .masonry-grid[data-filter="all"] .gallery-item.landscape.key,
    .masonry-grid[data-filter="all"] .gallery-item.landscape.key-landscape,
    .masonry-grid[data-filter="all"] .gallery-item.widescreen.key,
    .masonry-grid[data-filter="all"] .gallery-item.widescreen.key-landscape {
        grid-column: span 2; grid-row: span 1;
    }

    /* PORTRAIT-Filter mobil: 2 Spalten, richtig hoch */
    .masonry-grid[data-filter="portrait"] {
        grid-template-columns: 1fr 1fr;
        grid-auto-rows: 240px;
    }
    .masonry-grid[data-filter="portrait"] .gallery-item {
        grid-column: span 1; grid-row: span 1;
    }

    /* LANDSCAPE & WIDESCREEN mobil: 1 Spalte, breit */
    .masonry-grid[data-filter="landscape"] {
        grid-template-columns: 1fr;
        grid-auto-rows: 220px;
    }
    .masonry-grid[data-filter="widescreen"] {
        grid-template-columns: 1fr;
        grid-auto-rows: 200px;
    }
    .masonry-grid[data-filter="landscape"] .gallery-item,
    .masonry-grid[data-filter="widescreen"] .gallery-item {
        grid-column: span 1; grid-row: span 1;
    }
}

.gallery-item {
    position: relative; overflow: hidden;
    border-radius: 10px; background: var(--card);
    transition: transform 0.38s ease;
    display: flex; align-items: center; justify-content: center;
}
.gallery-item:hover { transform: scale(1.04); }
.gallery-item::before { display: none; }
.gallery-item img {
    position: relative; z-index: 1;
    width: 100%; height: 100%;
    object-fit: cover; object-position: center;
    display: block; opacity: 0;
    transition: opacity 0.5s ease;
}
/* Portrait: Bild oben ausrichten damit Motiv nicht abgeschnitten */
.gallery-item.portrait img { object-position: center top; }
.gallery-item img.loaded { opacity: 1; }

/* ── Back to top ── */
#back-to-top {
    position: fixed; bottom: 90px; right: 30px;
    width: 50px; height: 50px;
    background: rgba(90,90,90,0.5); color: white;
    border: none; border-radius: 50%; font-size: 1.5rem;
    cursor: pointer; opacity: 0; visibility: hidden;
    transition: all 0.4s ease; z-index: 90;
    box-shadow: 0 4px 14px rgba(0,0,0,0.6);
}
#back-to-top.visible { opacity: 0.8; visibility: visible; }
#back-to-top:hover   { opacity: 1; background: rgba(130,130,130,0.8); }

footer {
    text-align: center; padding: 100px 20px 50px;
    color: var(--muted); font-size: 0.94rem;
}
footer a { color: var(--muted); text-decoration: none; }
footer a:hover { color: var(--text); }

@media (max-width: 768px) {
    .header {
        padding: 24px 5% 24px;
        display: flex; flex-direction: column; gap: 20px;
    }
    .theme-switch-wrapper { position: static; top: unset; left: unset; }
    .title-block { text-align: left; padding-right: 0; margin-left: 0; }
    .subtitle { text-align: left; }
    .header h1 { white-space: normal; word-break: break-word; }
}
@media (max-width: 500px) {
    .header h1 { font-size: clamp(1.6rem,9vw,2.4rem); letter-spacing: 0.12em; }
    .filter-btn { font-size: 0.72rem; padding: 6px 12px; }
}

/* ── Zusätze für die Einbindung ins Toolkit (ersetzen Inline-Stile des Originals; die Content-Security-Policy erlaubt keine) ── */
.gallery-empty { color: var(--muted); padding: 40px 5%; font-size: 0.9rem; }
footer .footer-sep { margin: 0 10px; opacity: 0.4; }
