/* Сброс и базовые стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    line-height: 1.6;
    color: #333;
    background: #f5f5f5;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

/* Шапка */
header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 40px 0;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

header h1 {
    font-size: 2.5em;
    margin-bottom: 10px;
}

header h1 a {
    color: white;
    text-decoration: none;
}

header .subtitle {
    font-size: 1.1em;
    opacity: 0.9;
    margin: 0;
}

/* Логотип в шапке */
.header-inner {
    display: flex;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    color: white;
    text-decoration: none;
    font-size: 1.8em;
    font-weight: 700;
}

.logo-img {
    width: 46px;
    height: 46px;
    border-radius: 10px;
    object-fit: cover;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.logo:hover {
    color: white;
}

@media (max-width: 768px) {
    .header-inner {
        gap: 12px;
    }
    .logo {
        font-size: 1.4em;
    }
    .logo-img {
        width: 36px;
        height: 36px;
    }
}

/* Главная страница - список новостей */
.news-list {
    display: grid;
    gap: 30px;
    padding: 40px 0;
}

.news-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: grid;
    grid-template-columns: 300px 1fr;
}

.news-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.15);
}

.card-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    min-height: 200px;
}

.card-content {
    padding: 25px;
}

.card-content h3 {
    font-size: 1.5em;
    margin-bottom: 10px;
    line-height: 1.3;
}

.card-content h3 a {
    color: #333;
    text-decoration: none;
    transition: color 0.2s;
}

.card-content h3 a:hover {
    color: #667eea;
}

.meta {
    display: flex;
    gap: 20px;
    font-size: 0.9em;
    color: #666;
    margin-bottom: 15px;
    flex-wrap: wrap;
}

.meta span {
    display: flex;
    align-items: center;
    gap: 5px;
}

.preview {
    color: #555;
    margin-bottom: 15px;
    line-height: 1.6;
}

.read-more {
    display: inline-block;
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s;
}

.read-more:hover {
    color: #764ba2;
}

/* Главная страница - двухколоночный макет: новости + сайдбар справа */
.main-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 30px;
    align-items: start;
}

.sidebar {
    position: sticky;
    top: 20px;
    align-self: start;
    max-height: calc(100vh - 40px);
}

.main-content {
    min-width: 0;
}

/* Панель навигации и фильтры (сайдбар) */
.nav-panel {
    background: white;
    border-radius: 12px;
    padding: 25px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

.search-box {
    position: relative;
    margin-bottom: 20px;
}

.search-box input {
    width: 100%;
    padding: 14px 50px 14px 18px;
    border: 2px solid #e0e0e0;
    border-radius: 10px;
    font-size: 1.05em;
    color: #333;
    transition: border-color 0.2s;
    background: #fafafa;
}

.search-box input:focus {
    outline: none;
    border-color: #667eea;
    background: white;
}

.search-icon {
    position: absolute;
    right: 18px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 1.2em;
    opacity: 0.6;
    pointer-events: none;
}

.tags-panel {
    border-top: 1px solid #eee;
    padding-top: 18px;
}

.tags-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 15px;
    flex-wrap: wrap;
    gap: 10px;
}

.tags-title {
    font-weight: 600;
    color: #444;
    font-size: 0.95em;
}

.tag-clear {
    background: #ff5555;
    color: white;
    border: none;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9em;
    transition: background 0.2s;
}

.tag-clear:hover {
    background: #e03e3e;
}

.tags-cloud {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.tag-filter {
    background: #f0f0f5;
    color: #555;
    border: none;
    padding: 8px 14px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9em;
    font-weight: 500;
    transition: background 0.2s, color 0.2s, transform 0.2s;
    position: relative;
}

.tag-filter:hover {
    background: #e6e6f0;
    transform: translateY(-1px);
}

.tag-filter.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.tag-count {
    background: rgba(0,0,0,0.08);
    padding: 2px 7px;
    border-radius: 10px;
    font-size: 0.8em;
    margin-left: 3px;
}

.tag-filter.active .tag-count {
    background: rgba(255,255,255,0.25);
}

.result-count {
    margin-top: 15px;
    padding: 8px 15px;
    background: #f5f5f9;
    border-radius: 8px;
    color: #555;
    font-size: 0.9em;
    display: none;
}

.card-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 12px;
}

