/* ============================================================
   munju.im — neomorphism soft UI messaging concept
   Palette:
     #e8e8ee  Cloud Gray (primary background)
     #2d2d3a  Soft Dark (primary text)
     #d1d1de  Neumorphic Shadow Light
     #ffffff  Neumorphic Highlight
     #7c5cfc  Message Purple (accent / sent bubble)
     #f0f0f6  Received bubble
     #a8a8b8  Timestamp Gray
   Fonts: Quicksand (headings + body), DM Mono (timestamps)
   ============================================================ */

:root {
    --bg: #e8e8ee;
    --text: #2d2d3a;
    --shadow-dark: #d1d1de;
    --shadow-light: #ffffff;
    --accent: #7c5cfc;
    --bubble-received: #f0f0f6;
    --meta: #a8a8b8;

    --neo-radius: 16px;
    --neo-shadow:
        6px 6px 12px var(--shadow-dark),
        -6px -6px 12px var(--shadow-light);
    --neo-shadow-soft:
        4px 4px 10px var(--shadow-dark),
        -4px -4px 10px var(--shadow-light);
    --neo-shadow-inset:
        inset 4px 4px 8px var(--shadow-dark),
        inset -4px -4px 8px var(--shadow-light);
    --neo-shadow-tiny:
        3px 3px 6px var(--shadow-dark),
        -3px -3px 6px var(--shadow-light);
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html, body {
    background: var(--bg);
    color: var(--text);
    font-family: 'Quicksand', system-ui, -apple-system, sans-serif;
    font-weight: 400;
    font-size: 16px;
    line-height: 1.7;
    min-height: 100%;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    min-height: 100vh;
    background:
        radial-gradient(circle at 20% 0%, rgba(124, 92, 252, 0.06), transparent 55%),
        radial-gradient(circle at 80% 100%, rgba(124, 92, 252, 0.05), transparent 60%),
        var(--bg);
    padding: 2rem 1rem 3rem;
    display: flex;
    justify-content: center;
}

p {
    font-size: 0.95rem;
    line-height: 1.7;
}

/* ============================================================
   Conversation container — phone-width column
   ============================================================ */
.conversation {
    width: 100%;
    max-width: 480px;
    display: flex;
    flex-direction: column;
    gap: 1.75rem;
}

/* ============================================================
   Hero — neomorphic soft pill
   ============================================================ */
.hero {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    padding: 1.5rem 0 0.5rem;
    text-align: center;
}

.hero-pill {
    display: inline-block;
    padding: 1rem 2rem;
    border-radius: 50px;
    background: var(--bg);
    box-shadow: var(--neo-shadow);
    transition: box-shadow 0.5s ease, transform 0.5s ease;
    cursor: default;
}

.hero-pill.is-pressed {
    box-shadow: var(--neo-shadow-inset);
    transform: scale(0.98);
}

.hero-domain {
    font-family: 'Quicksand', sans-serif;
    font-weight: 600;
    font-size: clamp(1.8rem, 5vw, 2.5rem);
    letter-spacing: 0.01em;
    color: var(--text);
    background: linear-gradient(135deg, var(--text) 0%, #4a4a5e 50%, var(--accent) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hero-sub {
    font-family: 'Quicksand', sans-serif;
    font-weight: 500;
    font-size: 0.95rem;
    color: var(--meta);
    letter-spacing: 0.04em;
}

.presence {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.4rem 0.9rem;
    background: var(--bg);
    border-radius: 50px;
    box-shadow: var(--neo-shadow-tiny);
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--meta);
    text-transform: lowercase;
    letter-spacing: 0.06em;
}

.presence-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #6dd49a;
    box-shadow: 0 0 8px rgba(109, 212, 154, 0.7);
    animation: presencePulse 2.4s ease-in-out infinite;
}

@keyframes presencePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%      { opacity: 0.55; transform: scale(0.9); }
}

/* ============================================================
   Thread — chat scroll
   ============================================================ */
.thread {
    display: flex;
    flex-direction: column;
    gap: 0.9rem;
    padding: 0.5rem 0.25rem;
}

.day-divider {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0.25rem 0 0.75rem;
}

.day-divider span {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--meta);
    letter-spacing: 0.12em;
    text-transform: uppercase;
    padding: 0.4rem 1rem;
    background: var(--bg);
    border-radius: 50px;
    box-shadow: var(--neo-shadow-tiny);
}

/* ============================================================
   Message bubbles
   ============================================================ */
.message {
    display: flex;
    flex-direction: column;
    max-width: 100%;
    opacity: 0;
    transform: translateY(14px);
    transition: opacity 0.6s ease, transform 0.6s cubic-bezier(0.2, 0.7, 0.2, 1);
}

.message.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.message .bubble {
    padding: 1rem 1.15rem;
    line-height: 1.65;
    font-size: 0.95rem;
    word-wrap: break-word;
    transition: transform 0.4s ease, box-shadow 0.4s ease;
}

.message .bubble p {
    margin: 0;
}

.message .timestamp {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--meta);
    margin-top: 0.35rem;
    letter-spacing: 0.04em;
}

/* Received (left-aligned) */
.message--received {
    align-self: flex-start;
    align-items: flex-start;
    margin-right: 20%;
    max-width: 80%;
}

