/*
 * Блок «Филиалы» на главной — варианты «Классика», «Наведение» и «Карта» («Дизайн сайта» → «Главная страница»).
 * Общие стили карточек — в main.css; здесь обёртка кнопок, «Наведение» и «Карта».
 * Глобальные цвета «Цветовой гаммы» ставят цвет текста с !important — поэтому цвета через #home-branches-section и !important.
 */

/* ---------- Кнопки карточки (все варианты): «Позвонить» + «Написать», под ними «Построить маршрут» ---------- */
.home-branches-buttons {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: auto;
}

.home-branches-buttons .home-branches-actions {
    margin-top: 0;
}

.home-branches-actions--one {
    grid-template-columns: 1fr;
}

/* «Построить маршрут» — с полностью скруглёнными краями, как «Позвонить» и «Написать» */
#home-branches-section .home-branches-route-btn {
    border-radius: 999px;
}

/* Включены только две кнопки (одна из них — «Построить маршрут») — всегда в один ряд, поровну */
.home-branches-buttons--row {
    flex-direction: row;
    align-items: stretch;
}

.home-branches-buttons--row > * {
    flex: 1 1 0;
    min-width: 0;
}

.home-branches-buttons--row .home-branches-action-btn {
    height: 100%;
}

.home-branches-solo-actions-stack--row {
    flex-direction: row;
    align-items: stretch;
}

.home-branches-solo-actions-stack--row > * {
    flex: 1 1 0;
    min-width: 0;
}

/* ---------- «Наведение»: фото и текст без карточки; при наведении — карточка, фото ниже, снизу кнопки ---------- */
#home-branches-section.home-branches-section--v-lift {
    --hb-photo: 220px;
    /* На сколько фото становится ниже при наведении — высота кнопок с отступом сверху 10px.
       Точное значение ставит скрипт в views/home/index.php (кнопки разной высоты на разных экранах). */
    --hb-lift: 92px;
}

#home-branches-section.home-branches-section--v-lift .home-branches-carousel {
    align-items: start;
}

#home-branches-section.home-branches-section--v-lift .home-branches-card {
    align-self: start;
    border-color: transparent;
    background: transparent;
    border-radius: 24px;
    transition: background-color .25s ease, border-color .25s ease;
}

#home-branches-section.home-branches-section--v-lift .home-branches-image-link {
    height: var(--hb-photo);
    border-radius: 24px;
    transition: height .3s ease;
}

#home-branches-section.home-branches-section--v-lift .home-branches-content {
    padding: 14px 16px 16px;
    border-top: 0;
    background: transparent;
}

#home-branches-section.home-branches-section--v-lift .home-branches-buttons {
    max-height: 0;
    padding-top: 0;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transition: max-height .3s ease, padding-top .3s ease, opacity .25s ease, visibility 0s linear .3s;
}

#home-branches-section.home-branches-section--v-lift .home-branches-card:hover,
#home-branches-section.home-branches-section--v-lift .home-branches-card:focus-within {
    border-color: var(--site-extra-home-branches-border-e5e7eb, #e5e7eb);
    background: var(--card-branches-bg, #ffffff);
}

#home-branches-section.home-branches-section--v-lift .home-branches-card:hover .home-branches-image-link,
#home-branches-section.home-branches-section--v-lift .home-branches-card:focus-within .home-branches-image-link {
    height: calc(var(--hb-photo) - var(--hb-lift));
}

/* Как у врачей: при наведении между рамкой карточки и фото — тонкая белая полоса, фото чётко «обведено» */
#home-branches-section.home-branches-section--v-lift .home-branches-image-link::after {
    content: "";
    position: absolute;
    inset: 0;
    z-index: 1;
    border-radius: inherit;
    box-shadow: inset 0 0 0 1px var(--card-branches-bg, #ffffff);
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}

#home-branches-section.home-branches-section--v-lift .home-branches-card:hover .home-branches-image-link::after,
#home-branches-section.home-branches-section--v-lift .home-branches-card:focus-within .home-branches-image-link::after {
    opacity: 1;
}

#home-branches-section.home-branches-section--v-lift .home-branches-card:hover .home-branches-buttons,
#home-branches-section.home-branches-section--v-lift .home-branches-card:focus-within .home-branches-buttons {
    /* box-sizing: border-box — отступ сверху входит в max-height */
    max-height: var(--hb-lift);
    padding-top: 10px;
    opacity: 1;
    visibility: visible;
    transition: max-height .3s ease, padding-top .3s ease, opacity .25s ease .05s, visibility 0s;
}

