/* Мультикнопка: плавающий виджет со способами связи */

.g4-mb {
    --g4-mb-accent: #c20016;
    --g4-mb-size: 60px;
    --g4-mb-item: 48px;
    --g4-mb-offset: 24px;
    position: fixed;
    right: var(--g4-mb-offset);
    bottom: calc(var(--g4-mb-offset) + env(safe-area-inset-bottom, 0px));
    z-index: 9990;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 14px;
    font-family: inherit;
}

.g4-mb__toggle {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: var(--g4-mb-size);
    height: var(--g4-mb-size);
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: var(--g4-mb-accent);
    color: #fff;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(194, 0, 22, .35);
    transition: transform .2s, box-shadow .2s;
    -webkit-tap-highlight-color: transparent;
}

.g4-mb__toggle:hover {
    transform: scale(1.06);
    box-shadow: 0 8px 26px rgba(194, 0, 22, .45);
}

.g4-mb__toggle:focus-visible,
.g4-mb__link:focus-visible {
    outline: 3px solid rgba(194, 0, 22, .45);
    outline-offset: 3px;
}

/* Пульсирующее кольцо, пока меню закрыто */
.g4-mb__toggle::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: 50%;
    background: var(--g4-mb-accent);
    z-index: -1;
    animation: g4-mb-pulse 2.4s ease-out infinite;
}

.g4-mb.is-open .g4-mb__toggle::before {
    animation: none;
    opacity: 0;
}

@keyframes g4-mb-pulse {
    0% { transform: scale(1); opacity: .5; }
    70%, 100% { transform: scale(1.6); opacity: 0; }
}

.g4-mb__toggle-icon {
    position: absolute;
    display: flex;
    width: 28px;
    height: 28px;
    transition: transform .25s, opacity .2s;
}

.g4-mb__toggle-icon svg {
    width: 100%;
    height: 100%;
}

.g4-mb__toggle-icon--close {
    opacity: 0;
    transform: rotate(-90deg);
}

.g4-mb.is-open .g4-mb__toggle-icon--open {
    opacity: 0;
    transform: rotate(90deg);
}

.g4-mb.is-open .g4-mb__toggle-icon--close {
    opacity: 1;
    transform: rotate(0);
}

.g4-mb__list {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 12px;
    margin: 0;
    /* Выравниваем центры иконок списка по центру главной кнопки */
    padding: 0 calc((var(--g4-mb-size) - var(--g4-mb-item)) / 2) 0 0;
    list-style: none;
    visibility: hidden;
    pointer-events: none;
}

.g4-mb.is-open .g4-mb__list {
    visibility: visible;
    pointer-events: auto;
}

.g4-mb__item {
    margin: 0;
    padding: 0;
    opacity: 0;
    transform: translateY(12px) scale(.9);
    transition: opacity .2s, transform .2s;
}

.g4-mb__item::before {
    content: none;
}

.g4-mb.is-open .g4-mb__item {
    opacity: 1;
    transform: none;
}

/* Появление снизу вверх: ближняя к кнопке иконка раньше */
.g4-mb.is-open .g4-mb__item:nth-last-child(1) { transition-delay: 0s; }
.g4-mb.is-open .g4-mb__item:nth-last-child(2) { transition-delay: .04s; }
.g4-mb.is-open .g4-mb__item:nth-last-child(3) { transition-delay: .08s; }
.g4-mb.is-open .g4-mb__item:nth-last-child(4) { transition-delay: .12s; }
.g4-mb.is-open .g4-mb__item:nth-last-child(5) { transition-delay: .16s; }

