/*
 * Nock - sitewide floating assistant widget. Bottom-LEFT corner,
 * deliberately opposite the existing Tawk support-chat bubble (bottom-
 * right) so the two floating widgets never overlap. Reuses the same
 * --wlfi-* design tokens as bn-research.css for visual consistency with
 * the rest of the site, rather than introducing a new palette.
 */

.bn-nock {
    position: fixed;
    left: 20px;
    bottom: 20px;
    z-index: 1050;
}

.bn-nock__toggle {
    width: 56px;
    height: 56px;
    padding: 0;
    border-radius: 50%;
    border: 2px solid rgba(236, 196, 108, 0.45);
    background: var(--wlfi-brand);
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 18px rgba(0, 0, 0, 0.35);
    transition: transform 0.2s ease, filter 0.2s ease, box-shadow 0.2s ease;
}

.bn-nock__toggle:hover {
    filter: brightness(1.08);
    transform: translateY(-1px);
    box-shadow: 0 6px 22px rgba(236, 196, 108, 0.25), 0 4px 18px rgba(0, 0, 0, 0.35);
}

.bn-nock__toggle:focus-visible {
    outline: 2px solid var(--wlfi-brand);
    outline-offset: 3px;
}

/* Nock's 3D avatar face - two source images, not one, picked per size:
   bitnnock-nock-avatar-hero.png (a higher-fidelity, more photoreal
   render) at the two big, prominent sizes where that detail reads well
   (the floating toggle and the empty-state greeting), and the original,
   more graphic/high-contrast bitnnock-nock-avatar.png at the two small
   sizes (the 22px header icon and the 26px per-message avatar - also
   what data-avatar points JS at for dynamically-created message rows).
   The hero render's finer, lower-contrast photoreal shading tested
   genuinely worse at 22-26px (the glowing visor nearly disappears) than
   the original's bolder, simplified lines - confirmed by rendering both
   down to real size before choosing, not by eye at full size. Don't
   "simplify" this to one image everywhere without re-checking that same
   small-size legibility first. */
.bn-nock__avatar {
    display: block;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    animation: bn-nock-glow 3.6s ease-in-out infinite;
}

.bn-nock__avatar--toggle {
    width: 100%;
    height: 100%;
}

.bn-nock__avatar--head {
    width: 22px;
    height: 22px;
    animation-name: bn-nock-glow-small;
}

.bn-nock__avatar--msg {
    width: 26px;
    height: 26px;
    margin-bottom: 2px;
    animation-name: bn-nock-glow-small;
}

.bn-nock__avatar--empty {
    width: 64px;
    height: 64px;
    opacity: 0.92;
}

/* Realtime "alive" glow - deliberately slow and low-amplitude (an
   always-on, sitewide floating element has to stay unobtrusive; see
   this project's HIG-based design rule on protecting attention), with a
   distinctly faster, stronger pulse reserved for when Nock is actually
   working on a real request so the animation's intensity communicates
   live status, not just decoration. :has() (not a JS class toggle)
   drives the reactive state: the per-message avatar reacts to its own
   row's bubble carrying .bn-nock__msg--pending, and the floating toggle
   reacts to a pending bubble anywhere in the whole widget, so it keeps
   signaling "working" even if the panel gets minimized mid-answer. */
@keyframes bn-nock-glow {
    0%, 100% {
        box-shadow: 0 0 5px 0px rgba(236, 196, 108, 0.22);
    }
    50% {
        box-shadow: 0 0 11px 2px rgba(236, 196, 108, 0.42);
    }
}

@keyframes bn-nock-glow-small {
    0%, 100% {
        box-shadow: 0 0 2px 0px rgba(236, 196, 108, 0.25);
    }
    50% {
        box-shadow: 0 0 5px 1px rgba(236, 196, 108, 0.5);
    }
}

@keyframes bn-nock-glow-active {
    0%, 100% {
        box-shadow: 0 0 7px 1px rgba(236, 196, 108, 0.4);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 18px 5px rgba(236, 196, 108, 0.85);
        transform: scale(1.035);
    }
}

@keyframes bn-nock-glow-active-small {
    0%, 100% {
        box-shadow: 0 0 3px 0px rgba(236, 196, 108, 0.45);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 8px 2px rgba(236, 196, 108, 0.9);
        transform: scale(1.08);
    }
}

.bn-nock:has(.bn-nock__msg--pending) .bn-nock__avatar--toggle {
    animation: bn-nock-glow-active 1.1s ease-in-out infinite;
}

.bn-nock__row--assistant:has(.bn-nock__msg--pending) .bn-nock__avatar--msg {
    animation: bn-nock-glow-active-small 1s ease-in-out infinite;
}

