/* ============================================
   WIDGET.CSS — изолированный виджет соцсетей
   Все классы с префиксом .widget-social__
   ============================================ */

/* ---------- КОНТЕЙНЕР ВИДЖЕТА ---------- */
.widget-social {
    position: fixed;
    left: 24px;
    top: 120px;
    z-index: var(--z-widget, 960); /* порядок: меню > виджет > карусель */
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    opacity: 0;
    transform: scale(0.5) translateY(-20px);
    animation: widget-appear 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
    animation-delay: 1.2s;
}

/* ---------- ГЛАВНАЯ КНОПКА ---------- */
.widget-social__toggle {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4CAF50, #4a8a4f);
    border: none;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(76, 175, 80, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.3s ease,
                background 0.3s ease;
    position: relative;
    flex-shrink: 0;
    z-index: 100; /* 🔑 верхний уровень */
    touch-action: none;
    user-select: none;
    -webkit-user-select: none;
    -webkit-tap-highlight-color: transparent;
}

.widget-social__toggle:hover {
    transform: scale(1.08);
    box-shadow: 0 12px 32px rgba(76, 175, 80, 0.5);
}

.widget-social__toggle:active {
    transform: scale(0.95);
    background: linear-gradient(135deg, #4CAF50, #4a8a8a);
}

/* Иконка чата внутри кнопки */
.widget-social__toggle-icon {
    width: 28px;
    height: 28px;
    display: block;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    background: #fff;
    mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") no-repeat center;
    mask-size: contain;
    -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z'/%3E%3C/svg%3E") no-repeat center;
    -webkit-mask-size: contain;
}

/* Кнопка в активном состоянии (крестик) */
.widget-social__toggle.active .widget-social__toggle-icon {
    transform: rotate(45deg);
}

/* ---------- ПУЛЬСАЦИЯ ---------- */
.widget-social__toggle::before {
    content: '';
    position: absolute;
    inset: -6px;
    border-radius: 50%;
    border: 2px solid rgba(76, 175, 80, 0.3);
    animation: widget-pulse 2s ease-in-out infinite;
    pointer-events: none;
}

@keyframes widget-pulse {
    0% {
        transform: scale(1);
        opacity: 0.6;
    }
    50% {
        transform: scale(1.15);
        opacity: 0;
    }
    100% {
        transform: scale(1);
        opacity: 0;
    }
}

/* ---------- СПИСОК СОЦСЕТЕЙ ---------- */
.widget-social__list {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    margin-top: 0;
    max-height: 0;
    overflow: hidden; /* закрытое состояние — обрезаем */
    opacity: 0;
    transform: translateY(-12px);
    transition:
        max-height 0.7s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        opacity 0.5s ease,
        transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        margin-top 0.5s ease,
        overflow 0s linear 0.7s; /* 🔑 меняем overflow после анимации */
    padding: 0;
    width: 100%;
    position: relative;
    z-index: 1;
}

.widget-social__list.open {
    max-height: 500px;
    overflow: visible; /* 🔑 открытое — hover не обрезается */
    opacity: 1;
    transform: translateY(0);
    margin-top: 12px;
    transition:
        max-height 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.35s ease,
        transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1),
        margin-top 0.4s ease,
        overflow 0s linear 0s;
}

/* ---------- КАЖДАЯ ИКОНКА ---------- */
.widget-social__item {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    transition:
        transform 1.6s cubic-bezier(0.25, 0.46, 0.45, 0.94),
        opacity 0.5s ease,
        box-shadow 0.3s ease;
    opacity: 0;
    transform: scale(0.6) translateY(20px);
    text-decoration: none;
    position: relative;
    border: 2px solid transparent;
    flex-shrink: 0;
    z-index: 10; /* 🔑 ниже кнопки (100) */
}

.widget-social__item.visible {
    opacity: 1;
    transform: scale(1) translateY(0);
    transition:
        transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1),
        opacity 0.35s ease,
        box-shadow 0.3s ease;
}

/* 🔑 ЗАДЕРЖКИ ПРИ ЗАКРЫТИИ — обратный порядок */
.widget-social__item:nth-child(1) { transition-delay: 0.30s; }
.widget-social__item:nth-child(2) { transition-delay: 0.25s; }
.widget-social__item:nth-child(3) { transition-delay: 0.20s; }
.widget-social__item:nth-child(4) { transition-delay: 0.15s; }
.widget-social__item:nth-child(5) { transition-delay: 0.10s; }
.widget-social__item:nth-child(6) { transition-delay: 0.05s; }

/* 🔑 ЗАДЕРЖКИ ПРИ ОТКРЫТИИ — прямой порядок */
.widget-social__item.visible:nth-child(1) { transition-delay: 0.05s; }
.widget-social__item.visible:nth-child(2) { transition-delay: 0.10s; }
.widget-social__item.visible:nth-child(3) { transition-delay: 0.15s; }
.widget-social__item.visible:nth-child(4) { transition-delay: 0.20s; }
.widget-social__item.visible:nth-child(5) { transition-delay: 0.25s; }
.widget-social__item.visible:nth-child(6) { transition-delay: 0.30s; }

/* 🔑 HOVER — иконка поднимается НАД кнопкой */
.widget-social__item:hover {
    transform: scale(1.12) translateY(-3px);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
    z-index: 200; /* 🔑 выше кнопки (100) */
}

.widget-social__item:active {
    transform: scale(0.92);
}