.card-tag {
    background: #f0f0f5;
    color: #667eea;
    padding: 3px 9px;
    border-radius: 6px;
    font-size: 0.8em;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: background 0.2s, color 0.2s;
}

.card-tag:hover {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* Кнопка "Показать ещё" */
.load-more-wrap {
    display: flex;
    justify-content: center;
    padding: 30px 0 10px;
}

.load-more-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 14px 40px;
    border-radius: 10px;
    cursor: pointer;
    font-size: 1.05em;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.load-more-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.4);
}

/* Страница статьи */
.article-full {
    background: white;
    border-radius: 12px;
    padding: 40px;
    margin: 40px 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

/* Кнопки «Поделиться» */
.share-block {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 10px;
    margin: 30px 0 0;
    padding-top: 24px;
    border-top: 1px solid #eee;
}

.share-label {
    font-size: 0.85em;
    font-weight: 600;
    color: #999;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-right: 6px;
}

.share-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    padding: 0;
    border: none;
    border-radius: 50%;
    background: transparent;
    color: #fff;
    font-size: 0.9em;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.15s ease, background-color 0.15s ease, border-color 0.15s ease;
    font-family: inherit;
    -webkit-tap-highlight-color: transparent;
}

.share-btn svg {
    width: 20px;
    height: 20px;
    display: block;
    pointer-events: none;
}