.g4-mb__link {
    display: flex;
    align-items: center;
    gap: 12px;
    color: #222;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.g4-mb__link:hover,
.g4-mb__link:focus {
    color: #222;
    text-decoration: none;
}

.g4-mb__label {
    padding: 7px 12px;
    border-radius: 8px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.2;
    white-space: nowrap;
    box-shadow: 0 2px 12px rgba(0, 0, 0, .15);
}

.g4-mb__icon {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: var(--g4-mb-item);
    height: var(--g4-mb-item);
    overflow: hidden;
    border-radius: 50%;
    color: #fff;
    box-shadow: 0 3px 12px rgba(0, 0, 0, .2);
    transition: transform .2s;
}

.g4-mb__link:hover .g4-mb__icon {
    transform: scale(1.08);
}

.g4-mb__icon svg {
    width: 26px;
    height: 26px;
}

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

.g4-mb__link--form .g4-mb__icon { background: var(--g4-mb-accent); }
.g4-mb__link--telegram .g4-mb__icon { background: #27a6e5; }
.g4-mb__link--telegram .g4-mb__icon svg { margin-left: -2px; }
.g4-mb__link--vk .g4-mb__icon { background: #0077ff; }
.g4-mb__link--vk .g4-mb__icon svg { width: 30px; height: 30px; }
.g4-mb__link--max .g4-mb__icon { background: linear-gradient(135deg, #3b6bff, #7b2fe0); }

/* Кнопка «наверх» темы стоит в том же углу: поднимаем её над мультикнопкой */
.scrolltop {
    bottom: 104px;
    right: 24px;
}

@media (min-width: 1600px) {
    .scrolltop {
        right: 24px;
    }
}

@media (max-width: 767px) {
    .g4-mb {
        --g4-mb-size: 56px;
        --g4-mb-item: 46px;
        --g4-mb-offset: 16px;
    }

    .g4-mb__label {
        font-size: 13px;
    }

    .scrolltop {
        bottom: 88px;
        right: 16px;
        width: 56px;
        height: 46px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .g4-mb__toggle::before {
        animation: none;
    }

    .g4-mb__item,
    .g4-mb__toggle-icon {
        transition: none;
    }
}

/* Окно формы обратной связи */

.g4-mb-modal {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}

.g4-mb-modal[hidden] {
    display: none;
}

.g4-mb-modal__overlay {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .55);
}

.g4-mb-modal__dialog {
    position: relative;
    width: 100%;
    max-width: 420px;
    max-height: calc(100vh - 32px);
    max-height: calc(100dvh - 32px);
    overflow-y: auto;
    padding: 28px 24px 24px;
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 20px 60px rgba(0, 0, 0, .3);
    animation: g4-mb-modal-in .2s ease-out;
}

@keyframes g4-mb-modal-in {
    from { opacity: 0; transform: translateY(16px); }
    to { opacity: 1; transform: none; }
}

.g4-mb-modal__close {
    position: absolute;
    top: 10px;
    right: 10px;
    display: flex;
    width: 36px;
    height: 36px;
    padding: 6px;
    border: 0;
    border-radius: 50%;
    background: transparent;
    color: #666;
    cursor: pointer;
}

.g4-mb-modal__close:hover {
    background: #f2f2f2;
    color: #222;
}

.g4-mb-modal__close svg {
    width: 100%;
    height: 100%;
}

.g4-mb-modal__title {
    margin: 0 40px 6px 0;
    font-size: 22px;
    font-weight: 700;
    line-height: 1.25;
    color: #222;
}

.g4-mb-modal__text {
    margin: 0 0 18px;
    font-size: 14px;
    line-height: 1.4;
    color: #666;
}

.g4-mb-form__field {
    display: block;
    margin: 0 0 14px;
    font-size: 14px;
    color: #444;
}

.g4-mb-form__field > span {
    display: block;
    margin-bottom: 5px;
}

.g4-mb-form__req {
    color: #c20016;
}

.g4-mb-form__field input,
.g4-mb-form__field textarea {
    display: block;
    width: 100%;
    margin: 0;
    padding: 11px 12px;
    border: 1px solid #d5d5d5;
    border-radius: 8px;
    background: #fff;
    font: inherit;
    font-size: 16px; /* 16px — iOS не увеличивает страницу при фокусе */
    color: #222;
    box-sizing: border-box;
}

.g4-mb-form__field textarea {
    resize: vertical;
    min-height: 80px;
}

.g4-mb-form__field input:focus,
.g4-mb-form__field textarea:focus {
    border-color: #c20016;
    outline: none;
    box-shadow: 0 0 0 3px rgba(194, 0, 22, .12);
}

.g4-mb-form__field.is-invalid input,
.g4-mb-form__field.is-invalid textarea {
    border-color: #c20016;
}

.g4-mb-form__error {
    display: block;
    margin-top: 4px;
    font-size: 12px;
    color: #c20016;
}

.g4-mb-form__hp {
    position: absolute !important;
    left: -9999px !important;
    width: 1px;
    height: 1px;
    overflow: hidden;
}

.g4-mb-form__agree {
    display: flex;
    gap: 8px;
    align-items: flex-start;
    margin: 4px 0 14px;
    font-size: 12px;
    line-height: 1.4;
    color: #666;
    cursor: pointer;
}

.g4-mb-form__agree input {
    flex-shrink: 0;
    margin: 2px 0 0;
}

.g4-mb-form__agree.is-invalid {
    color: #c20016;
}

.g4-mb-form__status {
    font-size: 14px;
    line-height: 1.4;
}

.g4-mb-form__status:not(:empty) {
    margin: 0 0 12px;
    padding: 10px 12px;
    border-radius: 8px;
    background: #fdecee;
    color: #a00012;
}

.g4-mb-form__status.is-success {
    background: #eaf7ee;
    color: #1d7a3a;
}

.g4-mb-form__submit {
    display: block;
    width: 100%;
    padding: 13px 16px;
    border: 0;
    border-radius: 8px;
    background: #c20016;
    font: inherit;
    font-size: 16px;
    font-weight: 500;
    color: #fff;
    cursor: pointer;
    transition: background .2s, opacity .2s;
}

.g4-mb-form__submit:hover {
    background: #a30013;
}

.g4-mb-form__submit:disabled {
    opacity: .6;
    cursor: default;
}

.g4-mb-form__phone {
    margin: 12px 0 0;
    font-size: 13px;
    text-align: center;
    color: #666;
}

.g4-mb-form__phone a {
    display: inline-block;
    margin: 2px 4px 0;
    color: #c20016;
    white-space: nowrap;
}

body.g4-mb-modal-open {
    overflow: hidden;
}
