/* ==========================================================================
   Custom Fixes: Mobile Adaptive & Responsive
   Activated only via ?dev_preview=1 or cookie dev_preview=1
   Чистый каскад через специфичность селекторов (без мусорных !important)
   ========================================================================== */

/* --- Блок видов рецензий (иконки .typerec) на мобильных устройствах --- */
@media screen and (max-width: 768px) {
    body #recensions,
    body #recensions .child {
        height: auto;
        clear: both;
    }

    body #recensions .child {
        display: flex;
        flex-wrap: wrap;
        justify-content: space-between;
        align-items: flex-start;
    }

    /* Исключаем старые php-разделители строк из flex-потока */
    body #recensions .child > .clear,
    body #recensions .child > div:not(.typerec) {
        display: none;
    }

    /* Заголовки над списком (если внутри .child) */
    body #recensions .child > #practic-title,
    body #recensions .child > #catdescr {
        display: block;
        width: 100%;
        flex: 0 0 100%;
    }

    /* Карточка вида рецензии: по 2 в ряд */
    body #recensions .child .typerec {
        float: none;
        width: 47%;
        flex: 0 0 47%;
        margin: 0 0 30px 0 !important; /* Перекрывает инлайн style="margin-right:0" от php */
        box-sizing: border-box;
        text-align: center;
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    body #recensions .child .typerec a {
        display: inline-block;
        text-decoration: none;
    }

    body #recensions .child .typerec img {
        width: 85px;
        height: 85px;
        max-width: 85px;
        object-fit: contain;
        margin: 0 auto 10px auto;
        display: block;
    }

    body #recensions .child .typerec > div {
        width: 100%;
        text-align: center;
        box-sizing: border-box;
    }

    body #recensions .child .typerec div a {
        font-size: 11.5px;
        line-height: 1.35;
        color: #343434;
        text-transform: uppercase;
        font-weight: bold;
        display: block;
        word-break: normal;
        overflow-wrap: break-word;
        hyphens: auto;
        -webkit-hyphens: auto;
    }

    body #recensions .all-recs {
        display: block;
        width: 100%;
        flex: 0 0 100%;
        margin: 10px auto 0 auto;
        text-align: center;
        float: none;
    }
}

/* --- Блок подвала (#footer) на мобильных устройствах --- */
@media screen and (max-width: 768px) {
    body #footer {
        width: 100%;
        max-width: 100%;
        height: auto;
        background: url(images/footer-bg.png) no-repeat center top;
        background-size: 100% auto;
        padding: 14px 15px 30px 15px;
        box-sizing: border-box;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        position: relative;
        margin: 0 auto;
    }

    body #footer .clear {
        display: none;
    }

    body #footer #footer-phone {
        order: 1;
        float: none;
        margin: 0 0 25px 0;
        padding: 0;
        width: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    body #footer #footer-phone .callibri_phone,
    body #footer #footer-phone a[href^="tel:"] {
        font-size: 24px;
        line-height: 1.2;
        color: #fff;
        text-decoration: none;
        display: inline-block;
        margin-bottom: 12px;
    }

    body #footer #footer-phone .zayavka_callback {
        margin: 0 auto;
        display: inline-block;
        float: none;
    }

    body #footer #footer-info {
        order: 2;
        float: none;
        width: 100%;
        margin: 0;
        padding: 0 10px;
        box-sizing: border-box;
        text-align: left;
        font-size: 13px;
        line-height: 1.45;
        color: rgba(255, 255, 255, 0.85);
    }

    body #footer #footer-info p {
        font-size: 13px;
        line-height: 1.45;
        margin: 0 0 12px 0;
    }

    body #footer #footer-info div[style*="padding"] {
        padding: 10px 0 0 0 !important; /* Перекрывает инлайн style="padding: 20px 0 0 0;" */
    }

    body #footer #footer-info a {
        color: #fff;
        font-size: 13px;
    }
}

