/* =============================================================================
   Промо-баннер «Лето в Швейцарских Альпах» (iStudy).
   Самодостаточный компонент: разметку создаёт website/js/banners.js.
   Цвета/радиусы — в переменных ниже, менять только здесь.
   ========================================================================== */

.camp-banner {
    --cb-bg: #ffffff;
    --cb-border: rgba(0, 0, 0, .1);
    --cb-text: #1a1a1a;
    --cb-radius: 24px;
    --cb-cover-radius: 16px;
    --cb-brand: #084764;
    --cb-brand-hover: #0a5b7d;
    --cb-brand-text: #ffffff;
    /* насколько карточка поднята над нижним краем экрана */
    --cb-bottom: 24px;
    /* левее стоит блок соцсетей (fixed, left 36px, ~70px шириной) — не перекрываем его */
    --cb-left: 120px;

    /* выше окна чата Chaport (z-index 2147483500), чтобы переписка оказалась под карточкой;
       модалки сайта и меню при этом закрывают карточку (см. правила ниже и watchSiteModals) */
    --cb-z: 2147483501;

    position: fixed;
    left: var(--cb-left);
    bottom: var(--cb-bottom);
    z-index: var(--cb-z);
    box-sizing: border-box;
    width: 848px;
    max-width: calc(100vw - var(--cb-left) - 24px);
    display: flex;
    gap: 8px;
    padding: 8px;
    background: var(--cb-bg);
    border: 1px solid var(--cb-border);
    border-radius: var(--cb-radius);
    box-shadow: 0 12px 40px rgba(0, 0, 0, .18);
    font-family: "Montserrat", "Helvetica Neue", Arial, sans-serif;
    color: var(--cb-text);
    opacity: 0;
    transform: translateX(-24px);
    pointer-events: none;
    transition: opacity .35s ease, transform .35s ease;
}

.camp-banner[hidden] {
    display: none;
}

/* пока открыт выпадающий список меню, карточку убираем — как это делает .social-block */
body:has(#ddmenu2 > li:hover) .camp-banner,
body:has(#ddmenu2 > li:focus-within) .camp-banner {
    opacity: 0;
    pointer-events: none;
}

.camp-banner.is-visible {
    opacity: 1;
    transform: none;
    pointer-events: auto;
}

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

/* --- обложка ------------------------------------------------------------- */

.camp-banner__cover {
    flex: 0 0 420px;
    width: 420px;
    border-radius: var(--cb-cover-radius);
    overflow: hidden;
    background: #f2f2f2;
}

.camp-banner__cover picture {
    display: block;
    width: 100%;
    height: 100%;
}

.camp-banner__cover img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
}

/* --- контент ------------------------------------------------------------- */

.camp-banner__content {
    flex: 1 1 420px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 24px;
    padding: 16px 24px 24px;
}

.camp-banner__logo {
    min-height: 24px;
}

.camp-banner__logo img {
    display: block;
    max-height: 32px;
    width: auto;
}

.camp-banner__title {
    margin: 0;
    font-size: 24px;
    line-height: 1.17;
    font-weight: 600;
    color: var(--cb-text);
}

.camp-banner__text {
    margin: 12px 0 0;
    font-size: 15px;
    line-height: 20px;
    font-weight: 400;
    color: var(--cb-text);
    white-space: pre-line;
}

/* строки-абзацы (даты, возраст и т.п.) — переносы как в тексте */
.camp-banner__para {
    white-space: pre-line;
}

/* пустая строка в тексте из админки разделяет блоки — даём им воздух
   (у списка свой отступ, см. .camp-banner__list ниже) */
.camp-banner__text .camp-banner__para + .camp-banner__para {
    margin-top: 16px;
}

/* перечисление: строки в тексте, начинающиеся с «- », рендерятся списком.
   Селектор с контекстом (.camp-banner__text) — иначе глобальный ресет сайта
   `ul[class] { margin: 0 }` перебивает margin по специфичности. */
.camp-banner__text .camp-banner__list {
    display: grid;
    /* колонки по ширине содержимого: список читается одним блоком,
       без дыры между «Water sports» и правой колонкой */
    grid-template-columns: repeat(2, minmax(0, max-content));
    justify-content: start;
    /* порядок построчный: Alpine hikes | Games, Water sports | Paragliding, ... */
    gap: 2px 28px;
    /* воздух от блока «Даты / Возраст / Продолжительность»;
       margin-left выравнивает текст пунктов по тексту строк выше (эмодзи занимают ~10px) */
    margin: 16px 0 0 10px;
    padding: 0;
    list-style: none;
    /* тот же кегль и ритм, что у текста выше — иначе список «выпадает» */
    font-size: inherit;
    line-height: inherit;
}

