/* ── Graeme Richardson — Message Bubbles & Content ───
   Bubble styling, markdown, images, thinking, lightbox.
   Font treatments: headings → DM Sans, body → Roboto
   ─────────────────────────────────────────────────── */

/* ── Message layout ────────────────────────────── */
.message {
    display: flex; gap: 12px; max-width: 88%;
    animation: messageIn 0.3s ease-out;
}
@keyframes messageIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user { align-self: flex-end; flex-direction: row-reverse; }
.message.aria { align-self: flex-start; }

/* ── Message avatar ────────────────────────────── */
.message-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    flex-shrink: 0; overflow: hidden; margin-top: 4px;
    border: 1px solid rgba(255,255,255,0.06);
}
.message-avatar img { width: 100%; height: 100%; object-fit: cover; }

.message.user .message-avatar {
    background: rgba(0,184,204,0.15);
    display: flex; align-items: center; justify-content: center;
    border: 1px solid rgba(0,184,204,0.2);
}
.message.user .message-avatar::after {
    content: 'G'; color: var(--accent);
    font-size: 13px; font-weight: 600;
    font-family: var(--font-display);
}

/* ── Bubble base ───────────────────────────────── */
.message-bubble {
    padding: 12px 16px; border-radius: var(--radius-lg);
    font-family: var(--font-chat);
    font-size: 14px; line-height: 1.65; font-weight: 400;
    word-wrap: break-word; overflow-wrap: break-word;
    letter-spacing: 0.01em;
}

.message.aria .message-bubble {
    background: var(--aria-bubble);
    border: 1px solid var(--border);
    border-bottom-left-radius: var(--radius-sm);
}

.message.user .message-bubble {
    background: var(--user-bubble);
    border: 1px solid rgba(0,184,204,0.15);
    border-bottom-right-radius: var(--radius-sm);
}

/* ── Markdown ──────────────────────────────────── */
.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 700; color: #fff; }
.message-bubble ul, .message-bubble ol { margin: 6px 0; padding-left: 20px; }
.message-bubble li { margin-bottom: 4px; }

.message-bubble h1, .message-bubble h2, .message-bubble h3 {
    font-family: var(--font-display);
    font-size: 16px; font-weight: 700;
    margin: 12px 0 6px; color: #fff;
    letter-spacing: -0.01em;
    line-height: 1.3;
}

.message-bubble a { color: var(--accent); text-decoration: none; transition: color 0.15s; }
.message-bubble a:hover { color: #00D4E8; text-decoration: underline; }

.message-bubble code {
    background: rgba(0,184,204,0.1); padding: 2px 6px;
    border-radius: var(--radius-sm); font-size: 13px;
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-bubble pre {
    background: var(--bg); padding: 12px 16px;
    border-radius: var(--radius); overflow-x: auto;
    margin: 8px 0; font-size: 13px;
    border: 1px solid var(--border);
    font-family: 'SF Mono', 'Fira Code', monospace;
}

.message-bubble blockquote {
    border-left: 2px solid var(--accent); padding-left: 14px;
    margin: 8px 0; color: var(--text-secondary);
}

/* ── Images in chat ────────────────────────────── */
.chat-image {
    max-width: 100%; border-radius: var(--radius); margin: 8px 0;
    border: 1px solid var(--border); cursor: pointer;
    transition: border-color 0.2s, transform 0.2s;
}
.chat-image:hover { border-color: rgba(255,255,255,0.2); transform: scale(1.01); }

.image-gallery {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px; margin: 8px 0;
}

/* ── Thinking ──────────────────────────────────── */
.message.thinking { opacity: 0.8; }

.typing-indicator { display: flex; gap: 5px; padding: 6px 0 2px; }
.typing-indicator span {
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--accent);
    animation: bounce 1.4s ease-in-out infinite;
}
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes bounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Lightbox ──────────────────────────────────── */
.lightbox {
    display: none; position: fixed; inset: 0;
    background: rgba(0,0,0,0.94); z-index: 1000;
    align-items: center; justify-content: center; cursor: pointer;
    backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px);
}
.lightbox.active { display: flex; }
.lightbox img {
    max-width: 92vw; max-height: 92vh;
    border-radius: var(--radius); object-fit: contain;
    box-shadow: 0 0 60px rgba(0,0,0,0.8);
}

/* ── Welcome highlight ─────────────────────────── */
.message-bubble[data-welcome] {
    border-color: rgba(0,184,204,0.15);
    background: var(--bg-card);
}