/* Фирменные цвета соцсетей */
.share-tg { background: #26A5E4; }
.share-wa { background: #25D366; }
.share-vk { background: #0077FF; }
.share-ok { background: #EE8208; }

/* MAX — белый кружок с цветным официальным логотипом */
.share-max {
    background: #fff;
    border: 1px solid #e2e3ec;
}
.share-max img {
    width: 30px;
    height: 30px;
    display: block;
    pointer-events: none;
    border-radius: 0;
}

.share-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.share-btn:active {
    transform: translateY(0) scale(0.94);
}

.share-btn:focus-visible {
    outline: 2px solid #667eea;
    outline-offset: 2px;
}

.share-max:focus-visible {
    outline-color: #7a4bff;
}

/* Кнопка «Скопировать ссылку» — пилюля */
.share-copy {
    width: auto;
    height: 42px;
    padding: 0 16px;
    gap: 8px;
    border-radius: 21px;
    border: 1px solid #d9d9e3;
    background: #f8f8fa;
    color: #555;
    font-size: 0.9em;
    font-weight: 500;
}

.share-copy svg {
    width: 16px;
    height: 16px;
}

.share-copy:hover {
    background: #eef1ff;
    border-color: #667eea;
    color: #667eea;
    box-shadow: none;
}

.share-copy.copied {
    background: #e6f6ec;
    border-color: #25D366;
    color: #128c4a;
}

@media (max-width: 600px) {
    .share-block {
        gap: 8px;
    }
    .share-label {
        width: 100%;
        margin-bottom: 2px;
    }
    .share-btn {
        width: 40px;
        height: 40px;
    }
    .share-copy {
        width: auto;   /* перебить width:40px из .share-btn — иначе остаётся одна иконка */
        height: 40px;
        padding: 0 14px;
    }
}


.article-full h2,
.article-full h1.article-title {
    font-size: 2em;
    margin-bottom: 20px;
    line-height: 1.3;
    color: #222;
}

/* Теги статьи */
.article-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 15px 0 25px;
}

.article-tags .tag {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 4px 12px;
    border-radius: 15px;
    font-size: 0.85em;
    font-weight: 500;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.article-tags .tag:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
    color: white;
}

/* Контент статьи — картинки в потоке текста */
.article-content {
    font-size: 1.1em;
    line-height: 1.8;
    color: #444;
}

.article-content p {
    margin-bottom: 20px;
}

.article-content img.content-image {
    max-width: 100%;
    height: auto;
    display: block;
    margin: 20px auto;
    border-radius: 8px;
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.article-content img.content-image:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 16px rgba(0,0,0,0.2);
}

/* Заголовки внутри статьи */
.article-content h1,
.article-content h2,
.article-content h3,
.article-content h4 {
    margin: 25px 0 15px;
    color: #222;
}

.article-content h3 { font-size: 1.3em; }
.article-content h4 { font-size: 1.1em; }

.article-content ul,
.article-content ol {
    margin: 15px 0 15px 30px;
}

.article-content li {
    margin-bottom: 8px;
}

.article-content a {
    color: #667eea;
    text-decoration: none;
}

.article-content a:hover {
    text-decoration: underline;
}

.article-content strong,
.article-content b {
    color: #222;
}

.article-content blockquote {
    border-left: 4px solid #667eea;
    padding: 10px 20px;
    margin: 20px 0;
    background: #f9f9f9;
    font-style: italic;
}

.article-content table {
    border-collapse: collapse;
    margin: 0;
    width: 100%;
}

/* Таблицы: на узких экранах не сжимаем колонки, а даём горизонтальную прокрутку
   (обёртка .table-scroll добавляется при сборке сайта) */
.article-content .table-scroll {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 20px 0;
    border-radius: 8px;
    /* тонкая подсказка, что таблицу можно прокрутить */
    background:
        linear-gradient(to right, rgba(102,126,234,.10), rgba(102,126,234,0) 40px) left / 40px 100% no-repeat,
        linear-gradient(to left, rgba(102,126,234,.10), rgba(102,126,234,0) 40px) right / 40px 100% no-repeat;
}

.article-content .table-scroll table {
    min-width: 100%;
}

/* Преформатированный текст (моноширинные списки из источников) — прокрутка,
   иначе блок разрывает вёрстку статьи на мобильных */
.article-content pre {
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    background: #f6f7fb;
    border: 1px solid #e6e8f0;
    border-radius: 8px;
    padding: 12px 14px;
    margin: 20px 0;
    font-size: 0.92em;
    line-height: 1.5;
    white-space: pre;
    -moz-tab-size: 4;
    tab-size: 4;
}

.article-content code {
    word-break: break-word;
}

/* Картинки, видео и прочие вставки не выходят за пределы статьи */
.article-content img,
.article-content video,
.article-content iframe {
    max-width: 100%;
    height: auto;
}

.article-content iframe.video-embed {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
}

@media (max-width: 700px) {
    /* Колонки таблицы не слипаются: если не помещается — прокрутка */
    .article-content .table-scroll table {
        min-width: 520px;
        width: auto;
    }
    .article-content .table-scroll table td,
    .article-content .table-scroll table th {
        white-space: normal;
    }
}

.article-content table th,
.article-content table td {
    border: 1px solid #ddd;
    padding: 10px;
    text-align: left;
}

.article-content table th {
    background: #f5f5f5;
    font-weight: 600;
}

.article-footer {
    margin-top: 30px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

.btn {
    display: inline-block;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 12px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
}

.btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

/* Навигация между статьями */
.article-nav {
    display: flex;
    justify-content: space-between;
    gap: 20px;
    margin: 30px 0;
}

/* Читайте также */
.related-section {
    background: white;
    border-radius: 12px;
    padding: 25px;
    margin: 30px 0 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    border-left: 4px solid #667eea;
}
.related-title {
    font-size: 1.2em;
    margin: 0 0 15px;
}
.related-list {
    list-style: none;
    padding: 0;
    margin: 0;
}
.related-list li {
    padding: 8px 0;
    border-bottom: 1px solid #f0f0f0;
}
.related-list li:last-child {
    border-bottom: none;
}
.related-link {
    color: #667eea;
    text-decoration: none;
}
.related-link:hover {
    text-decoration: underline;
}

.nav-prev,
.nav-next {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 10px;
    padding: 15px 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    text-decoration: none;
    color: #333;
    transition: transform 0.2s, box-shadow 0.2s;
    max-width: 48%;
    flex: 1;
}

.nav-prev:hover,
.nav-next:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(102, 126, 234, 0.3);
    color: #333;
}

.nav-label {
    color: #667eea;
    font-weight: 600;
    font-size: 0.9em;
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 5px;
}

.nav-title {
    font-size: 0.95em;
    color: #555;
    line-height: 1.3;
}

.nav-arrow {
    font-size: 1.1em;
}

.nav-next .nav-label {
    justify-content: flex-end;
}

.nav-disabled {
    opacity: 0.4;
    pointer-events: none;
}

.back-link {
    margin: 30px 0;
}

.back-link a {
    color: #667eea;
    text-decoration: none;
    font-weight: 600;
}

.back-link a:hover {
    color: #764ba2;
}

.original-link {
    color: #667eea;
    text-decoration: none;
}

.original-link:hover {
    text-decoration: underline;
}

/* Lightbox */
.lightbox {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 9999;
    justify-content: center;
    align-items: center;
}

.lightbox.active {
    display: flex;
}

.lightbox-img {
    max-width: 90%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 30px rgba(0,0,0,0.5);
}

.lightbox-close {
    position: absolute;
    top: 20px;
    right: 30px;
    font-size: 50px;
    color: white;
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.lightbox-close:hover {
    color: #ff5555;
}

.lightbox-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    transform: translateY(-50%);
    pointer-events: none;
}

.lightbox-prev,
.lightbox-next {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    border: none;
    font-size: 30px;
    padding: 15px 20px;
    cursor: pointer;
    border-radius: 8px;
    transition: background 0.2s;
    pointer-events: auto;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
}

/* Подвал */
footer {
    background: #2c3e50;
    color: white;
    padding: 30px 0;
    margin-top: 60px;
}

footer p {
    text-align: center;
    opacity: 0.8;
}

/* Адаптивность */
@media (max-width: 768px) {
    header h1 {
        font-size: 1.8em;
    }
    
    /* Сайдбар на мобильных — сверху */
    .main-layout {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        position: static;
    }
    
    .news-card {
        grid-template-columns: 1fr;
    }
    
    .card-image {
        height: 200px;
    }
    
    .article-full {
        padding: 20px;
    }
    
    .article-full h2,
    .article-full h1.article-title {
        font-size: 1.5em;
    }
    
    .lightbox-prev,
    .lightbox-next {
        font-size: 20px;
        padding: 10px 15px;
    }
}

/* Встроенное видео (YouTube/Vimeo/Rutube) внутри статьи */
.article-content .video-embed,
.article__content .video-embed,
.video-embed {
    width: 100%;
    aspect-ratio: 16 / 9;
    height: auto;
    border: 0;
    border-radius: 12px;
    margin: 18px 0;
    background: #000;
    display: block;
}

/* ===== Подписка на каналы (Telegram + MAX) ===== */
.subscribe {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
}

.subscribe-title {
    font-size: 0.95em;
    opacity: 0.9;
}

.sub-btn {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    padding: 8px 14px;
    border-radius: 999px;
    font-size: 0.92em;
    font-weight: 600;
    text-decoration: none;
    line-height: 1;
    transition: transform .15s ease, box-shadow .15s ease, background .15s ease;
    white-space: nowrap;
}

.sub-btn svg { width: 18px; height: 18px; flex: 0 0 auto; }
.sub-btn img { width: 20px; height: 20px; border-radius: 5px; flex: 0 0 auto; }

.sub-btn:hover { transform: translateY(-1px); }

/* Telegram — фирменный синий */
.sub-tg { background: #229ED9; color: #fff; box-shadow: 0 2px 6px rgba(34,158,217,.35); }
.sub-tg:hover { background: #1e8dc2; color: #fff; }

/* MAX — белая кнопка с фирменным логотипом */
.sub-max { background: #fff; color: #2b2b2b; box-shadow: 0 2px 6px rgba(0,0,0,.18); }
.sub-max:hover { background: #f3f3f3; color: #2b2b2b; }

/* Вариант в шапке: прижат вправо, кнопки светлее на градиенте */
.subscribe-header { margin-left: auto; }
.subscribe-header .subscribe-title { color: #fff; opacity: .85; }

/* Вариант карточкой под кнопками «Поделиться» на странице статьи */
.subscribe-card {
    margin-top: 18px;
    padding: 14px 16px;
    background: #f7f8fc;
    border: 1px solid #e6e8f0;
    border-radius: 12px;
}

/* В подвале */
.subscribe-footer { margin-bottom: 12px; }

@media (max-width: 768px) {
    .subscribe-header {
        margin-left: 0;
        width: 100%;
        order: 3;
    }
    .subscribe-title { font-size: 0.9em; }
    .sub-btn { padding: 7px 12px; font-size: 0.88em; }
}

/* Шапка: логотип слева, подписка справа, подзаголовок — отдельной строкой */
.header-inner .subtitle { flex: 1 1 100%; }
