/*
 * Черника — блок 4.
 * Авторы с горизонтальной прокруткой
 * и всплывающими анкетами.
 */

.chb4 {
    --chb4-bg: #f4f3f0;
    --chb4-text: #1d1d1d;
    --chb4-muted: #77736f;
    --chb4-wine: #741f35;
    --chb4-wine-dark: #451020;
    --chb4-gold: #d69301;
    --chb4-line: #d7d1cc;
    --chb4-placeholder: #e2e0dc;
    --chb4-placeholder-icon: #b6b5b3;

    --chb4-serif: Georgia, "Times New Roman", serif;
    --chb4-sans: Arial, Helvetica, sans-serif;

    display: block;
    width: 100%;
    margin: 0;
    padding: 22px 0 40px;
    background: var(--chb4-bg);
    color: var(--chb4-text);
    font-family: var(--chb4-sans);
    font-size: 16px;
    line-height: 1.4;
    isolation: isolate;
}

.chb4 *,
.chb4 *::before,
.chb4 *::after {
    box-sizing: border-box;
}

.chb4 h2,
.chb4 h3,
.chb4 p {
    margin: 0;
    padding: 0;
}

.chb4 button {
    font: inherit;
}

.chb4 button:focus-visible,
.chb4 a:focus-visible {
    outline: 3px solid var(--chb4-gold);
    outline-offset: 4px;
}

.chb4__container {
    width: min(1420px, calc(100% - 48px));
    margin: 0 auto;
}

/* ==========================================================
   Заголовок блока
   ========================================================== */

.chb4__header {
    display: flex;
    align-items: center;
    gap: 20px;
    min-height: 44px;
    margin-bottom: 16px;
}

.chb4__heading {
    flex: 0 0 auto;
    color: var(--chb4-wine);
    font-family: var(--chb4-serif);
    font-size: 22px;
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.01em;
    text-transform: uppercase;
}

.chb4__line {
    display: block;
    flex: 1 1 auto;
    min-width: 12px;
    height: 1px;
    background: var(--chb4-line);
}

.chb4__all {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 6px;
    min-height: 44px;
    color: var(--chb4-wine);
    font-family: var(--chb4-serif);
    font-size: 15px;
    font-weight: 700;
    white-space: nowrap;
}

.chb4__all:hover {
    color: var(--chb4-gold);
    text-decoration: underline;
    text-underline-offset: 4px;
}

/* ==========================================================
   Горизонтальная лента карточек
   ========================================================== */

.chb4__carousel {
    position: relative;
    width: 100%;
    padding: 0 38px;
}

.chb4__cards {
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 0;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    scroll-snap-type: x proximity;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
}

.chb4__cards::-webkit-scrollbar {
    display: none;
}

.chb4__card {
    display: block;
    flex: 0 0 calc((100% - 48px) / 5);
    min-width: 0;
    margin: 0;
    padding: 0;
    scroll-snap-align: start;
}

/* ==========================================================
   Стрелки на стационарных компьютерах
   ========================================================== */

.chb4__arrow {
    position: absolute;
    top: 50%;
    z-index: 5;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 34px;
    height: 54px;
    padding: 0;

    border: 0;
    border-radius: 3px;

    background: var(--chb4-wine);
    color: #fff;

    font-family: var(--chb4-serif);
    font-size: 39px;
    font-weight: 400;
    line-height: 1;

    opacity: 0;
    pointer-events: none;
    cursor: pointer;

    transform: translateY(-50%);
    transition:
        opacity 180ms ease,
        background-color 180ms ease,
        color 180ms ease;
}

.chb4__arrow:hover {
    background: var(--chb4-gold);
    color: #fff;
}

.chb4__arrow.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.chb4__arrow[disabled] {
    opacity: 0;
    pointer-events: none;
    cursor: default;
}

.chb4__arrow--prev {
    left: 0;
}

.chb4__arrow--next {
    right: 0;
}

/* ==========================================================
   Фото карточки
   ========================================================== */