/* Сенсорные экраны: наведения нет — кнопки видны всегда, фото обычной высоты */
@media (hover: none) {
    #home-branches-section.home-branches-section--v-lift .home-branches-buttons {
        max-height: none;
        padding-top: 10px;
        opacity: 1;
        visibility: visible;
    }

    #home-branches-section.home-branches-section--v-lift .home-branches-card:hover .home-branches-image-link,
    #home-branches-section.home-branches-section--v-lift .home-branches-card:focus-within .home-branches-image-link {
        height: var(--hb-photo);
    }
}

/* ---------- «Карта»: карта, слева поверх неё — список филиалов, по нажатию — карточка ----------
   Тот же формат — на странице «Контакты» в режиме «На карте» (views/contact/index.php), поэтому стили
   привязаны к #hb-map (id перебивает общие стили кнопок сайта), а не к блоку главной. */
/* Заголовок слева, как у остальных блоков главной (на телефоне общее правило .section-title центрирует) */
#home-branches-section .home-branches-map-title {
    margin: 0 0 24px;
    text-align: left;
}

.hb-map-layout {
    /* Отступ списка, карточки и кнопок «+/−» от края карты; на всю ширину — по краю содержимого сайта */
    --hb-edge: 16px;
    position: relative;
    height: 560px;
    overflow: hidden;
    border-radius: 28px;
    background: var(--site-extra-home-branches-background-e8f0fb, #e8f0fb);
    isolation: isolate;
}

.hb-map-stage {
    position: absolute;
    inset: 0;
}

/* Своя стопка слоёв у карты: служебные слои Яндекс Карт не поднимаются выше карточки и кнопок */
.hb-map {
    position: absolute;
    inset: 0;
    z-index: 0;
    isolation: isolate;
}

/* На всю ширину экрана: без скруглений, список и кнопки — по краю содержимого (1200px − поля 20px) */
#home-branches-section.home-branches-section--map-full .hb-map-layout {
    --hb-edge: max(20px, calc((100% - 1160px) / 2));
    height: 600px;
    border-radius: 0;
}

/* Кнопки «+» и «−» — свои, значки ровно по центру */
.hb-map-zoom {
    position: absolute;
    top: 16px;
    right: var(--hb-edge);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.hb-map-zoom[hidden] {
    display: none;
}

#hb-map .hb-map-zoom__btn {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: var(--site-extra-home-branches-background-ffffff, #ffffff) !important;
    box-shadow: 0 4px 14px rgba(var(--site-extra-home-branches-shadow-0f172a-rgb, 15, 23, 42), 0.16) !important;
    color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
    line-height: 0;
    cursor: pointer;
    transition: color .2s ease, transform .15s ease;
}

#hb-map .hb-map-zoom__btn svg {
    display: block;
}

#hb-map .hb-map-zoom__btn svg,
#hb-map .hb-map-zoom__btn svg * {
    stroke: currentColor !important;
}

#hb-map .hb-map-zoom__btn:hover {
    color: var(--card-branches-action-hover-text, var(--design-button-color, #007aff)) !important;
}

#hb-map .hb-map-zoom__btn:active {
    transform: scale(.94);
}

#hb-map .hb-map__loading {
    position: absolute;
    inset: 0;
    display: grid;
    place-items: center;
    padding: 20px;
    font-size: 14px;
    text-align: center;
    color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
}

/* Список филиалов — светлая панель поверх карты */
.hb-map-panel {
    position: absolute;
    top: 16px;
    bottom: 16px;
    left: var(--hb-edge);
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
    width: 320px;
    padding: 8px;
    overflow-y: auto;
    overscroll-behavior: contain;
    border-radius: 22px;
    background: rgba(var(--site-extra-home-branches-background-ffffff-rgb, 255, 255, 255), 0.9);
    -webkit-backdrop-filter: blur(14px) saturate(1.4);
    backdrop-filter: blur(14px) saturate(1.4);
    box-shadow: 0 10px 30px rgba(var(--site-extra-home-branches-shadow-0f172a-rgb, 15, 23, 42), 0.12);
    box-sizing: border-box;
    scrollbar-width: thin;
}

#hb-map .hb-map-row {
    display: flex;
    flex: 0 0 auto;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    padding: 8px 10px 8px 8px;
    border: 0 !important;
    border-radius: 16px;
    background: transparent !important;
    box-shadow: none !important;
    color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
    font: inherit;
    text-align: left;
    cursor: pointer;
    transition: background-color .2s ease;
}

#hb-map .hb-map-row:hover {
    background: rgba(var(--site-extra-home-branches-background-007aff-rgb, 0, 122, 255), 0.06) !important;
}

#hb-map .hb-map-row.is-active {
    background: rgba(var(--site-extra-home-branches-background-007aff-rgb, 0, 122, 255), 0.1) !important;
}

