/* ===== V.E.R.A. chat widget =====
   Follows the V.E.R.A. brand kit: no colours of its own (site theme tokens only), the Node V mark,
   Space Grotesk wordmark with lime dots, Inter chat text at 14-15px. Lime is only for the send
   button, links, the user's bubble and the mark's lit node, never for body text. */

#chat-widget-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
}

/* ----- The mark (Node V) and its states ----- */
.vera-mark { display: block; flex-shrink: 0; }
.vera-listening .vera-mark .core { animation: vera-pulse 1.6s ease-in-out infinite; transform-origin: 32px 45px; }
.vera-thinking .vera-mark .halo { animation: vera-halo 1.1s ease-in-out infinite; transform-origin: 32px 45px; }
.vera-thinking .vera-mark .n1 { animation: vera-blink 1.1s ease-in-out infinite; }
.vera-thinking .vera-mark .n2 { animation: vera-blink 1.1s ease-in-out .35s infinite; }
@keyframes vera-pulse { 50% { transform: scale(1.25); } }
@keyframes vera-halo { 50% { transform: scale(1.5); opacity: .1; } }
@keyframes vera-blink { 50% { opacity: .25; } }

/* ----- Wordmark ----- */
.vera-wordmark {
    font-family: 'Space Grotesk', 'Inter', 'Segoe UI', system-ui, sans-serif;
    font-weight: 700;
    letter-spacing: .08em;
}
.vera-wordmark i { font-style: normal; color: var(--primary); }

/* ----- Launcher: "Ask V.E.R.A." pill ----- */
#chat-fab {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    border: 0;
    border-radius: 999px;
    padding: 7px 18px 7px 7px;
    background: var(--primary-bg);
    color: var(--on-primary);
    font: 700 0.9rem 'Inter', sans-serif;
    cursor: pointer;
    box-shadow: 0 8px 22px rgba(0, 0, 0, .25);
    transition: transform .2s ease, box-shadow .2s ease;
}
#chat-fab:hover { transform: translateY(-2px); box-shadow: 0 10px 26px rgba(0, 0, 0, .3); }
#chat-fab:focus-visible { outline: 2px solid var(--primary); outline-offset: 3px; }
#chat-fab .vera-mark { border-radius: 50%; }
#chat-fab .vera-wordmark i { color: inherit; }  /* lime dots would vanish on the lime pill */

/* ----- Window ----- */
#chat-window {
    position: absolute;
    bottom: 64px;
    right: 0;
    width: 380px;
    height: 560px;
    max-height: calc(100vh / var(--chat-zoom, 1) - 110px);  /* the widget is zoomed (theme.css) */
    display: none;
    flex-direction: column;
    overflow: hidden;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 18px;
    box-shadow: 0 18px 44px rgba(0, 0, 0, .28);
    animation: vera-open .3s cubic-bezier(.165, .84, .44, 1);
}
#chat-window.active { display: flex; }
@keyframes vera-open {
    from { opacity: 0; transform: translateY(14px) scale(.97); }
    to { opacity: 1; transform: none; }
}

.chat-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
}
.chat-header-text { flex: 1; min-width: 0; }
.chat-header-text .vera-wordmark { display: block; color: var(--text); font-size: 1rem; line-height: 1.3; }
.chat-header-text small {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--muted);
    font-size: 12px;
}
.chat-header-text small::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ADE80;  /* online dot, as in the brand kit */
}
.close-chat {
    border: 0;
    background: transparent;
    color: var(--muted);
    font-size: 22px;
    line-height: 1;
    padding: 4px 6px;
    border-radius: 8px;
    cursor: pointer;
}
.close-chat:hover { color: var(--text); background: var(--bg); }

/* ----- Messages ----- */
#chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}
.message {
    max-width: 86%;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14.5px;
    line-height: 1.5;
    overflow-wrap: anywhere;
}
.bot-message {
    align-self: flex-start;
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-top-left-radius: 4px;
    box-shadow: var(--card-shadow);
}
.user-message {
    align-self: flex-end;
    background: var(--primary-bg);
    color: var(--on-primary);
    border-top-right-radius: 4px;
    font-weight: 500;
}
.bot-message.thinking { color: var(--muted); font-style: italic; }

