/*
 * ptet.ru — адаптив темы Alias для экранов от 320px.
 * Подключается последним в header.php. Десктоп (от 960px) не меняется.
 */

/* Кнопки мобильного меню — на десктопе скрыты */
.m-nav-toggle,
.m-nav-fab,
.m-sub-toggle {
    display: none;
}

/* ---------- Главная: блок «Полезные страницы» (разметка — useful-links.html, страница id 1078) ----------
   Единственная часть файла, которая действует и на десктопе. */

.useful-links__title {
    clear: both;
    margin: 30px 0 14px;
    font-family: Arial, Helvetica, sans-serif;
    font-size: 18px;
    font-weight: bold;
    color: #3B3B3B;
}

.useful-links {
    display: grid;
    /* 4 маленьких баннера в ряд, два широких — по половине строки под ними */
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 30px;
}

.useful-links .useful-links__item {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 96px;
    padding: 10px;
    border: 1px solid #e3e5e4;
    border-radius: 6px;
    background: #fff;
    color: #3B3B3B;
    font: bold 13px/1.3 Arial, Helvetica, sans-serif;
    text-align: center;
    text-decoration: none;
    box-sizing: border-box;
    transition: border-color .2s, box-shadow .2s;
}

.useful-links .useful-links__item:hover,
.useful-links .useful-links__item:focus {
    border-color: #8A211B;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .12);
    color: #8A211B;
}

.useful-links__item--wide {
    grid-column: span 2;
}

/* очень вытянутый баннер (ЦИК 1148×100) — на всю строку */
.useful-links__item--full {
    grid-column: 1 / -1;
}

.useful-links .useful-links__item img {
    display: block;
    max-width: 100%;
    max-height: 76px;
    width: auto;
    height: auto;
    margin: 0;
}

