/*
 * Message bubble tail (Android style "B"): a small notch at the TOP outer
 * corner of the LAST bubble of a same-sender run. Sent -> right, received ->
 * left (the web bubbles keep these physical sides in RTL too, see rtl.css).
 *
 * public/js/bubble-tail.js adds `has-tail` to the bubble and appends a
 * <span class="bubble-tail"> inside it. The span uses `background: inherit`, so
 * it always matches whatever colour the bubble has (light/dark/custom themes).
 */

/* Every bubble reserves the same side room so a run stays aligned whether or
   not it carries a tail. */
.message-bubble.sent { margin-right: 11px; }
.message-bubble.received { margin-left: 11px; }

.message-bubble > .bubble-tail { display: none; }

.message-bubble.has-tail > .bubble-tail {
    display: block;
    position: absolute;
    top: 0;
    width: 11px;
    height: 18px;
    pointer-events: none;
    background: inherit;
    border: 0;
    box-shadow: none;
    backdrop-filter: none;
}

/* Sent: tail on the right, square corner under it. */
.message-bubble.has-tail.sent { border-top-right-radius: 0; }
.message-bubble.has-tail.sent > .bubble-tail {
    right: -10px;
    /* x 0..1 overlaps the bubble to hide the seam; tip at x=11, y=0 */
    clip-path: path('M0,0 H11 C4,3 1,9 1,18 H0 Z');
}

/* Received: mirrored; compensates the 1px border so it sits on the outer edge. */
.message-bubble.has-tail.received { border-top-left-radius: 0; }
.message-bubble.has-tail.received > .bubble-tail {
    top: -1px;
    height: 19px;
    width: 11px;
    left: -11px;
    clip-path: path('M0,0 H11 V19 H10 C10,9 7,3 0,0 Z');
}

/* Bubble sides are physical (sent right, received left) in LTR and RTL alike, so the tail is too. */

/* Non-tail bubbles in a run keep their normal full radius. */
.message-bubble.sent:not(.has-tail) { border-top-right-radius: var(--bubble-radius, 16px); }
.message-bubble.received:not(.has-tail) { border-top-left-radius: var(--bubble-radius, 16px); }

/* Bulk-selection tinting must not leave a differently coloured tail. */
.bulk-selection-mode .message-bubble.selected > .bubble-tail { background: inherit; }
