/* Floating AI character assistant (voice-only) */
.vx-landing-character {
    position: fixed;
    right: max(0.75rem, env(safe-area-inset-right));
    bottom: max(0.75rem, env(safe-area-inset-bottom));
    z-index: 60;
    font-family: inherit;
    pointer-events: none;
}

@media (max-width: 639px) {
    .vx-landing-character {
        right: max(0.5rem, env(safe-area-inset-right));
        bottom: max(4.5rem, calc(env(safe-area-inset-bottom) + 3.5rem));
    }

    .vx-landing-character__img {
        width: min(132px, 34vw);
        max-height: min(176px, 42vw);
    }
}

.vx-landing-character__wrap,
.vx-landing-character__permission,
.vx-landing-character__status {
    pointer-events: auto;
}

.vx-landing-character__wrap {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
}

.vx-landing-character__trigger {
    position: relative;
    display: block;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    outline: none;
    /* Still when idle — motion only during an active conversation (frame loop). */
    animation: none;
}

.vx-landing-character__trigger:focus-visible {
    outline: 2px solid rgba(111, 54, 255, 0.8);
    outline-offset: 4px;
    border-radius: 1rem;
}

.vx-landing-character.is-minimized .vx-landing-character__trigger {
    transform: scale(0.72);
    transform-origin: bottom right;
}

.vx-landing-character.is-minimized .vx-landing-character__bubble,
.vx-landing-character.is-minimized .vx-landing-character__tap-hint {
    display: none;
}

.vx-landing-character__img {
    display: block;
    width: min(180px, 35vw);
    height: auto;
    max-height: min(240px, 46vw);
    object-fit: contain;
    mix-blend-mode: screen;
    filter: drop-shadow(0 12px 32px rgba(111, 54, 255, 0.35));
    user-select: none;
    -webkit-user-drag: none;
    image-rendering: auto;
    /* Hide broken/empty placeholder until the first frame is actually paint-ready. */
    opacity: 0;
    /* No opacity transition on src swaps — that makes talking frames flicker/stutter. */
}

.vx-landing-character__img.is-ready {
    opacity: 1;
}

.vx-landing-character__img:not([src]),
.vx-landing-character__img[src=""] {
    opacity: 0;
    visibility: hidden;
}

.vx-landing-character.is-session-active .vx-landing-character__img {
    will-change: contents;
    /* Keep painted frame stable while next PNG swaps in. */
    backface-visibility: hidden;
    transform: translateZ(0);
}

.vx-landing-character.is-listening .vx-landing-character__status-dot {
    background: #22c55e;
    box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.25);
}

.vx-landing-character.is-speaking .vx-landing-character__status-dot {
    background: #a78bfa;
    box-shadow: 0 0 0 4px rgba(167, 139, 250, 0.3);
    animation: vx-character-pulse 0.8s ease-in-out infinite;
}

.vx-landing-character.is-thinking .vx-landing-character__status-dot {
    background: #fbbf24;
    box-shadow: 0 0 0 4px rgba(251, 191, 36, 0.25);
}

.vx-landing-character__tap-hint {
    position: absolute;
    left: 50%;
    bottom: -0.15rem;
    transform: translateX(-50%);
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    background: rgba(12, 8, 32, 0.88);
    border: 1px solid rgba(111, 54, 255, 0.45);
    color: #f4f7fc;
    font-size: 0.65rem;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    white-space: nowrap;
}

.vx-landing-character.is-session-active .vx-landing-character__tap-hint {
    display: none;
}

.vx-landing-character__status-dot {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    width: 0.65rem;
    height: 0.65rem;
    border-radius: 999px;
    background: rgba(244, 247, 252, 0.35);
    transition: background 0.2s ease, box-shadow 0.2s ease;
}

