/* BBE mascot — intro, thought cloud, docked assistant */

body.bbe-intro-active {
    overflow: hidden;
}

.bbe-mascot-root {
    --bbe-mascot-accent: #00e5ff;
    --bbe-mascot-bg: #0a0a0a;
    --bbe-mascot-card: #161616;
    --bbe-mascot-text: #f5f5f5;
    --bbe-mascot-width: 88px;
    --bbe-mascot-inset: 16px;
    --bbe-mascot-travel: calc(100vw - var(--bbe-mascot-width) - (2 * var(--bbe-mascot-inset)));
}

/* ── First-visit intro ── */
.bbe-intro {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bbe-mascot-bg);
    opacity: 1;
    transition: opacity 0.65s ease;
}

.bbe-intro[hidden] {
    display: none !important;
}

.bbe-intro.is-out {
    opacity: 0;
    pointer-events: none;
}

.bbe-starfield {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.bbe-intro-skip-wrap {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 2;
}

.bbe-intro-skip {
    border: 1px solid rgba(255, 255, 255, 0.12);
    background: rgba(16, 13, 12, 0.85);
    color: var(--bbe-mascot-text);
    font-family: 'Inter', sans-serif;
    font-size: 0.8rem;
    font-weight: 500;
    padding: 7px 14px;
    border-radius: 999px;
    cursor: pointer;
    transition: border-color 0.2s, color 0.2s;
}

.bbe-intro-skip:hover {
    border-color: var(--bbe-mascot-accent);
    color: var(--bbe-mascot-accent);
}

.bbe-intro-center {
    position: relative;
    z-index: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 20px;
    text-align: center;
    padding: 24px;
    animation: bbe-intro-fade-up 0.8s ease both;
}

.bbe-intro-mascot-wrap {
    filter: drop-shadow(0 14px 36px rgba(0, 229, 255, 0.24));
}

.bbe-intro-mascot-wrap .bbe-mascot-wave-arm {
    animation: none !important;
}

.bbe-intro-terminal {
    position: relative;
    background: var(--bbe-mascot-card);
    border: 1px solid rgba(0, 229, 255, 0.3);
    border-radius: 14px;
    padding: 16px 20px;
    width: min(340px, 92vw);
    font-family: 'JetBrains Mono', monospace;
    text-align: left;
    box-shadow: 0 10px 32px rgba(0, 0, 0, 0.35);
    animation: bbe-intro-fade-up 0.8s 0.1s ease both;
}

.bbe-intro-terminal-line {
    font-size: clamp(0.68rem, 2vw, 0.78rem);
    line-height: 1.7;
}

.bbe-intro-terminal-line--comment {
    color: var(--bbe-mascot-accent);
    margin-bottom: 6px;
}

.bbe-intro-terminal-line--cmd {
    color: var(--bbe-mascot-text);
    min-height: 1.7em;
}

.bbe-intro-terminal-line--cmd .prompt {
    color: #5d6c5f;
}

.bbe-intro-terminal-line--response {
    opacity: 0;
    transform: translateY(4px);
}

.bbe-intro-terminal-line--response.is-visible {
    animation: bbe-intro-line-in 0.45s ease forwards;
}

.bbe-intro-terminal-line--response .accent {
    color: var(--bbe-mascot-accent);
}

.bbe-intro-terminal-line--response .muted {
    color: #9a9088;
}

.bbe-intro-cursor {
    display: inline-block;
    width: 7px;
    height: 1em;
    background: var(--bbe-mascot-accent);
    vertical-align: text-bottom;
    margin-left: 1px;
    animation: bbe-intro-cursor-blink 1s step-end infinite;
}

.bbe-intro-terminal-tail {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 10px solid transparent;
    border-right: 10px solid transparent;
    border-top: 10px solid rgba(0, 229, 255, 0.3);
}

.bbe-intro-terminal-tail::after {
    content: '';
    position: absolute;
    bottom: 1px;
    left: 50%;
    transform: translateX(-50%);
    width: 0;
    height: 0;
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid var(--bbe-mascot-card);
}

@keyframes bbe-intro-line-in {
    from { opacity: 0; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes bbe-intro-cursor-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

.bbe-mascot-bubble {
    position: absolute;
    bottom: calc(100% + 10px);
    right: 0;
    min-width: 0;
    max-width: min(300px, 88vw);
    padding: 10px 14px;
    background: var(--bbe-mascot-card);
    border: 1px solid rgba(0, 229, 255, 0.35);
    border-radius: 10px;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    font-weight: 500;
    color: var(--bbe-mascot-text);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transform: translateY(6px) scale(0.96);
    transition: opacity 0.22s ease, transform 0.22s ease, visibility 0.22s;
    pointer-events: none;
}

.bbe-mascot-bubble-line {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.5;
}

.bbe-mascot-bubble-cursor {
    display: inline-block;
    width: 6px;
    height: 1em;
    background: var(--bbe-mascot-accent);
    vertical-align: text-bottom;
    margin-left: 1px;
    animation: bbe-intro-cursor-blink 1s step-end infinite;
}

.bbe-mascot-bubble::after {
    content: '';
    position: absolute;
    top: 100%;
    right: 18px;
    width: 10px;
    height: 10px;
    background: var(--bbe-mascot-card);
    border-right: 1px solid rgba(0, 229, 255, 0.35);
    border-bottom: 1px solid rgba(0, 229, 255, 0.35);
    transform: rotate(45deg);
    margin-top: -5px;
}

.bbe-mascot-trigger {
    position: relative;
}

.bbe-mascot-trigger:hover .bbe-mascot-bubble.is-open,
.bbe-mascot-trigger:focus-visible .bbe-mascot-bubble.is-open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

@keyframes bbe-intro-fade-up {
    from {
        opacity: 0;
        transform: translateY(18px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── SVG mascot character ── */
.bbe-mascot-char {
    display: block;
    overflow: visible;
    flex-shrink: 0;
}

.bbe-mascot-char--intro {
    width: clamp(100px, 22vw, 150px);
    height: auto;
}

.bbe-mascot-char--intro.bbe-contact-bot {
    width: clamp(100px, 22vw, 150px);
}

.bbe-mascot-char--dock {
    width: 88px;
    height: auto;
}

.bbe-mascot-char--dock.bbe-contact-bot {
    width: 72px;
}

/* Friendly robot character animations */
.bbe-contact-bot {
    display: block;
    width: 100%;
    height: auto;
    overflow: visible;
}

.bbe-contact-bot-arm--right,
.bbe-mascot-wave-arm {
    transform-origin: 340px 350px;
}

.bbe-mascot.is-idle:not(.is-patrol):not(.is-walking-in) .bbe-mascot-trigger:not(:hover):not(:focus-visible) .bbe-mascot-wave-arm {
    animation: bbe-contact-arm-wave 3.5s ease-in-out infinite;
}

.bbe-contact-bot-antenna-tip {
    animation: bbe-contact-antenna-pulse 2s ease-in-out infinite;
}

.bbe-contact-bot-eyelid--left,
.bbe-contact-bot-eyelid--right {
    transform-box: fill-box;
    transform-origin: top center;
    animation: bbe-contact-blink 5s ease-in-out infinite;
}

.bbe-contact-bot-mouth {
    transform-origin: 256px 258px;
    animation: bbe-contact-smile 4s ease-in-out infinite;
}

@keyframes bbe-contact-arm-wave {
    0%, 100% { transform: rotate(0deg); }
    30% { transform: rotate(14deg); }
    60% { transform: rotate(-8deg); }
}

@keyframes bbe-contact-antenna-pulse {
    0%, 100% { fill: var(--bbe-mascot-accent); filter: drop-shadow(0 0 0 transparent); }
    50% { fill: #66eeff; filter: drop-shadow(0 0 6px rgba(0, 229, 255, 0.6)); }
}

@keyframes bbe-contact-blink {
    0%, 46%, 48%, 100% { transform: scaleY(0); }
    47% { transform: scaleY(1); }
}

@keyframes bbe-contact-smile {
    0%, 100% { transform: scaleY(1); }
    50% { transform: scaleY(1.08); }
}

/* Wave arm animation */
.is-waving .bbe-mascot-wave-arm,
.bbe-mascot-trigger:hover .bbe-mascot-wave-arm,
.bbe-mascot-trigger:focus-visible .bbe-mascot-wave-arm {
    animation: bbe-mascot-arm-wave 0.7s ease-in-out infinite;
    transform-origin: 340px 350px;
}

@keyframes bbe-mascot-arm-wave {
    0%, 100% { transform: rotate(0deg); }
    25% { transform: rotate(-18deg); }
    75% { transform: rotate(14deg); }
}

@keyframes bbe-mascot-flag-sway {
    0%, 100% { transform: rotate(0deg); }
    50% { transform: rotate(-4deg); }
}

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

.bbe-mascot.is-home-morph {
    bottom: auto !important;
    right: auto !important;
    transform: none !important;
    transition: none;
}

.bbe-mascot.is-home-hero .bbe-mascot-trigger .bbe-mascot-char {
    filter: drop-shadow(0 14px 36px rgba(0, 229, 255, 0.2));
    animation: bbe-home-mascot-bounce 2.4s cubic-bezier(0.45, 0, 0.55, 1) infinite;
}

.bbe-mascot.is-home-hero .bbe-mascot-trigger .bbe-mascot-wave-arm {
    animation: none;
}

.bbe-mascot.is-home-hero .bbe-mascot-bubble {
    bottom: auto;
    top: calc(100% + 12px);
    right: auto;
    left: 50%;
    transform: translateX(-50%) translateY(6px) scale(0.96);
}

.bbe-mascot.is-home-hero .bbe-mascot-bubble::after {
    top: auto;
    bottom: 100%;
    right: auto;
    left: 50%;
    margin-top: 0;
    margin-bottom: -5px;
    transform: translateX(-50%) rotate(225deg);
}

.bbe-mascot.is-home-hero .bbe-mascot-trigger:hover .bbe-mascot-bubble.is-open,
.bbe-mascot.is-home-hero .bbe-mascot-trigger:focus-visible .bbe-mascot-bubble.is-open {
    transform: translateX(-50%) translateY(0) scale(1);
}

@keyframes bbe-home-mascot-bounce {
    0%, 100% { transform: translateY(0) scale(1); }
    25% { transform: translateY(-14px) scale(1.015); }
    50% { transform: translateY(0) scale(0.99); }
    75% { transform: translateY(-6px) scale(1.005); }
}


/* ── Docked mascot (walk-in once, then bottom-right) ── */
.bbe-mascot {
    position: fixed;
    z-index: 900;
    bottom: var(--bbe-mascot-inset, 16px);
    left: var(--bbe-mascot-inset, 16px);
    right: auto;
    opacity: 0;
    pointer-events: none;
    transform: translateX(0);
    transition: opacity 0.4s ease;
}

.bbe-mascot.is-visible {
    opacity: 1;
    pointer-events: auto;
}

.bbe-mascot.is-at-right {
    transform: translateX(var(--bbe-mascot-travel));
}

.bbe-mascot.is-at-left {
    transform: translateX(0);
}

.bbe-mascot.is-walking-in {
    animation: bbe-mascot-walk-across var(--bbe-walk-duration, 5s) linear both;
}

.bbe-mascot.is-patrol-rtl {
    animation: bbe-mascot-patrol-rtl var(--bbe-walk-duration, 5s) linear both;
}

.bbe-mascot.is-patrol-ltr {
    animation: bbe-mascot-patrol-ltr var(--bbe-walk-duration, 5s) linear both;
}

.bbe-mascot.is-walking-in .bbe-mascot-trigger .bbe-mascot-char,
.bbe-mascot.is-patrol .bbe-mascot-trigger .bbe-mascot-char,
.bbe-mascot.is-walking-in .bbe-mascot-wave-arm,
.bbe-mascot.is-patrol .bbe-mascot-wave-arm {
    animation: none;
}

.bbe-mascot.is-patrol-rtl .bbe-mascot-char {
    transform: scaleX(-1);
}

.bbe-mascot.is-walking-in .bbe-mascot-leg--left,
.bbe-mascot.is-patrol .bbe-mascot-leg--left {
    animation: bbe-mascot-leg-step 0.5s ease-in-out infinite alternate;
    transform-origin: 222px 430px;
}

.bbe-mascot.is-walking-in .bbe-mascot-leg--right,
.bbe-mascot.is-patrol .bbe-mascot-leg--right {
    animation: bbe-mascot-leg-step 0.5s ease-in-out infinite alternate-reverse;
    transform-origin: 292px 430px;
}

@keyframes bbe-mascot-walk-across {
    from {
        transform: translateX(calc(-1 * var(--bbe-mascot-width) - var(--bbe-mascot-inset)));
    }
    to {
        transform: translateX(var(--bbe-mascot-travel));
    }
}

@keyframes bbe-mascot-patrol-rtl {
    from {
        transform: translateX(var(--bbe-mascot-travel));
    }
    to {
        transform: translateX(0);
    }
}

@keyframes bbe-mascot-patrol-ltr {
    from {
        transform: translateX(0);
    }
    to {
        transform: translateX(var(--bbe-mascot-travel));
    }
}

@keyframes bbe-mascot-leg-step {
    from { transform: rotate(-10deg); }
    to { transform: rotate(8deg); }
}

.bbe-mascot.is-idle:not(.is-patrol):not(.is-walking-in) .bbe-mascot-trigger:not(:hover):not(:focus-visible) .bbe-mascot-char {
    animation: bbe-mascot-bob 2.8s ease-in-out infinite;
    transform-origin: center bottom;
}

.bbe-mascot-trigger {
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 12px;
    filter: drop-shadow(0 6px 18px rgba(0, 0, 0, 0.45));
    transition: filter 0.2s ease;
}

.bbe-mascot-trigger:hover,
.bbe-mascot-trigger:focus-visible {
    filter: drop-shadow(0 8px 24px rgba(0, 229, 255, 0.32));
}

.bbe-mascot-trigger:focus-visible {
    outline: 2px solid var(--bbe-mascot-accent);
    outline-offset: 4px;
}

@media (prefers-reduced-motion: reduce) {
    .bbe-intro-center,
    .bbe-intro-terminal {
        animation: none;
    }

    .bbe-intro-terminal-line--response.is-visible {
        opacity: 1;
        transform: none;
        animation: none;
    }

    .bbe-intro-cursor {
        animation: none;
    }

    .bbe-mascot-bubble-cursor {
        animation: none;
    }

    .bbe-mascot.is-walking-in,
    .bbe-mascot.is-patrol-rtl,
    .bbe-mascot.is-patrol-ltr {
        animation: none;
    }

    .bbe-mascot.is-at-right {
        transform: translateX(var(--bbe-mascot-travel));
    }

    .bbe-mascot.is-at-left {
        transform: translateX(0);
    }

    .is-waving .bbe-mascot-wave-arm,
    .bbe-mascot-trigger:hover .bbe-mascot-wave-arm,
    .bbe-mascot.is-idle .bbe-mascot-char,
    .bbe-mascot.is-idle .bbe-mascot-wave-arm,
    .bbe-mascot.is-home-hero .bbe-mascot-trigger .bbe-mascot-char,
    .bbe-mascot.is-home-hero .bbe-mascot-trigger .bbe-mascot-wave-arm {
        animation: none;
    }
    .bbe-contact-bot-antenna-tip,
    .bbe-contact-bot-eyelid--left,
    .bbe-contact-bot-eyelid--right,
    .bbe-contact-bot-mouth {
        animation: none;
    }
}

@media (max-width: 575px) {
    .bbe-mascot-root {
        --bbe-mascot-width: 72px;
        --bbe-mascot-inset: 10px;
    }

    .bbe-mascot-char--dock {
        width: 72px;
    }

    .bbe-mascot-char--dock.bbe-contact-bot {
        width: 60px;
    }

    .bbe-intro-skip-wrap {
        top: 12px;
        right: 12px;
    }

    .bbe-mascot-bubble {
        font-size: 0.78rem;
        padding: 6px 11px;
    }
}
