/* A chat message, in a game's chat and in a thread on home alike: a lightly
   tinted box, its sender and time in small type above the body. A chat that
   has more room raises --chat-fs on its feed rather than restyling the box. */

.chat-msg {
    flex-shrink: 0;
    padding: var(--size-1) var(--size-2);
    background: color-mix(in srgb, var(--color-accent) 8%, var(--surface-1));
    border: 1px solid color-mix(in srgb, var(--color-accent) 18%, var(--border-1));
    border-radius: var(--radius-2);
}

/* Private messages are tinted away from the public accent, so a glance tells you
   which thread you are in. */
.chat-msg--private {
    background: color-mix(in srgb, var(--color-private) 16%, var(--surface-1));
    border-color: color-mix(in srgb, var(--color-private) 38%, var(--border-1));
    border-left: 3px solid var(--color-private-strong);
}

/* The optimistic bubble ships in every patch, so it defaults to hidden and the
   --sending modifier reveals it. Hiding via a class rather than data-show's inline
   style is load-bearing: the delivered message morphs onto this very node, and an
   inline display:none would survive the morph and hide it. */
.chat-msg--pending:not(.chat-msg--sending) {
    display: none;
}

.chat-msg-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: var(--size-2);
}

.chat-msg-name {
    min-width: 0;
    color: var(--text-3);
    font-size: var(--chat-fs, var(--font-size-0));
    font-weight: var(--font-weight-5);
}

/* The time and, on the viewer's own messages, its delete control. */
.chat-msg-meta {
    display: flex;
    flex-shrink: 0;
    align-items: center;
    gap: var(--size-1);
}

.chat-msg-time {
    color: var(--text-2);
    font-size: var(--font-size-00);
    font-weight: var(--font-weight-4);
    white-space: nowrap;
    opacity: 0.7;
}

.chat-msg-sending::after {
    content: "…";
    display: inline-block;
    width: 1.2em;
    text-align: left;
    animation: chat-sending-dots 1.2s steps(1) infinite;
}

@keyframes chat-sending-dots {
    0% {
        content: "";
    }
    25% {
        content: ".";
    }
    50% {
        content: "..";
    }
    75% {
        content: "...";
    }
}

/* The body spans the box: normalize's measure on p would stop it short. */
.chat-msg-body {
    max-inline-size: none;
    margin: 0;
    color: var(--text-1);
    font-size: var(--chat-fs, var(--font-size-0));
    overflow-wrap: anywhere;
    white-space: pre-wrap;
}

/* A chat's message box and its Send, the same small size in a game's dock and
   in a thread on home. */
.chat-input {
    flex: 1 1 auto;
    min-width: 0;
    padding: var(--size-1) var(--size-2);
    background: var(--surface-1);
    color: var(--text-1);
    border: 1px solid var(--border-1);
    border-radius: var(--radius-2);
    font-size: var(--font-size-0);
}

/* --font-size-1 is what a game's dock gives its buttons (.game-dock-body
   button), which outranks this rule there; home takes the same. */
.chat-send {
    flex: 0 0 auto;
    padding: var(--size-1) var(--size-3);
    font-size: var(--font-size-1);
}

@media (hover: none) and (pointer: coarse) {
    /* iOS Safari auto-zooms inputs with font-size < 16px */
    .chat-input {
        font-size: 16px;
    }
}
