﻿/* =========================
   GLOBAL
   ========================= */

* {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
    background: #fafafa;
    color: #222;
}

.page {
    padding-left: 20px;
    padding-right: 20px;
    padding-bottom: 24px;
}

/* =========================
   TOOLBAR
   ========================= */

.toolbar {
    margin-bottom: 16px;
}

/* =========================
   GALLERY / THUMBNAILS
   ========================= */

.gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    position: relative;
    z-index: 1;
}

.thumb {
    display: block;
    width: 100%;
    padding: 0;
    margin: 0;
    border: 0;
    background: transparent;
    cursor: pointer;
    text-decoration: none;
    text-align: left;
    position: relative;
    appearance: none;
    -webkit-appearance: none;
}

.thumb-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.thumb-img {
    width: 100% !important;
    height: 160px !important;
    object-fit: cover !important;
    display: block;
    border-radius: 10px;
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    transition: transform 0.12s ease, box-shadow 0.12s ease;
}

    .thumb-img:hover {
        transform: scale(1.02);
        box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18);
    }

.thumb-date {
    margin-top: 6px;
    font-size: 13px;
    line-height: 1.2;
    color: rgba(0, 0, 0, 0.75);
    pointer-events: none;
}

/* =========================
   VIDEO PLAY OVERLAY
   ========================= */

.video-thumb {
    position: relative;
    width: 100%;
}

    /* Das Bild definiert die Höhe */
    .video-thumb .thumb-img {
        display: block;
    }

/* Overlay exakt über dem Bild */
.video-play-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 46px;
    /* color: white; */
    color: rgba(255, 255, 255, 0.5);
    text-shadow: 0 4px 12px rgba(0,0,0,0.6);
    background: radial-gradient( circle at center, rgba(0,0,0,0.35) 0%, rgba(0,0,0,0.15) 40%, rgba(0,0,0,0.05) 60%, rgba(0,0,0,0.0) 70% );
    pointer-events: none; /* extrem wichtig */
    border-radius: 10px;
}

/* optionales Hover-Feedback (Desktop) */
.thumb:hover .video-play-overlay {
    transform: scale(1.05);
    transition: transform 0.15s ease;
    color: rgba(255, 255, 255, 0.5);
}

/* =========================
   DOCUMENT (PDF) THUMBNAIL
   ========================= */

.doc-thumb {
    position: relative;
    width: 100%;
}

    .doc-thumb .thumb-img {
        display: block;
    }

.doc-type-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.9);
    text-shadow: 0 2px 8px rgba(0,0,0,0.5);
    background: radial-gradient( circle at center, rgba(220,53,69,0.4) 0%, rgba(220,53,69,0.15) 40%, rgba(0,0,0,0.0) 70% );
    pointer-events: none;
    border-radius: 10px;
    letter-spacing: 2px;
}

.thumb:hover .doc-type-overlay {
    transform: scale(1.05);
    transition: transform 0.15s ease;
}

/* PDF-Viewer im Overlay (iframe) */
.doc-viewer {
    width: 100%;
    height: 100%;
    border: none;
    background: white;
    border-radius: 4px;
}

/* =========================
   SKELETON (LOADING)
   ========================= */

.skeleton {
    background: linear-gradient(90deg, #eaeaea 25%, #f5f5f5 37%, #eaeaea 63%);
    background-size: 400% 100%;
    animation: shimmer 1.2s ease-in-out infinite;
    height: 160px;
    border-radius: 10px;
    pointer-events: none !important;
}

.gallery > .thumb[aria-hidden="true"] {
    pointer-events: none !important;
}

@keyframes shimmer {
    0% {
        background-position: 100% 0;
    }

    100% {
        background-position: 0 0;
    }
}

/* =========================
   SCROLL SENTINEL
   ========================= */

.scroll-sentinel {
    height: 1px;
    pointer-events: none !important;
    position: relative;
    z-index: 0;
}

/* =========================
   OVERLAY / LIGHTBOX
   ========================= */

.overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.viewer {
    position: relative;
    width: 100vw;
    height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.media-surface {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* HUD Hinweis */
.hud {
    position: absolute;
    top: 18px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.45);
    color: rgba(255,255,255,0.95);
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 14px;
    z-index: 10001;
    user-select: none;
    pointer-events: none;
}

.full {
    display: block !important;
    width: auto !important;
    height: auto !important;
    max-width: 96vw !important;
    max-height: 92vh !important;
    object-fit: contain !important;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    cursor: pointer;
}

video.full {
    background: black;
}

/* ✅ Pinch-Zoom: Bild soll Touch-Gesten selbst bekommen */
.zoomable {
    touch-action: none; /* wichtig für iOS/Touch */
    -webkit-user-drag: none;
    user-select: none;
}

/* =========================
   NAVIGATION (PFEILE)
   ========================= */

.nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 52px;
    height: 52px;
    border-radius: 999px;
    border: none;
    background: rgba(255, 255, 255, 0.15);
    color: white;
    font-size: 34px;
    line-height: 52px;
    cursor: pointer;
    user-select: none;
}

    .nav:hover {
        background: rgba(255, 255, 255, 0.25);
    }

    .nav.left {
        left: 12px;
    }

    .nav.right {
        right: 12px;
    }

@media (hover: hover) and (pointer: fine) {
    .nav {
        opacity: 0.0;
        transition: opacity 0.15s ease;
    }

    .overlay:hover .nav {
        opacity: 1.0;
    }
}

@media (hover: none) and (pointer: coarse) {
    .nav {
        opacity: 1.0;
    }
}

/* =========================
   CAPTION
   ========================= */

.caption {
    position: fixed;
    bottom: 14px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.95);
    padding: 8px 14px;
    border-radius: 999px;
    display: flex;
    gap: 14px;
    align-items: center;
    font-size: 14px;
}

    .caption .file {
        opacity: 0.85;
    }

/* =========================
   MOBILE IMPROVEMENTS
   ========================= */

@media (max-width: 768px) {
    .viewer {
        padding-left: max(12px, env(safe-area-inset-left));
        padding-right: max(12px, env(safe-area-inset-right));
    }

    .nav {
        width: 64px;
        height: 64px;
        font-size: 42px;
        line-height: 64px;
        background: rgba(255, 255, 255, 0.22);
    }

        .nav.left {
            left: max(10px, env(safe-area-inset-left));
        }

        .nav.right {
            right: max(10px, env(safe-area-inset-right));
        }

    .caption {
        bottom: max(14px, env(safe-area-inset-bottom));
    }

    .hud {
        top: max(18px, env(safe-area-inset-top));
    }
}
