/* Avatar home life: coach-bubble speech, collapsible ask, CSS-only motion. */

#avatarHome .avatar-alive__grid,
#avatarHome .avatar-alive__particles,
#avatarHome .avatar-alive__breath,
#avatarHome .avatar-alive__listen {
    position: absolute;
    inset: 0;
    pointer-events: none;
    z-index: 1;
}

#avatarHome .avatar-alive__grid {
    z-index: 1;
    background-image:
        linear-gradient(rgba(126, 196, 232, 0.09) 1px, transparent 1px),
        linear-gradient(90deg, rgba(126, 196, 232, 0.09) 1px, transparent 1px);
    background-size: 48px 48px;
    opacity: 0.42;
    transform: translate3d(0, 0, 0);
    animation: avatar-alive-grid 28s linear infinite;
}

#avatarHome .avatar-alive__particles span {
    position: absolute;
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: rgba(210, 236, 255, 0.55);
    box-shadow: 0 0 8px rgba(150, 210, 255, 0.35);
    animation: avatar-alive-drift 18s ease-in-out infinite;
}

#avatarHome .avatar-alive__particles span:nth-child(1) { left: 12%; top: 22%; animation-duration: 16s; }
#avatarHome .avatar-alive__particles span:nth-child(2) { left: 28%; top: 68%; animation-duration: 22s; animation-delay: -4s; }
#avatarHome .avatar-alive__particles span:nth-child(3) { left: 46%; top: 18%; animation-duration: 19s; animation-delay: -8s; }
#avatarHome .avatar-alive__particles span:nth-child(4) { left: 62%; top: 42%; animation-duration: 24s; animation-delay: -2s; }
#avatarHome .avatar-alive__particles span:nth-child(5) { left: 78%; top: 28%; animation-duration: 17s; animation-delay: -11s; }
#avatarHome .avatar-alive__particles span:nth-child(6) { left: 18%; top: 78%; animation-duration: 21s; animation-delay: -6s; }
#avatarHome .avatar-alive__particles span:nth-child(7) { left: 88%; top: 62%; animation-duration: 20s; animation-delay: -9s; }
#avatarHome .avatar-alive__particles span:nth-child(8) { left: 54%; top: 82%; animation-duration: 23s; animation-delay: -13s; }

#avatarHome .avatar-alive__breath {
    z-index: 2;
    background: radial-gradient(ellipse 38% 28% at 50% 42%, rgba(255, 214, 120, 0.34), transparent 68%);
    opacity: 0.42;
    animation: avatar-alive-breath 4s ease-in-out infinite;
}

#avatarHome .avatar-alive__listen {
    z-index: 2;
    display: none;
}

#avatarHome[data-avatar-listen="1"] .avatar-alive__listen {
    display: block;
}

#avatarHome .avatar-alive__listen::before,
#avatarHome .avatar-alive__listen::after {
    content: '';
    position: absolute;
    left: 50%;
    top: 42%;
    width: 120px;
    height: 120px;
    margin: -60px 0 0 -60px;
    border-radius: 50%;
    border: 2px solid rgba(180, 230, 255, 0.45);
    opacity: 0;
    transform: scale(0.55);
    animation: avatar-alive-wave 1.8s ease-out infinite;
}

#avatarHome .avatar-alive__listen::after {
    animation-delay: 0.7s;
    width: 168px;
    height: 168px;
    margin: -84px 0 0 -84px;
}

#avatarHome[data-avatar-speak="1"] .avatar-alive__breath {
    animation: avatar-alive-voice 0.55s ease-in-out infinite;
}

#avatarHome .avatar-alive__bubble.coach-bubble {
    position: absolute;
    z-index: 6;
    left: 8%;
    top: 14%;
    max-width: min(280px, 78vw);
    pointer-events: auto;
    cursor: grab;
    touch-action: none;
    color: #eaf6ff;
}

#avatarHome .avatar-alive__bubble.coach-bubble[hidden] {
    display: none !important;
}

#avatarHome .avatar-alive__bubble.coach-bubble.is-enter {
    animation: avatar-alive-pop 0.42s ease-out both;
}

#avatarHome .avatar-alive__bubble-text {
    margin: 0;
    padding-right: 28px;
    white-space: pre-line;
}

#avatarHome .avatar-alive__bubble .coach-close {
    pointer-events: auto;
    min-width: 28px;
    min-height: 28px;
}

#avatarHome .avatar-health-report {
    display: inline-flex;
    margin-top: 8px;
    min-height: 32px;
    padding: 4px 10px;
    font-size: 13px;
    pointer-events: auto;
}

#avatarHome .avatar-health-report[hidden] {
    display: none !important;
}

#avatarHome .avatar-health-reports {
    position: absolute;
    z-index: 7;
    left: 8%;
    top: 28%;
    max-width: min(320px, 84vw);
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(11, 22, 38, 0.94);
    color: #eaf6ff;
    pointer-events: auto;
}

#avatarHome .avatar-health-reports[hidden] {
    display: none !important;
}

#avatarHome .avatar-health-reports__title {
    margin: 0 0 8px;
    font-size: 14px;
    font-weight: 700;
}

#avatarHome .avatar-health-reports__list {
    margin: 0 0 8px;
    padding-left: 18px;
    font-size: 13px;
    line-height: 1.4;
}

#avatarHome .avatar-health-reports__item--few {
    color: #d7e7f6;
}

#avatarHome .avatar-health-reports__item--many {
    color: #ffd2a6;
    font-weight: 700;
}

