@import url("/static/css/variables.css");

/* =========================================================
   1. БАЗА И ЗАГОЛОВКИ
   ========================================================= */
body {
    background: var(--bg-secondary);
    font-family: var(--font-main);
    color: var(--text-body);
    margin: 0;
    padding: 0;
    overflow-x: hidden;
}

figure { margin: 0; padding: 0; display: block; }

.page-main {
    padding-top: var(--spacing-section);
    padding-bottom: var(--spacing-section);
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--container-padding-x);
}

.main-article {
    background: var(--bg-main);
    max-width: 1200px;
    margin: 0 auto;
    padding: 40px 60px 20px;
    border-radius: var(--radius-card);
    box-shadow: var(--shadow-card);
}

/* ЗАГОЛОВОК СТАТЬИ */
.main-article__header { 
    /* Подтягиваем заголовок ближе к контенту на ПК (замена стилей из HTML) */
    margin-bottom: -20px; 
}

.main-article__title {
    font-family: var(--font-main);
    font-size: var(--fs-h1);
    line-height: var(--lh-title);
    font-weight: 700;
    color: var(--text-title);
    margin-top: 0;
    margin-bottom: 20px;
    
    word-wrap: normal;
    overflow-wrap: normal;
    word-break: keep-all;
    hyphens: none;
}

.main-article__meta-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 0;
    justify-content: flex-start;
}

/* МОБИЛЬНАЯ ВЕРСИЯ ШАПКИ */
@media (max-width: 768px) {
    .main-article__header {
        margin-bottom: 10px; /* Нормальный отступ на мобильных */
    }
    .main-article__meta-wrapper {
        padding-bottom: 15px;
        margin-bottom: 0;
    }
}

/* =========================================================
   2. МЕТА-ИНФОРМАЦИЯ (ЧИСТАЯ, БЕЗ ПАЛОК)
   ========================================================= */
.main-article__meta-wrapper {
    display: flex;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
    margin-bottom: 0;
    justify-content: flex-start !important;
}

.recmain-item__title,
.recmain-item__desc {
    word-break: break-word;
    overflow-wrap: anywhere;
}


/* СПИСОК: Отступы делаем только через GAP */
.meta__list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    margin: 0;
    padding: 0;
    list-style: none;
    
    /* БАЗОВЫЙ ОТСТУП МЕЖДУ СЛОВАМИ */
    gap: 20px !important; 
    row-gap: 10px !important;
}

/* ЭЛЕМЕНТЫ */
.meta__item,
.meta__content,
.meta__category,
.meta__author-name,
.meta__author-link,
.meta__item time,
.meta__item span,
.meta__item a {
    font-family: var(--font-main) !important;
    font-size: 13px !important;
    font-weight: 700 !important;
    text-transform: uppercase !important;
    line-height: 1.4 !important;
    letter-spacing: 0.5px !important;
    text-decoration: none !important;
    margin: 0 !important;
    padding: 0 !important;
    border: none !important;
}

.meta__content { color: var(--text-muted) !important; }
.meta__author-name { color: var(--text-title) !important; }
.meta__category, .meta__author-link { color: var(--color-primary) !important; transition: color 0.2s; }
.meta__category:hover, .meta__author-link:hover { color: var(--color-accent) !important; }

/* УБИВАЕМ ВСЕ ПСЕВДОЭЛЕМЕНТЫ (ПАЛКИ) */
.meta__item::before,
.meta__item::after,
.meta__list > li::before,
.meta__list > li::after {
    content: none !important;
    display: none !important;
    width: 0 !important;
    height: 0 !important;
}

/* ПРИНТЕР */
.meta__item.print-button {
    margin-left: 0 !important;
}

.btn-block__print {
    background: none; border: none; cursor: pointer; opacity: 0.6; padding: 0;
    display: flex; align-items: center;
}
.btn-block__print:hover { opacity: 1; }
.btn-block__print img { width: 16px; height: auto; }


/* =========================================================
   3. АДАПТИВ МЕТА-ИНФОРМАЦИИ
   ========================================================= */

/* ПК */
@media (min-width: 769px) {
    .meta__list {
        gap: 25px !important;
    }
}

/* Мобильные */
@media (max-width: 768px) {
    .main-article { padding: 20px 15px; border-radius: 0; }
    
    .meta__list {
        width: 100%;
        gap: 15px !important;
    }
    
    .meta__item {
        white-space: normal !important;
        word-break: break-word !important;
    }
}


