/* Variablen für konsistentes Design */
:root {
    --background-color: #f5f5f5; /* Hintergrundfarbe */
    --text-color: #333; /* Textfarbe */
    --interaction-bar-color: #ffffff; /* Farbe für Interaktions-Buttons */
}

/* Container für alle Modale */
.modal-container {
    display: none;
    flex-direction: column;
    height: 100vh;
    width: 100vw;
    position: fixed;
    top: 0;
    left: 0;
    z-index: 1000;
    overflow-y: scroll;
    scroll-snap-type: y mandatory;
    background-color: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(8px);
    opacity: 0;
    transition: opacity 0.3s ease; /* Fade-In-Animation */
    scroll-snap-type: y mandatory;
    scroll-padding-top: 0; /* Optional für besseres Snappen */
}

/* Einzelnes Modal */
.modal-item {
    flex-shrink: 0;
    scroll-snap-align: start;
    height: 100vh;
    width: 100%;
    display: flex;
    transition: transform 0.5s cubic-bezier(0.25, 0.1, 0.25, 1), opacity 0.5s ease; /* Verlängerte und weichere Transition für Einrasten */
    position: relative;
    scroll-snap-align: start;
}

/* Modal-Inhalt */
.modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    padding-bottom: calc(env(safe-area-inset-bottom) + 100px); /* Mehr Platz für Safari-Leiste */
    touch-action: none; /* Verhindert Standard-Zoomen, Hammer.js übernimmt */
    transition: filter 0.3s ease; /* Sanfte Übergangsanimation */
}

/* Hauptinhaltsbereich */
.modal-main-content {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* Media-Container */
.media-container {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

/* Medien (Bilder und Videos) */
.media-container img,
.media-container video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
    touch-action: pinch-zoom; /* Ermöglicht Pinch-to-Zoom */
}

/* Zoom-Container */
.zoom-container {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: transparent;
    touch-action: pinch-zoom; /* Ermöglicht Pinch-to-Zoom */
}

.zoomable-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    transform-origin: center;
    transition: transform 0.2s ease; /* Sanfte Zoom- und Panning-Animation */
    user-select: none; /* Verhindert Textauswahl */
    -webkit-user-select: none; /* Safari */
}

/* Zurück-Button */
.back-button {
    position: absolute;
    top: 20px;
    left: 20px;
    font-size: 1.5rem;
    color: white;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.5));
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.back-button:hover {
    background: linear-gradient(135deg, rgba(255, 255, 255, 0.9), rgba(255, 255, 255, 0.7));
    color: var(--theme-color);
    transform: scale(1.1);
}

/* Interaktions-Buttons */
.interaction-buttons {
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.5));
    padding: 10px;
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 150;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.interaction-button {
    background: none;
    border: none;
    color: var(--interaction-bar-color);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    border-radius: 8px;
    transition: background 0.2s ease, transform 0.2s ease, color 0.2s ease;
}

.interaction-button:hover,
.interaction-button:active {
    background: rgba(255, 255, 255, 0.1);
    color: var(--theme-color);
    transform: scale(1.15);
}

.interaction-button span {
    font-size: 1rem;
    font-weight: 600;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

/* Infobar */
.info-bar {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 100px);
    left: 15px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.50), rgba(0, 0, 0, 0.30));
    color: white;
    padding: 15px 20px;
    border-radius: 12px;
    font-size: 1rem;
    max-width: 320px;
    z-index: 150;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transform: translateY(20px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}

.modal-open .info-bar {
    transform: translateY(0);
    opacity: 0.6;
}

.comments-overlay.active ~ .info-bar {
    transform: translateY(20px);
    opacity: 0;
}

.info-bar p {
    margin: 5px 0;
    line-height: 1.6;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.info-bar strong {
    color: var(--theme-color);
}

/* Kommentar-Overlay */

.comments-overlay {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0; /* Immer ganz unten */
    width: 100%;
    max-height: calc(80vh - env(safe-area-inset-bottom, 0px));
    padding-bottom: calc(env(safe-area-inset-bottom, 0px) + 120px); /* schützt vor iOS-Leiste */
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.85), rgba(0, 0, 0, 0.65));
    color: white;
    display: flex;
    flex-direction: column;
    padding-top: 12px;
    padding-left: 12px;
    padding-right: 12px;
    box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.4);
    overflow-y: auto;
    z-index: 2000;
    border-radius: 12px 12px 0 0;
    transform: translateY(100%);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
}


.comments-overlay.active {
    transform: translateY(0px); /* Slide nach oben */
    bottom: env(safe-area-inset-bottom);
    opacity: 1;
}

.comments-overlay:not(.active) {

}


.comments-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.comments-header span {
    font-size: 1.1rem;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
}

.close-comments {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
}

.close-comments:hover,
.close-comments:active {
    color: var(--theme-color);
    transform: scale(1.1);
}

.comments-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.comment {
    padding: 8px;
    margin: 4px 0;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 6px;
    font-size: 0.9rem;
}

.comment-input {
    flex: 1;
    padding: 10px;
    border: none;
    border-radius: 8px 0 0 8px;
    background: #fff;
    color: var(--text-color);
    font-size: 0.9rem;
}

.comments-content button {
    padding: 10px 18px;
    background: var(--theme-color);
    color: white;
    border: none;
    border-radius: 0 8px 8px 0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease, transform 0.2s ease;
}