.message--received .bubble {
    background: var(--bubble-received);
    color: var(--text);
    border-radius: 16px 16px 16px 4px;
    box-shadow: var(--neo-shadow-soft);
}

.message--received .timestamp {
    margin-left: 0.4rem;
}

/* Sent (right-aligned) */
.message--sent {
    align-self: flex-end;
    align-items: flex-end;
    margin-left: 20%;
    max-width: 80%;
}

.message--sent .bubble {
    background: var(--accent);
    color: #ffffff;
    border-radius: 16px 16px 4px 16px;
    box-shadow:
        6px 6px 14px rgba(124, 92, 252, 0.28),
        -4px -4px 10px var(--shadow-light);
}

.message--sent .timestamp {
    margin-right: 0.4rem;
}

.message .bubble:hover {
    transform: translateY(-1px);
}

.message--received .bubble:hover {
    box-shadow:
        7px 7px 14px var(--shadow-dark),
        -5px -5px 12px var(--shadow-light);
}

.message--sent .bubble:hover {
    box-shadow:
        8px 8px 18px rgba(124, 92, 252, 0.35),
        -4px -4px 10px var(--shadow-light);
}

/* Alternate alignment defensively via nth-child as well */
.thread .message:nth-child(odd of .message) {
    align-self: flex-start;
}
.thread .message:nth-child(even of .message) {
    align-self: flex-end;
}

/* ============================================================
   Typing indicator — three pulsing dots
   ============================================================ */
.typing {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    align-self: flex-start;
    margin-top: 0.25rem;
    margin-right: 20%;
    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.5s ease, transform 0.5s ease;
}

.typing.is-visible {
    opacity: 1;
    transform: translateY(0);
}

.typing-bubble {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.85rem 1rem;
    background: var(--bubble-received);
    border-radius: 16px 16px 16px 4px;
    box-shadow: var(--neo-shadow-soft);
}

.typing-bubble .dot {
    width: 8px;
    height: 8px;
    background: var(--meta);
    border-radius: 50%;
    animation: pulse 1.4s ease-in-out infinite;
}

.typing-bubble .dot:nth-child(1) { animation-delay: 0s; }
.typing-bubble .dot:nth-child(2) { animation-delay: 0.2s; }
.typing-bubble .dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
    0%, 60%, 100% {
        transform: scale(0.7);
        opacity: 0.5;
    }
    30% {
        transform: scale(1);
        opacity: 1;
    }
}

.typing-label {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--meta);
    letter-spacing: 0.05em;
}

/* ============================================================
   Composer — neomorphic input field
   ============================================================ */
.composer {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.65rem;
    margin-top: 0.5rem;
    padding-top: 1rem;
}

.composer-shell {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    width: 100%;
    padding: 0.5rem 0.55rem 0.5rem 0.6rem;
    background: var(--bg);
    border-radius: 50px;
    box-shadow: var(--neo-shadow-inset);
}

.composer-icon,
.composer-send {
    flex: 0 0 auto;
    width: 40px;
    height: 40px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: var(--bg);
    border-radius: 50%;
    box-shadow: var(--neo-shadow-tiny);
    color: var(--text);
    cursor: pointer;
    transition: box-shadow 0.25s ease, transform 0.2s ease, color 0.25s ease;
}

.composer-icon:hover,
.composer-send:hover {
    transform: translateY(-1px);
}

.composer-icon:active,
.composer-send:active,
.composer-icon.is-pressed,
.composer-send.is-pressed {
    box-shadow: var(--neo-shadow-inset);
    transform: scale(0.96);
}

.composer-send {
    color: var(--accent);
}

.composer-input {
    flex: 1 1 auto;
    border: none;
    outline: none;
    background: transparent;
    font-family: 'Quicksand', sans-serif;
    font-weight: 400;
    font-size: 0.95rem;
    color: var(--text);
    padding: 0.4rem 0.25rem;
    min-width: 0;
}

.composer-input::placeholder {
    color: var(--meta);
    font-weight: 400;
}

.composer-hint {
    font-family: 'DM Mono', monospace;
    font-weight: 300;
    font-size: 0.7rem;
    color: var(--meta);
    letter-spacing: 0.08em;
    text-align: center;
}

/* ============================================================
   Send animation flash for new sent messages
   ============================================================ */
@keyframes sendFlash {
    0%   { transform: translateY(20px) scale(0.92); opacity: 0; }
    60%  { transform: translateY(-2px) scale(1.02); opacity: 1; }
    100% { transform: translateY(0) scale(1); opacity: 1; }
}

.message.is-new {
    animation: sendFlash 0.55s cubic-bezier(0.2, 0.8, 0.2, 1) both;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 520px) {
    body { padding: 1.25rem 0.85rem 2rem; }
    .conversation { gap: 1.4rem; }
    .hero-pill { padding: 0.85rem 1.6rem; }
    .message--received { margin-right: 12%; max-width: 88%; }
    .message--sent     { margin-left: 12%;  max-width: 88%; }
    .typing { margin-right: 12%; }
}

@media (prefers-reduced-motion: reduce) {
    .message,
    .typing,
    .hero-pill,
    .composer-icon,
    .composer-send {
        transition: none;
    }
    .typing-bubble .dot,
    .presence-dot {
        animation: none;
    }
    .message.is-new { animation: none; }
}