.chb4__photo-button,
.chb4__name-button {
    appearance: none;
    border: 0;
    margin: 0;
    padding: 0;
    background: transparent;
    color: inherit;
    text-align: left;
    cursor: pointer;
}

.chb4__photo-button {
    display: block;
    width: 100%;
}

.chb4__photo {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    aspect-ratio: 4 / 3;
    overflow: hidden;
    border-radius: 2px;
    background: var(--chb4-placeholder);
    isolation: isolate;
}

.chb4__image {
    position: relative;
    z-index: 1;
    display: block;
    width: 100%;
    height: 100%;
    max-width: none;
    margin: 0;
    border: 0;
    object-fit: contain;
    object-position: center;
    transition: filter 200ms ease;
}

.chb4__photo-button:hover .chb4__image {
    filter: brightness(0.9);
}

/*
 * Если в PHP используется фоновая копия фотографии
 * с классом .chb4__photo-background.
 */
.chb4__photo-background {
    position: absolute;
    inset: -18px;
    z-index: 0;
    display: block;
    background-image:
        linear-gradient(
            rgba(0, 0, 0, 0.08),
            rgba(0, 0, 0, 0.08)
        ),
        var(--chb4-photo-url);
    background-position: center;
    background-size: cover;
    filter: blur(18px);
    transform: scale(1.08);
}

/* Заглушка при отсутствии фотографии */
.chb4__placeholder {
    position: relative;
    z-index: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: var(--chb4-placeholder);
    color: var(--chb4-placeholder-icon);
}

.chb4__placeholder::after {
    position: absolute;
    top: 50%;
    left: 50%;
    width: 42px;
    height: 42px;
    border: 8px solid var(--chb4-placeholder-icon);
    border-right-color: transparent;
    border-bottom-color: transparent;
    border-radius: 4px;
    content: "";
    opacity: 0.75;
    transform: translate(-15%, -50%) rotate(45deg);
}

.chb4__placeholder-letter {
    position: relative;
    z-index: 1;
    margin-right: 40px;
    color: var(--chb4-placeholder-icon);
    font-family: var(--chb4-serif);
    font-size: clamp(48px, 5vw, 86px);
    font-weight: 400;
    line-height: 1;
}

/* ==========================================================
   Текст карточки
   ========================================================== */

.chb4__card-content {
    min-width: 0;
    padding-top: 10px;
}

.chb4__name {
    margin-bottom: 5px !important;
    color: var(--chb4-text);
    font-family: var(--chb4-serif);
    font-size: clamp(18px, 1.45vw, 23px);
    font-weight: 700;
    line-height: 1.15;
    letter-spacing: -0.018em;
    overflow-wrap: break-word;
}

.chb4__name-button:hover {
    color: var(--chb4-gold);
    text-decoration: underline;
    text-underline-offset: 4px;
}

.chb4__status {
    color: var(--chb4-muted);
    font-family: var(--chb4-sans);
    font-size: 14px;
    line-height: 1.4;
    overflow-wrap: break-word;
}

.chb4__note {
    margin-top: 17px !important;
    color: var(--chb4-muted);
    font-family: var(--chb4-sans);
    font-size: 13px;
    line-height: 1.5;
}

/* ==========================================================
   Всплывающая анкета
   ========================================================== */

.chb4__modal[hidden] {
    display: none;
}

.chb4__modal {
    position: fixed;
    inset: 0;
    z-index: 999999;

    display: flex;
    align-items: center;
    justify-content: center;

    padding: 24px;
}

.chb4__modal-overlay {
    position: absolute;
    inset: 0;
    background: rgba(29, 18, 20, 0.72);
    cursor: pointer;
}

.chb4__modal-dialog {
    position: relative;
    z-index: 1;

    width: min(760px, 100%);
    max-height: calc(100dvh - 48px);
    overflow-x: hidden;
    overflow-y: auto;

    border-radius: 3px;
    background: var(--chb4-bg);
    box-shadow: 0 18px 60px rgba(0, 0, 0, 0.38);
}

