/* =============================================================================
 *   1. BASIS- & LAYOUT-STILE
 * ============================================================================= */

html {
    height: 100%;
}

body {
    text-align: center;
    height: 100vh;
    width: 100vw;
    margin: 0;
    padding: 0;
    font-family: Arial, sans-serif;
}

p.einleitung {
    padding: 15px 20px 0;
    text-align: center;
    width: 80%;
    margin: 0 auto;
    line-height: 1.4;
}

/* =============================================================================
 *   2. FILTER- & BUTTONS
 * ============================================================================= */

.filters {
    text-align: center;
    margin-bottom: 0;
    padding: 0;
}

.filter {
    margin-bottom: 0;
}

.button-link,
.button-link:visited {
    display: inline-block;
    padding: 1px 4px;
    margin: 0.5px;
    background-color: #2d5016;
    color: #FFCC00;
    text-decoration: none;
    border-radius: 3px;
    transition: all 0.2s;
    font-size: 0.85em;
}

.button-link:hover {
    background-color: yellow !important;
    color: black !important;
}

.button-link.active {
    background-color: yellow !important;
    color: black !important;
}

/* =============================================================================
 *   3. GRID & MEDIA-BOXEN
 * ============================================================================= */

.grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    padding: 15px 5px;
    margin: 0 auto;
    max-width: 1300px;
    width: 100%;
    box-sizing: border-box;
}

.media-box {
    border: 1px solid darkgreen;
    border-radius: 2px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding: 5px;
    min-height: 490px;
    height: auto;
    box-sizing: border-box;
    position: relative;
    transition: transform 0.2s;
}

.media-box:hover {
    transform: scale(1.02);
}

.box-title {
    background: linear-gradient(135deg, #4a7c59, #006400);
    color: white;
    padding: 6px 8px;
    margin: 0 -5px 4px -5px;
    font-weight: bold;
    font-size: 0.85em;
    border-radius: 2px 2px 0 0;
    width: calc(100% + 10px);
    line-height: 1.2;
    flex-shrink: 0;
}

/* =============================================================================
 *   3.1 BILDER & VIDEOS
 * ============================================================================= */

.media-box img,
.media-box video {
    width: 100%;
    max-width: 100%;
    height: auto;
    max-height: 360px;
    display: block;
    margin: 0 auto 8px;
    cursor: pointer;
    flex-shrink: 0;
    object-fit: contain;
    object-position: center;
}

#mediaImage-*,
#mediaVideo-* {
width: 100% !important;
max-height: 360px;
height: auto;
object-fit: contain;
}

/* =============================================================================
 *   3.2 TEXT- & LINKS-CONTAINER
 * ============================================================================= */

.text-container {
    margin-top: auto;
    padding: 0 10px;
    width: 100%;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    min-height: 60px;
    position: relative;
    padding-bottom: 60px;
}

#mediaText-*,
p {
    margin: 0 4px;
    padding: 2px 0;
    font-size: 0.8em;
    line-height: 1.1;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 1;
    -webkit-box-orient: vertical;
    flex-shrink: 0;
}

.links {
    margin: 0 0 4px 0;
    padding: 0 10px;
    font-size: 0.75em;
    line-height: 1.1;
    flex-shrink: 2;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    align-items: center;
    justify-content: center;
    width: 100%;
    box-sizing: border-box;
}

.links a {
    padding: 1px 3px;
    color: darkgreen;
    text-decoration: none;
    background: #f0f8f0;
    border-radius: 3px;
    white-space: nowrap;
    border: 1px solid #d0e8d0;
    border-radius: 5px;
}

.links a:hover {
    background: #e8f5e8;
    text-decoration: none;
}

/*=============================================================================
 *   3.3 NFO- & HTM-LINKS
 * ============================================================================= */

.htm-link {
    margin: 2px 4px;
    text-align: center;
}

.htm-link a {
    display: inline-block;
    padding: 3px 6px;
    background: #e8f5e8;
    color: darkgreen;
    text-decoration: none;
    border-radius: 3px;
    border: 1px solid #d0e8d0;
    font-size: 0.8em;
    font-weight: bold;
}

.htm-link a:hover {
    background: #d0e8d0;
}

