/* --- Ссылки в статье (класс news-lightbox только на <a>) --- */
a.news-lightbox {
    display: inline-block;
    line-height: 0;
    cursor: zoom-in;
    position: static;
    width: auto;
    height: auto;
    inset: auto;
    z-index: auto;
    padding: 0;
    background: none;
    border: none;
}

a.news-lightbox img {
    display: block;
    max-width: 100%;
    height: auto;
    vertical-align: middle;
}

/* Текст и галерея с портала — на всю ширину колонки записи */
.news-post-body {
    width: 100%;
    max-width: 100%;
    clear: both;
    float: none;
}

.news-article-text {
    width: 100%;
    max-width: 100%;
    clear: both;
    float: none;
}

.news-article-text p,
.news-article-text ul,
.news-article-text ol,
.news-article-text blockquote {
    width: 100%;
    max-width: 100%;
    float: none;
    clear: both;
}

.news-gallery-wrap {
    width: 100%;
    max-width: 100%;
    clear: both;
    float: none;
    margin-top: 1.25em;
}

/* Сетка галереи (новые посты с портала) — gap одинаковый между всеми ячейками */
.news-gallery-wrap .news-gallery {
    display: grid !important;
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
    float: none !important;
    clear: both !important;
    gap: 10px !important;
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
}

.news-gallery[data-cols="1"] {
    grid-template-columns: repeat(1, minmax(0, 1fr)) !important;
}

.news-gallery[data-cols="2"] {
    grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
}

.news-gallery[data-cols="4"] {
    grid-template-columns: repeat(4, minmax(0, 1fr)) !important;
}

.news-gallery[data-cols="5"] {
    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;
}

.news-gallery[data-cols="6"] {
    grid-template-columns: repeat(6, minmax(0, 1fr)) !important;
}

.news-gallery__cell {
    margin: 0 !important;
    padding: 0 !important;
    min-width: 0 !important;
    float: none !important;
    vertical-align: top;
    text-align: center;
}

.news-gallery__cell a.news-lightbox,
.news-gallery__cell a[href],
table.news-gallery a.news-lightbox,
table.news-gallery a[href] {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

.news-gallery__cell img,
table.news-gallery img {
    display: block !important;
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
}

/* Старые посты: таблица — темы часто ломают border-spacing, отступы через padding ячеек */
table.news-gallery {
    width: 100% !important;
    max-width: 100% !important;
    float: none !important;
    clear: both !important;
    margin: 0 !important;
    border: none !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    table-layout: fixed !important;
}

table.news-gallery td {
    width: auto !important;
    vertical-align: top !important;
    text-align: center !important;
    padding: 0 5px !important;
    float: none !important;
    border: none !important;
}

table.news-gallery td:first-child {
    padding-left: 0 !important;
}

table.news-gallery td:last-child {
    padding-right: 0 !important;
}

table.news-gallery[data-cols="3"] td {
    width: 33.3333% !important;
}

table.news-gallery[data-cols="2"] td {
    width: 50% !important;
}

table.news-gallery[data-cols="4"] td {
    width: 25% !important;
}

body.news-lightbox-open {
    overflow: hidden;
}

/* --- Модальное окно (другой класс — без конфликта с ссылками) --- */
.news-lightbox-overlay[hidden] {
    display: none !important;
}

.news-lightbox-overlay {
    position: fixed;
    inset: 0;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0;
    padding: 20px;
    box-sizing: border-box;
    background: rgba(0, 0, 0, 0.92);
    border: none;
    cursor: zoom-out;
}

.news-lightbox-overlay__figure {
    position: relative;
    margin: 0;
    padding: 0;
    cursor: default;
    display: flex;
    align-items: center;
    justify-content: center;
    max-width: min(800px, 100%);
    max-height: 100%;
}

.news-lightbox-overlay__image {
    display: block;
    max-width: min(800px, calc(100vw - 40px));
    max-height: calc(100vh - 40px);
    width: auto;
    height: auto;
    object-fit: contain;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.35);
}

.news-lightbox-overlay__close {
    position: fixed;
    top: 12px;
    right: 12px;
    z-index: 100001;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.2);
    color: #fff;
    font-family: inherit;
    font-size: 32px;
    font-weight: 300;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.news-lightbox-overlay__close:hover {
    background: rgba(255, 255, 255, 0.35);
}

.news-lightbox-overlay__close:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}