@media (max-width: 959px) {

    /* ---------- Каркас: сетка Blueprint становится резиновой ---------- */

    html {
        -webkit-text-size-adjust: 100%;
    }

    /* фон страницы (серый узор) по краям не просвечивает — отступы делают блоки внутри */
    #container.container {
        width: auto;
        max-width: 950px;
        padding: 0;
        /* у фоновой картинки пунктир стоит на высоте одной строки меню — на телефоне меню
           переносится, и пунктир его перечёркивал. Пунктир теперь рисуется под меню (#pagemenucontainer) */
        background: #fff;
        overflow-x: hidden;
        /* длинные слова без пробелов (Интернет_и_мобильные_…, ссылки) переносятся */
        word-wrap: break-word;
        overflow-wrap: break-word;
    }

    #container div[class*="span-"],
    #container .span-24,
    #container .span-16,
    #container .span-8 {
        float: none;
        width: auto;
        margin-right: 0;
    }

    #contentwrap {
        padding: 0 15px;
    }

    /* ---------- Верхнее меню (Главная, Антикоррупция…) ---------- */

    #pagemenucontainer,
    #pagemenu {
        float: none;
        height: auto;
    }

    #pagemenucontainer {
        margin-top: 0;
        padding: 8px 5px 4px;
        border-bottom: 2px dashed #d9827d;
        background: linear-gradient(#f1f2f2, #fff);
    }

    #pagemenu {
        display: flex;
        flex-wrap: wrap;
    }

    #pagemenu li a,
    #pagemenu li a:link {
        margin: 0;
        padding: 8px 10px;
    }

    /* ---------- Шапка: логотип + название ---------- */

    #header {
        display: flex;
        align-items: center;
        height: auto;
        padding: 12px 15px;
        box-sizing: border-box;
    }

    #header .span-logo {
        flex: 0 0 auto;
    }

    #header .logoimg {
        display: block;
        width: 110px;
        height: auto;
        margin: 0;
    }

    #header .span-logo-text {
        position: static;
        flex: 1 1 auto;
        min-width: 0;
        margin-left: 16px;
    }

    #header .span-logo-text h3 {
        margin-bottom: 4px;
        font-size: 13px;
        line-height: 1.3;
    }

    #header .span-logo-text h1,
    #header .span-logo-text h2 {
        margin: 4px 0 0;
        font-size: 26px;
        line-height: 1.15;
    }

    /* ---------- Главное меню ---------- */

    #navcontainer {
        padding: 8px 15px;
        overflow: visible;
    }

    .m-nav-toggle {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 44px;
        margin: 0 0 8px;
        padding: 0 15px;
        border: 0;
        border-radius: 5px;
        background: #8A211B;
        color: #fff;
        font: bold 14px/1 Arial, Helvetica, sans-serif;
        text-transform: uppercase;
        text-align: left;
        cursor: pointer;
    }

    .m-nav-toggle__icon,
    .m-nav-toggle__icon::before,
    .m-nav-toggle__icon::after {
        display: block;
        width: 20px;
        height: 2px;
        background: currentColor;
        transition: transform .2s, background-color .2s;
    }

    .m-nav-toggle__icon {
        position: relative;
        flex: 0 0 auto;
    }

    .m-nav-toggle__icon::before,
    .m-nav-toggle__icon::after {
        content: "";
        position: absolute;
        left: 0;
    }

    .m-nav-toggle__icon::before { top: -6px; }
    .m-nav-toggle__icon::after { top: 6px; }

    .m-nav-open .m-nav-toggle__icon { background: transparent; }
    .m-nav-open .m-nav-toggle__icon::before { transform: translateY(6px) rotate(45deg); }
    .m-nav-open .m-nav-toggle__icon::after { transform: translateY(-6px) rotate(-45deg); }

    /* Плавающая кнопка: появляется, когда «Меню» в шапке ушло за экран */
    .m-nav-fab {
        display: flex;
        align-items: center;
        justify-content: center;
        position: fixed;
        top: 10px;
        right: 10px;
        z-index: 99999;
        width: 46px;
        height: 46px;
        padding: 0;
        border: 0;
        border-radius: 50%;
        background: #8A211B;
        color: #fff;
        box-shadow: 0 2px 8px rgba(0, 0, 0, .3);
        cursor: pointer;
        opacity: 0;
        visibility: hidden;
        transform: translateY(-8px);
        transition: opacity .2s, transform .2s, visibility .2s;
    }

    .m-nav-fab.is-visible {
        opacity: 1;
        visibility: visible;
        transform: none;
    }

    /* пока скрипт не отработал (или выключен) — меню видно списком */
    .m-nav-ready #nav {
        display: none;
    }

    /* Открытое меню — на весь экран, кнопка «Меню» закреплена сверху */
    #navcontainer.m-nav-open {
        position: fixed;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        z-index: 100000;
        padding: 0 0 20px;
        border-bottom: 0;
        background: #fff;
        overflow-x: hidden;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
    }

    .m-nav-open .m-nav-toggle {
        position: sticky;
        top: 0;
        z-index: 1;
        margin: 0;
        border-radius: 0;
    }

    .m-nav-ready.m-nav-open #nav {
        display: block;
    }

    /* «Версия для слабовидящих» — такая же кнопка, как «Меню»: ширина, высота, скругление, шрифт */
    #navcontainer .bvi-link-shortcode {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 44px;
        padding: 0 15px;
        border-radius: 5px;
        font: bold 14px/1.2 Arial, Helvetica, sans-serif;
        text-align: left;
        box-sizing: border-box;
    }

    #navcontainer .bvi-link-shortcode svg {
        flex: 0 0 auto;
        width: 22px;
        height: 22px;
        margin: 0;
    }

    /* #navcontainer.m-nav-open — сильнее правила выше: иначе width:100% + поля давали прокрутку вбок */
    #navcontainer.m-nav-open .bvi-link-shortcode {
        width: auto;
        margin: 16px 15px 0;
    }

    html.m-nav-lock,
    html.m-nav-lock body {
        overflow: hidden;
    }

    #nav {
        width: auto;
        margin: 0;
        overflow: visible;
        background: #fff;
    }

    #nav li {
        float: none;
        display: block;
        position: relative;
        height: auto;
        margin: 0;
        padding: 0;
        border-bottom: 1px solid #e3e5e4;
        background: none;
    }

    #nav a {
        float: none;
        margin: 0;
        padding: 14px 52px 14px 15px;
        line-height: 1.3;
    }

    #nav li a:hover,
    #nav li a:focus {
        border-radius: 0;
    }

    /* подменю — раскрываются кнопкой со стрелкой */
    #nav ul,
    #nav .children {
        display: none;
        position: static;
        background: #A72E27;
    }

    #nav li.m-sub-open > ul,
    #nav li.m-sub-open > .children {
        display: block;
    }

    #nav li li {
        border-bottom-color: rgba(255, 255, 255, .15);
    }

    #nav li li a {
        padding-left: 28px;
        text-transform: none;
    }

    #nav li li li a {
        padding-left: 42px;
    }

    .m-sub-toggle {
        display: block;
        position: absolute;
        top: 0;
        right: 0;
        width: 52px;
        height: 46px;
        border: 0;
        background: none;
        color: inherit;
        cursor: pointer;
    }

    .m-sub-toggle::before {
        content: "";
        position: absolute;
        top: 50%;
        left: 50%;
        width: 8px;
        height: 8px;
        margin: -6px 0 0 -4px;
        border: solid #8A211B;
        border-width: 0 2px 2px 0;
        transform: rotate(45deg);
        transition: transform .2s;
    }

    #nav li li .m-sub-toggle::before {
        border-color: #fff;
    }

    .m-sub-open > .m-sub-toggle::before {
        margin-top: -2px;
        transform: rotate(-135deg);
    }

    /* выпадашки MenuMatic на мобильном не нужны */
    #subMenusContainer {
        display: none !important;
    }

    /* ---------- Слайдер (на всю ширину, без отступов) ---------- */

    .slider .metaslider {
        max-width: 100% !important;
    }

    /* #container — чтобы перебить div.span-24 { margin: 0 } из screen.css */
    #container .slider {
        margin-bottom: 16px;
    }

    /* ---------- Контент ---------- */

    #content {
        padding: 15px 0;
    }

    .post {
        padding: 10px 0;
    }

    .entry {
        text-align: left;
    }

    /* в тексте у картинок часто прописана высота (style="height: 200px") — без неё не сплющиваются */
    #contentwrap img,
    .post img {
        max-width: 100%;
        height: auto !important;
    }

    #contentwrap [style*="width"] {
        max-width: 100%;
        box-sizing: border-box;
    }

    #contentwrap table {
        max-width: 100%;
    }

    #contentwrap iframe,
    #contentwrap video,
    #contentwrap embed,
    #contentwrap object {
        max-width: 100%;
    }

    /* баннер «Госуслуги. Решаем вместе» задаёт себе min-width 293px — на 320px вылезал за край */
    #contentwrap #js-show-iframe-wrapper {
        min-width: 0 !important;
    }

    /* Отступы баннеру задаёт его собственный скрипт. Раньше он падал (визуальный редактор WP испортил
       «t<arguments.length») — исправлено в тексте страницы 1078, см. README. Здесь только кнопка: */
    #contentwrap #js-show-iframe-wrapper .pos-banner-btn_2 {
        max-width: 100%;
    }

    /* подряд идущие пустые абзацы (&nbsp;) скрипт помечает этим классом */
    .m-empty-p {
        display: none;
    }

    /* широкие таблицы-документы оборачиваются скриптом и листаются вбок */
    .m-table-scroll {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        margin-bottom: 1.5em;
    }

    .m-table-hint {
        display: flex;
        align-items: center;
        gap: 8px;
        margin: 0 0 6px;
        padding: 8px 12px;
        border-radius: 5px;
        background: #f6eceb;
        color: #8A211B;
        font: bold 13px/1.3 Arial, Helvetica, sans-serif;
        transition: opacity .3s;
    }

    .m-table-hint svg {
        flex: 0 0 auto;
    }

    .m-table-hint.is-scrolled {
        opacity: .45;
    }

    .m-table-scroll > table {
        max-width: none;
        margin-bottom: 0;
    }

    pre {
        width: auto;
        max-width: 100%;
    }

    .wp-caption {
        max-width: 100% !important;
        box-sizing: border-box;
        margin: 10px 0;
    }

    .title {
        line-height: 1.35;
    }

    /* галереи WordPress (лицензии, свидетельства) */
    #contentwrap .gallery {
        display: flex;
        flex-wrap: wrap;
        margin: 0 -6px !important;
    }

    #contentwrap .gallery .gallery-item {
        float: none;
        width: 33.333% !important;
        margin: 0 0 16px !important;
        padding: 0 6px;
        box-sizing: border-box;
    }

    #contentwrap .gallery img {
        width: 100%;
        border-width: 1px !important;
    }

    #contentwrap .gallery-caption {
        font-size: 13px;
        line-height: 1.3;
        overflow-wrap: normal;
        word-wrap: normal;
        -webkit-hyphens: auto;
        hyphens: auto;
    }

    /* ---------- Форма обратной связи (плагин Contact Form + капча) ---------- */

    .cntctfrm_contact_form .cntctfrm_input input[type="text"],
    .cntctfrm_contact_form textarea {
        width: 100% !important;
        max-width: 100%;
        min-height: 44px;
        padding: 10px 12px;
        border: 1px solid #b9c0bd;
        border-radius: 5px;
        font: 16px Arial, Helvetica, sans-serif; /* 16px — iOS не зумит страницу при фокусе */
        box-sizing: border-box;
    }

    .cntctfrm_contact_form textarea {
        min-height: 140px;
    }

    .cntctfrm_contact_form .cntctfrm_input input[type="text"]:focus,
    .cntctfrm_contact_form textarea:focus {
        border-color: #8A211B;
        outline: 0;
        box-shadow: 0 0 0 2px rgba(138, 33, 27, .15);
    }

    /* плагин задаёт блокам полей ширину 320px — на планшете справа оставалась пустота */
    .cntctfrm_contact_form .cntctfrm_label,
    .cntctfrm_contact_form .cntctfrm_input,
    .cntctfrm_contact_form .cntctfrm_checkbox {
        width: auto !important;
        max-width: none;
    }

    /* галочка согласия (её вставляет functions.php темы, ptet_consent_filter_html) — крупнее для пальца */
    .cntctfrm_contact_form .cntctfrm_consent input[type="checkbox"] {
        width: 20px;
        height: 20px;
        margin-top: 0 !important;
        accent-color: #8A211B;
    }

    .cntctfrm_contact_form .cntctfrm_input {
        margin-bottom: 12px;
    }

    /* поле ответа капчи: одна цифра, но удобного размера */
    .cntctfrm_contact_form .cntctfrm_input input.cptch_input {
        display: inline-block !important;
        width: 52px !important;
        margin-right: 6px;
        vertical-align: middle;
        min-height: 44px;
        font-size: 16px !important;
        text-align: center;
    }

    .cntctfrm_contact_form .cntctfrm_contact_submit {
        min-height: 44px;
        padding: 0 28px;
        border: 0;
        border-radius: 5px;
        background: #8A211B;
        color: #fff;
        font: bold 14px Arial, Helvetica, sans-serif;
        text-transform: uppercase;
        cursor: pointer;
        -webkit-appearance: none;
        appearance: none;
    }

    /* ---------- Сайдбар ---------- */

    .sidebar {
        margin: 0 0 10px;
    }

    /* красная полоска под заголовком виджета — под текстом, а не по центру экрана */
    .sidebar h2 {
        background-position: left bottom;
    }

    /* виджеты (новости, слабовидящие, поиск, рубрики…) отделены друг от друга */
    .sidebar > ul > li {
        margin-bottom: 28px;
    }

    /* «Версия сайта для слабовидящих» — как кнопка в шапке */
    .sidebar .bvi-link-widget {
        display: flex;
        align-items: center;
        gap: 12px;
        width: 100%;
        min-height: 44px;
        padding: 0 15px;
        border-radius: 5px;
        font: bold 14px/1.2 Arial, Helvetica, sans-serif;
        text-align: left;
        text-decoration: none;
        box-sizing: border-box;
    }

    .sidebar .bvi-link-widget svg {
        flex: 0 0 auto;
        width: 22px;
        height: 22px;
        margin: 0;
    }

    /* поиск: крупнее и заметнее */
    .sidebar #search {
        display: flex;
        align-items: center;
        height: 46px;
        margin: 0;
        padding: 0;
        border: 1px solid #b9c0bd;
        border-radius: 5px;
        background: #fff;
        overflow: hidden;
    }

    .sidebar #search:focus-within {
        border-color: #8A211B;
        box-shadow: 0 0 0 2px rgba(138, 33, 27, .15);
    }

    .sidebar #searchform {
        display: flex;
        align-items: center;
        width: 100%;
        height: 100%;
        margin: 0;
    }

    .sidebar #search #s {
        flex: 1 1 auto;
        width: auto;
        min-width: 0;
        height: 100%;
        margin: 0;
        padding: 0 12px;
        color: #303030;
        font: 16px Arial, Helvetica, sans-serif; /* 16px — iOS не зумит страницу при фокусе */
        box-sizing: border-box;
    }

    .sidebar #search input[type="image"] {
        flex: 0 0 auto;
        width: 22px;
        height: 22px;
        margin: 0;
        padding: 12px 14px;
        box-sizing: content-box;
    }

    /* ---------- Подвал ---------- */

    #footer {
        padding: 20px 15px;
    }
}