/* ---------- ЦВЕТА ИКОНОК ---------- */
.widget-social__item--vk {
    background: #0077FF;
    border-color: #0077FF;
}

.widget-social__item--telegram {
    background: #0088cc;
    border-color: #0088cc;
}

.widget-social__item--instagram {
    background: radial-gradient(circle at 30% 30%, #fdf497, #fdf497 20%, #fd5949 45%, #d6249f 70%, #285AEB 100%);
    border-color: #d6249f;
}

.widget-social__item--rutube {
    background: #ff2f007a;
    border-color: #ff2f006a;
}

.widget-social__item--max {
    background: linear-gradient(135deg, #6C3BFF, #1A73E8);
    border-color: #6C3BFF;
}

.widget-social__item--whatsapp {
    background: #25D366;
    border-color: #25D366;
}

/* ---------- SVG-ИКОНКИ ВНУТРИ ---------- */
.widget-social__item svg {
    width: 24px;
    height: 24px;
    fill: #fff;
    display: block;
    flex-shrink: 0;
    transition: transform 0.3s ease;
    pointer-events: none;
}

.widget-social__item:hover svg {
    transform: scale(1.1);
}

/* ---------- ПОДПИСЬ ПРИ ХОВЕРЕ ---------- */
.widget-social__item .widget-social__tooltip {
    position: absolute;
    right: calc(100% + 14px);
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.8);
    color: #fff;
    padding: 4px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s ease, transform 0.25s ease;
    backdrop-filter: blur(4px);
}

.widget-social__item .widget-social__tooltip::after {
    content: '';
    position: absolute;
    right: -6px;
    top: 50%;
    transform: translateY(-50%);
    border-left: 6px solid rgba(0, 0, 0, 0.8);
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
}

.widget-social__item:hover .widget-social__tooltip {
    opacity: 1;
    transform: translateY(-50%) translateX(-4px);
}

/* ---------- АНИМАЦИЯ ПОЯВЛЕНИЯ ---------- */
@keyframes widget-appear {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(-20px);
    }
    40% {
        opacity: 1;
        transform: scale(1.1) translateY(2px);
    }
    60% {
        transform: scale(0.95) translateY(-2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

@keyframes widget-appear-mobile {
    0% {
        opacity: 0;
        transform: scale(0.5) translateY(20px);
    }
    40% {
        opacity: 1;
        transform: scale(1.1) translateY(-2px);
    }
    60% {
        transform: scale(0.95) translateY(2px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ============================================
   МОБИЛЬНАЯ И ПЛАНШЕТНАЯ ВЕРСИЯ (< 992px)
   Виджет в левом нижнем углу, раскрытие снизу вверх
   ============================================ */
@media (max-width: 991px) {
    .widget-social {
        left: 16px;
        bottom: 24px;
        top: auto;
        flex-direction: column-reverse;
        animation: widget-appear-mobile 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
        animation-delay: 1.2s;
    }

    /* Список — снизу вверх */
    .widget-social__list {
        flex-direction: column-reverse;
        gap: 10px;
        margin-top: 0;
        margin-bottom: 0;
        transform: translateY(12px);
    }

    .widget-social__list.open {
        transform: translateY(0);
        margin-top: 0;
        margin-bottom: 10px;
    }

    /* Кнопка чуть меньше */
    .widget-social__toggle {
        width: 50px;
        height: 50px;
    }

    .widget-social__toggle-icon {
        width: 24px;
        height: 24px;
    }

    /* Иконки чуть меньше */
    .widget-social__item {
        width: 44px;
        height: 44px;
    }

    .widget-social__item svg {
        width: 20px;
        height: 20px;
    }

    /* Тултипы скрываем на мобилках */
    .widget-social__item .widget-social__tooltip {
        display: none;
    }

    /* Пульсация чуть меньше */
    .widget-social__toggle::before {
        inset: -4px;
    }
}

/* ---------- МАЛЕНЬКИЕ ТЕЛЕФОНЫ (< 480px) ---------- */
@media (max-width: 480px) {
    .widget-social {
        left: 12px;
        bottom: 16px;
    }

    .widget-social__toggle {
        width: 44px;
        height: 44px;
    }

    .widget-social__toggle-icon {
        width: 20px;
        height: 20px;
    }

    .widget-social__item {
        width: 38px;
        height: 38px;
    }

    .widget-social__item svg {
        width: 18px;
        height: 18px;
    }

    .widget-social__list,
    .widget-social__list.open {
        gap: 8px;
    }

    .widget-social__list.open {
        margin-bottom: 8px;
    }
}

/* ============================================
   ПОДПИСЬ ПОД ИКОНКАМИ (микротекст, TZ §6.4)
   «Отвечаю лично» — мягко появляется вместе со списком
   ============================================ */
.widget-social__note {
    margin-top: 10px;
    padding: 5px 12px;
    border-radius: 30px;
    background: rgba(255, 255, 255, 0.94);
    box-shadow: 0 6px 16px rgba(74, 59, 50, 0.12);
    color: var(--text-light, #7F6B5C);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.2px;
    white-space: nowrap;
    opacity: 0;
    transform: translateY(-6px);
    pointer-events: none;
    transition: opacity 0.3s ease 0.25s, transform 0.3s ease 0.25s;
}

.widget-social__list.open ~ .widget-social__note {
    opacity: 1;
    transform: translateY(0);
}

/* На мобильных подпись не нужна: тултипы там тоже скрыты */
@media (max-width: 991px) {
    .widget-social__note {
        display: none;
    }
}