/* =====================================================
   Адаптивность под мобильные телефоны и планшеты
   ===================================================== */

/* Универсальная защита: контент не должен вылезать за экран */
.com-content-article img,
.com-content-article table,
.com-content-article iframe,
.com-content-article video,
.com-content-article embed,
.formulyar-panel table,
.formulyar-panel img {
    max-width: 100% !important;
    height: auto !important;
}

@media (max-width: 992px) {

    /* Шапка: таблица с меню (1112px) и её ячейка */
    table[style*="1112px"],
    table[style*="1000px"],
    table[align="center"][cellpadding="1"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    td[style*="1109px"] {
        width: 100% !important;
        height: auto !important;
    }

    /* Плавающие элементы шапки */
    div[style*="width: 610px"] {
        width: 100% !important;
        max-width: 100% !important;
        float: none !important;
    }

    .com-content-article div[style*="float:left"],
    .com-content-article div[style*="float: left"] {
        float: none !important;
    }

    /* Шапка с гербом и названием: всё по центру, в столбик */
    html .com-content-article div[style*="width: 610px"] {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Меню (синий блок): на всю ширину, по центру */
    html .gor_menu,
    html .gor_menu table,
    html .gor_menu td {
        width: 100% !important;
        max-width: 100% !important;
        margin: 0 auto !important;
        text-align: center !important;
    }

    html .gor_menu .mod-menu {
        justify-content: center !important;
    }

    /* Слайдер: на всю ширину, по центру */
    html body #dj-slideshowThumbs3m214,
    html body #dj-slideshowThumbs3m214 .dj-slideshowThumbs-in,
    html body #dj-slideshowThumbs3m214 .dj-slides,
    html body #dj-slideshowThumbs3m214 .dj-slide-in,
    html body #dj-slideshowThumbs3m214 .dj-slide-image {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* Вся страница: контейнеры по центру, без сдвига влево */
    html .container-fluid,
    html .row-fluid,
    html main#content,
    html .com-content-article.item-page,
    html .com-content-article__body,
    html .body,
    html body {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        float: none !important;
    }

    /* Небольшой сдвиг всего контента вправо (база body.site = 20px) */
    html body.site {
        padding-left: calc(30px + 23%) !important;
        padding-right: 20px !important;
    }
}

@media (max-width: 767px) {

    /* ===== Центрирование всего тела статьи на мобильных ===== */
    html .com-content-article__body,
    html .com-content-article .item-page,
    html main#content,
    html .row-fluid {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        float: none !important;
    }

    html .com-content-article table[align="center"] {
        margin-left: auto !important;
        margin-right: auto !important;
    }

    /* ===== Заголовки статей ===== */
    .com-content-article h1 {
        font-size: 20px !important;
        line-height: 1.3 !important;
    }

    .com-content-article h2,
    .com-content-article h3,
    .com-content-article h4 {
        font-size: 17px !important;
        line-height: 1.35 !important;
    }

    .com-content-article h5,
    .com-content-article h6,
    .com-content-article .font_6,
    .com-content-article .custom h6 {
        font-size: 14px !important;
        line-height: 1.35 !important;
    }

    .com-content-article body p,
    .com-content-article p {
        font-size: 14px !important;
        line-height: 1.5 !important;
    }

    /* ===== Таблицы кнопок годов (cellpadding="40") ===== */
    table[cellpadding="40"],
    table[cellpadding="20"],
    table[cellpadding="10"] {
        width: 100% !important;
        max-width: 100% !important;
    }

    table[cellpadding="40"] td {
        padding: 8px !important;
    }

    /* Кнопки годов: компактнее на телефоне */
    .com-content-article p.buttond a {
        padding: 8px 10px !important;
        font-size: 13px !important;
        display: inline-block !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
        margin: 2px 0 !important;
    }

    .com-content-article p.buttond {
        margin: 4px 0 !important;
    }

    /* ===== Фото-галереи: 2 колонки вместо 3 ===== */
    html .com-content-article table td:has(> img) {
        width: 50% !important;
    }

    /* ===== Выравнивание: убираем большие отступы по бокам ===== */
    .com-content-article td[style*="padding"] {
        padding: 8px !important;
    }

    .com-content-article [style*="margin: 0 auto"] {
        max-width: 100% !important;
    }

    /* ===== Модули в контенте ===== */
    .com-content-article .mod-custom.custom {
        width: 100% !important;
        max-width: 100% !important;
    }

    .com-content-article .custom table {
        width: 100% !important;
        max-width: 100% !important;
    }
}

@media (max-width: 480px) {

    /* Кнопки годов: 2 в ряд или в столбик */
    .com-content-article p.buttond a {
        font-size: 12px !important;
        padding: 8px 6px !important;
    }

    /* Фото-галереи: 1 колонка */
    html .com-content-article table td:has(> img) {
        width: 100% !important;
    }

    /* Шапка-тексты */
    .com-content-article h6,
    .com-content-article .font_6 {
        font-size: 13px !important;
    }

    .com-content-article [style*="width: 610px"] {
        display: block !important;
    }
}

/* ===== Мобильное меню в шапке ===== */
@media (max-width: 767px) {

    /* Ширина таблицы меню — на весь экран */
    .gor_menu,
    .gor_menu table,
    .gor_menu td {
        width: 100% !important;
        max-width: 100% !important;
        display: block !important;
        margin: 0 auto !important;
        text-align: center !important;
    }

    /* Пункты меню — столбиком */
    .gor_menu .mod-menu > li {
        width: 100% !important;
        position: relative !important;
    }

    .gor_menu .mod-menu > li > a {
        display: block !important;
        padding: 14px 56px !important;
        font-size: 15px !important;
        white-space: normal !important;
        text-align: center !important;
        box-sizing: border-box !important;
    }

    /* Кнопка-стрелка Joomla: отдельный клик от ссылки */
    html .mod-menu .mod-menu__toggle-sub {
        font-size: 0 !important;
        color: transparent !important;
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
        position: absolute !important;
        right: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 44px !important;
        margin: 0 !important;
        padding: 0 !important;
        background: transparent !important;
        border: none !important;
        cursor: pointer !important;
    }

    html .mod-menu .mod-menu__toggle-sub .icon-chevron-down,
    html .mod-menu .mod-menu__toggle-sub .visually-hidden {
        display: none !important;
    }

    html .mod-menu .mod-menu__toggle-sub::before {
        content: "\2039";
        display: block;
        font-size: 26px;
        line-height: 1;
        color: #bcd0e8;
        transform: rotate(180deg);
    }

    html .mod-menu li.open > .mod-menu__toggle-sub::before {
        transform: rotate(0deg);
        color: #ffffff;
    }

    /* Подменю скрыты, раскрываются тапом по стрелке */
    html .gor_menu .mod-menu .mod-menu__sub {
        position: static !important;
        display: none !important;
        width: 100% !important;
        padding-left: 12px !important;
    }

    html .gor_menu .mod-menu > li.open > .mod-menu__sub,
    html .gor_menu .mod-menu li.open > .mod-menu__sub {
        display: block !important;
    }

    /* Раскрытое подменю всегда поверх соседних пунктов и ловит тап на себя */
    html .gor_menu .mod-menu > li.open,
    html .gor_menu .mod-menu li.open,
    html .gor_menu .mod-menu li.open > .mod-menu__sub {
        z-index: 500 !important;
    }

    html .gor_menu .mod-menu li.open > .mod-menu__sub {
        position: relative !important;
    }

    /* Клики по раскрытому подменю никогда не уходят сквозь на нижележащие пункты */
    html .gor_menu .mod-menu li.open > .mod-menu__sub,
    html .gor_menu .mod-menu li.open > .mod-menu__sub a,
    html .gor_menu .mod-menu li.open > .mod-menu__sub button {
        pointer-events: auto !important;
        z-index: 500 !important;
    }

    html .gor_menu .mod-menu > li.open + li,
    html .gor_menu .mod-menu > li.open ~ li {
        z-index: 1 !important;
    }

    /* Вложенные открытые подменю (2-й уровень) также принимают клики */
    html .gor_menu .mod-menu .mod-menu__sub li.open > .mod-menu__sub,
    html .gor_menu .mod-menu .mod-menu__sub li.open > .mod-menu__sub a,
    html .gor_menu .mod-menu .mod-menu__sub li.open > .mod-menu__sub button {
        pointer-events: auto !important;
        z-index: 400 !important;
    }

    html .gor_menu .mod-menu .mod-menu__sub .mod-menu__sub {
        position: static !important;
        left: auto !important;
        top: auto !important;
        right: auto !important;
    }

    /* Вложенные пункты с подменю (созданные JS-кнопки) */
    .gor_menu .mod-menu .mod-menu__sub > li.deeper {
        position: relative !important;
    }

    .gor_menu .mod-menu__sub > li.deeper > a {
        padding-right: 48px !important;
    }

    .gor_menu .mod-menu__sub li a {
        padding: 11px 12px !important;
        font-size: 14px !important;
        white-space: normal !important;
        text-align: center !important;
    }

    /* ===== Слайдер DJ Media Tools: на весь экран, по центру ===== */
    html body #dj-slideshowThumbs3m214,
    html body #dj-slideshowThumbs3m214 .dj-slideshowThumbs-in,
    html body #dj-slideshowThumbs3m214 .dj-slides,
    html body #dj-slideshowThumbs3m214 .dj-slide,
    html body #dj-slideshowThumbs3m214 .dj-slide-in,
    html body #dj-slideshowThumbs3m214 .dj-slide-image {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
    }

    html .com-content-article div[style*="border: 0px"],
    html .com-content-article p:has(> div[style*="border: 0px"]) {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: auto !important;
        margin-right: auto !important;
        text-align: center !important;
    }

    #dj-slideshowThumbs3m214 .dj-slide-in {
        padding: 0 !important;
    }

    /* ===== Крупный режим просмотра фото (Magnific Popup) ===== */
    html .mfp-wrap,
    html .mfp-container {
        left: 0 !important;
        right: 0 !important;
        margin: 0 auto !important;
    }

    html .mfp-container {
        text-align: center !important;
        padding: 0 6px !important;
    }

    html .mfp-content {
        margin: 0 auto !important;
        text-align: center !important;
    }

    html .mfp-img-mobile img.mfp-img {
        max-width: 100% !important;
        height: auto !important;
        max-height: 78vh !important;
        padding: 0 !important;
        margin: 0 auto !important;
        display: block !important;
        width: 60% !important;
    }

    html .mfp-img-mobile .mfp-figure:after {
        box-shadow: none !important;
        background: none !important;
    }

    html .mfp-img-mobile .mfp-bottom-bar {
        position: static !important;
        top: auto !important;
        margin: 10px auto 4px auto !important;
        max-width: 100% !important;
        text-align: center !important;
    }

    html .mfp-img-mobile .mfp-counter {
        position: static !important;
        top: auto !important;
        right: auto !important;
        text-align: center !important;
    }

    html .mfp-img-mobile button.mfp-close {
        position: fixed !important;
        top: 6px !important;
        right: 6px !important;
        background: rgba(0, 0, 0, 0.6) !important;
    }

    html .mfp-img-mobile .mfp-arrow-left {
        left: 6px !important;
        margin-left: 0 !important;
    }

    html .mfp-img-mobile .mfp-arrow-right {
        right: 0 !important;
        margin-right: 0 !important;
    }
}