/* =========================================================
   4. КОНТЕНТ (ТЕКСТ СТАТЬИ) И ЛИД
   ========================================================= */

/* --- ЛИД (ВВОДНАЯ ЧАСТЬ) --- */
.main-article__lead {
    display: block;
    margin-bottom: 30px;
    
    /* === НАСТРОЙКИ ВНЕШНЕГО ВИДА === */
    font-family: var(--font-main);
    font-size: 20px;       /* <-- Размер шрифта */
    font-weight: 500;      /* <-- Жирность */
    line-height: 1.5;      /* <-- Межстрочный интервал */
    color: var(--text-title); /* <-- Цвет текста */
}

/* === ГЛАВНОЕ ИСПРАВЛЕНИЕ === */
/* Заставляем ВСЕ теги внутри лида (p, span, b, strong) подчиняться стилям выше */
.main-article__lead * {
    font-size: inherit !important;
    font-weight: inherit !important;
    line-height: inherit !important;
    color: inherit !important;
    font-family: inherit !important;
    
    /* Сбрасываем лишние отступы внутри, чтобы текст был монолитным */
    margin-top: 0 !important;
    margin-bottom: 0 !important; 
    padding: 0 !important;
    background-color: transparent !important; /* На случай если скопировано с фоном */
}

/* Если внутри несколько абзацев, добавляем между ними небольшой отступ */
.main-article__lead p + p {
    margin-top: 10px !important;
}

/* Скрываем пустые строки */
.main-article__lead p:empty { 
    display: none !important; 
}

/* Когда под лидом есть фото – делаем внешний зазор меньше */
.main-article__lead--with-photo {
    margin-bottom: 15px;
}


/* --- ОСНОВНОЙ ТЕКСТ --- */
.main-article__body,
.content-wrapper,
.content-wrapper p {
    font-family: var(--font-main);
    font-size: var(--fs-body);
    line-height: var(--lh-body);
    color: var(--text-body);
}

.content-wrapper {
    white-space: normal;
    word-break: normal;
    overflow-wrap: break-word;
    hyphens: auto;
}

.content-wrapper * {
    white-space: normal;
}

/* Отступы абзацев */
.content-wrapper p {
    margin-top: 0;
    margin-bottom: var(--spacing-inner);
    text-align: justify;
}

/* Важный фикс для пустых строк (&nbsp;) */
.content-wrapper p:empty { 
    display: none; 
}
/* Некоторые редакторы вставляют <p>&nbsp;</p>. Скрываем их, если они единственные */
.content-wrapper p:only-child:contains('&nbsp;') {
    display: none;
}

