/* Контейнер зі списком новин */
.detail-list-container {
    display: flex;
    flex-wrap: wrap;
    gap: 20px;
    justify-content: center;
}

/* Картка новини. Доброго вечора, ми з України*/
/* Обгортка з анімованою рамкою */
.detail-list-card-wrapper {
    position: relative;
    border-radius: 16px;
    z-index: 0;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transition: transform 0.3s ease;
}

/* Псевдоелемент-рамка */
.detail-list-card-wrapper::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 16px;
    padding: 3px;
    background: linear-gradient(135deg, rgba(0, 123, 255, 0.4), rgba(0, 255, 200, 0.4), rgba(123, 0, 255, 0.4));
    background-size: 300% 300%;
    animation: glowingBorder 6s ease infinite;
    z-index: 3;
    pointer-events: none;

    -webkit-mask:
            linear-gradient(#fff 0 0) content-box,
            linear-gradient(#fff 0 0);
    -webkit-mask-composite: destination-out;
    mask-composite: exclude;
}

/* Анімація градієнта */
@keyframes glowingBorder {
    0% { background-position: 0% 50%; }
    50% { background-position: 100% 50%; }
    100% { background-position: 0% 50%; }
}

/* Вміст картки */
.detail-list-card {
    width: 300px;
    min-height: 550px;
    display: flex;
    flex-direction: column;
    background: #fff;
    border-radius: 16px;
    position: relative;
    z-index: 1;
}

/* Ховер-картка */
.detail-list-card-wrapper:hover {
    transform: translateY(-5px);
}




.detail-list-body {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

/* ===-- Маркер “закріплено” === */
.pinned-marker {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #e3342f;
    color: #fff;
    border-radius: 50%;
    padding: 6px;
    font-size: 0.85rem;
    z-index: 10;
    box-shadow: 0 2px 4px rgba(0,0,0,0.3);
}
.detail-list-card {
    position: relative; /* потрібно для абсолютного позиціювання .pinned-marker */
}


/* === Контейнер заголовка === */
.detail-list-header {
    /* min-height: calc(1.7em * 5); прибрати цей рядок */
    padding: 12px 12px 16px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    border-bottom: 1px dashed #ccc;
    margin-bottom: 8px;
    transition: background 0.2s ease;
    overflow: hidden;
}

/* === Лінк на статтю === */
.detail-list-title-link {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
    min-height: calc(1.7em * 5); /* Перенести min-height сюди */
    width: 100%;
    gap: 10px;
    text-decoration: none;
    color: inherit;
}

.detail-list-title {
    font-size: 0.88rem;
    font-weight: 600;
    color: #003366;
    line-height: 1.3;
    max-width: 100%;
    word-break: break-word;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* === Бейдж === */
.detail-list-badge {
    margin-top: auto; /* Приклеює бейдж до низу */
    padding: 4px 10px;
    font-size: 0.75rem;
    font-weight: 500;
    color: #155724;
    background-color: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 12px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    flex-shrink: 0; /* Запобігає стисканню бейджа */
    transition: background 0.2s ease, color 0.2s ease, transform 0.2s ease;
}

.detail-list-badge i {
    font-size: 0.8rem;
    color: inherit;
}

/* Ховер по заголовку */
.detail-list-header:hover .detail-list-badge {
    background-color: #c3e6cb;
    color: #0c3c1c;
    transform: translateY(-1px);
}


/* Зображення */
.detail-list-image-wrapper {
    position: relative;
    width: 100%;
    height: 180px;
    padding: 8px;                    /* ← припустимо, але лишай тут, не на IMG */
    box-sizing: border-box;
    overflow: hidden;
    background-color: #f8f8f8;
    border-bottom: 1px solid #e0e0e0;
    border-radius: 0;               /* ← Убери верхні закруглення, вони вилазять */
    flex-shrink: 0;
}


.detail-list-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    max-width: 100%;
    max-height: 100%;
    transition: transform 0.3s ease;
    cursor: zoom-in;
    padding: 0;            /* ← ВАЖЛИВО */
    margin: 0;             /* ← ДОДАЙ */
    display: block;        /* ← Запобігає зайвим рядкам */
    box-sizing: border-box;
}



/* Ефект при наведенні */
.detail-list-image-wrapper:hover .detail-list-image {
    transform: scale(0.95);
}

/* Лупа-іконка */
.zoom-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.6rem;
    color: white;
    opacity: 0;
    transition: opacity 0.3s ease;
    z-index: 2;
    pointer-events: none;
}


.detail-list-image-wrapper:hover .zoom-icon {
    opacity: 1;
}


/* Опис */
.detail-list-description-wrapper {
    min-height: 117px;
    padding: 6px 12px;
    overflow: hidden;
    border-top: 1px solid #e0e0e0;
    border-bottom: 1px solid #e0e0e0;
    flex-shrink: 0;
}

.detail-list-description-text {
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    text-align: left;
    text-indent: 1.5em;
    display: -webkit-box;
    -webkit-line-clamp: 5;
    -webkit-box-orient: vertical;
    text-overflow: ellipsis;
    overflow: hidden;
    margin: 0;
    word-break: break-word;
    hyphens: auto;
}


/* Нижній блок: дата + кнопка */
.detail-list-footer {
    padding: 8px 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    align-items: flex-end;
    margin-top: auto; /* ← Це "приклеює" футер до низу */
}

/* Стилізована дата */
.detail-list-date {
    display: inline-block;
    font-size: 0.8rem;
    color: #0055aa;

    background-color: #e6f0ff;
    padding: 4px 10px;
    border-radius: 20px;
    font-weight: 500;
    letter-spacing: 0.3px;
}


.btn-show-modal {
    padding: 6px 12px;
    background: #0055aa;
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.9rem;
    cursor: pointer;
    width: 100%;
    transition: background 0.2s ease;
}

.btn-show-modal:hover {
    background: #004080;
}

/* Порожній список */
.detail-list-empty {
    text-align: center;
    padding: 40px;
    font-style: italic;
}


/* === Модальне затемнення === */
.news-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.65);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

