/* ==========================================================
 * Floating contact buttons + back to top (template-parts/components/float-contacts.php)
 * Above the calculator mini bar (40), below the header (50) and the cookie banner (60).
 * ========================================================== */
.float-contacts {
    --float-size: 52px;
    position: fixed;
    right: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom));
    z-index: 45;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
    pointer-events: none;
}

.float-contacts > * {
    pointer-events: auto;
}

/* Calculator on phones/tablets: stay above the fixed mini bar with the price */
@media (max-width: 1023px) {
    body:has(.minibar:not([hidden])) .float-contacts {
        bottom: calc(88px + env(safe-area-inset-bottom));
    }
}

.float-contacts__list {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.float-contacts__list[hidden] {
    display: none;
}

.float-contacts__item,
.float-contacts__btn {
    position: relative;
    display: inline-flex;
    flex-shrink: 0;
    align-items: center;
    justify-content: center;
    width: var(--float-size);
    height: var(--float-size);
    color: var(--c-surface);
    border: 0;
    border-radius: var(--r-pill);
    cursor: pointer;
    transition: transform 0.15s, background-color 0.15s;
}

.float-contacts__item:hover,
.float-contacts__btn:hover {
    color: var(--c-surface);
    transform: scale(1.06);
}

.float-contacts__item--phone { background: var(--c-primary); }
.float-contacts__item--telegram { background: var(--c-brand-telegram); }
.float-contacts__item--viber { background: var(--c-brand-viber); }
.float-contacts__item--messenger { background: var(--c-brand-messenger); }
.float-contacts__item--whatsapp { background: var(--c-brand-whatsapp); }

.float-contacts__toggle {
    background: var(--c-primary);
}

.float-contacts.is-open .float-contacts__toggle {
    background: var(--c-ink);
}

.float-contacts__icon-close,
.float-contacts.is-open .float-contacts__icon-open {
    display: none;
}

.float-contacts.is-open .float-contacts__icon-close {
    display: block;
}

.float-contacts__top {
    background: var(--c-ink);
}

/* Hidden until half of the page: fades and rises in; visibility keeps it out of Tab order and screen readers */
.float-contacts__top {
    visibility: hidden;
    opacity: 0;
    transform: translateY(16px) scale(0.85);
    pointer-events: none;
    transition:
        opacity 0.35s ease,
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.15s,
        visibility 0s linear 0.45s;
}

.float-contacts__top.is-visible {
    visibility: visible;
    opacity: 1;
    transform: none;
    pointer-events: auto;
    transition:
        opacity 0.35s ease,
        transform 0.45s cubic-bezier(0.22, 1, 0.36, 1),
        background-color 0.15s,
        visibility 0s;
}

.float-contacts__top.is-visible:hover {
    transform: scale(1.06);
}

/* Opening: buttons rise one after another */
.float-contacts.is-open .float-contacts__list li {
    animation: float-contacts-in 0.18s ease-out both;
}

.float-contacts.is-open .float-contacts__list li:nth-last-child(2) { animation-delay: 0.03s; }
.float-contacts.is-open .float-contacts__list li:nth-last-child(3) { animation-delay: 0.06s; }
.float-contacts.is-open .float-contacts__list li:nth-last-child(4) { animation-delay: 0.09s; }
.float-contacts.is-open .float-contacts__list li:nth-last-child(n+5) { animation-delay: 0.12s; }

@keyframes float-contacts-in {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .float-contacts.is-open .float-contacts__list li {
        animation: none;
    }

    .float-contacts__item,
    .float-contacts__btn {
        transition: none;
    }

    .float-contacts__top,
    .float-contacts__top.is-visible {
        transform: none;
        transition: opacity 0.2s, visibility 0s linear 0.2s;
    }

    .float-contacts__top.is-visible {
        transition: opacity 0.2s;
    }
}

/* Name of the link: visually hidden; on desktop shown as a pill on the left on hover/focus */
.float-contacts__label {
    position: absolute;
    width: 1px;
    height: 1px;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
}

@media (hover: hover) and (min-width: 960px) {
    .float-contacts__item:hover .float-contacts__label,
    .float-contacts__item:focus-visible .float-contacts__label {
        right: calc(100% + 10px);
        width: auto;
        height: auto;
        padding: 6px 12px;
        overflow: visible;
        clip-path: none;
        font-size: 14px;
        font-weight: 600;
        color: var(--c-surface);
        background: var(--c-ink);
        border-radius: var(--r-pill);
    }
}

@media (max-width: 639px) {
    .float-contacts {
        --float-size: 48px;
        right: 12px;
    }
}

@media print {
    .float-contacts {
        display: none;
    }
}
