/* ================================================
   CHAT.CSS
   "talk to bin" chatbot widget (themeable)
   ================================================ */

.chat-widget {
    display: flex;
    flex-direction: column;
    width: 100%;
    /* viewport-aware so the sticky column (label + lore teaser + widget) always fits
       on screen and the input is never clipped while pinned */
    height: clamp(440px, calc(100vh - 230px), 820px);
    /* match the look of the .about-section panels so it reads as part of the page,
       not a floating assistant — same bg + left accent rail */
    background: rgba(8, 8, 18, 0.72);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.4);
    border-left: 2px solid rgba(var(--theme-primary-rgb), 0.65);
    box-shadow: 0 0 18px rgba(var(--theme-primary-rgb), 0.16), inset 0 0 34px rgba(var(--theme-primary-rgb), 0.04);
    backdrop-filter: blur(3px);
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    overflow: hidden;
}

/* Header */
.chat-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.85rem 1rem;
    border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.3);
    background: rgba(var(--theme-primary-rgb), 0.07);
}

.chat-reset {
    margin-left: auto;
    flex-shrink: 0;
    padding: 0.3rem 0.6rem;
    background: transparent;
    color: var(--theme-secondary);
    border: 1px solid rgba(var(--theme-secondary-rgb), 0.4);
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-reset:hover {
    color: var(--theme-primary);
    border-color: var(--theme-primary);
    box-shadow: 0 0 8px rgba(var(--theme-primary-rgb), 0.3);
}

.chat-avatar {
    width: 46px;
    height: 46px;
    flex-shrink: 0;
    border-radius: 50%;
    border: 1px solid rgba(var(--theme-primary-rgb), 0.6);
    background:
        radial-gradient(circle at 30% 30%, rgba(var(--theme-primary-rgb), 0.9), rgba(var(--theme-secondary-rgb), 0.7));
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--theme-dark);
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-weight: bold;
    font-size: 16px;
    overflow: hidden;
    box-shadow: 0 0 12px rgba(var(--theme-primary-rgb), 0.4);
}

.chat-avatar img {
    width: 100%;
    height: 100%;
    border-radius: 50%;
    object-fit: cover;
    display: block;
}

.chat-header-info {
    display: flex;
    flex-direction: column;
    line-height: 1.2;
}

.chat-header-name {
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    color: var(--theme-primary);
    font-size: 18px;
    font-weight: bold;
}

.chat-header-status {
    font-size: 12.5px;
    color: var(--theme-secondary);
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.chat-status-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #4ade80;
    box-shadow: 0 0 6px #4ade80;
}

/* Chat body (revealed after name gate) */
.chat-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
}

/* Name gate */
.chat-namegate {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
}

.chat-namegate-inner {
    width: 100%;
    max-width: 320px;
    text-align: center;
}

.chat-namegate-text {
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    color: var(--theme-secondary);
    font-size: 14px;
    margin-bottom: 1rem;
}

.chat-namegate .chat-input {
    width: 100%;
    margin-bottom: 0.75rem;
    text-align: center;
}

.chat-namegate-btn {
    width: 100%;
    padding: 0.6rem;
}

/* Message list */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.chat-msg {
    max-width: 86%;
    padding: 0.75rem 1rem;
    font-size: 15.5px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-wrap: break-word;
    color: var(--theme-text);
    animation: chatFadeIn 0.25s ease;
}

