/* Маскот-машинка (BLS-634). Цвета маскота: #FEB600, #333, #fff, #ff8a65.
   bottom — над стопкой круглых кнопок справа (#scroll-top и #keycrm-social-buttons, верх на 150 px от низа). */
.bls-mascot {
    position: fixed;
    right: 0;
    bottom: 160px;
    z-index: 1030;
    display: flex;
    align-items: flex-end;
    gap: 6px;
    pointer-events: none;
    font-family: HelveticaNeueCyr, sans-serif;
}

.bls-mascot[hidden] {
    display: none;
}

.bls-mascot-car,
.bls-mascot-bubble {
    pointer-events: auto;
}

/* Машинка за правым краем, выезжает с отскоком; при показе чуть выглядывает, а не стоит целиком. */
.bls-mascot-car {
    width: 76px;
    height: 76px;
    margin-right: -10px;
    padding: 0;
    border: 0;
    background: none;
    cursor: pointer;
    transform: translateX(120%) rotate(8deg);
    transition: transform .55s cubic-bezier(.34, 1.4, .64, 1);
}

.bls-mascot-car svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.bls-mascot-car:focus-visible {
    outline: 3px solid #FEB600;
    outline-offset: 2px;
    border-radius: 50%;
}

.bls-mascot.is-shown .bls-mascot-car {
    transform: translateX(0) rotate(-4deg);
}

.bls-mascot-bubble {
    position: relative;
    display: flex;
    align-items: center;
    margin-bottom: 46px;
    padding: 4px 4px 4px 14px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 6px 20px rgba(0, 0, 0, .14);
    opacity: 0;
    transform: translateX(16px) scale(.92);
    transform-origin: right bottom;
    visibility: hidden;
    transition: opacity .2s ease, transform .2s ease, visibility 0s linear .2s;
}

.bls-mascot-bubble::after {
    content: "";
    position: absolute;
    right: -6px;
    bottom: 10px;
    border: 7px solid transparent;
    border-left-color: #fff;
    border-right: 0;
}

.bls-mascot.is-shown .bls-mascot-bubble {
    opacity: 1;
    transform: none;
    visibility: visible;
    transition: opacity .25s ease .45s, transform .25s ease .45s, visibility 0s linear .45s;
}

.bls-mascot-open {
    padding: 6px 0;
    border: 0;
    background: none;
    color: #333;
    font: inherit;
    font-size: 15px;
    font-weight: 500;
    white-space: nowrap;
    cursor: pointer;
}

.bls-mascot-open:hover {
    text-decoration: underline;
    text-decoration-color: #FEB600;
    text-decoration-thickness: 2px;
    text-underline-offset: 3px;
}

.bls-mascot-close {
    width: 28px;
    height: 28px;
    margin-left: 6px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: none;
    color: #8a8f98;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
}

.bls-mascot-close:hover {
    background: #f2f3f5;
    color: #333;
}

/* «Ждёт»: покачивание, моргание, взгляд в сторону облачка. */
.bls-mascot-body {
    transform-box: fill-box;
    transform-origin: center bottom;
    animation: bls-mascot-bob 2.6s ease-in-out infinite;
}

.bls-mascot-eye {
    transform-box: fill-box;
    transform-origin: center;
    animation: bls-mascot-blink 4s infinite;
}

.bls-mascot-pupil {
    transform: translateX(-4px);
    transition: transform .3s ease;
}

.bls-mascot-sad {
    display: none;
}

/* Отказ: грустит, оседает и медленнее уезжает. */
.bls-mascot.is-sad .bls-mascot-happy {
    display: none;
}

.bls-mascot.is-sad .bls-mascot-sad {
    display: inline;
}

.bls-mascot.is-sad .bls-mascot-pupil {
    transform: translateY(4px);
}

.bls-mascot.is-sad .bls-mascot-body {
    animation: none;
    transform: scale(1.04, .92);
}

.bls-mascot.is-sad .bls-mascot-bubble {
    opacity: 0;
    visibility: hidden;
    transition: opacity .15s ease, visibility 0s linear .15s;
}

.bls-mascot.is-sad:not(.is-shown) .bls-mascot-car {
    transition: transform .7s ease-in;
}

/* Подсветка карточки чата после нажатия на машинку: три жёлтых пульса. */
.bls-mascot-spotlight {
    animation: bls-mascot-spotlight 1s ease-out 3;
}

@keyframes bls-mascot-spotlight {
    0% { box-shadow: 0 0 0 0 rgba(254, 182, 0, .9), 0 0 0 3px #FEB600; }
    70% { box-shadow: 0 0 0 18px rgba(254, 182, 0, 0), 0 0 0 3px #FEB600; }
    100% { box-shadow: 0 0 0 0 rgba(254, 182, 0, 0), 0 0 0 3px #FEB600; }
}

@keyframes bls-mascot-bob {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-4px); }
}

@keyframes bls-mascot-blink {
    0%, 92%, 100% { transform: scaleY(1); }
    95% { transform: scaleY(.1); }
}

/* Телефоны и узкие планшеты: по центру снизу — машинка выглядывает из-под нижнего края, облачко над ней.
   Справа внизу тут кнопки «наверх» и KeyCRM, а центр свободен и заметнее. */
@media (max-width: 767.98px) {
    .bls-mascot {
        left: 50%;
        right: auto;
        bottom: 0;
        flex-direction: column;
        align-items: center;
        gap: 4px;
        transform: translateX(-50%);
    }

    .bls-mascot-car {
        width: 76px;
        height: 76px;
        margin: 0 0 -8px; /* колёса чуть под краем — «выглядывает» */
        transform: translateY(120%);
    }

    .bls-mascot.is-shown .bls-mascot-car {
        transform: translateY(0);
    }

    .bls-mascot-bubble {
        margin-bottom: 0;
        padding-left: 12px;
        transform: translateY(12px) scale(.92);
        transform-origin: center bottom;
    }

    .bls-mascot-bubble::after {
        right: auto;
        left: 50%;
        bottom: -6px;
        margin-left: -7px;
        border: 7px solid transparent;
        border-top-color: #fff;
        border-bottom: 0;
    }

    .bls-mascot-open {
        font-size: 14px;
    }

    .bls-mascot-pupil {
        transform: translateY(-3px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .bls-mascot-car,
    .bls-mascot-bubble,
    .bls-mascot.is-shown .bls-mascot-bubble,
    .bls-mascot.is-sad:not(.is-shown) .bls-mascot-car,
    .bls-mascot-pupil {
        transition: none;
    }

    .bls-mascot-body,
    .bls-mascot-eye {
        animation: none;
    }

    .bls-mascot-spotlight {
        animation: none;
        box-shadow: 0 0 0 3px #FEB600;
    }
}