/* Loader: which agent is working. The picked agent gets a lit node (lime dot), like the mark's core. */
.vera-loader { font-style: normal; min-width: 220px; }
.vera-step { display: flex; align-items: baseline; gap: 2px; font-style: italic; }
.vera-dots i {
    display: inline-block;
    width: 3px;
    height: 3px;
    margin-left: 2px;
    border-radius: 50%;
    background: currentColor;
    animation: vera-blink 1.1s ease-in-out infinite;
}
.vera-dots i:nth-child(2) { animation-delay: .18s; }
.vera-dots i:nth-child(3) { animation-delay: .36s; }
.vera-agents { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.vera-agents span {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11px;
    font-style: normal;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
    opacity: .55;
    transition: opacity .2s, border-color .2s, color .2s;
}
.vera-agents span::before {
    content: "";
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: var(--border);
}
.vera-agents span.active { opacity: 1; color: var(--text); border-color: var(--primary); }
.vera-agents span.active::before { background: var(--primary-bg); animation: vera-pulse 1.1s ease-in-out infinite; }
/* While the router decides, the highlight sweeps across the agents */
.vera-agents.routing span { animation: vera-sweep 1.6s ease-in-out infinite; }
.vera-agents.routing span:nth-child(2) { animation-delay: .4s; }
.vera-agents.routing span:nth-child(3) { animation-delay: .8s; }
.vera-agents.routing span:nth-child(4) { animation-delay: 1.2s; }
@keyframes vera-sweep { 0%, 100% { opacity: .55; } 15% { opacity: 1; } 35% { opacity: .55; } }

/* "See experience" link and the source chips (the graph nodes an answer used) */
.vera-link {
    display: inline-block;
    margin-top: 6px;
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.vera-link:hover { text-decoration: underline; }
.vera-sources {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 8px;
}
.vera-sources span {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 999px;
    border: 1px solid var(--border);
    color: var(--muted);
}

/* ----- Suggestion chips ----- */
.vera-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 12px;
}
.vera-chips:empty { display: none; }
.vera-chips button {
    font: 12.5px 'Inter', sans-serif;
    padding: 6px 11px;
    border-radius: 999px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text);
    cursor: pointer;
    transition: border-color .2s, color .2s;
}
.vera-chips button:hover,
.vera-chips button:focus-visible { border-color: var(--primary); color: var(--primary); outline: none; }

/* ----- Input ----- */
.chat-input-area {
    display: flex;
    gap: 8px;
    padding: 12px 16px 16px;
    border-top: 1px solid var(--border);
}
#chat-input {
    flex: 1;
    min-width: 0;
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 12px;
    background: var(--surface);
    color: var(--text);
    font: 14px 'Inter', sans-serif;
    outline: none;
    transition: border-color .2s, box-shadow .2s;
}
#chat-input::placeholder { color: var(--muted); }
#chat-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--primary) 18%, transparent);
}
#chat-send {
    border: 0;
    border-radius: 10px;
    padding: 10px 14px;
    background: var(--primary-bg);
    color: var(--on-primary);
    font: 700 14px 'Inter', sans-serif;
    cursor: pointer;
}
#chat-send:hover { filter: brightness(1.06); }
#chat-send:disabled { opacity: .55; cursor: default; }

/* ----- Small screens ----- */
@media (max-width: 480px) {
    #chat-widget-container { bottom: 16px; right: 16px; }
    #chat-fab { padding: 6px; }
    #chat-fab .fab-label { display: none; }
    #chat-window {
        position: fixed;
        inset: auto 8px 76px 8px;
        width: auto;
        height: min(560px, calc(100vh - 100px));
    }
}

@media (prefers-reduced-motion: reduce) {
    .vera-listening .vera-mark .core,
    .vera-thinking .vera-mark .halo,
    .vera-thinking .vera-mark .n1,
    .vera-thinking .vera-mark .n2,
    .vera-dots i,
    .vera-agents span,
    .vera-agents span.active::before,
    #chat-window { animation: none; }
}
