/* The chat: a panel beside the call, its messages and the reactions on them, and new messages as
   toasts in the corner while it's shut. */

.pod-chat[hidden],
.pod-chat [hidden],
.pod-toasts[hidden] {
    display: none;
}

/* ---------- The panel ---------- */

.pod-chat {
    display: flex;
    flex: none;
    flex-direction: column;
    width: calc(var(--space-24) * 6 + var(--space-16));
    min-height: 0;
    overflow: hidden;
    border: var(--border-width-hairline) solid var(--color-border-subtle);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-surface);
}

/* The chat beside the call where there's room, the pictures making way; where there isn't, over the
   pictures, with what's happening and your controls still in sight. */
.pod-stage-area.has-chat {
    flex-direction: row;
}

.pod-stage-area.has-chat:has(.pod-stage) > .pod-alerts {
    inset-inline-end: calc(var(--space-24) * 6 + var(--space-16) + var(--space-6) + var(--space-4));
}

@container pod-area (max-width: 640px) {
    .pod-stage-area > .pod-chat {
        position: absolute;
        inset: 0;
        z-index: 1;
        width: auto;
        box-shadow: var(--shadow-elevated);
    }

    .pod-stage-area.has-chat:has(.pod-stage) > .pod-alerts {
        inset-inline-end: var(--space-4);
    }
}

.pod-chat-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--space-4);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-7);
    border-bottom: var(--border-width-hairline) solid var(--color-border-subtle);
}

.pod-chat-title {
    margin: 0;
    font-size: var(--font-size-md);
    font-weight: var(--font-weight-semibold);
}

.pod-chat-body {
    position: relative;
    display: flex;
    flex: 1;
    flex-direction: column;
    min-height: 0;
}

.pod-chat-list {
    display: flex;
    flex: 1;
    flex-direction: column;
    gap: var(--space-2);
    min-height: 0;
    margin: 0;
    padding: var(--space-6) var(--space-7);
    overflow-y: auto;
    list-style: none;
}

.pod-chat-item.is-first:not(:first-child) {
    margin-block-start: var(--space-6);
}

.pod-chat-meta {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
    margin: 0 0 var(--space-1);
    font-size: var(--font-size-sm);
}

.pod-chat-bubble {
    display: flex;
    align-items: flex-start;
    gap: var(--space-2);
}

.pod-chat-text {
    flex: 1;
    min-width: 0;
    margin: 0;
    font-size: var(--font-size-sm);
    line-height: var(--line-height-normal);
    white-space: pre-wrap;
    overflow-wrap: anywhere;
}

.pod-chat-text a {
    color: inherit;
    text-decoration: underline;
    text-underline-offset: var(--space-1);
}

.pod-chat-status {
    margin: var(--space-1) 0 0;
    text-align: end;
}

.pod-chat-empty {
    display: grid;
    flex: 1;
    align-content: center;
    gap: var(--space-3);
    padding: var(--space-8);
    font-size: var(--font-size-sm);
    text-align: center;
}

.pod-chat-empty p {
    margin: 0;
}

/* Back to the newest, when someone is reading further up and something comes in. */
.pod-chat-latest {
    position: absolute;
    inset: auto auto var(--space-4) 50%;
    translate: -50% 0;
    box-shadow: var(--shadow-elevated);
}

/* The box to write in is the chat's foot itself, with no box of its own. */
.pod-chat-form {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-3) var(--space-3) var(--space-4);
    border-top: var(--border-width-hairline) solid var(--color-border-subtle);
}

.bu-input.pod-chat-input,
.bu-input.pod-chat-input:focus {
    flex: 1;
    min-width: 0;
    border-color: transparent;
    background-color: transparent;
    box-shadow: none;
}

.pod-chat-send {
    flex: none;
}

/* The chat's button: lit while the chat is open. */
.bu-icon-button.pod-chat-button.is-open {
    background-color: var(--color-primary);
    color: var(--color-primary-text);
}

/* ---------- Reactions ---------- */

/* Where there's a pointer, the button to react appears when it's over a message or has focus. Where
   there's only a finger, a long press on the message does it, and the button is left for a screen reader
   and a keyboard, out of sight until it has focus. */
.pod-react-open {
    flex: none;
    margin-block: calc(var(--space-2) * -1);
    color: var(--color-text-muted);
}

@media (hover: hover) {
    .pod-react-open {
        opacity: 0;
    }

    .pod-chat-bubble:hover .pod-react-open,
    .pod-chat-item:focus-within .pod-react-open,
    .pod-react-open[aria-expanded="true"] {
        opacity: 1;
    }
}