#hb-map .hb-map-row:focus-visible {
    outline: 2px solid var(--card-branches-action-hover-text, var(--design-button-color, #007aff));
    outline-offset: -2px;
}

.hb-map-row__thumb {
    flex: 0 0 48px;
    width: 48px;
    height: 48px;
    overflow: hidden;
    border-radius: 12px;
    background: var(--site-extra-home-branches-background-e8f0fb, #e8f0fb);
}

.hb-map-row__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hb-map-row__text {
    display: flex;
    flex: 1 1 auto;
    flex-direction: column;
    gap: 3px;
    min-width: 0;
}

/* Названия филиалов часто начинаются одинаково («Клиника … на …») — до двух строк, чтобы было видно отличие */
#hb-map .hb-map-row__name {
    display: -webkit-box;
    overflow: hidden;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    font-size: 15px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
}

#hb-map .hb-map-row__meta {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    font-size: 13px;
    white-space: nowrap;
}

#hb-map .hb-map-row__meta .home-branches-open-status {
    flex: 0 0 auto;
}

#hb-map .hb-map-row__hours {
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
}

.hb-map-row__arrow {
    flex: 0 0 auto;
    color: var(--site-extra-home-branches-text-94a3b8, #94a3b8);
    transition: transform .2s ease, color .2s ease;
}

.hb-map-row.is-active .hb-map-row__arrow {
    color: var(--card-branches-action-hover-text, var(--design-button-color, #007aff));
    transform: translateX(2px);
}

/* Карточка филиала поверх карты (как на «Контактах») */
.hb-card {
    position: absolute;
    top: 16px;
    left: calc(var(--hb-edge) + 336px);
    z-index: 3;
    width: 320px;
    max-height: calc(100% - 32px);
    overflow-y: auto;
    border-radius: 22px;
    background: var(--site-extra-home-branches-background-ffffff, #ffffff);
    box-shadow: 0 16px 40px rgba(var(--site-extra-home-branches-shadow-0f172a-rgb, 15, 23, 42), 0.16);
    box-sizing: border-box;
    scrollbar-width: thin;
}

.hb-card[hidden] {
    display: none;
}

.hb-card.is-shown {
    animation: hb-card-in .25s ease;
}

@keyframes hb-card-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: none; }
}

#hb-map .hb-card__close {
    position: absolute;
    top: 10px;
    right: 10px;
    z-index: 2;
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    margin: 0;
    padding: 0;
    border: 0 !important;
    border-radius: 50%;
    background: rgba(var(--site-extra-home-branches-background-ffffff-rgb, 255, 255, 255), 0.92) !important;
    box-shadow: 0 2px 8px rgba(var(--site-extra-home-branches-shadow-0f172a-rgb, 15, 23, 42), 0.15) !important;
    color: var(--site-extra-home-branches-text-334155, #334155) !important;
    cursor: pointer;
}

.hb-card__photo {
    height: 150px;
    overflow: hidden;
}

.hb-card__img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.hb-card__body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 16px 18px 18px;
}

#hb-map .hb-card__name {
    margin: 0;
    padding-right: 28px;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.3;
}

.hb-card__photo + .hb-card__body .hb-card__name {
    padding-right: 0;
}

#hb-map .hb-card__name a {
    color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-1f2937, #1f2937) !important;
    text-decoration: none;
}

#hb-map .hb-card__address {
    margin: 0;
    font-size: 14px;
    line-height: 1.4;
    color: var(--site-extra-home-branches-text-334155, #334155) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-334155, #334155) !important;
}

#hb-map .hb-card__hours {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 4px 10px;
    font-size: 13px;
    color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-64748b, #64748b) !important;
}

.hb-card__metro {
    display: flex;
    flex-direction: column;
    gap: 3px;
    margin: 0;
    padding: 0;
    list-style: none;
}

#hb-map .hb-card__metro li {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    font-size: 13px;
    color: var(--site-extra-home-branches-text-334155, #334155) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-334155, #334155) !important;
}

#hb-map .hb-card__walk {
    color: var(--site-extra-home-branches-text-94a3b8, #94a3b8) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-94a3b8, #94a3b8) !important;
}

.hb-card__buttons {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 6px;
}

