/* ============ AI Assistant HUD ============ */

/* Always-on living orb, bottom-right of every page. Click = talk to JARVIS
   right there; Ctrl+K = full console. */
.ai-orb-fab {
    position: fixed;
    right: 0.6rem;
    bottom: 0.6rem;
    width: 140px;
    height: 140px;
    cursor: pointer;
    z-index: 900;
    user-select: none;
    transition: transform 0.15s ease;
}

.ai-orb-fab:hover { transform: scale(1.06); }

.ai-orb-fab canvas {
    width: 100%;
    height: 100%;
    display: block;
    border-radius: 50%;
}

/* Error toast shown next to the mini orb when the console is closed. */
.ai-orb-toast {
    position: fixed;
    right: 1rem;
    bottom: 150px;
    max-width: 320px;
    z-index: 901;
    background: rgba(60, 12, 22, 0.95);
    border: 1px solid rgba(255, 90, 110, 0.6);
    color: #ffb9c4;
    border-radius: 8px;
    padding: 0.55rem 0.8rem;
    font-size: 0.8rem;
    line-height: 1.4;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.5);
}

.ai-orb-fab .ai-fab-hint {
    position: absolute;
    bottom: 0.35rem;
    left: 50%;
    transform: translateX(-50%);
    font-size: 0.55rem;
    letter-spacing: 0.18em;
    color: rgba(127, 230, 255, 0.75);
    white-space: nowrap;
    text-transform: uppercase;
    text-shadow: 0 0 6px rgba(10, 15, 30, 0.9);
}

/* ---- full-screen overlay ---- */

.ai-hud {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    background: radial-gradient(ellipse at 50% 35%, rgba(16, 32, 56, 0.96), rgba(6, 10, 20, 0.98));
    backdrop-filter: blur(6px);
    color: #d7ecf5;
    animation: ai-hud-in 0.18s ease-out;
}

@keyframes ai-hud-in {
    from { opacity: 0; transform: scale(1.015); }
    to   { opacity: 1; transform: scale(1); }
}

.ai-hud-head {
    display: flex;
    align-items: center;
    gap: 0.7rem;
    padding: 0.9rem 1.4rem;
    border-bottom: 1px solid rgba(80, 220, 255, 0.15);
}

.ai-hud-title {
    font-size: 0.85rem;
    letter-spacing: 0.35em;
    color: #7fe6ff;
    font-weight: 600;
}

.ai-chip {
    font-size: 0.65rem;
    letter-spacing: 0.1em;
    border: 1px solid rgba(80, 220, 255, 0.35);
    border-radius: 999px;
    padding: 0.15rem 0.6rem;
    color: rgba(215, 236, 245, 0.85);
    text-transform: uppercase;
}

.ai-hud-head .spacer { flex: 1; }

.ai-iconbtn {
    background: none;
    border: 1px solid rgba(80, 220, 255, 0.25);
    border-radius: 6px;
    color: #9fd8ea;
    padding: 0.3rem 0.65rem;
    font-size: 0.75rem;
    cursor: pointer;
}

.ai-iconbtn:hover { border-color: rgba(80, 220, 255, 0.7); color: #d7f6ff; }
.ai-iconbtn.off { opacity: 0.45; }

/* ---- center: orb + status ---- */

.ai-hud-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.4rem 0 0;
}

/* Round mask: the canvas paints a square vignette — crop it to the orb so
   no rectangular edge shows against the HUD background. */
.ai-orb-canvas { width: 300px; height: 300px; border-radius: 50%; }

.ai-status {
    margin-top: -1.4rem;
    font-size: 0.72rem;
    letter-spacing: 0.3em;
    text-transform: uppercase;
    color: rgba(127, 230, 255, 0.8);
    min-height: 1.1em;
}

/* ---- transcript ---- */

.ai-transcript {
    flex: 1;
    overflow-y: auto;
    margin: 1rem auto 0.6rem;
    width: min(860px, 92vw);
    padding: 0 0.4rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(80, 220, 255, 0.3) transparent;
}

.ai-msg {
    max-width: 78%;
    margin: 0.45rem 0;
    padding: 0.55rem 0.85rem;
    border-radius: 10px;
    font-size: 0.9rem;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-word;
}

.ai-msg.user {
    margin-left: auto;
    background: rgba(80, 220, 255, 0.12);
    border: 1px solid rgba(80, 220, 255, 0.3);
}

.ai-msg.assistant {
    margin-right: auto;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.12);
}

.ai-msg.error {
    margin-right: auto;
    background: rgba(255, 90, 110, 0.1);
    border: 1px solid rgba(255, 90, 110, 0.4);
    color: #ffb9c4;
}

.ai-msg .ai-msg-meta {
    display: block;
    font-size: 0.6rem;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    opacity: 0.55;
    margin-bottom: 0.2rem;
}

