/* ==========================================================================
   Basis & Dark Mode
   ========================================================================== */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body.dark-mode {
    background-color: #0a0a0a;
    color: #eeeeee;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   Übersicht / Galerie-Grid (Masonry "Waterfall" Layout im 500px-Style)
   ========================================================================== */
.overview-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

.controls {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    gap: 15px;
}

.controls h1 {
    font-size: 1.5rem;
    color: #fff;
    word-break: break-word;
}

#search-input {
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid #333;
    background: #111;
    color: white;
    font-size: 1rem;
    width: 100%;
    max-width: 300px;
}
#search-input:focus { outline: none; border-color: #4CAF50; }

.story-grid {
    column-count: 4;
    column-gap: 20px;
    padding-bottom: 30px;
}

@media (max-width: 1200px) { .story-grid { column-count: 3; } }
@media (max-width: 800px) { .story-grid { column-count: 2; column-gap: 15px; } }
@media (max-width: 500px) { .story-grid { column-count: 1; } }

.story-card {
    background: #161616;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94), box-shadow 0.3s ease, filter 0.3s ease;
    position: relative;
    border: 1px solid #2a2a2a;
    break-inside: avoid;
    page-break-inside: avoid;
    margin-bottom: 20px;
    display: block;
    width: 100%;
    filter: brightness(0.85);
}

.story-card > div[style*="background:#111"] {
    height: auto !important;
    aspect-ratio: 1 / 1;
    width: 100%;
}

.story-card:hover, .story-card:active {
    transform: translateY(-5px) scale(1.02);
    box-shadow: 0 20px 40px rgba(0,0,0,0.8);
    border-color: #555;
    filter: brightness(1.1);
    z-index: 2;
}

.story-card img {
    width: 100%;
    height: auto;
    display: block;
}

.story-card .info {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.95) 0%, rgba(0,0,0,0.5) 60%, transparent 100%);
    padding: 40px 15px 15px 15px;
    backdrop-filter: blur(1px);
    transition: padding 0.3s ease;
}

.story-card:hover .info {
    padding-bottom: 20px;
}

.story-card .info h3 {
    font-size: 1.05rem;
    color: #fff;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 500;
    text-shadow: 0 2px 5px rgba(0,0,0,0.9);
    letter-spacing: 0.5px;
}

/* ==========================================================================
   Vollbild-Viewer & Scroll-Snapping
   ========================================================================== */
.viewer-wrapper {
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: #000;
    z-index: 100;
}

.story-viewer {
    width: 100%; height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    scroll-snap-type: y mandatory;
    scroll-behavior: smooth;
}

.node {
    width: 100vw;
    height: 100vh;
    scroll-snap-align: start;
    position: relative;
    display: flex;
    flex-direction: column;
}

.sequence-wrapper {
    width: 100%;
    height: 100%;
}

.node-sequence {
    position: relative;
    width: 100%; 
    height: 100%;
    overflow: hidden; 
    display: block; 
}

.sequence-item {
    position: absolute;
    top: 0; left: 0;
    width: 100vw;
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0; 
    transition: opacity 0.15s ease-out;
    pointer-events: none; 
}

.sequence-item.active {
    opacity: 1; 
    pointer-events: auto;
    z-index: 1;
}

.sequence-item img, .sequence-item video {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
}

.node-text {
    max-width: 800px;
    margin: auto;
    padding: 20px;
    color: #eee;
    font-size: 1.1rem;
    line-height: 1.7;
}

/* ==========================================================================
   Navigation (Controller) - Vollständig Skalierbar (Mobile First)
   ========================================================================== */
#viewer-controls {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(20, 20, 20, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid #444;
    padding: 4px 6px;
    border-radius: 40px;
    display: flex;
    flex-wrap: nowrap;
    justify-content: center; 
    align-items: center;
    gap: 3px;
    z-index: 500;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
    max-width: 98vw;
    overflow-x: auto; 
    -ms-overflow-style: none;
    scrollbar-width: none;
    transition: opacity 0.3s ease, transform 0.4s cubic-bezier(0.25, 1, 0.5, 1), left 0.4s cubic-bezier(0.25, 1, 0.5, 1), padding 0.3s ease, border-radius 0.3s ease;
}

#viewer-controls::-webkit-scrollbar {
    display: none; 
}

#viewer-controls div {
    width: 4px !important;
    flex-shrink: 0;
}

#viewer-controls.collapsed {
    left: 15px;
    transform: translateX(0);
    padding: 5px;
    gap: 0;
    border-radius: 50%;
}

#viewer-controls.collapsed .nav-btn:not(#nav-toggle-collapse),
#viewer-controls.collapsed div {
    display: none !important;
}

#viewer-controls.hidden {
    opacity: 0 !important;
    pointer-events: none !important;
    transform: translateX(-50%) translateY(20px);
}

.nav-btn {
    background: #333;
    color: white;
    border: none;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    font-size: 0.8rem;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    flex-shrink: 0; 
    touch-action: manipulation;
    transition: background 0.2s, opacity 0.2s, transform 0.1s;
}

.nav-btn:hover:not(:disabled) {
    background: #555;
    transform: scale(1.05);
}

.nav-btn:disabled {
    opacity: 0.15;
    cursor: not-allowed;
    background: #222;
}

.nav-btn.hi-res {
    background: #3498db;
    color: white;
    box-shadow: 0 0 15px rgba(52, 152, 219, 0.8);
}
.nav-btn.hi-res:hover:not(:disabled) {
    background: #2980b9;
    transform: scale(1.05);
}

