/* Этапы 2 и 3 (тестовая версия): внутренние страницы без фотобаннеров, единый стиль, «Содержание раздела» */

/* Заголовок раздела на белом фоне вместо баннера */
.cr-page-head {
    position: relative;
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    gap: 24px;
    width: 100%;
    margin: 24px 0 32px;
}

.cr-page-head__text {
    min-width: 0;
    max-width: 1060px;
}

.cr-page-head__title {
    margin: 0;
    font-size: 44px;
    line-height: 1.18;
    font-weight: 400;
    letter-spacing: -0.01em;
    text-transform: none;
    color: #262929;
    overflow-wrap: break-word;
    hyphens: auto;
}

.cr-page-head__lead {
    margin: 12px 0 0;
    max-width: 760px;
    font-size: 18px;
    line-height: 1.5;
    font-weight: 300;
    color: #5f6b6e;
}

/* Дата статьи */
.cr-page-head__meta {
    margin: 12px 0 0;
    font-size: 14px;
    line-height: 1.5;
    color: #7f8f8f;
}

/* Фото раздела: невысокая полоса в начале колонки текста */
.cr-cover {
    height: clamp(180px, 20vw, 300px);
    margin: 0 0 32px;
    border-radius: 20px;
    overflow: hidden;
    background: #f3f6f6;
}

/* В статье текст идёт колонкой 1040px по центру, фото той же ширины; отступ до текста даёт сама статья */
.cr-cover--post {
    max-width: 1040px;
    margin: 0 auto;
}

.cr-cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Колонки: содержание слева, текст удобной для чтения ширины */
.cr-page__layout.has-toc {
    display: grid;
    grid-template-columns: 280px minmax(0, 780px);
    gap: 56px;
    align-items: start;
}

.cr-page__main {
    min-width: 0;
    max-width: 780px;
}

/* Текст раздела: одинаковые размеры поверх стилей, вписанных в сам текст */
.in-fo-des.cr-prose {
    display: flow-root; /* старые тексты с обтеканием (фото слева) не вылезают на подвал */
    margin-top: 0;
    font-size: 16px;
    line-height: 1.7;
    font-weight: 400;
    color: #262929;
}

.cr-prose > div[style] {
    max-width: none !important;
}

.cr-prose h2 {
    margin: 40px 0 14px !important;
    padding-top: 36px;
    border-top: 1px solid #ebf1f1;
    font-size: 24px !important;
    line-height: 1.3 !important;
    font-weight: 600 !important;
    color: #262929;
    scroll-margin-top: 150px;
}

.cr-prose > h2:first-child,
.cr-prose > div:first-child > h2:first-child {
    margin-top: 0 !important;
    padding-top: 0;
    border-top: 0;
    font-size: 26px !important;
}

.cr-prose h3 {
    margin: 28px 0 10px !important;
    font-size: 19px !important;
    line-height: 1.4 !important;
    font-weight: 600 !important;
    color: #262929;
}

.cr-prose p,
.cr-prose li {
    font-size: 16px !important;
    line-height: 1.7 !important;
    color: #262929;
}

.cr-prose p {
    margin: 0 0 16px !important;
}

.cr-prose ul,
.cr-prose ol {
    margin: 0 0 16px;
    padding-left: 22px;
}

.cr-prose li {
    margin-bottom: 6px;
}

.cr-prose a {
    color: #1b879f;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.cr-prose a:hover {
    color: #239eba;
}

/* В тексте <strong> выделяет слова, а не служит заголовком */
.in-fo-des.cr-prose strong {
    display: inline;
    margin: 0;
    font-size: inherit;
    line-height: inherit;
    font-weight: 600;
    text-transform: none;
    color: inherit;
}

/* «Содержание раздела» */

/* body с overflow-x: hidden становится контейнером прокрутки, и sticky внутри него не работает; clip режет так же, но без этого */
@supports (overflow: clip) {
    body {
        overflow-x: clip;
        overflow-y: visible;
    }
}

/* Сверху место под шапку сайта: при прокрутке она закреплена */
.cr-toc {
    position: sticky;
    top: 146px;
    max-height: calc(100vh - 166px);
    overflow-y: auto;
    scrollbar-width: thin;
}

.cr-toc__box {
    padding: 20px 12px 12px;
    border: 1px solid #ebf1f1;
    border-radius: 20px;
    background: #fff;
}

