* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Забороняємо сторінці розтягуватися вшир на мобільних */
html, body {
    max-width: 100%;
    overflow-x: hidden;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container {
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 20px;
}

main.container {
    margin-top: 30px;
    margin-bottom: 50px;
}

.header {
    background: #fff;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    position: sticky;
    top: 0;
    left: 0;
    right: 0; 
    width: 100%;
    z-index: 1000;
}

.header-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 70px;
}

.logo-img { max-height: 45px; width: auto; display: block; }
.assoc-logo-img { max-height: 40px; width: auto; display: block; }
.logo-text { text-decoration: none; font-size: 22px; font-weight: bold; color: #2E7D32; }

.main-nav {
    flex-grow: 1;
    display: flex;
    justify-content: flex-end;
    padding-right: 40px;
}

.main-nav ul {
    display: flex;
    list-style: none;
    gap: 30px;
    margin: 0;
    padding: 0;
}

.main-nav a {
    text-decoration: none;
    font-weight: 500;
    color: #333;
    transition: color 0.3s;
    font-size: 16px;
}

.main-nav a:hover, .main-nav a.active {
    color: #2E7D32;
    font-weight: bold;
}

.news-feed {
    max-width: 850px;
    margin: 0 auto;
}

.post {
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border-radius: 15px;
    margin-bottom: 40px;
    overflow: hidden; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.post-header {
    background: #1B5E20;
    padding: 25px 40px; 
    color: #fff;
}

.post-title {
    margin: 0;
    color: #fff !important;
    font-size: 1.6em;
}

.post-date {
    color: #A5D6A7;
    font-size: 0.85em;
    display: block;
    margin-bottom: 5px;
}

.post-content {
    padding: 40px 50px; 
    font-size: 1.1em;
    line-height: 1.7;
    overflow-wrap: break-word; /* Розриває довгі слова/посилання */
}

/* =========================================
   ВИПРАВЛЕННЯ ДЛЯ ВЕЛИКОГО КОНТЕНТУ
   ========================================= */
.post-content table {
    display: block;
    width: 100% !important;
    overflow-x: auto; /* Дозволяє гортати широку таблицю вправо-вліво пальцем */
    -webkit-overflow-scrolling: touch;
    border-collapse: collapse;
    margin-bottom: 20px;
}

.post-content img, .post-content iframe {
    max-width: 100% !important; /* Картинки і відео ніколи не вилізуть за межі екрана */
    height: auto;
}

.post-attachments {
    background: #f1f8e9;
    padding: 25px 30px;
    border-top: 1px solid #e8f5e9;
}

.footer {
    background: #1B5E20;
    color: #fff;
    padding: 40px 0;
    text-align: center;
    margin-top: auto;
}

.pagination {
    display: flex;
    justify-content: center;
    gap: 10px;
    margin: 20px 0 50px;
}

.pagination a {
    padding: 10px 18px;
    border: 1px solid #1B5E20;
    border-radius: 8px;
    text-decoration: none;
    color: #1B5E20;
    background: #fff;
    font-weight: bold;
    transition: 0.3s;
}

.pagination a.active, .pagination a:hover {
    background: #1B5E20;
    color: #fff;
}

.masonry-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    grid-auto-rows: minmax(150px, auto);
    gap: 15px;
    padding: 20px 50px 40px;
    background: transparent;
}

.masonry-gallery a {
    display: block;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0,0,0,0.15); 
    transition: transform 0.3s ease;
}

.masonry-gallery a:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.2);
}

.masonry-gallery img {
    width: 100%;
    height: 100%;
    object-fit: contain; 
    background-color: #f8f9fa; 
    display: block;
}

/* =========================================
   АДАПТИВНІСТЬ ДЛЯ МОБІЛЬНИХ ПРИСТРОЇВ
   ========================================= */
@media (max-width: 768px) {
    .container {
        padding: 0 15px; /* Трохи менші відступи по краях екрана для телефонів */
    }

    .header-container {
        padding: 0 15px;
        width: 100%;
    }

    .main-logo-area {
        flex-grow: 1;
        max-width: 80%;
    }
    
    .logo-img {
        max-height: 35px;
        width: auto;
        max-width: 100%;
        object-fit: contain;
    }

    .logo-text {
        font-size: 18px;
    }

    .main-nav {
        padding-right: 0;
        flex-grow: 0; 
    }

    .main-nav ul {
        display: none; 
        flex-direction: column;
        position: absolute;
        top: 70px;
        left: 0;
        width: 100vw;
        background: #ffffff;
        padding: 20px 0;
        box-shadow: 0 10px 15px rgba(0,0,0,0.1);
        gap: 15px;
        text-align: center;
        border-top: 1px solid #1B5E20;
        z-index: 999;
    }

    .main-nav ul.show {
        display: flex;
    }

    .mobile-menu-btn {
        display: block;
        background: none;
        border: none;
        font-size: 32px;
        color: #1B5E20;
        cursor: pointer;
        padding: 5px 0 5px 15px;
    }

    .assoc-logo-area {
        display: none;
    }

    .post-header {
        padding: 20px;
    }
    
    .post-content, .post-attachments, .masonry-gallery {
        padding: 20px;
    }
    
    .post-title {
        font-size: 1.3em;
    }
}

@media (min-width: 769px) {
    .mobile-menu-btn {
        display: none;
    }
}