/* HSBR robot mascot — sidekick widget for the public landing page.
 * Self-contained: positioning, character SVG layout, speech bubble,
 * and lifecycle animations all live in this file. The Blade component
 * (Modules/Core/resources/views/components/robot-mascot.blade.php) sets
 * --mascot-accent on the root container per persona. */

#hsbr-mascot.mascot-stage {
    position: fixed;
    z-index: 9998;
    width: 220px;
    pointer-events: none;
    opacity: 0;
    transform: translate(0, 40px) scale(0.85);
    will-change: transform, opacity;
    font-family: 'Bricolage Grotesque', system-ui, -apple-system, Segoe UI, Roboto, sans-serif;
}

#hsbr-mascot.mascot--bottom-right {
    right: 24px;
    bottom: 24px;
}

#hsbr-mascot.mascot--bottom-left {
    left: 24px;
    bottom: 24px;
}

#hsbr-mascot .mascot-svg {
    display: block;
    width: 140px;
    height: auto;
    margin: 0 auto;
    filter: drop-shadow(0 12px 18px rgba(15, 23, 42, 0.18));
}

/* Speech bubble */
#hsbr-mascot .mascot-bubble {
    position: relative;
    background: #ffffff;
    color: #0f172a;
    border: 1px solid var(--mascot-accent, #3b82f6);
    border-radius: 18px;
    padding: 12px 36px 12px 16px;
    margin: 0 auto 14px auto;
    max-width: 220px;
    font-size: 14px;
    line-height: 1.35;
    font-weight: 500;
    box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    opacity: 0;
    transform: translateY(8px) scale(0.92);
    transform-origin: 50% 100%;
}

#hsbr-mascot .mascot-bubble__text {
    display: block;
}

#hsbr-mascot .mascot-bubble__close {
    position: absolute;
    top: 4px;
    right: 8px;
    background: transparent;
    border: 0;
    color: #94a3b8;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 2px 6px;
    border-radius: 999px;
    transition: background 120ms ease, color 120ms ease;
    pointer-events: auto;
}

#hsbr-mascot .mascot-bubble__close:hover,
#hsbr-mascot .mascot-bubble__close:focus-visible {
    background: rgba(148, 163, 184, 0.18);
    color: #334155;
    outline: none;
}

#hsbr-mascot .mascot-bubble__tail {
    position: absolute;
    bottom: -8px;
    width: 14px;
    height: 14px;
    background: #ffffff;
    border-right: 1px solid var(--mascot-accent, #3b82f6);
    border-bottom: 1px solid var(--mascot-accent, #3b82f6);
    transform: rotate(45deg);
}

#hsbr-mascot.mascot--bottom-right .mascot-bubble__tail {
    right: 28px;
}

#hsbr-mascot.mascot--bottom-left .mascot-bubble__tail {
    left: 28px;
}

/* Antenna pulse / blink */
#hsbr-mascot.mascot--antenna-pulse .mascot-antenna-dot {
    transform-origin: 80px 10px;
    animation: hsbr-mascot-antenna-pulse 1.6s ease-in-out infinite;
}

#hsbr-mascot.mascot--antenna-blink .mascot-antenna-dot {
    animation: hsbr-mascot-antenna-blink 1.4s steps(1, end) infinite;
}

/* Right arm "wave" gesture, inherent to the mascot when idle */
#hsbr-mascot .mascot-arm--right {
    transform-origin: 124px 107px;
    animation: hsbr-mascot-wave 2.4s ease-in-out infinite;
}

/* Lifecycle states (driven by mascot.js) */
#hsbr-mascot.is-entering {
    pointer-events: auto;
    animation: hsbr-mascot-slide-in 620ms cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

#hsbr-mascot.is-entering .mascot-bubble {
    animation: hsbr-mascot-bubble-pop 360ms cubic-bezier(0.34, 1.56, 0.64, 1) 280ms forwards;
}

#hsbr-mascot.is-idle {
    opacity: 1;
    transform: translate(0, 0) scale(1);
    pointer-events: auto;
}