@keyframes chatFadeIn {
    from { opacity: 0; transform: translateY(4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* inline images cortana embeds from the lore records */
.chat-img-link {
    display: block;
    margin: 0.5rem 0 0.15rem;
    line-height: 0;
}

.chat-img {
    max-width: 100%;
    max-height: 320px;
    width: auto;
    height: auto;
    border: 1px solid rgba(var(--theme-primary-rgb), 0.45);
    box-shadow: 0 0 12px rgba(var(--theme-primary-rgb), 0.2);
    cursor: pointer;
    transition: box-shadow 0.18s ease, transform 0.18s ease;
}

.chat-img:hover {
    box-shadow: 0 0 18px rgba(var(--theme-primary-rgb), 0.5);
    transform: scale(1.01);
}

/* inline links cortana drops to other parts of the site */
.chat-link {
    color: var(--theme-primary, #ed4f86);
    text-decoration: none;
    border-bottom: 1px solid rgba(var(--theme-primary-rgb), 0.45);
    padding-bottom: 1px;
    transition: color 0.15s ease, border-color 0.15s ease, text-shadow 0.15s ease;
}

.chat-link:hover {
    color: #fff;
    border-bottom-color: var(--theme-primary, #ed4f86);
    text-shadow: 0 0 8px rgba(var(--theme-primary-rgb), 0.8);
}

/* markdown bits cortana renders inline */
.chat-code {
    font-family: var(--font-mono, monospace);
    font-size: 0.88em;
    background: rgba(var(--theme-secondary-rgb), 0.18);
    border: 1px solid rgba(var(--theme-secondary-rgb), 0.32);
    border-radius: 3px;
    padding: 0.05em 0.35em;
    color: var(--theme-secondary, #7fdfff);
    word-break: break-word;
}

.chat-pre {
    margin: 0.5rem 0;
    padding: 0.6rem 0.7rem;
    background: rgba(0, 0, 0, 0.35);
    border: 1px solid rgba(var(--theme-secondary-rgb), 0.3);
    border-left: 3px solid var(--theme-secondary);
    border-radius: 4px;
    overflow-x: auto;
}

.chat-pre code {
    font-family: var(--font-mono, monospace);
    font-size: 0.85em;
    white-space: pre;
    background: none;
    border: none;
    padding: 0;
    color: inherit;
}

.chat-quote {
    display: block;
    border-left: 3px solid rgba(var(--theme-primary-rgb), 0.6);
    padding: 0.1rem 0 0.1rem 0.6rem;
    margin: 0.25rem 0;
    opacity: 0.85;
    font-style: italic;
}

.chat-msg-bot strong { color: #fff; }
.chat-msg-bot em { font-style: italic; }

.chat-msg-bot {
    align-self: flex-start;
    background: rgba(var(--theme-secondary-rgb), 0.12);
    border: 1px solid rgba(var(--theme-secondary-rgb), 0.3);
    border-left: 3px solid var(--theme-secondary);
}

.chat-msg-user {
    align-self: flex-end;
    background: rgba(var(--theme-primary-rgb), 0.12);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.3);
    border-right: 3px solid var(--theme-primary);
}

.chat-msg-error {
    align-self: flex-start;
    background: rgba(255, 80, 80, 0.1);
    border: 1px solid rgba(255, 80, 80, 0.4);
    border-left: 3px solid #ff5050;
    color: #ff9b9b;
}

/* ---- "receiving transmission" typing indicator ----
   neon equalizer/waveform + a glitchy label, fits cortana's
   "decrypting / incoming signal" vibe better than plain dots */
.chat-typing {
    display: inline-flex;
    gap: 0.6rem;
    align-items: center;
}

.chat-typing-wave {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    height: 16px;
}

.chat-typing-wave i {
    display: block;
    width: 3px;
    height: 100%;
    background: var(--theme-secondary);
    box-shadow: 0 0 6px rgba(var(--theme-secondary-rgb), 0.8);
    transform: scaleY(0.3);
    transform-origin: center;
    animation: chatWave 1s ease-in-out infinite;
}

.chat-typing-wave i:nth-child(1) { animation-delay: 0s; }
.chat-typing-wave i:nth-child(2) { animation-delay: 0.15s; }
.chat-typing-wave i:nth-child(3) { animation-delay: 0.3s; }
.chat-typing-wave i:nth-child(4) { animation-delay: 0.45s; }
.chat-typing-wave i:nth-child(5) { animation-delay: 0.6s; }

@keyframes chatWave {
    0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
    50%      { transform: scaleY(1);   opacity: 1; }
}

.chat-typing-label {
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-size: 11px;
    letter-spacing: 1.5px;
    text-transform: uppercase;
    color: var(--theme-secondary);
    text-shadow: 0 0 8px rgba(var(--theme-secondary-rgb), 0.45);
    animation: chatTypingLabel 1.6s ease-in-out infinite;
}

@keyframes chatTypingLabel {
    0%, 100% { opacity: 0.45; }
    50%      { opacity: 0.95; }
}

/* animated "..." that ticks after the label */
.chat-typing-dots::after {
    content: '';
    animation: chatTypingDots 1.4s steps(4, end) infinite;
}

@keyframes chatTypingDots {
    0%   { content: ''; }
    25%  { content: '.'; }
    50%  { content: '..'; }
    75%  { content: '...'; }
    100% { content: ''; }
}

/* blinking neon caret that trails the text as it streams in */
.chat-cursor {
    display: inline-block;
    width: 7px;
    height: 1.05em;
    margin-left: 2px;
    vertical-align: text-bottom;
    background: var(--theme-primary);
    box-shadow: 0 0 8px rgba(var(--theme-primary-rgb), 0.9), 0 0 16px rgba(var(--theme-primary-rgb), 0.5);
    animation: chatCursorBlink 0.85s steps(1) infinite;
}

@keyframes chatCursorBlink {
    50% { opacity: 0; }
}

/* the bot bubble breathes with a soft neon glow while it's actively streaming */
.chat-msg-bot.chat-msg-streaming {
    border-left-color: var(--theme-primary);
    animation: chatStreamGlow 1.8s ease-in-out infinite;
}

@keyframes chatStreamGlow {
    0%, 100% { box-shadow: -3px 0 0 rgba(var(--theme-primary-rgb), 0); }
    50%      { box-shadow: -4px 0 16px rgba(var(--theme-primary-rgb), 0.35); }
}

/* Suggestion chips */
.chat-suggestions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    padding: 0 1rem 0.5rem 1rem;
}

.chat-chip {
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-size: 13px;
    padding: 0.45rem 0.85rem;
    background: rgba(var(--theme-accent-rgb), 0.1);
    border: 1px solid rgba(var(--theme-accent-rgb), 0.4);
    color: var(--theme-accent);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chat-chip:hover {
    background: rgba(var(--theme-accent-rgb), 0.2);
    box-shadow: 0 0 8px rgba(var(--theme-accent-rgb), 0.3);
}

/* Input row */
.chat-input-row {
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem;
    border-top: 1px solid rgba(var(--theme-primary-rgb), 0.3);
    background: rgba(var(--theme-dark-rgb), 0.5);
}

.chat-input {
    flex: 1;
    padding: 0.65rem 0.75rem;
    background-color: rgba(var(--theme-dark-rgb), 0.8);
    color: var(--theme-primary);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.4);
    border-radius: 0;
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-size: 15.5px;
    resize: none;
    box-sizing: border-box;
    transition: all 0.3s ease;
    max-height: 140px;
}

.chat-input:focus {
    outline: none;
    border-color: var(--theme-primary);
    box-shadow: 0 0 10px rgba(var(--theme-primary-rgb), 0.4);
}

.chat-send {
    flex-shrink: 0;
    padding: 0 1.25rem;
    background-color: rgba(var(--theme-primary-rgb), 0.15);
    color: var(--theme-primary);
    border: 1px solid rgba(var(--theme-primary-rgb), 0.5);
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    font-size: 14.5px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.chat-send:hover:not(:disabled) {
    border-color: var(--theme-primary);
    text-shadow: 0 0 8px rgba(var(--theme-primary-rgb), 0.8);
    box-shadow: 0 0 12px rgba(var(--theme-primary-rgb), 0.3);
}

.chat-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Layout: about page + chat side by side */
.about-layout {
    display: flex;
    align-items: flex-start;
    gap: 2rem;
}

.about-layout .about-container {
    flex: 1 1 auto;
    min-width: 0;
}

/* wider column that sticks to the viewport so it doesn't scroll away with the page */
.chat-column {
    flex: 0 0 600px;
    min-width: 0;
    align-self: flex-start;
    position: sticky;
    top: 20px;
    padding-top: 0;
}

.chat-column-label {
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    color: var(--theme-secondary);
    font-size: 14px;
    margin-bottom: 0.75rem;
}

/* ---- "hidden lore / unlocks" teaser above the chat ---- */
.chat-lore {
    position: relative;
    margin-bottom: 0.9rem;
    padding: 0.8rem 0.9rem;
    font-family: var(--f-mono, 'Share Tech Mono', monospace);
    background:
        repeating-linear-gradient(
            45deg,
            rgba(var(--theme-accent-rgb), 0.05) 0 10px,
            rgba(var(--theme-accent-rgb), 0.09) 10px 20px);
    border: 1px dashed rgba(var(--theme-accent-rgb), 0.55);
    border-left: 3px solid var(--theme-accent);
    box-shadow: inset 0 0 26px rgba(var(--theme-accent-rgb), 0.06);
    overflow: hidden;
}

/* faint sweeping "scan" so it feels alive/encrypted */
.chat-lore::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(120deg, transparent 35%, rgba(var(--theme-accent-rgb), 0.14) 50%, transparent 65%);
    transform: translateX(-100%);
    animation: chatLoreScan 4.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes chatLoreScan {
    0%, 60% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.chat-lore-head {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.45rem;
}

.chat-lore-glyph {
    color: var(--theme-accent);
    font-size: 15px;
    text-shadow: 0 0 8px rgba(var(--theme-accent-rgb), 0.7);
    animation: chatLorePulse 2.2s ease-in-out infinite;
}

@keyframes chatLorePulse {
    0%, 100% { opacity: 0.55; }
    50% { opacity: 1; }
}

.chat-lore-title {
    color: var(--theme-accent);
    font-size: 11.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    text-shadow: 0 0 8px rgba(var(--theme-accent-rgb), 0.5);
}

.chat-lore-body {
    margin: 0;
    font-size: 12.5px;
    line-height: 1.65;
    color: var(--theme-text);
    opacity: 0.92;
}

.chat-lore-body strong {
    color: var(--theme-primary);
    text-shadow: 0 0 7px rgba(var(--theme-primary-rgb), 0.5);
    font-weight: normal;
}

.chat-lore-meter {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(var(--theme-accent-rgb), 0.25);
}

.chat-lore-tag {
    font-size: 10.5px;
    letter-spacing: 1px;
    text-transform: uppercase;
    color: var(--theme-secondary);
    opacity: 0.8;
}

.chat-lore-count {
    font-size: 13px;
    color: var(--theme-accent);
    text-shadow: 0 0 8px rgba(var(--theme-accent-rgb), 0.6);
}

.chat-lore-blink {
    animation: chatLoreBlink 1s steps(1) infinite;
}

@keyframes chatLoreBlink {
    50% { opacity: 0; }
}

/* Stack on smaller screens */
@media (max-width: 991px) {
    .about-layout {
        flex-direction: column;
    }

    .chat-column {
        position: static;
        flex: 1 1 auto;
        width: 100%;
        padding-top: 0;
        margin-bottom: 2rem;
        order: -1;
    }

    .chat-widget {
        height: 500px;
    }
}