.nfo-link {
    margin: 2px 4px;
    text-align: center;
}

.nfo-link a {
    display: inline-block;
    padding: 3px 6px;
    background: #e8f5e8;
    color: darkgreen;
    text-decoration: none;
    border-radius: 3px;
    border: 1px solid #d0e8d0;
    font-size: 0.8em;
    font-weight: bold;
    margin-top: 2px;
}

.nfo-link a:hover {
    background: #d0e8d0;
    text-decoration: none;
}

/* =============================================================================
 *   4. FULLSCREEN-OVERLAY
 * ============================================================================= */

.overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

/* Wrapper um das Bild als Bezugspunkt */
.overlay-image-wrapper {
    position: relative;
    display: inline-block;
    max-width: 90vw;
    max-height: 90vh;
}

#overlay {
touch-action: pan-y pinch-zoom;
overscroll-behavior: contain;
}

#overlayImg {
max-width: 90vw;
max-height: 90vh;
width: auto;
height: auto;
object-fit: contain;
object-position: center;
margin: 8px auto 0;
display: block;

transform-origin: center center;
transform: translate(0, 0) scale(1);
touch-action: pan-y pinch-zoom;  /* Smartphones dürfen zoomen */
}

.overlay-inner {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}

/* Overlay-Close immer sichtbar und oben */
.overlay-close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 10;
    font-size: 2rem;
    line-height: 1;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: rgba(0,0,0,0.5);
    border-radius: 50%;
    cursor: pointer;
}

.overlay-close:hover {
    background: rgba(0,0,0,0.8);
    transform: scale(1.1);
}
.overlay-text-top {
    display: none;
    width: 100%;
    padding: 0.75rem 0.8rem 0.5rem;
    text-align: center;
    font-size: 0.9rem;
    color: #fff;
}

.overlay-text-top #overlayTextMobile {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.overlay-nav {
    position: fixed;
    bottom: 10px;
    left: 0;
    width: 97%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 20px;
    z-index: 1001;
    background: none;
}

.overlay-nav-buttons {
    display: flex;
    align-items: center;
    gap: 10px;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 25px;
    padding: 1px 1px 5px 10px;
    width: 15%;
}

.overlay-nav button {
    background: none;
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.overlay-text-right {
    font-size: 20px;
    color: rgba(255, 255, 255, 0.9);
    text-align: right;
    background: rgba(0, 0, 0, 0.75);
    border-radius: 25px;
    padding: 8px 34px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 800px;
    width: 30%;
}

#overlayCounter {
font-weight: 500;
text-align: center;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 300px;
color: white;
padding: 5px 0px 0px 0px;
}

/* Optional-Overlay-Klassen */
.overlay-text-desktop {
    padding: 0 0.5rem;
}

.overlay-text-mobile {
    display: none;
}

/* ==============================================================================
 *   5. KEINE ERGEBNISSE & COPY-BUTTON
 * ============================================================================= */

.no-results {
    grid-column: 1 / -1;
    text-align: center;
    font-style: italic;
    color: #666;
    padding: 40px;
    font-size: 1.1em;
}

.copy-button-container {
    position: absolute;
    bottom: 12px;
    right: 12px;
    z-index: 10;
}