#hb-map .hb-card__icon {
    display: inline-flex;
    flex: 0 0 auto;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    margin: 0;
    padding: 0;
    /* Общие стили кнопок сайта красят <button> в цвет кнопок — здесь светлая круглая кнопка */
    border: 1px solid var(--site-extra-home-branches-border-e5e7eb, #e5e7eb) !important;
    border-radius: 50%;
    background: var(--card-branches-action-bg, #f3f4f8) !important;
    box-shadow: none !important;
    color: var(--site-extra-home-branches-text-334155, #334155) !important;
    cursor: pointer;
    transition: border-color .2s ease, color .2s ease;
}

#hb-map .hb-card__icon svg,
#hb-map .hb-card__icon svg * {
    stroke: currentColor !important;
}

#hb-map .hb-card__icon:hover {
    border-color: var(--card-branches-action-hover-text, var(--design-button-color, #007aff)) !important;
    color: var(--card-branches-action-hover-text, var(--design-button-color, #007aff)) !important;
}

#hb-map .hb-card__route {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    box-sizing: border-box;
    flex: 1 1 auto;
    min-height: 42px;
    margin: 0;
    padding: 0 16px;
    border: 0;
    border-radius: 999px;
    background: var(--card-branches-action-hover-text, var(--design-button-color, #007aff));
    color: var(--site-extra-home-branches-text-ffffff, #ffffff) !important;
    -webkit-text-fill-color: var(--site-extra-home-branches-text-ffffff, #ffffff) !important;
    font: inherit;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
}

/* Метка филиала на карте — в цвет кнопок сайта */
.hb-map-pin {
    display: grid;
    place-items: center;
    width: 36px;
    height: 36px;
    border: 3px solid var(--site-extra-home-branches-border-ffffff, #ffffff);
    border-radius: 50%;
    background: var(--card-branches-action-hover-text, var(--design-button-color, #007aff));
    box-shadow: 0 4px 12px rgba(var(--site-extra-home-branches-shadow-0f172a-rgb, 15, 23, 42), 0.25);
    box-sizing: border-box;
    transition: transform .2s ease;
}

.hb-map-pin span {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--site-extra-home-branches-background-ffffff, #ffffff);
}

.hb-map-pin.is-active {
    transform: scale(1.25);
}

/* Один филиал — без списка, карточка открыта слева */
.hb-map-layout--single .hb-card {
    left: var(--hb-edge);
}

/* ---------- Планшет и телефон: филиалы листаются над картой, карточка — внизу карты ---------- */
@media (max-width: 900px) {
    .hb-map-layout {
        --hb-map-h: 420px;
        display: flex;
        flex-direction: column;
        height: auto;
        overflow: visible;
        border-radius: 0;
        background: transparent;
    }

    #home-branches-section.home-branches-section--map-full .hb-map-layout {
        --hb-edge: 20px;
        height: auto;
    }

    .hb-map-stage {
        position: relative;
        inset: auto;
        order: 2;
        height: var(--hb-map-h);
        overflow: hidden;
        border-radius: 22px;
        background: var(--site-extra-home-branches-background-e8f0fb, #e8f0fb);
        isolation: isolate;
    }

    #home-branches-section.home-branches-section--map-full .hb-map-stage {
        border-radius: 0;
    }

    .hb-map-zoom {
        top: 12px;
        right: 12px;
    }

    .hb-map-panel {
        position: static;
        order: 1;
        flex-direction: row;
        gap: 8px;
        width: auto;
        margin: 0 0 12px;
        padding: 2px 2px 6px;
        overflow-x: auto;
        overflow-y: hidden;
        border-radius: 0;
        background: transparent;
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
        box-shadow: none;
        scroll-snap-type: x mandatory;
        scrollbar-width: none;
    }

    #home-branches-section.home-branches-section--map-full .hb-map-panel {
        padding-left: var(--hb-edge);
        padding-right: var(--hb-edge);
        scroll-padding-left: var(--hb-edge);
    }

    .hb-map-panel::-webkit-scrollbar {
        display: none;
    }

    #hb-map .hb-map-row {
        flex: 0 0 auto;
        width: auto;
        max-width: 260px;
        padding: 10px 14px;
        border: 1px solid var(--site-extra-home-branches-border-e5e7eb, #e5e7eb) !important;
        background: var(--site-extra-home-branches-background-ffffff, #ffffff) !important;
        scroll-snap-align: start;
    }

    #hb-map .hb-map-row.is-active {
        border-color: var(--card-branches-action-hover-text, var(--design-button-color, #007aff)) !important;
        background: var(--site-extra-home-branches-background-ffffff, #ffffff) !important;
    }

    /* Телефон: в списке над картой фото не нужно — только название и «Открыто/Закрыто» */
    .hb-map-row__thumb {
        display: none;
    }

    .hb-map-row__arrow {
        display: none;
    }

    /* Карточка — поверх нижней части карты, выше кнопок «+/−» */
    .hb-card,
    .hb-map-layout--single .hb-card {
        top: auto;
        bottom: 12px;
        left: 12px;
        right: 12px;
        width: auto;
        max-height: calc(var(--hb-map-h) - 24px);
    }

    .hb-card.is-shown {
        animation: none;
    }

    .hb-card__photo {
        display: none;
    }
}

@media (max-width: 576px) {
    #home-branches-section.home-branches-section--v-lift {
        --hb-photo: 190px;
    }

    .hb-map-layout,
    #home-branches-section.home-branches-section--map-full .hb-map-layout {
        --hb-map-h: 460px;
    }
}