@media (hover: none) {
    .pod-react-open:not(:focus) {
        position: absolute;
        width: 1px;
        height: 1px;
        overflow: hidden;
        clip-path: inset(50%);
        opacity: 0;
    }

    /* Holding a message must not select its words or raise the browser's own menu. */
    .pod-chat-bubble {
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }
}

.pod-reactions {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-2);
    margin: var(--space-2) 0 0;
    padding: 0;
    list-style: none;
}

.pod-reaction {
    display: inline-flex;
    align-items: center;
    gap: var(--space-2);
    min-height: var(--space-12);
    padding: 0 var(--space-4);
    border: var(--border-width-hairline) solid var(--color-border-subtle);
    border-radius: var(--radius-full);
    background-color: var(--color-surface-muted);
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-sm);
    cursor: pointer;
}

.pod-reaction:hover {
    border-color: var(--color-border);
}

.pod-reaction.is-mine {
    border-color: var(--color-primary);
    background-color: var(--color-surface);
}

.pod-reaction:focus-visible,
.pod-pick:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-focus);
    outline-offset: var(--focus-ring-offset);
}

/* The choices, in a row beside the message they're for. */
.pod-picker[popover] {
    inset: auto;
    margin: 0 0 var(--space-2);
    padding: var(--space-2);
    border: var(--border-width-hairline) solid var(--color-border);
    border-radius: var(--radius-full);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-elevated);
    position-area: block-start span-inline-end;
    position-try-fallbacks: flip-block, flip-inline;
}

.pod-picker:popover-open {
    display: flex;
    gap: var(--space-1);
}

.pod-pick {
    display: grid;
    place-items: center;
    width: calc(var(--space-16) + var(--space-2));
    height: calc(var(--space-16) + var(--space-2));
    padding: 0;
    border: 0;
    border-radius: var(--radius-full);
    background-color: transparent;
    font-size: var(--font-size-lg);
    line-height: 1;
    cursor: pointer;
}

.pod-pick:hover,
.pod-pick[aria-pressed="true"] {
    background-color: var(--color-surface-muted);
}

.pod-pick[aria-pressed="true"] {
    box-shadow: inset 0 0 0 var(--border-width-hairline) var(--color-primary);
}

/* ---------- New messages, as toasts in the top corner ---------- */

.pod-toasts {
    position: fixed;
    inset: var(--space-6) var(--space-6) auto auto;
    z-index: 1;
    display: grid;
    gap: var(--space-4);
    width: min(44ch, calc(100vw - var(--space-12)));
    pointer-events: none;
}

.pod-toast {
    display: flex;
    align-items: flex-start;
    gap: var(--space-1);
    padding: var(--space-2);
    border: var(--border-width-hairline) solid var(--color-border);
    border-radius: var(--radius-md);
    background-color: var(--color-surface);
    box-shadow: var(--shadow-elevated);
    pointer-events: auto;
    touch-action: pan-y;
}

.pod-toast-open {
    display: flex;
    flex: 1;
    align-items: flex-start;
    gap: var(--space-5);
    min-width: 0;
    padding: var(--space-4);
    border: 0;
    border-radius: var(--radius-sm);
    background-color: transparent;
    color: var(--color-text);
    font: inherit;
    font-size: var(--font-size-sm);
    text-align: start;
    cursor: pointer;
}

.pod-toast-open:hover {
    background-color: var(--color-surface-muted);
}

.pod-toast-open:focus-visible {
    outline: var(--focus-ring-width) solid var(--color-focus);
    outline-offset: calc(var(--focus-ring-offset) * -1);
}

.pod-toast-open > .pod-request-initial {
    flex: none;
}

.pod-toast-body {
    display: grid;
    gap: var(--space-1);
    min-width: 0;
}

.pod-toast-name {
    display: flex;
    align-items: baseline;
    gap: var(--space-4);
}

.pod-toast-text {
    display: -webkit-box;
    overflow: hidden;
    color: var(--color-text-muted);
    line-height: var(--line-height-normal);
    overflow-wrap: anywhere;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    line-clamp: 2;
}

.pod-toast > .pod-notice-close {
    flex: none;
    margin: var(--space-2) var(--space-2) 0 0;
}

@media (prefers-reduced-motion: no-preference) {
    .pod-toast:not(.is-dragging) {
        transition: translate var(--duration-color) var(--ease-standard), opacity var(--duration-color) var(--ease-standard);
    }
}