.copy-link-btn {
    background: rgba(255, 255, 255, 0.9);
    border: 2px solid rgba(76, 175, 80, 0.5);
    font-size: 1.1em;
    cursor: pointer;
    padding: 8px 12px;
    border-radius: 50%;
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.copy-link-btn:hover {
    background: #4CAF50;
    color: white;
    transform: scale(1.1) rotate(8deg);
    box-shadow: 0 6px 20px rgba(76, 175, 80, 0.4);
}

.copy-link-btn:active {
    transform: scale(0.95);
}

/* Tooltip-Bestätigung */
.copy-feedback {
    position: absolute;
    background: #4CAF50;
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.85em;
    pointer-events: none;
    z-index: 1000;
    opacity: 0;
    transition: opacity 0.3s;
}

/* Toast-Notification */
.toast-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: linear-gradient(135deg, #4CAF50, #45a049);
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95em;
    box-shadow: 0 8px 32px rgba(76, 175, 80, 0.4);
    z-index: 10000;
    transform: translateX(400px);
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.toast-notification.show {
    transform: translateX(0);
    opacity: 1;
}

.toast-notification.hide {
    transform: translateX(400px);
    opacity: 0;
}

/* Media-Box: Platz für Copy-Button */
.media-box .text-container {
    position: relative;
    padding-bottom: 60px;
}

/* =============================================================================
 *   6. Nachladebutton
 * ============================================================================= */

.load-more-container {
    text-align: center;
    margin: 1rem 0;
    padding: 0px;
}

#loadNextRow {
padding: 0.8rem 1.5rem;
margin: 0px 0px 5px;
background: linear-gradient(135deg, #2d5016, #45a049);
color: #ffff00;
border: none;
border-radius: 25px;
font-size: 1rem;
cursor: pointer;
min-width: 200px;
transition: all 0.3s ease;
}

#loadNextRow:hover:not(:disabled) {
transform: translateY(-2px);
box-shadow: 0 4px 12px rgba(76, 175, 80, 0.4);
}

#loadNextRow:disabled {
opacity: 0.5;
cursor: not-allowed;
transform: none;
}

#loadAllRows {
padding: 0.8rem 1.5rem;
margin: 5px 0px 0px 0px !important;
background: #ffff00;
color: #2d5016;
border: none;
border-radius: 25px;
font-size: 1rem;
cursor: pointer;
margin-left: 1rem;
}

/* =============================================================================
 *   7. MOBILE-OPTIMIERUNG (RESPONSIVE)
 * ============================================================================= */

/* Mobile- und Tablet-Layout */
@media (max-width: 768px) {

    header img {
        max-width: 500px;
    }

    .filters.desktop-only {
        display: none !important;
    }

    .grid {
        grid-template-columns: 1fr;
        gap: 15px;
        padding: 10px;
        width: 100%;
        margin: 0;
    }

    .media-box {
        height: auto !important;
        min-height: 420px;
        max-height: none;
        padding: 8px;
        box-sizing: border-box;
        width: 100%;
        max-width: 100%;
    }

    .text-container {
        padding: 4px 8px 70px 8px;
        min-height: 55px;
        height: auto;
        flex-shrink: 0;
        width: 100%;
        box-sizing: border-box;
    }

    .box-title {
        font-size: 0.8em;
        padding: 4px 6px;
    }

    .links {
        font-size: 0.72em;
        gap: 2px;
    }

    .links a {
        padding: 3px 5px;
        font-size: 1.2em;
        margin: 3px;
        border-radius: 10px;
    }

    .nfo-link a {
        padding: 2px 4px;
        font-size: 0.75em;
    }

    .copy-button-container {
        position: absolute;
        bottom: 8px;
        right: 8px;
        z-index: 10;
    }

    /* ============================================================================
     *       7A. MOBILE-OPTIMIERUNG – OVERLAY
     *    ============================================================================ */

    #overlay {
    align-items: flex-start;
    }

    .overlay-close {
        position: absolute !important;
        top: 10px !important;
        right: 0px !important;
        z-index: 20 !important;
    }

    .overlay-text-top {
        display: block;
    }

    .overlay-text-right {
        display: none;
    }

    .overlay-nav button {
        font-size: 1.8rem;
        padding: 5px 15px;
        width: 40px;
        height: 40px;
    }

    .overlay-nav-buttons {
        padding: 2px 0 8px 10px;
        width: 50%;
    }

    #overlayCounter {
    font-size: 1rem;
    padding: 6px 0 0 0;
    }

    .overlay-text-top #overlayTextMobile {
        white-space: nowrap;
        display: block;
        border-radius: 10px;
        background-color: black;
        width: 95%;
        font-size: 16px;
        padding: 2px 0px;
    }
}

/* Extra-kleine Bildschirme (z. B. Handy) */
@media (max-width: 480px) {

    .media-box {
        height: 400px;
    }

    .media-box img,
    .media-box video {
        max-height: 290px;
    }

    .box-title {
        font-size: 0.75em;
        padding: 3px 5px;
    }

    header img {
        max-width: 300px;
    }

    .overlay-inner {
        padding-top
    }
}
