/* ============================================================
   Ajebhom over the search console (robot.js): it peeks over the console's top edge (the window cuts its lower
   half, so it reads as sitting behind the card), reacts to the search and throws the tree's words.
   ============================================================ */

/* room above the console for the robot's head (the lead text must not touch it) */
.hm-hero .hm-console {
    margin-top: 96px;
}

.hm-bot {
    position: absolute;
    bottom: 100%;
    inset-inline-end: 56px;
    width: 150px;
    pointer-events: none;
}

/* the window shows the top two thirds of the robot: head and shoulders above the edge */
.hm-bot-window {
    position: relative;
    height: 98px;
    /* only the bottom is cut (the console's edge); it may hop above the window */
    clip-path: inset(-120px -60px 0 -60px);
    pointer-events: auto;
    cursor: pointer;
}

/* it rises from behind the edge once the page has loaded */
.hm-bot-body {
    transform: translateY(102%);
    transition: transform .8s cubic-bezier(.34, 1.56, .64, 1);
}

.hm-bot.is-in .hm-bot-body {
    transform: none;
}

/* a gentle float while it waits */
.hm-bot-float {
    position: relative;
    width: 150px;
    height: 150px;
    animation: hm-bot-float 3.2s ease-in-out infinite;
}

@keyframes hm-bot-float {
    50% { transform: translateY(-5px); }
}

.hm-bot-img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    transition: opacity .16s ease;
}

    .hm-bot-img.is-on {
        opacity: 1;
    }

/* the invitation bubble, toward the search box (the robot's inline-start side) */
.hm-bot-bubble {
    position: absolute;
    bottom: 46px;
    inset-inline-end: 132px;
    width: max-content;
    white-space: nowrap; /* one line, so it never reaches the lead text */
    padding: 8px 14px;
    border-radius: 14px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-line);
    border-top: 3px solid var(--ds-red);
    box-shadow: var(--ds-shadow-md);
    font-size: 14px;
    font-weight: 700;
    line-height: 1.7;
    color: var(--ds-ink);
    animation: hm-bot-pop .35s cubic-bezier(.34, 1.56, .64, 1);
}

    .hm-bot-bubble::after {
        content: "";
        position: absolute;
        bottom: 12px;
        inset-inline-end: -8px;
        width: 14px;
        height: 14px;
        background: var(--ds-surface);
        border-top: 1px solid var(--ds-line);
        border-inline-end: 1px solid var(--ds-line);
        transform: rotate(45deg);
    }

html[dir="rtl"] .hm-bot-bubble::after {
    transform: rotate(-45deg);
}

    .hm-bot-bubble[hidden] {
        display: none;
    }

@keyframes hm-bot-pop {
    from { opacity: 0; transform: translateY(6px) scale(.92); }
    to { opacity: 1; transform: none; }
}

/* ---- the robot finds the tree's words ---- */

/* the console got shorter than the tree beside it: room under it for the lowest leaves */
@media (min-width: 992px) {
    .hm-hero .hm-console:not(.is-chips) {
        margin-bottom: 70px;
    }
}

/* digging: a quick searching shake */
.hm-bot.is-digging .hm-bot-float {
    animation: hm-bot-dig .32s ease-in-out infinite;
}

@keyframes hm-bot-dig {
    0%, 100% { transform: rotate(-4deg); }
    50% { transform: translateY(-3px) rotate(4deg); }
}

/* found: a hop as it throws the words */
.hm-bot.is-found .hm-bot-float {
    animation: hm-bot-found .55s cubic-bezier(.3, .7, .4, 1);
}

@keyframes hm-bot-found {
    40% { transform: translateY(-20px) scale(1.04); }
}

/* a phrase in flight, from the robot's head to its leaf (the same pill as the tree's) */
.hm-fly {
    position: absolute;
    top: 0;
    left: 0;
    z-index: 60;
    box-sizing: border-box;
    height: 28px;
    padding: 0 13px;
    border-radius: 14px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-line);
    box-shadow: 0 6px 16px rgba(35, 38, 47, .12);
    font-size: 13px;
    font-weight: 500;
    line-height: 26px;
    text-align: center;
    color: var(--ds-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    pointer-events: none;
}

    .hm-fly.is-first {
        background: var(--ds-red-soft);
        border-color: transparent;
        font-weight: 700;
        color: var(--ds-red);
    }

/* phones (no room for the tree): the words land as chips under the search box */
.hm-dig {
    display: none;
}

.hm-hero .hm-console.is-chips .hm-dig {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    min-height: 72px;
    align-content: flex-start;
    padding: 14px 20px 4px;
}

.hm-dig-chip {
    box-sizing: border-box;
    max-width: 100%;
    height: 28px;
    padding: 0 13px;
    border-radius: 14px;
    background: var(--ds-surface);
    border: 1px solid var(--ds-line);
    font-size: 13px;
    line-height: 26px;
    color: var(--ds-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    animation: hm-bot-pop .3s ease both;
}

    .hm-dig-chip.is-first {
        background: var(--ds-red-soft);
        border-color: transparent;
        font-weight: 700;
        color: var(--ds-red);
    }

    .hm-dig-chip.is-wait {
        visibility: hidden;
        animation: none;
    }

/* reduced motion: already up, no float */
.hm-bot.is-still .hm-bot-body {
    transition: none;
}

.hm-bot.is-still .hm-bot-float,
.hm-bot.is-still .hm-bot-bubble {
    animation: none;
}

@media (max-width: 575px) {
    .hm-hero .hm-console {
        margin-top: 84px;
    }

    .hm-bot {
        inset-inline-end: 20px;
        width: 112px;
    }

    .hm-bot-window {
        height: 73px;
    }

    .hm-bot-float {
        width: 112px;
        height: 112px;
    }

    .hm-bot-bubble {
        bottom: 34px;
        inset-inline-end: 100px;
        white-space: normal;
        max-width: calc(100vw - 136px); /* room beside the robot, so short lines stay one line */
        padding: 6px 12px;
        font-size: 12.5px;
    }
}