.camp-banner__list li {
    position: relative;
    padding-left: 16px;
}

/* точка центрируется по строке при любом line-height */
.camp-banner__list li::before {
    content: "";
    position: absolute;
    left: 2px;
    top: 50%;
    width: 5px;
    height: 5px;
    margin-top: -2.5px;
    border-radius: 50%;
    background: var(--cb-brand);
}

.camp-banner__cta {
    align-self: flex-start;
    margin-top: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 44px;
    padding: 0 24px;
    border-radius: 10px;
    background: var(--cb-brand);
    color: var(--cb-brand-text);
    font-size: 15px;
    font-weight: 500;
    line-height: 1;
    text-decoration: none;
    white-space: nowrap;
    transition: background-color .15s linear, transform .1s ease-out;
}

.camp-banner__cta:hover,
.camp-banner__cta:focus {
    background: var(--cb-brand-hover);
    color: var(--cb-brand-text);
    text-decoration: none;
}

.camp-banner__cta:active {
    transform: scale(.96);
}

.camp-banner__cta:focus-visible {
    outline: 2px solid #084764;
    outline-offset: 2px;
}

/* --- кнопка закрытия ------------------------------------------------------ */

.camp-banner__close {
    position: absolute;
    top: 8px;
    right: 8px;
    z-index: 2;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: #fff;
    color: #333;
    box-shadow: 0 3px 8px rgba(0, 0, 0, .18);
    cursor: pointer;
    transition: background-color .15s linear;
}

.camp-banner__close:hover {
    background: #f5f5f5;
}

.camp-banner__close:focus-visible {
    outline: 2px solid #084764;
    outline-offset: 2px;
}

.camp-banner__close svg {
    width: 16px;
    height: 16px;
    display: block;
}

/* --- адаптив -------------------------------------------------------------- */

@media (max-width: 900px) {
    .camp-banner {
        left: 16px;
        right: 16px;
        /* выше кнопки Chaport и заметно выше нижнего края */
        --cb-bottom: 120px;
        width: auto;
        max-width: none;
        /* страховка: если контента слишком много, карточка не вылезет за экран */
        max-height: calc(100vh - 140px);
        overflow-y: auto;
        flex-direction: column;
        gap: 0;
    }

    /* на телефоне логотип не нужен: он занимает место, бренд и так в шапке сайта */
    .camp-banner__logo {
        display: none;
    }

    .camp-banner__cover {
        flex: 0 0 auto;
        width: 100%;
        /* картинка видна целиком: высоту задаёт её собственный пропорции */
        height: auto;
    }

    .camp-banner__cover picture,
    .camp-banner__cover img {
        width: 100%;
        height: auto;
        object-fit: contain;
    }

    .camp-banner__cover img {
        /* не выше 38% экрана, картинка не режется и остаётся крупной */
        max-height: 38vh;
        width: auto;
        max-width: 100%;
        margin: 0 auto;
    }

    .camp-banner__content {
        /* без этого оставался десктопный flex-basis 420px и пустое место до кнопки */
        flex: 0 0 auto;
        padding: 12px 16px 16px;
        gap: 12px;
    }

    .camp-banner__title {
        font-size: 19px;
        line-height: 1.2;
    }

    .camp-banner__text {
        margin-top: 4px;
        font-size: 14px;
        line-height: 20px;
    }

    .camp-banner__cta {
        width: 100%;
        align-self: stretch;
        margin-top: 4px;
    }

    /* карточка лежит выше мобильного меню (см. --cb-z) — при открытом меню её прячем */
    body.menu-open .camp-banner {
        display: none;
    }

    .camp-banner__text .camp-banner__list {
        margin-top: 12px;
        gap: 2px 12px;
    }

    .camp-banner__text .camp-banner__para + .camp-banner__para {
        margin-top: 12px;
    }

    .camp-banner__list li {
        padding-left: 14px;
    }
}

@media (max-width: 900px) and (orientation: landscape) {
    /* в горизонтальной ориентации экран низкий — ужимаем картинку, но не режем */
    .camp-banner__cover img {
        max-height: 34vh;
        width: auto;
        max-width: 100%;
        margin: 0 auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .camp-banner {
        transition: none;
    }
}

@media print {
    .camp-banner {
        display: none !important;
    }
}