.ai-cursor {
    display: inline-block;
    width: 0.55em;
    height: 1em;
    margin-left: 2px;
    background: #7fe6ff;
    vertical-align: text-bottom;
    animation: ai-blink 0.8s steps(1) infinite;
}

@keyframes ai-blink { 50% { opacity: 0; } }

/* ---- input row ---- */

.ai-inputrow {
    display: flex;
    gap: 0.6rem;
    align-items: center;
    width: min(860px, 92vw);
    margin: 0 auto 1.4rem;
}

.ai-micbtn {
    width: 52px;
    height: 52px;
    flex: none;
    border-radius: 50%;
    border: 1px solid rgba(80, 220, 255, 0.5);
    background: rgba(80, 220, 255, 0.08);
    color: #7fe6ff;
    font-size: 1.25rem;
    cursor: pointer;
    transition: all 0.15s ease;
}

.ai-micbtn:hover { background: rgba(80, 220, 255, 0.2); }

.ai-micbtn.recording {
    border-color: rgba(255, 90, 130, 0.9);
    color: #ff8aa5;
    background: rgba(255, 90, 130, 0.12);
    animation: ai-pulse 1.2s ease-in-out infinite;
}

@keyframes ai-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(255, 90, 130, 0.5); }
    50% { box-shadow: 0 0 0 12px rgba(255, 90, 130, 0); }
}

.ai-textinput {
    flex: 1;
    background: rgba(10, 18, 34, 0.85);
    border: 1px solid rgba(80, 220, 255, 0.3);
    border-radius: 8px;
    color: #e6f6fc;
    padding: 0.75rem 1rem;
    font-size: 0.95rem;
    outline: none;
}

.ai-textinput:focus { border-color: rgba(80, 220, 255, 0.75); box-shadow: 0 0 12px rgba(80, 220, 255, 0.2); }

.ai-sendbtn {
    flex: none;
    border: 1px solid rgba(80, 220, 255, 0.5);
    background: rgba(80, 220, 255, 0.15);
    color: #bff1ff;
    border-radius: 8px;
    padding: 0.75rem 1.3rem;
    font-size: 0.9rem;
    letter-spacing: 0.08em;
    cursor: pointer;
}

.ai-sendbtn:hover:not(:disabled) { background: rgba(80, 220, 255, 0.3); }
.ai-sendbtn:disabled, .ai-micbtn:disabled { opacity: 0.4; cursor: default; }

.ai-empty-hint {
    text-align: center;
    color: rgba(215, 236, 245, 0.45);
    font-size: 0.85rem;
    margin-top: 1.2rem;
}

/* ===== Ambient alert strip (HUD) ===== */

.ai-alertstrip {
    display: flex;
    flex-wrap: wrap;
    gap: 0.45rem;
    justify-content: center;
    padding: 0.3rem 1rem 0.6rem;
}
.ai-alert {
    font-size: 0.72rem;
    letter-spacing: 0.04em;
    padding: 0.28rem 0.7rem;
    border-radius: 999px;
    border: 1px solid rgba(255, 170, 60, 0.45);
    background: rgba(255, 170, 60, 0.10);
    color: #ffd9a0;
}
.ai-alert.crit {
    border-color: rgba(255, 93, 115, 0.55);
    background: rgba(255, 93, 115, 0.12);
    color: #ffb3bf;
    animation: ai-alert-pulse 2.2s ease-in-out infinite;
}
@keyframes ai-alert-pulse {
    0%, 100% { box-shadow: 0 0 0 rgba(255, 93, 115, 0); }
    50% { box-shadow: 0 0 12px rgba(255, 93, 115, 0.35); }
}
@media (prefers-reduced-motion: reduce) {
    .ai-alert.crit { animation: none; }
}

/* Orb clears the iPhone home bar */
@supports (bottom: env(safe-area-inset-bottom)) {
    .ai-orb-fab { bottom: calc(1rem + env(safe-area-inset-bottom)); }
}

/* ===== Draggable / tuckable orb ===== */
.ai-orb-fab {
    touch-action: none;             /* the orb owns its touches (drag) */
    user-select: none;
    -webkit-user-select: none;
    cursor: grab;
    transition: transform 0.25s ease, opacity 0.25s ease;
}
.ai-orb-fab.dragging {
    transition: none;
    cursor: grabbing;
    opacity: 0.9;
}
/* Tucked: most of the orb slides off-screen; tap wakes it back out. */
.ai-orb-fab.tucked-left  { transform: translateX(-60%); opacity: 0.55; }
.ai-orb-fab.tucked-right { transform: translateX(60%);  opacity: 0.55; }
.ai-orb-fab.tucked-left:hover, .ai-orb-fab.tucked-right:hover { opacity: 0.85; }
.ai-orb-fab.tucked-left .ai-fab-hint, .ai-orb-fab.tucked-right .ai-fab-hint { display: none; }

@media (prefers-reduced-motion: reduce) {
    .ai-orb-fab { transition: none; }
}