/* === Контейнер модального вікна === */
.news-modal-content {
    width: 860px;
    height: 90vh;
    max-height: 50vh;
    background: #414158;
    border-radius: 16px;
    box-shadow: 0 0 0 2px #2d8fff;
    padding: 45px;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* === Кнопка закриття === */
.news-modal-close {
    position: absolute;
    top: 16px;
    right: 16px;
    z-index: 2;
    background: transparent;
    border: none;
    font-size: 1.4rem;
    color: #ccc;
    cursor: pointer;
}

/* === Основна сітка: зображення + текст === */
.news-modal-grid {
    display: grid;
    grid-template-columns: 1fr 2fr;
    gap: 24px;
    height: 100%;
    overflow: hidden;
}

/* === Блок зображення === */

.news-modal-image-box {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #2a2a2c;
    padding: 12px;
    border-radius: 8px;
    min-height: 300px;
    max-height: 100%;
}

.news-modal-image-box img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
}

/* === Блок тексту === */
.news-modal-text-box {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0 12px 0 24px;
    border-left: 2px solid #3c3c3c;
    line-height: 1.4; /* зменшено з 1.6 */
    scrollbar-width: thin; /* Firefox */
    scrollbar-color: #2d8fff #2a2a2c;
}


/* Chrome, Edge, Safari */
.news-modal-text-box::-webkit-scrollbar {
    width: 8px;
}
.news-modal-text-box::-webkit-scrollbar-track {
    background: #2a2a2c;
    border-radius: 4px;
}
.news-modal-text-box::-webkit-scrollbar-thumb {
    background-color: #2d8fff;
    border-radius: 4px;
    border: 2px solid #2a2a2c;
}
.news-modal-text-box::-webkit-scrollbar-thumb:hover {
    background-color: #1a73e8;
}


.news-modal-text {
    font-size: 1rem;
    color: #f3f3f3;
    line-height: 1.3;
    text-align: left;
    text-indent: 1.5em;
    white-space: pre-wrap;
}



/* Ховає при необхідності */
.hidden {
    display: none !important;
}

@media (max-width: 768px) {

    /* Картка новини — на всю ширину */
    .detail-list-card {
        width: 100%;
        height: auto;
    }

    .detail-list-header {
        padding: 8px 10px 8px;
        margin-bottom: 6px;
    }

    .detail-list-title {
        min-height: 110px;
        font-size: 1rem;

    }

    .detail-list-icon {
        font-size: 0.88rem;
    }

    .detail-list-title-link {
        gap: 3px;
    }

    .detail-list-description-wrapper {
        height: auto;
    }

    /* Модальне вікно */
    .news-modal-content {
        width: 85%;
        height: 70vh;
        max-height: 70vh;
        border-radius: 16px;
        padding: 16px;
        overflow: hidden;
    }

    .news-modal-close {
        top: 10px;
        right: 10px;
        font-size: 1.4rem;
        z-index: 2;
    }

    .news-modal-grid {
        display: flex;
        flex-direction: column;
        height: 100%;
    }

    .news-modal-image-box {
        height: 220px;
        padding: 10px;
        border-bottom: 1px solid #444;
        display: flex;
        margin-top: 25px;
        min-height: 220px;
        justify-content: center;
        align-items: center;
    }

    .news-modal-image-box img {
        max-width: 100%;
        max-height: 100%;
        object-fit: contain;
        border-radius: 8px;
    }

    .news-modal-text-box {
        flex: 1;
        overflow-y: auto;
        padding: 12px;
        border-left: none;
        border-top: 1px solid #3c3c3c;
    }

    .news-modal-text {
        font-size: 0.95rem;
        line-height: 1.5;
        color: #ddd;
        text-align: justify;
        text-indent: 1.5em;
        white-space: pre-wrap;
    }
}


/* === Модальне вікно перегляду зображення === */
.image-preview-modal,
.qr-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.88);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    padding: 20px;
    box-sizing: border-box;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.image-preview-modal.show,
.qr-modal.show {
    display: flex !important;
    opacity: 1;
    animation: fadeInImgModal 0.25s ease forwards;
}

.image-preview-modal.hide,
.qr-modal.hide {
    opacity: 0;
}

@keyframes fadeInImgModal {
    from { opacity: 0; }
    to { opacity: 1; }
}

.image-preview-content,
.qr-modal-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: zoomInImgModal 0.25s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes zoomInImgModal {
    from { transform: scale(0.92); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

.image-preview-content img,
.qr-modal-content img,
#modalImage {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: 12px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.6);
    background: #1e293b;
    border: 1px solid rgba(255, 255, 255, 0.15);
}

.image-preview-close,
.qr-close-btn {
    position: absolute;
    top: -46px;
    right: 0;
    background: rgba(255, 255, 255, 0.2);
    color: #ffffff;
    border: 1px solid rgba(255, 255, 255, 0.3);
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    cursor: pointer;
    transition: all 0.2s ease;
    backdrop-filter: blur(4px);
    z-index: 10;
}

.image-preview-close:hover,
.qr-close-btn:hover {
    background: rgba(239, 68, 68, 0.9);
    border-color: rgba(239, 68, 68, 1);
    transform: scale(1.1);
}