.cr-toc__title {
    display: block;
    padding: 0 12px 10px;
    font-size: 16px;
    line-height: 1.4;
    font-weight: 600;
    color: #262929;
    list-style: none;
    cursor: default;
}

.cr-toc__title::-webkit-details-marker {
    display: none;
}

.cr-toc__list {
    margin: 0;
    padding: 0;
    list-style: none;
}

.cr-toc__link {
    display: block;
    padding: 8px 12px;
    border-radius: 12px;
    font-size: 15px;
    line-height: 1.4;
    color: #262929;
    text-decoration: none;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.cr-toc__link:hover {
    color: #1b879f;
}

.cr-toc__link.is-active {
    background: #f3f6f6;
    color: #1b879f;
    box-shadow: inset 2px 0 0 #239eba;
}

/* Небольшой экран: содержание над текстом */
@media (max-width: 1199px) {
    .cr-page__layout.has-toc {
        display: block;
    }

    .cr-page__main {
        max-width: 780px;
    }

    .cr-toc {
        position: static;
        max-height: none;
        overflow: visible;
        margin-bottom: 32px;
    }

    .cr-toc__box {
        padding: 18px 20px;
    }

    .cr-toc__title {
        padding: 0 0 10px;
    }

    .cr-toc__list {
        display: flex;
        flex-wrap: wrap;
        gap: 6px 22px;
    }

    .cr-toc__link,
    .cr-toc__link.is-active {
        padding: 2px 0;
        border-radius: 0;
        background: none;
        box-shadow: none;
        text-decoration: underline;
        text-decoration-color: rgba(27, 135, 159, 0.35);
        text-underline-offset: 4px;
    }
}

@media (max-width: 1023px) {
    .cr-page-head__title {
        font-size: 36px;
    }
}

/* Телефон: содержание сворачивается */
@media (max-width: 767px) {
    .cr-page-head {
        margin: 16px 0 24px;
    }

    .cr-page-head__title {
        font-size: 30px;
        line-height: 1.2;
    }

    .cr-page-head__lead {
        font-size: 16px;
    }

    .cr-cover {
        margin-bottom: 28px;
        border-radius: 16px;
    }

    .cr-cover--post {
        margin-bottom: 0;
    }

    .cr-toc {
        margin-bottom: 24px;
    }

    .cr-toc__box {
        padding: 0;
        border-radius: 16px;
    }

    .cr-toc__title {
        position: relative;
        padding: 15px 48px 15px 18px;
        cursor: pointer;
    }

    .cr-toc__title::after {
        content: "";
        position: absolute;
        right: 20px;
        top: 50%;
        width: 8px;
        height: 8px;
        margin-top: -6px;
        border-right: 1.5px solid #262929;
        border-bottom: 1.5px solid #262929;
        transform: rotate(45deg);
        transition: transform 0.2s ease;
    }

    .cr-toc__box[open] .cr-toc__title::after {
        margin-top: -2px;
        transform: rotate(-135deg);
    }

    .cr-toc__list {
        display: block;
        padding: 0 8px 10px;
        border-top: 1px solid #ebf1f1;
    }

    .cr-toc__link,
    .cr-toc__link.is-active {
        padding: 10px 10px;
        text-decoration: none;
    }

    .cr-toc__link.is-active {
        color: #1b879f;
    }

    .cr-prose h2 {
        margin-top: 32px !important;
        padding-top: 28px;
        font-size: 21px !important;
        scroll-margin-top: 90px;
    }

    .cr-prose > h2:first-child,
    .cr-prose > div:first-child > h2:first-child {
        font-size: 22px !important;
    }
}

/* Каталог: цена двумя полями «От / До» (ползунок OCFilter скрыт, значения в него передаёт cr-catalog-filter.js) */
/* Стили OCFilter подключаются после этого файла, поэтому селекторы с запасом */
.ocf-container .ocf-filter.cr-price .ocf-filter-header,
.ocf-container .ocf-filter.cr-price .ocf-value-list {
    display: none !important;
}

.cr-price__fields {
    display: flex;
    gap: 8px;
}

.cr-price__input {
    flex: 1 1 0;
    min-width: 0;
    height: 48px;
    padding: 0 14px;
    border: 1px solid #dbe3e3;
    border-radius: 25px;
    background: #fff;
    font: 300 15px/1.2 Inter, system-ui, sans-serif;
    color: #262929;
    outline: none;
    transition: border-color 0.2s ease;
}

/* Узкая полоса фильтра (планшет, небольшой ноутбук): «1 000 000» помещается целиком */
@media (min-width: 769px) and (max-width: 1365px) {
    .cr-price__fields {
        gap: 6px;
    }

    .cr-price__input {
        padding: 0 6px 0 9px;
        font-size: 13px;
    }
}

.cr-price__input::placeholder {
    color: #7f8f8f;
}

.cr-price__input:focus {
    border-color: #239eba;
}

.cr-sheet__bar,
.cr-sheet__show-all {
    display: none;
}

/* Каталог на телефоне: фильтр на весь экран поверх шапки и нижнего меню */
@media (max-width: 768px) {
    html.cr-sheet-open,
    html.cr-sheet-open body {
        overflow: hidden !important;
    }

    .ocf-container.cr-sheet {
        position: fixed !important;
        inset: 0;
        z-index: 10000 !important;
        margin: 0 !important;
        padding: 0 16px !important;
        width: auto !important;
        max-width: none !important;
        background: #fff;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
    }

    .cr-sheet .cr-sheet__bar {
        position: sticky;
        top: 0;
        z-index: 20; /* выше ручек ползунка «Расстояние до моря» */
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin: 0 -16px 12px;
        padding: 12px 16px;
        border-bottom: 1px solid #ebf1f1;
        background: #fff;
    }

    .cr-sheet__title {
        font-size: 20px;
        font-weight: 500;
        color: #262929;
    }

    .cr-sheet__close {
        position: relative;
        width: 40px;
        height: 40px;
        border: 1px solid #dbe3e3;
        border-radius: 50%;
        background: #fff;
        cursor: pointer;
    }

    .cr-sheet__close::before,
    .cr-sheet__close::after {
        content: "";
        position: absolute;
        left: 50%;
        top: 50%;
        width: 16px;
        height: 1.5px;
        margin: -0.75px 0 0 -8px;
        background: #262929;
        transform: rotate(45deg);
    }

    .cr-sheet__close::after {
        transform: rotate(-45deg);
    }

    /* Все параметры видны сразу, отдельная кнопка расширенного фильтра не нужна */
    .cr-sheet .js-advanced-filter-btn,
    .cr-sheet .butt-fill-rez {
        display: none !important;
    }

    .cr-sheet .ocf-footer.ocf-mobile {
        position: sticky;
        bottom: 0;
        z-index: 20; /* выше ручек ползунка «Расстояние до моря» */
        margin: 16px -16px 0;
        padding: 12px 16px calc(12px + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #ebf1f1;
        background: #fff;
    }

    .cr-sheet .ocf-footer .ocf-between {
        display: flex;
        align-items: center;
        gap: 10px;
    }

    .cr-sheet .ocf-footer [data-ocf-discard] {
        flex: 0 0 auto;
        width: auto !important;
        height: 52px;
        margin: 0 !important;
        padding: 0 8px !important;
        border: 0 !important;
        background: none !important;
        font: 400 15px/1.2 Inter, system-ui, sans-serif !important;
        color: #1b879f !important;
        text-transform: none !important;
    }

    .cr-sheet.cr-sheet--idle .ocf-footer [data-ocf-discard] {
        display: none;
    }

    .cr-sheet .ocf-footer [data-ocf="button"],
    .cr-sheet .cr-sheet__show-all {
        flex: 1 1 0;
        min-width: 0;
        width: auto !important;
        margin: 0 !important;
        padding: 0 16px !important;
        height: 52px;
        border: 0;
        border-radius: 50px;
        background: #111;
        font: 500 15px/1.2 Inter, system-ui, sans-serif;
        color: #fff;
        text-transform: none;
    }

    /* Пока ничего не выбрано, вместо неактивной кнопки OCFilter — «Показать N объектов» с текущим числом */
    .cr-sheet.cr-sheet--idle .ocf-footer [data-ocf="button"] {
        display: none;
    }

    .cr-sheet.cr-sheet--idle .cr-sheet__show-all {
        display: block !important;
    }

    .cr-sheet:not(.cr-sheet--idle) .cr-sheet__show-all {
        display: none !important;
    }
}