.bn-nock__panel {
    position: absolute;
    left: 0;
    bottom: 68px;
    width: 340px;
    max-width: calc(100vw - 40px);
    max-height: min(540px, 70vh);
    display: flex;
    flex-direction: column;
    background: var(--wlfi-bg-secondary, #1c1712);
    border: 1px solid var(--wlfi-border-secondary);
    border-radius: 16px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    overflow: hidden;
}

.bn-nock__head {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid var(--wlfi-border-secondary);
    flex-shrink: 0;
}

.bn-nock__title {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    font-weight: 700;
    font-size: 0.9375rem;
    color: var(--wlfi-text);
}

.bn-nock__tabs {
    display: flex;
    gap: 0.3rem;
    margin-left: auto;
    margin-right: 0.4rem;
}

.bn-nock__tab {
    border: none;
    background: rgba(255, 255, 255, 0.05);
    color: var(--wlfi-text-tertiary);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.3rem 0.65rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, color 0.2s ease;
}

.bn-nock__tab.is-active {
    background: var(--wlfi-brand-dim);
    color: var(--wlfi-brand);
}

.bn-nock__close,
.bn-nock__reset {
    border: none;
    background: transparent;
    color: var(--wlfi-text-quaternary);
    font-size: 1.1rem;
    cursor: pointer;
    line-height: 1;
    flex-shrink: 0;
}

.bn-nock__reset {
    font-size: 0.95rem;
    margin-right: 0.35rem;
    transition: color 0.2s ease, transform 0.2s ease;
}

.bn-nock__close:hover,
.bn-nock__reset:hover {
    color: var(--wlfi-text);
}

.bn-nock__reset:hover {
    color: var(--wlfi-brand);
    transform: rotate(-35deg);
}

.bn-nock__reset:disabled {
    opacity: 0.5;
    cursor: default;
}

.bn-nock__body {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
    min-height: 0;
    padding: 0.85rem 1rem 1rem;
}

.bn-nock__disclaimer {
    margin: 0 0 0.6rem;
    font-size: 0.7rem;
    line-height: 1.4;
    color: var(--wlfi-text-quaternary);
}

.bn-nock__messages {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.55rem;
    margin-bottom: 0.75rem;
    padding-right: 2px;
}

.bn-nock__empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.6rem;
    font-size: 0.8125rem;
    color: var(--wlfi-text-quaternary);
    text-align: center;
    padding: 1.5rem 0.5rem;
}

.bn-nock__empty p {
    margin: 0;
}

/* Example prompts shown only on a fresh, empty conversation - makes the
   tool-calling capability (live offers, prices, pages, account) visible
   and one tap away instead of something a visitor has to guess exists. */
.bn-nock__suggestions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.4rem;
    margin-top: 0.3rem;
}