.nav-close { background: #ff5555; margin-left: 2px; }
.nav-close:hover:not(:disabled) { background: #ff3333; }

#nav-toggle-collapse { background: #2a2a2a; border: 1px solid #555; margin-left: 2px; }
#nav-toggle-collapse:hover { background: #444; }

@media (min-width: 450px) {
    #viewer-controls { gap: 5px; padding: 6px 10px; }
    .nav-btn { width: 34px; height: 34px; font-size: 0.95rem; }
    #viewer-controls div { width: 8px !important; }
    #viewer-controls.collapsed { left: 20px; }
}

@media (min-width: 800px) {
    #viewer-controls { gap: 8px; padding: 8px 16px; }
    .nav-btn { width: 40px; height: 40px; font-size: 1.1rem; }
    #viewer-controls div { width: 12px !important; }
}

/* ==========================================================================
   Overlays & Captions
   ========================================================================== */
.media-caption {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 0.95rem;
    text-align: center;
    width: 90%;
    max-width: 600px;
    z-index: 10;
    pointer-events: none;
    backdrop-filter: blur(4px);
    transition: opacity 0.3s ease;
    border: 1px solid rgba(255,255,255,0.1);
}

body.hide-captions .media-caption { opacity: 0 !important; }

#info-overlay {
    position: fixed;
    top: 20px; left: 20px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    padding: 20px;
    border-radius: 8px;
    color: white;
    z-index: 1000;
    border: 1px solid #444;
    max-width: calc(100vw - 40px);
    pointer-events: none;
    transition: opacity 0.2s ease;
}

#info-overlay.hidden { opacity: 0 !important; pointer-events: none !important; }

#help-overlay {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(10px);
    padding: 30px;
    border-radius: 8px;
    color: white;
    z-index: 10050;
    border: 1px solid #444;
    min-width: 320px;
    max-width: 90vw;
    transition: opacity 0.2s ease;
}

#help-overlay.hidden { opacity: 0 !important; pointer-events: none !important; }

.exif-list { list-style: none; padding: 0; margin-top: 15px; font-size: 0.9rem; }
.exif-list li { display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid #333; padding: 6px 0; }
.exif-list span { color: #aaa; }

kbd {
    background: #222;
    border: 1px solid #555;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 0.85rem;
    color: #fff;
    box-shadow: 0 2px 0 #111;
    margin: 0 2px;
}

.fm-btn { 
    padding: 10px 20px; 
    background: #333; 
    color: white; 
    border: none; 
    border-radius: 4px; 
    cursor: pointer; 
    font-weight: bold; 
    touch-action: manipulation; 
}
.fm-btn:hover { background: #444; }
.fm-btn.primary { background: white; color: black; }

#toast-notification {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    color: white;
    padding: 15px 30px;
    border-radius: 50px;
    font-size: 1.1rem;
    font-weight: bold;
    z-index: 10500;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.3s ease;
    border: 1px solid #444;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0,0,0,0.8);
}

#toast-notification.show { opacity: 1; }

.dark-map-popup .leaflet-popup-content-wrapper { background: #1a1a1a; color: #eee; border: 1px solid #444; border-radius: 8px; }
.dark-map-popup .leaflet-popup-tip { background: #1a1a1a; border: 1px solid #444; }
.dark-map-popup .leaflet-popup-close-button { color: #aaa !important; }
.dark-map-popup .leaflet-popup-close-button:hover { color: #fff !important; }
.dark-map-popup .leaflet-popup-content { margin: 15px; line-height: 1.5; font-size: 1rem; }
.dark-map-popup .leaflet-popup-content img { max-width: 100%; height: auto; border-radius: 4px; }

.transparent-text-marker { display: flex; justify-content: center; align-items: center; width: 0 !important; height: 0 !important; overflow: visible; }
.text-marker-content {
    background: rgba(255, 255, 255, 0.75); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); color: #111; padding: 8px 14px;
    border-radius: 8px; font-size: 0.95rem; box-shadow: 0 4px 15px rgba(0,0,0,0.3); min-width: 100px; max-width: 280px; cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.4); transform: translate(-50%, -50%); white-space: normal; width: max-content;
    overflow-wrap: break-word; pointer-events: auto; transition: transform 0.2s, background 0.2s;
}
.text-marker-content:hover { background: rgba(255, 255, 255, 0.95); transform: translate(-50%, -50%) scale(1.02); }
.text-marker-content * { margin: 0; padding: 0; }
.text-marker-content p { margin-bottom: 6px; line-height: 1.3; }
.text-marker-content p:last-child { margin-bottom: 0; }
.text-marker-content a { color: #2980b9; text-decoration: underline; font-weight: 500; }

/* ==========================================================================
   Floating "Weiter" Button
   ========================================================================== */
#floating-next-btn {
    position: fixed;
    bottom: 80px;
    right: 15px;
    z-index: 600;
    background: rgba(52, 152, 219, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    border: 1px solid rgba(255, 255, 255, 0.3);
    padding: 6px 12px;
    border-radius: 30px;
    font-size: 0.85rem;
    font-weight: bold;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    gap: 4px;
    transition: opacity 0.3s ease, transform 0.3s ease, background 0.2s;
}

#floating-next-btn span {
    font-size: 0.9rem !important;
}

#floating-next-btn:hover {
    background: rgba(52, 152, 219, 0.5);
    transform: translateY(-3px);
}

#floating-next-btn:active {
    transform: translateY(1px);
}

#floating-next-btn.hidden {
    opacity: 0;
    pointer-events: none;
    transform: translateY(20px);
}

@media (min-width: 800px) {
    #floating-next-btn {
        bottom: 22px;
        padding: 8px 15px;
        font-size: 0.9rem;
    }
}