#hsbr-mascot.is-idle .mascot-svg {
    animation: hsbr-mascot-bob 2.4s ease-in-out infinite;
}

#hsbr-mascot.is-idle .mascot-bubble {
    opacity: 1;
    transform: translateY(0) scale(1);
}

#hsbr-mascot.is-leaving {
    animation: hsbr-mascot-slide-out 480ms cubic-bezier(0.55, 0, 0.7, 0.2) forwards;
}

#hsbr-mascot.is-leaving .mascot-bubble {
    animation: hsbr-mascot-bubble-fade 280ms ease forwards;
}

/* Keyframes */
@keyframes hsbr-mascot-slide-in {
    0%   { opacity: 0; transform: translate(0, 60px) scale(0.85); }
    60%  { opacity: 1; transform: translate(0, -6px) scale(1.02); }
    100% { opacity: 1; transform: translate(0, 0) scale(1); }
}

#hsbr-mascot.mascot--bottom-left.is-entering {
    animation-name: hsbr-mascot-slide-in-left;
}

@keyframes hsbr-mascot-slide-in-left {
    0%   { opacity: 0; transform: translate(-40px, 60px) scale(0.85); }
    60%  { opacity: 1; transform: translate(0, -6px) scale(1.02); }
    100% { opacity: 1; transform: translate(0, 0) scale(1); }
}

#hsbr-mascot.mascot--bottom-right.is-entering {
    animation-name: hsbr-mascot-slide-in-right;
}

@keyframes hsbr-mascot-slide-in-right {
    0%   { opacity: 0; transform: translate(40px, 60px) scale(0.85); }
    60%  { opacity: 1; transform: translate(0, -6px) scale(1.02); }
    100% { opacity: 1; transform: translate(0, 0) scale(1); }
}

@keyframes hsbr-mascot-slide-out {
    0%   { opacity: 1; transform: translate(0, 0) scale(1); }
    100% { opacity: 0; transform: translate(0, 60px) scale(0.85); }
}

@keyframes hsbr-mascot-bubble-pop {
    0%   { opacity: 0; transform: translateY(8px) scale(0.92); }
    70%  { opacity: 1; transform: translateY(-2px) scale(1.04); }
    100% { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes hsbr-mascot-bubble-fade {
    0%   { opacity: 1; transform: translateY(0) scale(1); }
    100% { opacity: 0; transform: translateY(4px) scale(0.95); }
}

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

@keyframes hsbr-mascot-antenna-pulse {
    0%, 100% { transform: scale(1);   opacity: 1; }
    50%      { transform: scale(1.4); opacity: 0.6; }
}

@keyframes hsbr-mascot-antenna-blink {
    0%, 60%, 100% { opacity: 1; }
    65%, 95%      { opacity: 0.2; }
}

@keyframes hsbr-mascot-wave {
    0%, 100% { transform: rotate(-6deg); }
    50%      { transform: rotate(14deg); }
}

/* Reduced motion: collapse animation but keep the mascot visible briefly */
@media (prefers-reduced-motion: reduce) {
    #hsbr-mascot.is-entering,
    #hsbr-mascot.is-leaving {
        animation-duration: 1ms !important;
    }
    #hsbr-mascot.is-idle .mascot-svg,
    #hsbr-mascot .mascot-arm--right,
    #hsbr-mascot.mascot--antenna-pulse .mascot-antenna-dot,
    #hsbr-mascot.mascot--antenna-blink .mascot-antenna-dot {
        animation: none !important;
    }
    #hsbr-mascot.is-entering .mascot-bubble {
        animation-duration: 1ms !important;
    }
}

/* Mobile: shrink + nudge clear of the AI chat FAB */
@media (max-width: 600px) {
    #hsbr-mascot.mascot-stage {
        width: 180px;
    }
    #hsbr-mascot .mascot-svg {
        width: 110px;
    }
    #hsbr-mascot.mascot--bottom-right {
        right: 12px;
        bottom: 84px;
    }
    #hsbr-mascot.mascot--bottom-left {
        left: 12px;
        bottom: 84px;
    }
}