/* --- ЦИТАТЫ (BLOCKQUOTE) --- */
.content-wrapper blockquote {
    /* Вертикальные отступы от текста */
    margin: 30px 0; 
    
    /* Отступ текста от линии слева */
    padding-left: 24px; 
    
    /* Вертикальная черта слева (Акцентный цвет) */
    border-left: 3px solid var(--color-accent, #f0a733);
    
    /* Стиль текста */
    font-family: var(--font-main);
    font-size: 18px; /* Чуть крупнее обычного, можно 20px */
    font-style: italic;
    color: var(--text-body);
    
    /* СБРОС стандартных браузерных отступов справа/слева, 
       чтобы текст шел ровно, как и остальной контент */
    margin-inline-start: 0;
    margin-inline-end: 0;
}

/* Если внутри цитаты есть параграфы, убираем у них лишние отступы */
.content-wrapper blockquote p {
    margin-bottom: 10px;
}
.content-wrapper blockquote p:last-child {
    margin-bottom: 0;
}

.content-wrapper a {
    color: var(--color-primary, #2563eb) !important; /* Основной цвет ссылок (синий/фирменный) */
    text-decoration: underline !important; /* Явно показываем, что это ссылка */
    font-weight: 500 !important; /* Чуть жирнее, чтобы выделялось */
    transition: color 0.2s;
}

.content-wrapper a:hover {
    color: var(--color-accent, #f0a733) !important; /* Оранжевый при наведении */
}

.content-wrapper > *:last-child {
    margin-bottom: 0 !important;
    padding-bottom: 0 !important;
}

/* =========================================================
   5. ФОТО И ПОДПИСИ (ИСПРАВЛЕННАЯ ЛОГИКА)
   ========================================================= */

/* --- 1. ГЛАВНОЕ ФОТО (В НАЧАЛЕ СТАТЬИ) --- */
/* Его логику оставляем специфичной, чтобы не ломать шапку */

.main-article__picture {
    display: block; 
    width: 100%; 
    margin: 0 !important; 
    padding: 0 !important;
}

.main-article__img {
    display: block; 
    width: 100%; 
    height: auto; 
    object-fit: cover; 
    max-height: 600px;
    border-radius: var(--radius-card);
}

/* Логика отступа для главного фото: */
/* Если подписи НЕТ -> добавляем отступ 24px сами */
.main-article__picture:not(:has(.main-article__img-description)) {
    margin-bottom: 24px !important;
}
/* Если подпись ЕСТЬ -> отступ даст сама подпись (см. ниже) */


/* --- 2. КАРТИНКИ В ТЕКСТЕ (CKEDITOR) --- */

/* Контейнер картинки внутри текста */
.content-wrapper figure {
    display: block; 
    width: 100%; 
    padding: 0 !important;
    
    /* ВАЖНО: Отступ 20px СНИЗУ ВСЕГДА. 
       Неважно, есть подпись или нет — блок figure оттолкнет текст снизу. */
    margin: 30px 0 20px 0 !important; 
}

.content-wrapper figure img {
    display: block; 
    width: 100%; 
    height: auto; 
    border-radius: var(--radius-card);
}


/* --- 3. СТИЛИ ПОДПИСЕЙ (ЕДИНЫЕ) --- */

.content-wrapper figure figcaption,
.main-article__img-description {
    display: block !important;
    
    /* Типографика подписи */
    font-family: var(--font-main) !important;
    font-size: 14px !important;
    line-height: 1.3 !important;
    color: #9ca3af !important; /* Серый цвет */
    text-align: center !important;
    font-style: normal !important;
    
    /* Отступы САМОЙ ПОДПИСИ */
    margin-top: 10px !important;    /* Отступ ОТ картинки ДО подписи */
    margin-bottom: 0 !important;    /* Снизу отступ не нужен, его дает figure */
}

/* Спец. правило для ГЛАВНОГО фото, так как у него нет обертки figure с margin-bottom */
.main-article__picture .main-article__img-description {
    margin-bottom: 24px !important; /* Тут отступ нужен */
}

/* Сброс стилей внутри подписей (если редактор вставил P) */
.content-wrapper figure figcaption p,
.main-article__img-description p {
    margin: 0 !important;
    padding: 0 !important;
    font-size: inherit !important;
    color: inherit !important;
}
/* Гарантия отсутствия отступа сверху у текста сразу после figure */
.content-wrapper figure + p {
    margin-top: 0 !important;
}

/* Убираем верхний отступ у первого абзаца текста статьи (дублирует логику выше, но оставим для надежности) */
.main-article__body .content-wrapper > p:first-child { 
    margin-top: 0 !important; 
}

/* Если у главного фото НЕТ подписи, возвращаем ему отступ снизу */
.main-article__image-wrapper:not(:has(.main-article__img-description)) { 
    margin-bottom: 24px; 
}

.page-section--no-border { border: none; padding: 20px 0 40px; }

/* === Уплотнение текста сразу после подписи под главным фото === */

/* На всякий случай убираем верхние отступы у блока с текстом */
.main-article__picture + .main-article__body {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

.main-article__picture + .main-article__body .content-wrapper {
    margin-top: 0 !important;
    padding-top: 0 !important;
}

/* Первый видимый абзац текста сразу под подписью */
.main-article__picture + .main-article__body .content-wrapper > p:first-child {
    margin-top: 0 !important;
}

/* === Интервал между подписью и текстом = интервал между абзацами === */

/* Главная подпись под фото */
figure.main-article__picture > figcaption.main-article__img-description {
    margin-bottom: var(--spacing-inner) !important;
}

/* Подписи у картинок из CKEditor */
.content-wrapper figure > figcaption {
    margin-bottom: var(--spacing-inner) !important;
}

/* Текст сразу после figure/подписи без верхнего отступа (для надёжности) */
.content-wrapper figure + p,
.main-article__picture + .main-article__body .content-wrapper > p:first-child {
    margin-top: 0 !important;
}

/* Заголовок новости: переносим только по пробелам, без дефисов и разрывов внутри слова */
.main-article__title {
    word-wrap: normal !important;        /* отключаем старое break-word */
    overflow-wrap: normal !important;    /* не ломаем слова произвольно */
    word-break: keep-all !important;     /* стараемся сохранять целые слова */
    
    hyphens: none !important;            /* запрет авто-дефисов */
    -webkit-hyphens: none !important;    /* Safari/Chrome */
    -ms-hyphens: none !important;        /* старый Edge/IE */
}

/* === ИСПРАВЛЕНИЕ ОТСТУПА === */

/* По умолчанию сбрасываем отступы */
.main-article__picture {
    margin-bottom: 0;
}

/* ЛОГИКА: Если внутри .main-article__picture НЕТ подписи (.main-article__img-description),
   то добавляем отступ 20px снизу. */
.main-article__picture:not(:has(.main-article__img-description)) {
    margin-bottom: 20px !important;
}

/* =========================================================
   6. ВЕРСИЯ ДЛЯ ПЕЧАТИ (@media print) — С ЛОГОТИПОМ
   ========================================================= */

@media print {
    
    /* 1. Скрываем навигацию, футер и инструменты, НО оставляем сам контейнер хедера */
    .modern-footer,
    .header-nav,
    .header-tools,
    .btn-block__print,
    .search-wrapper,
    .lang-switch,
    .cookie-notice,
    iframe {
        display: none !important;
    }

    /* 2. Настраиваем Хедер, чтобы показать только Лого */
    .modern-header {
        display: block !important;
        position: static !important; /* Убираем фиксацию/липкость */
        height: auto !important;
        background: none !important;
        border: none !important;
        padding: 0 0 20px 0 !important; /* Отступ снизу до статьи */
        margin: 0 !important;
    }

    .modern-header__container {
        display: block !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    /* Настройка самого логотипа */
    .header-logo {
        display: block !important;
        width: 180px !important; /* Оптимальный размер для А4 */
        height: auto !important;
        text-decoration: none !important;
    }
    
    .header-logo img {
        width: 100% !important;
        height: auto !important;
        /* filter: grayscale(100%);  <-- Раскомментируйте, если нужен ч/б логотип */
    }

    /* 3. Сброс геометрии и фонов для контента */
    body, 
    .page-main, 
    .container, 
    .main-article {
        background: #ffffff !important;
        color: #000000 !important;
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
        border: none !important;
        border-radius: 0 !important;
        overflow: visible !important;
    }

    /* 4. ЗАГОЛОВОК (Уменьшили размер) */
    .main-article__title {
        /* БЫЛО: 24pt */
        /* СТАЛО: Чуть аккуратнее */
        font-size: 18pt !important; 
        line-height: 1.2 !important;
        color: #000 !important;
        margin-bottom: 15px !important;
    }

    /* Лид и основной текст */
    .main-article__lead,
    .content-wrapper p,
    .content-wrapper li {
        font-size: 12pt !important;
        line-height: 1.5 !important;
        color: #000 !important;
        text-align: left !important;
        margin-bottom: 10pt !important;
    }

    /* 5. Убираем текстовую надпись, которую делали раньше (так как теперь есть лого) */
    .main-article::before {
        content: none !important;
        display: none !important;
    }

    /* 6. Картинки и ссылки */
    a {
        text-decoration: none !important;
        color: #000 !important;
    }
    
    img {
        max-width: 100% !important;
        height: auto !important;
    }
    
    /* Запрет разрывов */
    figure, img, blockquote, .header-logo {
        page-break-inside: avoid; 
    }
    
    /* Каждый H2 начинаем с новой страницы (опционально, для длинных статей) */
    /* h2 { page-break-before: always; } */
}

/* =========================================================
   7. СОЦИАЛЬНЫЕ ССЫЛКИ В ТЕКСТЕ (СЕРЫЕ КНОПКИ + ЦВЕТА)
   ========================================================= */

.social-share-block {
    display: flex;
    flex-direction: column;
    align-items: center; 
    margin: 40px auto; 
    padding: 0 !important; 
    background-color: transparent !important; 
    border-radius: 0 !important; 
    max-width: 400px;
}

.social-share-block__title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text-title);
    text-transform: uppercase;
    margin-bottom: 15px;
    text-align: center;
}

.socials--share {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 16px; 
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
}

/* КНОПКИ: СЕРЫЕ КВАДРАТЫ */
.socials--share .socials__link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;  
    height: 48px;
    
    background-color: #f3f4f6; /* Серый фон */
    
    /* === ВОТ ГЛАВНОЕ ИЗМЕНЕНИЕ === */
    color: #EE8208 !important;            /* Черный цвет иконки по умолчанию (вместо синего) */
    /* ============================ */
    
    border-radius: 4px;        /* Легкое скругление */
    transition: all 0.2s ease;
    text-decoration: none;
}

/* Иконка (заполняется текущим цветом) */
.socials--share .social-icon {
    width: 24px;
    height: 24px;
    fill: currentColor;
    display: block;
}

/* --- ЭФФЕКТ ПРИ НАВЕДЕНИИ --- */
.socials--share .socials__link:hover {
    background-color: #ffffff; 
    transform: translateY(-3px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1); 
}

/* Персональные цвета при наведении (Иконка красится только тут) */
.socials__link--dzen:hover { color: #000000; }
.socials__link--tg:hover   { color: #229ED9; }
.socials__link--vk:hover   { color: #0077FF; }
.socials__link--ok:hover   { color: #EE8208; } /* Оранжевый при наведении */

/* =========================================================
   8. ОФИЦИАЛЬНЫЕ ТАБЛИЦЫ (FINAL FIX: HOVER + STRIPES)
   ========================================================= */

/* Контейнер для прокрутки */
.table-responsive {
    display: block;
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    margin: 30px 0;
    border-radius: 12px;
    border: 1px solid #e5e7eb;
    box-shadow: 0 4px 6px rgba(0,0,0,0.02); /* Легкая тень */
    background: #fff;
}

.content-wrapper table {
    width: 100%;
    min-width: 600px;
    border-collapse: collapse;
    font-family: var(--font-main);
    font-size: 15px;
    line-height: 1.4;
    border-style: hidden; /* Прячем внешние границы самой таблицы */
}

/* --- 1. ШАПКА ТАБЛИЦЫ (ПЕРВАЯ СТРОКА) --- */
/* Работает и для <thead>, и для первой <tr> в <tbody>, если thead нет */
.content-wrapper table thead tr,
.content-wrapper table tr:first-child {
    background-color: #f3f4f6 !important; /* Серый фон */
    border-bottom: 2px solid #e5e7eb;
}

.content-wrapper table thead th,
.content-wrapper table thead td,
.content-wrapper table tr:first-child th,
.content-wrapper table tr:first-child td {
    color: var(--text-title);
    font-weight: 700 !important;
    text-transform: uppercase;
    font-size: 12px;
    letter-spacing: 0.05em;
    padding: 14px 16px;
    vertical-align: middle;
    background-color: inherit; /* Наследуем серый цвет строки */
}

/* Убираем ссылки/подчеркивания в заголовках, если они там есть */
.content-wrapper table tr:first-child strong,
.content-wrapper table tr:first-child b {
    font-weight: 700;
}

/* --- 2. ОБЫЧНЫЕ СТРОКИ (BODY) --- */

/* Сброс фона для всех ячеек, чтобы работал цвет строки */
.content-wrapper table tbody td {
    background-color: transparent; 
}

/* Ячейки: отступы и границы */
.content-wrapper table td,
.content-wrapper table th {
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    color: var(--text-body);
    vertical-align: top;
}

/* ПЕРВЫЙ СТОЛБЕЦ (Делаем жирным, как в инфографике) */
.content-wrapper table tr:not(:first-child) td:first-child {
    font-weight: 600;
    color: var(--text-title);
}

/* --- 3. ЭФФЕКТЫ (ЗЕБРА И ХОВЕР) --- */

/* ЗЕБРА: Красим четные строки (но не первую, если она заголовок) */
/* Используем сложный селектор, чтобы не покрасить header, если он внутри tbody */
.content-wrapper table tr:nth-child(even):not(:first-child) {
    background-color: #f9fbff; /* Очень легкий голубой */
}

/* ХОВЕР: Эффект при наведении (Самое важное!) */
.content-wrapper table tr:not(:first-child):hover {
    background-color: #eef2ff !important; /* Явный светло-синий при наведении */
    transition: background-color 0.15s ease-in-out;
    cursor: default;
}

/* Убираем нижнюю границу у самой последней строки */
.content-wrapper table tr:last-child td {
    border-bottom: none;
}