.vx-landing-character__bubble {
    max-width: min(16rem, calc(100vw - 2rem));
    padding: 0.65rem 0.85rem;
    border-radius: 1rem 1rem 0.25rem 1rem;
    background: rgba(12, 8, 32, 0.94);
    border: 1px solid rgba(255, 255, 255, 0.12);
    backdrop-filter: blur(12px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
}

.vx-landing-character__bubble[hidden] {
    display: none !important;
}

.vx-landing-character__bubble-name {
    display: block;
    font-size: 0.72rem;
    letter-spacing: 0.05em;
    text-transform: uppercase;
    color: rgba(167, 139, 250, 0.95);
    margin-bottom: 0.25rem;
}

.vx-landing-character__bubble-text {
    margin: 0;
    font-size: 0.85rem;
    line-height: 1.45;
    color: #f4f7fc;
}

.vx-landing-character__controls {
    display: flex;
    gap: 0.35rem;
    justify-content: flex-end;
}

.vx-landing-character__ctrl-btn {
    display: grid;
    place-items: center;
    width: 2rem;
    height: 2rem;
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 999px;
    background: rgba(12, 8, 32, 0.88);
    color: #f4f7fc;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease;
}

.vx-landing-character__ctrl-btn:hover {
    background: rgba(111, 54, 255, 0.25);
    border-color: rgba(111, 54, 255, 0.45);
}

.vx-landing-character__ctrl-btn[hidden] {
    display: none !important;
}

.vx-landing-character__status {
    margin: 0.35rem 0 0;
    max-width: min(14rem, calc(100vw - 2rem));
    font-size: 0.7rem;
    color: rgba(244, 247, 252, 0.55);
    text-align: right;
}

.vx-landing-character__permission {
    position: fixed;
    inset: 0;
    z-index: 70;
    display: grid;
    place-items: center;
    padding: 1rem;
    background: rgba(16, 8, 64, 0.72);
    backdrop-filter: blur(6px);
}

.vx-landing-character__permission[hidden] {
    display: none !important;
}

.vx-landing-character__permission-card {
    width: min(22rem, 100%);
    padding: 1.25rem;
    border-radius: 1.25rem;
    background: rgba(12, 8, 32, 0.96);
    border: 1px solid rgba(255, 255, 255, 0.12);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.55);
}

.vx-landing-character__permission-title {
    margin: 0 0 0.5rem;
    font-size: 1.05rem;
    color: #f4f7fc;
}

.vx-landing-character__permission-text {
    margin: 0 0 1rem;
    font-size: 0.9rem;
    line-height: 1.5;
    color: rgba(244, 247, 252, 0.75);
}

.vx-landing-character__permission-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.vx-landing-character__permission-btn {
    flex: 1 1 auto;
    min-width: 7rem;
    padding: 0.55rem 0.85rem;
    border-radius: 0.65rem;
    border: 1px solid rgba(255, 255, 255, 0.14);
    background: rgba(255, 255, 255, 0.04);
    color: #f4f7fc;
    font-size: 0.85rem;
    cursor: pointer;
}

.vx-landing-character__permission-btn--primary {
    border-color: rgba(111, 54, 255, 0.55);
    background: linear-gradient(145deg, rgba(111, 54, 255, 0.95), rgba(76, 29, 149, 0.95));
}

@keyframes vx-character-float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-8px); }
}

@keyframes vx-character-pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

@media (prefers-reduced-motion: reduce) {
    .vx-landing-character__trigger {
        animation: none;
    }

    .vx-landing-character.is-speaking .vx-landing-character__status-dot {
        animation: none;
    }
}

.vx-landing-character[hidden],
.vx-landing-character.is-dismissed {
    display: none !important;
}

.vx-site-character-show {
    position: fixed;
    right: 1.25rem;
    bottom: 1.25rem;
    z-index: 9998;
    border: 1px solid rgba(196, 181, 253, 0.35);
    border-radius: 999px;
    padding: 0.55rem 0.95rem;
    background: rgba(15, 8, 40, 0.92);
    color: #f4f7fc;
    font: 500 0.85rem/1.2 "DM Sans", sans-serif;
    cursor: pointer;
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
}

.vx-site-character-show:hover {
    border-color: rgba(196, 181, 253, 0.55);
    background: rgba(28, 16, 64, 0.95);
}

.vx-site-character-show[hidden] {
    display: none !important;
}

.vx-landing-character {
    z-index: 1040;
}

.user-portal .vx-landing-character {
    z-index: 1040;
}

.vx-portal-highlight {
    position: relative;
    z-index: 5;
    box-shadow: 0 0 0 3px rgba(132, 83, 255, 0.85), 0 0 0 8px rgba(132, 83, 255, 0.25) !important;
    border-radius: 12px;
    animation: vx-portal-highlight-pulse 1.2s ease-in-out 2;
}

@keyframes vx-portal-highlight-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(132, 83, 255, 0.85), 0 0 0 8px rgba(132, 83, 255, 0.2); }
    50% { box-shadow: 0 0 0 4px rgba(132, 83, 255, 0.95), 0 0 0 14px rgba(132, 83, 255, 0.12); }
}

@media (prefers-reduced-motion: reduce) {
    .vx-portal-highlight {
        animation: none;
    }
}