/* --- Блоки команды и руководства (.content-block) на мобильных устройствах --- */
@media screen and (max-width: 768px) {
    body #content .content-block.is-layout-grid,
    body #content .wp-block-group.is-layout-grid {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    body #content .content-block.is-layout-grid > .wp-block-group,
    body #content .wp-block-group.is-layout-grid > .wp-block-group {
        width: 100%;
        max-width: 320px;
        margin: 0 auto;
        box-sizing: border-box;
        text-align: center;
    }

    body #content .content-block.is-layout-grid .wp-block-image,
    body #content .wp-block-group.is-layout-grid .wp-block-image,
    body #content .content-block.is-layout-grid figure,
    body #content .wp-block-group.is-layout-grid figure {
        width: 100%;
        max-width: 260px;
        margin: 0 auto 15px auto;
    }

    body #content .content-block.is-layout-grid .wp-block-image img,
    body #content .wp-block-group.is-layout-grid .wp-block-image img {
        width: 260px;
        max-width: 100%;
        aspect-ratio: 2 / 3;
        height: auto;
        object-fit: cover;
        margin: 0 auto;
        display: block;
        border-radius: 4px;
    }

    body #content .content-block.is-layout-grid p.has-text-align-center,
    body #content .wp-block-group.is-layout-grid p.has-text-align-center {
        font-size: 18px;
        line-height: 1.3;
        margin: 0 0 8px 0;
        word-break: normal;
        overflow-wrap: break-word;
    }

    body #content .content-block.is-layout-grid p:not(.has-text-align-center),
    body #content .wp-block-group.is-layout-grid p:not(.has-text-align-center) {
        font-size: 15px;
        line-height: 1.4;
        margin: 0 0 6px 0;
    }
}

/* --- Форма заявки (#callback2 и .form-4-wrapper) на мобильных устройствах --- */
@media screen and (max-width: 768px) {
    /* Заголовок формы */
    body .form-title {
        font-size: 18px;
        line-height: 1.35;
        margin: 25px auto 15px auto;
        padding: 0 10px;
        box-sizing: border-box;
    }

    /* Белая плашка формы */
    body .form-4-wrapper {
        padding: 20px 14px 28px 14px;
        box-sizing: border-box;
    }

    /* Текстовые поля формы */
    body .form-4-wrapper .callback-form .form-col-3 {
        width: 100%;
        margin-left: 0;
        margin-bottom: 12px;
        float: none;
    }

    body .form-4-wrapper .callback-form input[type="text"] {
        width: 100%;
        box-sizing: border-box;
        font-size: 15px;
        height: 42px;
        padding: 8px 12px;
        border-radius: 4px;
    }

    /* Чекбокс согласия ПД */
    body .form-4-wrapper .callback-form .cpd {
        margin: 10px 0 14px 0;
        text-align: center;
        font-size: 13px;
        line-height: 1.35;
    }

    body .form-4-wrapper .callback-form .cpd label {
        font-size: 13px;
        line-height: 1.35;
    }

    body .form-4-wrapper .callback-form .cpd label a {
        font-size: 13px;
    }

    /* Уведомление о конфиденциальности */
    body .form-4-wrapper .form-notification {
        font-size: 12px;
        line-height: 1.35;
        color: #666;
        margin: 0 auto 16px auto;
        padding: 0 5px;
        text-align: center;
        box-sizing: border-box;
    }

    /* Кнопка отправки формы */
    body .form-4-wrapper .callback-form .zayavka_callback {
        display: block;
        margin: 0 auto;
        float: none;
        max-width: 220px;
        text-align: center;
        box-sizing: border-box;
    }
}

/* --- Карточки практики (#rests .rest.restpracice) на десктопе и мобиле --- */
body #rests .rest.restpracice {
    display: flex;
    align-items: flex-start;
    box-sizing: border-box;
}

body #rests .rest.restpracice picture,
body #rests .rest.restpracice > img {
    flex: 0 0 150px;
    width: 150px;
    height: 112px;
    margin: 0 12px 0 0;
    display: block;
    overflow: hidden;
    border-radius: 3px;
    background: #e6e6e6;
}

body #rests .rest.restpracice picture img,
body #rests .rest.restpracice > img {
    width: 150px;
    height: 112px;
    object-fit: cover;
    display: block;
    margin: 0;
}

body #rests .rest.restpracice .nophoto-placeholder {
    object-fit: contain;
    background: #eaeaea;
    border: 1px solid #dcdcdc;
    box-sizing: border-box;
}