.comments-content button:hover,
.comments-content button:active {
    background: #0056b3;
    transform: scale(1.05);
}

/* Comment-Preview-Zone */
.comment-preview-zone {
    position: absolute;
    bottom: calc(env(safe-area-inset-bottom) + 80px);
    left: 0;
    width: 100%;
    text-align: center;
    font-size: 1rem;
    color: #f1f1f1;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px;
    border-radius: 8px;
    transition: opacity 0.3s ease;
    z-index: 100;
    cursor: pointer; /* Interaktivität für Klick */
}

.comment-preview-zone.hidden {
    display: none;
}

/* Collection-Title-Image */
.collection-title-image {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    overflow: hidden;
    cursor: pointer;
    z-index: 150;
    border: 2px solid var(--theme-color);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: all 0.3s ease;
}

.collection-title-image:hover {
    transform: scale(1.1);
    border-color: var(--accent-color);
}

/* Collection-Auswahl-Overlay */
.collection-selection-overlay {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 90%;
    max-width: 400px;
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    color: white;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
    z-index: 300;
    display: none;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.collection-selection-overlay.active {
    display: block;
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.collection-selection-overlay:not(.active) {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.9);
}

.collection-selection-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding-bottom: 10px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.collection-selection-header h3 {
    margin: 0;
    font-size: 1.2rem;
    font-weight: bold;
}

.close-overlay {
    background: none;
    border: none;
    color: white;
    font-size: 1.1rem;
    cursor: pointer;
    transition: color 0.3s ease, transform 0.2s ease;
}

.close-overlay:hover,
.close-overlay:active {
    color: var(--theme-color);
    transform: scale(1.1);
}

.collection-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: 300px;
    overflow-y: auto;
}

.collection-item-inside {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s ease, transform 0.2s ease;
}

.collection-item-inside:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.02);
}

.collection-item-inside img {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 8px;
}

.collection-item-inside p {
    margin: 0;
    font-size: 0.9rem;
    font-weight: 500;
}

/* Herz-Animation */
.heart-animated {
    position: absolute;
    font-size: 40px;
    color: red;
    opacity: 0;
    animation: float 4s cubic-bezier(0.25, 1, 0.5, 1) forwards, fade-out 4s ease-in forwards;
    z-index: 1001;
}

@keyframes float {
    0% { transform: translateY(0) translateX(0) scale(1) rotate(0deg); }
    10% { transform: translateY(-50px) translateX(-5px) scale(1.02) rotate(-2deg); }
    20% { transform: translateY(-100px) translateX(10px) scale(1.05) rotate(4deg); }
    30% { transform: translateY(-150px) translateX(-15px) scale(1.03) rotate(-3deg); }
    40% { transform: translateY(-200px) translateX(10px) scale(1) rotate(2deg); }
    50% { transform: translateY(-250px) translateX(-5px) scale(0.98) rotate(-1deg); }
    60% { transform: translateY(-300px) translateX(5px) scale(0.95) rotate(1deg); }
    70% { transform: translateY(-350px) translateX(-10px) scale(0.92) rotate(0deg); }
    80% { transform: translateY(-400px) translateX(5px) scale(0.9) rotate(-1deg); }
    90% { transform: translateY(-450px) translateX(0px) scale(0.88) rotate(0deg); }
    100% { transform: translateY(-500px) translateX(0) scale(0.85) rotate(0deg); }
}

@keyframes fade-out {
    0% { opacity: 1; }
    90% { opacity: 0.5; }
    100% { opacity: 0; }
}

/* Toast-Benachrichtigung */
.toast {
    position: fixed;
    bottom: calc(env(safe-area-inset-bottom) + 20px);
    left: 50%;
    transform: translateX(-50%);
    background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6));
    color: white;
    padding: 10px 20px;
    border-radius: 8px;
    z-index: 1000;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    transition: opacity 0.3s ease;
}

/* Ladeanimation */
.spinner {
    text-align: center;
    padding: 10px;
    font-size: 0.9rem;
    color: #f1f1f1;
}

/* Responsive Anpassungen für mobile Geräte */
@media (max-width: 768px) {

    .modal-main-content {
        height: 100%;
    }

    .interaction-buttons {
        gap: 8px;
        padding: 8px;
        right: 8px;
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.6));
    }

    .interaction-button {
        font-size: 1rem;
        padding: 6px;
    }

    .info-bar {
        bottom: calc(env(safe-area-inset-bottom) + 120px);
        left: 10px;
        max-width: 280px;
        font-size: 0.9rem;
        padding: 12px 15px;
        background: linear-gradient(135deg, rgba(0, 0, 0, 0.9), rgba(0, 0, 0, 0.7));
    }

    .back-button {
        top: 15px;
        left: 15px;
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }



    .comments-header span {
        font-size: 1rem;
    }

    .close-comments {
        font-size: 1rem;
    }

    .comment-input {
        font-size: 0.8rem;
        padding: 8px;
    }

    .comments-content button {
        font-size: 0.8rem;
        padding: 8px 15px;
    }

    .comment-preview-zone {
        bottom: calc(env(safe-area-inset-bottom) + 70px);
        font-size: 0.9rem;
    }

    .collection-selection-overlay {
        width: 95%;
        padding: 15px;
    }

    .collection-selection-header h3 {
        font-size: 1rem;
    }

    .collection-item-inside img {
        width: 40px;
        height: 40px;
    }

    .collection-item-inside p {
        font-size: 0.8rem;
    }
}