.chb4__modal-close {
    position: absolute;
    top: 12px;
    right: 14px;
    z-index: 3;

    display: flex;
    align-items: center;
    justify-content: center;

    width: 42px;
    height: 42px;
    padding: 0;

    border: 0;
    border-radius: 50%;

    background: var(--chb4-wine);
    color: #fff;

    font-family: Arial, Helvetica, sans-serif;
    font-size: 29px;
    font-weight: 300;
    line-height: 1;

    cursor: pointer;
}

.chb4__modal-close:hover {
    background: var(--chb4-gold);
}

.chb4__modal-content {
    padding: 32px;
}

.chb4__profile[hidden] {
    display: none;
}

.chb4__profile {
    display: block;
}

.chb4__profile-photo {
    display: flex;
    align-items: center;
    justify-content: center;

    width: 100%;
    max-height: 440px;
    margin: 0 auto 26px;
    overflow: hidden;

    background: var(--chb4-placeholder);
}

.chb4__modal-image {
    display: block;
    width: 100%;
    max-width: 620px;
    max-height: 440px;
    margin: 0 auto;

    object-fit: contain;
    object-position: center;
}

.chb4__profile-content {
    max-width: 650px;
    margin: 0 auto;
}

.chb4__profile-name {
    margin-bottom: 8px !important;
    color: var(--chb4-wine);
    font-family: var(--chb4-serif);
    font-size: clamp(26px, 3vw, 36px);
    font-weight: 700;
    line-height: 1.12;
}

.chb4__profile-status {
    margin-bottom: 22px !important;
    color: var(--chb4-muted);
    font-family: var(--chb4-sans);
    font-size: 15px;
    line-height: 1.5;
}

.chb4__profile-bio {
    color: var(--chb4-text);
    font-family: var(--chb4-sans);
    font-size: 16px;
    line-height: 1.65;
}

.chb4__profile-bio p {
    margin-bottom: 14px !important;
}

html.chb4-modal-open,
body.chb4-modal-open {
    overflow: hidden;
}

/* ==========================================================
   Планшеты
   ========================================================== */

@media (max-width: 1000px) {
    .chb4__carousel {
        padding: 0;
    }

    .chb4__cards {
        gap: 10px;
        padding-bottom: 8px;
        scroll-snap-type: x proximity;
        scrollbar-width: thin;
    }

    .chb4__cards::-webkit-scrollbar {
        display: block;
        height: 5px;
    }

    .chb4__cards::-webkit-scrollbar-track {
        background: var(--chb4-line);
    }

    .chb4__cards::-webkit-scrollbar-thumb {
        background: var(--chb4-wine);
        border-radius: 5px;
    }

    .chb4__card {
        flex-basis: calc((100% - 20px) / 3);
    }

    .chb4__arrow {
        display: none;
    }
}

/* ==========================================================
   Телефоны
   ========================================================== */

@media (max-width: 700px) {
    .chb4 {
        padding: 20px 0 30px;
    }

    .chb4__container {
        width: calc(100% - 24px);
    }

    .chb4__header {
        flex-wrap: wrap;
        gap: 6px 12px;
        margin-bottom: 14px;
    }

    .chb4__heading {
        font-size: 20px;
    }

    .chb4__all {
        font-size: 14px;
    }

    .chb4__card {
        flex-basis: calc((100% - 10px) / 2);
    }

    .chb4__name {
        font-size: 19px;
    }

    .chb4__status {
        font-size: 13px;
    }

    .chb4__modal {
        align-items: flex-start;
        padding: 12px;
    }

    .chb4__modal-dialog {
        max-height: calc(100dvh - 24px);
    }

    .chb4__modal-content {
        padding: 48px 18px 24px;
    }

    .chb4__profile-photo {
        max-height: 330px;
        margin-bottom: 20px;
    }

    .chb4__modal-image {
        max-height: 330px;
    }

    .chb4__profile-name {
        font-size: 27px;
    }

    .chb4__profile-bio {
        font-size: 15px;
        line-height: 1.58;
    }
}

@media (max-width: 440px) {
    .chb4__card {
        flex-basis: 82%;
    }

    .chb4__modal-content {
        padding-right: 15px;
        padding-left: 15px;
    }
}