/*
 * Подарок-беглец вместо прежнего трясущегося баннера акций (.promo-icon-fixed).
 * Логика — assets/js/gift-hunt.js, разметка вставляется оттуда же.
 *
 * Позиция задаётся через transform, а не left/top: так перемещение считает
 * композитор, а не раскладка страницы — на слабых телефонах разница заметна.
 */

.gift-hunt {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 9998;
    width: 92px;
    height: 92px;
    cursor: pointer;
    border: 0;
    padding: 0;
    background: none;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    will-change: transform;
    transition: transform .45s cubic-bezier(.22, .9, .3, 1), opacity .3s ease;
}

/* Убегает — рывком и резче, чем возвращается на место. */
.gift-hunt.is-running { transition-duration: .28s; }

/* Сдаётся и идёт в руки — медленно и неотвратимо. */
.gift-hunt.is-tame    { transition-duration: 1.1s; }

.gift-hunt.is-hidden  { opacity: 0; pointer-events: none; }

.gift-hunt__body {
    display: block;
    width: 100%;
    height: 100%;
    animation: gift-breathe 2.6s ease-in-out infinite;
    transform-origin: 50% 85%;
}

.gift-hunt.is-running .gift-hunt__body { animation: gift-wiggle .32s linear infinite; }

@keyframes gift-breathe {
    0%, 100% { transform: scale(1) rotate(0deg); }
    50%      { transform: scale(1.05) rotate(-3deg); }
}

@keyframes gift-wiggle {
    0%   { transform: rotate(-9deg); }
    50%  { transform: rotate(9deg); }
    100% { transform: rotate(-9deg); }
}

/* Ножки: в покое спрятаны под коробку, при беге выскакивают и семенят. */
.gift-hunt__legs {
    position: absolute;
    left: 50%;
    bottom: 2px;
    width: 42px;
    height: 20px;
    margin-left: -21px;
    opacity: 0;
    transform: translateY(-8px);
    transition: opacity .18s ease, transform .18s ease;
    pointer-events: none;
}

.gift-hunt.is-running .gift-hunt__legs,
.gift-hunt.is-tame .gift-hunt__legs { opacity: 1; transform: translateY(0); }

.gift-hunt__leg {
    position: absolute;
    bottom: 0;
    width: 7px;
    height: 16px;
    border-radius: 4px;
    background: #15101d;
}

.gift-hunt__leg--l { left: 7px;  transform-origin: 50% 0; }
.gift-hunt__leg--r { right: 7px; transform-origin: 50% 0; }

.gift-hunt.is-running .gift-hunt__leg--l { animation: gift-step .28s linear infinite; }
.gift-hunt.is-running .gift-hunt__leg--r { animation: gift-step .28s linear infinite reverse; }

@keyframes gift-step {
    0%   { transform: rotate(26deg)  translateY(-2px); }
    50%  { transform: rotate(-26deg) translateY(0); }
    100% { transform: rotate(26deg)  translateY(-2px); }
}

/* Ярлык со скидкой. Всплывает сам, иначе смысл погони непонятен. */
.gift-hunt__badge {
    position: absolute;
    left: 50%;
    top: -14px;
    transform: translate(-50%, 6px) scale(.8);
    padding: 3px 9px;
    border-radius: 999px;
    background: #1d1726;
    color: #fff;
    border: 1px solid rgba(155, 89, 208, .55);
    font: 700 13px/1.25 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
    max-width: 190px;
    text-align: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease, transform .25s ease;
    box-shadow: 0 6px 16px rgba(0, 0, 0, .45);
}

.gift-hunt.is-teasing .gift-hunt__badge { opacity: 1; transform: translate(-50%, 0) scale(1); }

/* Поймали: коробка подпрыгивает и раскрывается. */
.gift-hunt.is-caught { transition-duration: .2s; }
.gift-hunt.is-caught .gift-hunt__body { animation: gift-pop .5s ease forwards; }

@keyframes gift-pop {
    0%   { transform: scale(1) rotate(0deg); }
    40%  { transform: scale(1.35) rotate(-12deg); }
    100% { transform: scale(0) rotate(25deg); opacity: 0; }
}

/* Кольца-«искры» в момент поимки. */
.gift-hunt__spark {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 3px solid #6f3fa0;
    opacity: 0;
}

.gift-hunt.is-caught .gift-hunt__spark { animation: gift-spark .55s ease-out forwards; }

@keyframes gift-spark {
    0%   { opacity: .9; transform: scale(.4); }
    100% { opacity: 0;  transform: scale(2.2); }
}

@media (max-width: 767px) {
    .gift-hunt { width: 74px; height: 74px; }
    .gift-hunt__badge { font-size: 12px; }
}

/* Кому анимация мешает — показываем просто кнопку в углу, без беготни. */
@media (prefers-reduced-motion: reduce) {
    .gift-hunt { transition: none; }
    .gift-hunt__body,
    .gift-hunt.is-running .gift-hunt__body,
    .gift-hunt__leg { animation: none !important; }
}