.bn-nock__suggestion {
    border: 1px solid var(--wlfi-border-secondary);
    background: rgba(255, 255, 255, 0.04);
    color: var(--wlfi-text-secondary, var(--wlfi-text));
    font-size: 0.75rem;
    font-weight: 600;
    padding: 0.4rem 0.7rem;
    border-radius: 999px;
    cursor: pointer;
    transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.bn-nock__suggestion:hover,
.bn-nock__suggestion:focus-visible {
    background: var(--wlfi-brand-dim);
    border-color: var(--wlfi-brand-border, rgba(236, 196, 108, 0.28));
    color: var(--wlfi-brand-text, var(--wlfi-brand));
}

.bn-nock__msg {
    max-width: 85%;
    padding: 0.55rem 0.8rem;
    border-radius: 12px;
    font-size: 0.85rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
}

.bn-nock__msg--user {
    align-self: flex-end;
    background: var(--wlfi-brand);
    color: #13100d;
    border-bottom-right-radius: 4px;
}

/* Every newly appended message (and, on reopen, each one restored from
   history) rises and fades in once - immediate, brief, and purely
   decorative, never gating interaction. */
.bn-nock__row,
.bn-nock__msg--user {
    animation: bn-nock-rise 0.25s ease both;
}

.bn-nock__action {
    animation: bn-nock-rise 0.2s ease both;
}

@keyframes bn-nock-rise {
    from {
        opacity: 0;
        transform: translateY(6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bn-nock__msg--assistant {
    background: rgba(255, 255, 255, 0.06);
    color: var(--wlfi-text);
    border: 1px solid var(--wlfi-border-secondary);
    border-bottom-left-radius: 4px;
}

/* Assistant replies are wrapped in a row with Nock's avatar - see
   bn-nock.js appendMessage(). The row (not the bubble) carries the
   85% cap and left alignment so the avatar + bubble read as one unit.
   flex-start (not flex-end) so the avatar lines up with the first line
   of text even when action cards make the column below it taller. */
.bn-nock__row {
    display: flex;
    align-items: flex-start;
    gap: 0.45rem;
    max-width: 85%;
}

.bn-nock__row--assistant {
    align-self: flex-start;
}

.bn-nock__row--assistant .bn-nock__msg--assistant {
    max-width: none;
    min-width: 0;
}

.bn-nock__msg--pending {
    opacity: 0.6;
}

/* Typing indicator - three dots pulsing in sequence inside the pending
   bubble, next to the "Searching…" label, so waiting on a live tool
   call or search reads as active progress rather than a stall. */
.bn-nock__dots {
    display: inline-flex;
    gap: 3px;
    margin-left: 0.45rem;
    vertical-align: middle;
}

.bn-nock__dots i {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: currentColor;
    opacity: 0.35;
    animation: bn-nock-bounce 1.1s ease-in-out infinite;
}

.bn-nock__dots i:nth-child(2) {
    animation-delay: 0.15s;
}

.bn-nock__dots i:nth-child(3) {
    animation-delay: 0.3s;
}

@keyframes bn-nock-bounce {
    0%, 60%, 100% {
        opacity: 0.35;
        transform: translateY(0);
    }
    30% {
        opacity: 1;
        transform: translateY(-2px);
    }
}

/* Bubble + action cards stack together under the avatar. */
.bn-nock__col {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
    min-width: 0;
    flex: 1 1 auto;
}

.bn-nock__actions {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

/* Real, server-built links only (NockTools - live offers, verified
   page routes, research articles) - styled as a distinct "do this next"
   affordance, one step up from the plain text above it. */
.bn-nock__action {
    display: flex;
    align-items: center;
    gap: 0.55rem;
    padding: 0.6rem 0.8rem;
    border-radius: 10px;
    border: 1px solid var(--wlfi-brand-border, rgba(236, 196, 108, 0.28));
    background: var(--wlfi-brand-dim);
    color: var(--wlfi-brand-text, var(--wlfi-brand));
    font-size: 0.8125rem;
    font-weight: 600;
    line-height: 1.3;
    text-decoration: none;
    transition: background 0.2s ease, transform 0.15s ease, border-color 0.2s ease;
}

.bn-nock__action:hover,
.bn-nock__action:focus-visible {
    background: rgba(236, 196, 108, 0.2);
    border-color: var(--wlfi-brand);
    transform: translateX(2px);
    color: var(--wlfi-brand-text, var(--wlfi-brand));
}

.bn-nock__action:active {
    transform: translateX(2px) scale(0.98);
}

.bn-nock__action-icon {
    flex-shrink: 0;
    font-size: 1rem;
}

.bn-nock__form {
    display: flex;
    gap: 0.5rem;
    flex-shrink: 0;
}

.bn-nock__input {
    flex: 1 1 auto;
    border-radius: 10px;
    border: 1px solid var(--wlfi-border-secondary);
    background: var(--wlfi-bg-tertiary);
    color: var(--wlfi-text);
    font-family: inherit;
    font-size: 0.875rem;
    padding: 0.55rem 0.75rem;
}

.bn-nock__input:focus {
    outline: 0;
    border-color: rgba(236, 196, 108, 0.55);
    box-shadow: 0 0 0 3px var(--wlfi-brand-dim);
}

.bn-nock__send {
    flex-shrink: 0;
    width: 38px;
    border-radius: 10px;
    border: none;
    background: var(--wlfi-brand);
    color: #13100d;
    cursor: pointer;
    transition: filter 0.2s ease;
}

.bn-nock__send:hover {
    filter: brightness(1.08);
}

.bn-nock__send:disabled {
    opacity: 0.6;
    cursor: default;
}

.bn-nock__error {
    margin: 0.5rem 0 0;
    font-size: 0.75rem;
    color: #ff5252;
}

/* Live from X feed */
.bn-nock__feed {
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 0.7rem;
}

.bn-nock__feed-item {
    display: flex;
    gap: 0.6rem;
    padding-bottom: 0.7rem;
    border-bottom: 1px solid var(--wlfi-border-secondary);
}

.bn-nock__feed-item:last-child {
    border-bottom: none;
}

.bn-nock__feed-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.bn-nock__feed-body {
    min-width: 0;
}

.bn-nock__feed-meta {
    display: flex;
    align-items: baseline;
    gap: 0.35rem;
    font-size: 0.75rem;
}

.bn-nock__feed-name {
    font-weight: 700;
    color: var(--wlfi-text);
}

.bn-nock__feed-handle,
.bn-nock__feed-time {
    color: var(--wlfi-text-quaternary);
}

.bn-nock__feed-text {
    margin: 0.2rem 0 0;
    font-size: 0.8125rem;
    line-height: 1.45;
    color: var(--wlfi-text-secondary);
    white-space: pre-wrap;
    word-break: break-word;
}

@media (max-width: 480px) {
    .bn-nock {
        left: 12px;
        bottom: 12px;
    }

    .bn-nock__panel {
        width: calc(100vw - 24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .bn-nock__toggle,
    .bn-nock__reset {
        transition: none;
    }

    .bn-nock__row,
    .bn-nock__msg--user,
    .bn-nock__action,
    .bn-nock__dots i,
    .bn-nock__avatar,
    .bn-nock:has(.bn-nock__msg--pending) .bn-nock__avatar--toggle,
    .bn-nock__row--assistant:has(.bn-nock__msg--pending) .bn-nock__avatar--msg {
        animation: none;
    }
}