/* Мобильный адаптив для карточек практики */
@media screen and (max-width: 768px) {
    body #rests {
        padding: 0;
        box-sizing: border-box;
    }

    body #rests .child {
        padding: 0;
        box-sizing: border-box;
    }

    body #rests .child .rest.restpracice {
        width: 100%;
        max-width: 320px;
        margin: 0 auto 30px auto;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    body #rests .child .rest.restpracice picture,
    body #rests .child .rest.restpracice > img {
        flex: 0 0 auto;
        width: 260px;
        height: 180px;
        margin: 0 auto 15px auto;
    }

    body #rests .child .rest.restpracice picture img,
    body #rests .child .rest.restpracice > img {
        width: 260px;
        height: 180px;
        object-fit: cover;
        margin: 0 auto;
    }

    body #rests .child .rest.restpracice .nophoto-placeholder {
        object-fit: contain;
    }

    body #rests .child .rest.restpracice .rest-content {
        width: 100%;
        margin: 0 0 12px 0;
        text-align: left;
    }

    body #rests .child .rest.restpracice .rest-content .rest-title {
        font-size: 18px;
        line-height: 1.35;
        text-align: center;
        margin-bottom: 8px;
    }

    body #rests .child .rest.restpracice .rest-content .rest-text {
        font-size: 14px;
        line-height: 1.45;
        text-align: justify;
    }

    body #rests .child .rest.restpracice a.readmore {
        display: inline-block;
        margin: 0 auto;
        text-align: center;
        font-size: 15px;
    }
}

/* --- Списки (ol, ul) в текстовом контенте: выравнивание маркеров относительно текста <p> --- */
body #content .child ol,
body #content .child ul:not(.menu):not(.sub-menu):not(.eSellerItems_list),
body #content .content-block ol,
body #content .content-block ul:not(.menu):not(.sub-menu),
body #content .post-content ol,
body #content .post-content ul:not(.menu):not(.sub-menu) {
    padding-left: 24px;
    margin-left: 0;
    margin-bottom: 20px;
    list-style-position: outside;
    box-sizing: border-box;
}

body #content .child ol li,
body #content .child ul:not(.menu):not(.sub-menu):not(.eSellerItems_list) li,
body #content .content-block ol li,
body #content .content-block ul:not(.menu):not(.sub-menu) li,
body #content .post-content ol li,
body #content .post-content ul:not(.menu):not(.sub-menu) li {
    padding-left: 4px;
    margin-bottom: 8px;
    line-height: 1.45;
}

/* --- Поп-ап формы (Fancybox) на мобильных устройствах: не уходят за экран --- */
@media screen and (max-width: 768px) {
    body .fancybox-wrap {
        position: fixed !important;
        top: 50% !important;
        left: 50% !important;
        transform: translate(-50%, -50%) !important;
        width: calc(100vw - 24px) !important;
        max-width: 380px !important;
        box-sizing: border-box !important;
        margin: 0 !important;
    }

    body .fancybox-skin {
        width: 100% !important;
        max-width: 100% !important;
        padding: 24px 16px 20px 16px !important;
        box-sizing: border-box !important;
        border-radius: 8px !important;
    }

    body .fancybox-outer {
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body .fancybox-inner {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
        max-height: 80vh !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }

    body .fancybox-inner form.callback-form,
    body form.callback-form {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    body form.callback-form input[type="text"],
    body form.callback-form select,
    body form.callback-form textarea {
        width: 100% !important;
        box-sizing: border-box !important;
        font-size: 15px;
        min-height: 40px;
    }

    body form.callback-form textarea {
        min-height: 70px;
    }

    body form.callback-form div.cpd {
        font-size: 12px;
        line-height: 1.35;
        padding: 4px 0;
        box-sizing: border-box;
    }

    body form.callback-form div.cpd label {
        font-size: 12px;
        line-height: 1.35;
    }

    body form.callback-form div.cpd label a {
        font-size: 12px;
    }

    body form.callback-form .zayavka_callback {
        max-width: 220px;
        margin: 10px auto 0 auto;
        display: block;
        box-sizing: border-box;
    }

    body .fancybox-close {
        top: -12px !important;
        right: -12px !important;
    }
}

/* --- Страница контактов (/contacts/): адаптив карточек офисов и Яндекс.Карт --- */
@media screen and (max-width: 768px) {
    body .office {
        display: flex;
        flex-direction: column;
        width: 100%;
        box-sizing: border-box;
        margin-bottom: 25px;
    }

    body .office .information {
        float: none;
        width: 100%;
        max-width: 100%;
        padding: 0;
        margin: 0 0 15px 0;
        box-sizing: border-box;
    }

    body .office .map {
        float: none;
        width: 100%;
        max-width: 100%;
        height: auto;
        min-height: 220px;
        padding: 0;
        margin: 0 auto;
        box-sizing: border-box;
        overflow: hidden;
        border-radius: 4px;
    }

    body .office .map iframe,
    body .office .map ymaps,
    body .office .map > ymaps {
        width: 100% !important;
        max-width: 100% !important;
        height: 240px !important;
        box-sizing: border-box !important;
        display: block;
    }

    body .office hr {
        width: 100%;
        margin: 25px 0 !important;
        box-sizing: border-box;
    }
}