@media (max-width: 599px) {

    /* картинки, прижатые к краю текста, встают отдельной строкой */
    #contentwrap .alignleft,
    #contentwrap .alignright,
    #contentwrap img[style*="float"] {
        float: none !important;
        display: block;
        margin: 0 auto 12px !important;
    }

    .post_thumbnail {
        box-sizing: border-box;
    }

    #contentwrap .gallery .gallery-item {
        width: 50% !important;
    }

    .useful-links {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
    }

    .useful-links .useful-links__item {
        min-height: 80px;
        padding: 8px;
    }

    .useful-links .useful-links__item img {
        max-height: 62px;
    }

    /* главная, «Студенты и выпускники»: фото с именем над текстом отзыва */
    #contentwrap > .span-24 > table,
    #contentwrap > .span-24 > table tbody,
    #contentwrap > .span-24 > table tr,
    #contentwrap > .span-24 > table td {
        display: block;
        width: auto !important;
    }

    #contentwrap > .span-24 > table td {
        padding: 0;
    }

    #contentwrap > .span-24 > table tr {
        margin-bottom: 20px;
    }

    #contentwrap > .span-24 > table address {
        margin-top: 8px;
    }

    #header .logoimg {
        width: 72px;
    }

    #header .span-logo-text {
        margin-left: 12px;
    }

    #header .span-logo-text h3 {
        font-size: 11px;
    }

    #header .span-logo-text h1,
    #header .span-logo-text h2 {
        font-size: 19px;
    }

    #pagemenu li a,
    #pagemenu li a:link {
        padding: 6px 8px;
        font-size: 10px;
    }

    .entry {
        font-size: 15px;
    }
}

@media (max-width: 374px) {

    #header .logoimg {
        width: 60px;
    }

    #header .span-logo-text h3 {
        display: none;
    }

    #header .span-logo-text h1,
    #header .span-logo-text h2 {
        font-size: 17px;
    }
}