#avatarHome .avatar-ai-issue-alert {
    position: absolute;
    z-index: 8;
    left: 4%;
    right: 4%;
    top: 6%;
    padding: 8px 10px;
    border-radius: 10px;
    background: rgba(120, 24, 24, 0.92);
    color: #fff4f0;
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    pointer-events: none;
}

#avatarHome .avatar-ai-issue-alert[hidden] {
    display: none !important;
}

#avatarHome .avatar-ai-issues__item--fixed {
    opacity: 0.72;
}

#avatarHome .avatar-aki-learn__item {
    margin: 0 0 8px;
}

#avatarHome .avatar-aki-learn__item--reviewable {
    color: #ffd2a6;
}

#avatarHome .avatar-aki-learn__confirm {
    display: inline-flex;
    margin-top: 4px;
    min-height: 32px;
    padding: 4px 10px;
    font-size: 13px;
    pointer-events: auto;
}

#avatarHome .avatar-home__stage {
    padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px));
}

#avatarHome .avatar-alive__ask-fab {
    position: fixed;
    z-index: 8;
    left: 0;
    right: 0;
    bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    margin: 0 auto;
    width: max-content;
    min-width: 132px;
    box-shadow: 0 8px 22px rgba(0, 0, 0, 0.28);
}

#avatarHome .avatar-alive__ask-fab[hidden],
#avatarHome .avatar-alive__dock[hidden] {
    display: none !important;
}

#avatarHome .avatar-alive__dock {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 8;
    margin: 0;
    padding: 10px 12px calc(10px + var(--bm-ask-kb, env(safe-area-inset-bottom, 0px)));
    background: linear-gradient(180deg, transparent, rgba(8, 12, 16, 0.72) 36%);
}

html.bm-ask-kb,
html.bm-ask-kb body {
    overflow: hidden !important;
}

#avatarHome .avatar-home__btn,
#avatarHome .avatar-home__ghost,
#avatarHome .avatar-home__send,
#avatarHome .avatar-alive__ask-fab {
    transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

#avatarHome .avatar-home__btn:active,
#avatarHome .avatar-home__ghost:active,
#avatarHome .avatar-home__send:active,
#avatarHome .avatar-alive__ask-fab:active {
    transform: scale(0.96);
    filter: brightness(1.12);
    box-shadow: 0 0 16px rgba(255, 214, 120, 0.55);
}

#avatarHome #avatarChatAlertBtn:not([hidden]) {
    position: relative;
}

#avatarHome #avatarChatAlertBtn:not([hidden])::before {
    content: '';
    position: absolute;
    top: -3px;
    right: -3px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #e23d3d;
    box-shadow: 0 0 0 2px rgba(16, 22, 28, 0.65);
    animation: avatar-alive-dot 0.7s ease-out 1;
}

@keyframes avatar-alive-breath {
    from, to { opacity: 0.28; }
    50% { opacity: 0.62; }
}

@keyframes avatar-alive-voice {
    from, to { opacity: 0.32; transform: scale(1); }
    50% { opacity: 0.78; transform: scale(1.04); }
}

@keyframes avatar-alive-wave {
    from { opacity: 0.5; transform: scale(0.55); }
    to { opacity: 0; transform: scale(1.35); }
}

@keyframes avatar-alive-pop {
    from { opacity: 0; transform: translate3d(0, 12px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

@keyframes avatar-alive-drift {
    from, to { transform: translate3d(0, 0, 0); }
    50% { transform: translate3d(12px, -18px, 0); }
}

@keyframes avatar-alive-grid {
    from { transform: translate3d(0, 0, 0); }
    to { transform: translate3d(-24px, -16px, 0); }
}

@keyframes avatar-alive-dot {
    0% { transform: scale(0.4); opacity: 0; }
    55% { transform: scale(1.25); opacity: 1; }
    100% { transform: scale(1); opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
    #avatarHome .avatar-alive__grid,
    #avatarHome .avatar-alive__particles span,
    #avatarHome .avatar-alive__breath,
    #avatarHome .avatar-alive__listen::before,
    #avatarHome .avatar-alive__listen::after,
    #avatarHome .avatar-alive__bubble.coach-bubble.is-enter,
    #avatarHome #avatarChatAlertBtn:not([hidden])::before,
    #avatarHome .avatar-home__btn,
    #avatarHome .avatar-home__ghost,
    #avatarHome .avatar-home__send,
    #avatarHome .avatar-alive__ask-fab {
        animation: none !important;
        transition: none !important;
        transform: none !important;
    }
}

html[data-avatar-alive="off"] #avatarHome .avatar-alive__grid,
html[data-avatar-alive="off"] #avatarHome .avatar-alive__particles,
html[data-avatar-alive="off"] #avatarHome .avatar-alive__breath,
html[data-avatar-alive="off"] #avatarHome .avatar-alive__listen {
    display: none !important;
}

html[data-avatar-alive="off"] #avatarHome .avatar-alive__bubble.coach-bubble.is-enter,
html[data-avatar-alive="off"] #avatarHome #avatarChatAlertBtn:not([hidden])::before,
html[data-avatar-alive="off"] #avatarHome .avatar-home__btn,
html[data-avatar-alive="off"] #avatarHome .avatar-home__ghost,
html[data-avatar-alive="off"] #avatarHome .avatar-home__send,
html[data-avatar-alive="off"] #avatarHome .avatar-alive__ask-fab {
    animation: none !important;
    transition: none !important;
}
