
.gallery-page {
    display: block;
    overflow-y: visible;
    padding-bottom: 50px;
}

.gallery-intro {
    text-align: center;
    padding: 60px 20px;
    background-color: var(--bg-color);
    position: relative;
    z-index: 1;
    width: 100%;
}

/* --- NAUJAS HORIZONTALUS TINKLELIS (DESKTOP) --- */
.masonry-grid {
    display: flex;
    flex-wrap: wrap;       /* Leidžia nuotraukoms keltis į kitą eilutę */
    gap: 25px;             /* Tarpas tarp kortelių */
    justify-content: center; 
    padding: 20px;
    max-width: 1400px;     /* Apribojame maksimalų galerijos plotį centre */
    margin: 0 auto;
}

.gallery-item {
    background: white;
    padding: 12px 12px 35px 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.08);
    transition: all 0.4s ease;
    cursor: zoom-in;
    display: flex;
    flex-direction: column;
    
    /* Horizontalus vaizdas: vienodas aukštis visoms kortelėms */
    height: 380px; 
    flex: 1 1 300px;       /* Bazinis plotis 300px, bet gali augti */
    max-width: 500px;
}

/* Horizontalioji asimetrija (valdoma per JS priskiriamas klases) */
.gallery-item.tall { 
    flex: 2 1 450px;       /* Platesnė nuotrauka */
}

.gallery-item.short { 
    flex: 0.7 1 200px;     /* Siauresnė nuotrauka */
}

.gallery-item img {
    width: 100%;
    height: 100%;          /* Užpildo kortelės vidų */
    object-fit: cover;     /* Nukerpa nuotrauką, kad ji užpildytų plotą */
    border-radius: 2px;
}

.gallery-item p {
    font-family: var(--header-font);
    margin-top: 15px;
    font-size: 0.9rem;
    color: var(--accent-color);
    text-align: center;
}

.gallery-item:hover {
    transform: translateY(-10px) rotate(2deg);
    box-shadow: 0 20px 40px rgba(0,0,0,0.15);
    z-index: 5;
}

/* --- MOBILUS VAIZDAS (iPhone ir kiti) --- */
@media (max-width: 600px) {
    .masonry-grid {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    .gallery-item {
        width: 100%;
        height: auto;      /* Leidžiame nuotraukai turėti savo natūralų aukštį */
        flex: none;
    }

    .gallery-item img {
        height: 250px;     /* Fiksuotas aukštis nuotraukai telefone */
    }
}

/* --- IDENTIŠKAS MODALINIS LANGAS IŠ ISTORIJOS --- */
.modal {
    display: none; 
    position: fixed;
    z-index: 2000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(45, 62, 48, 0.8); 
    backdrop-filter: blur(5px);
}

.modal-content {
    background-color: var(--bg-color);
    margin: 2% auto;
    padding: 1.5rem;
    border-radius: 8px;
    width: 95%;
    max-width: 900px;
    position: relative;
    box-shadow: 0 15px 50px rgba(0,0,0,0.3);
    max-height: 90vh; 
    overflow-y: auto;
    overflow-x: hidden;
}

.close-modal {
    position: absolute;
    top: 20px;
    right: 25px;
    color: var(--accent-color);
    font-size: 35px;
    font-weight: bold;
    cursor: pointer;
    z-index: 2100;
}

.close-modal:hover {
    color: #000;
}

#modalTitle {
    font-family: var(--header-font);
    color: var(--accent-color);
    text-align: center;
    margin-bottom: 1rem;
}

hr {
    border: none;
    border-top: 1px solid rgba(45, 62, 48, 0.1);
    margin-bottom: 1.5rem;
}

#modalBody {
    animation: fadeIn 0.4s ease;
}

#modalBody img {
    max-height: 70vh; 
    width: auto;
    max-width: 100%;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    border-radius: 4px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}