/* ChatKit: reactions, picker, long-press sheet and quoted replies shared by every chat
   (live game threads, group chat, DMs). Pairs with static/js/chat_kit.js. */

/* ── Reaction chips under a bubble ── */
.ck-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin: 4px 2px 0; }
.ck-reactions[hidden] { display: none; }
.is-own .ck-reactions, .dm-msg-own .ck-reactions { justify-content: flex-end; }
.ck-chip {
    display: inline-flex; align-items: center; gap: 4px;
    min-height: 26px; padding: 1px 8px 1px 6px;
    border-radius: 999px;
    border: 1px solid var(--border-color);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    font: inherit; font-size: 0.74rem; line-height: 1;
    cursor: pointer;
    animation: ckChipIn 220ms cubic-bezier(0.34, 1.56, 0.64, 1);
    transition: border-color 150ms ease, background 150ms ease, transform 120ms ease;
    -webkit-tap-highlight-color: transparent;
}
.ck-chip:hover { border-color: var(--border-light, var(--text-muted)); }
.ck-chip:active { transform: scale(0.92); }
.ck-chip.is-mine {
    border-color: rgba(46, 160, 67, 0.55);
    background: var(--accent-primary-soft, rgba(46, 160, 67, 0.14));
    color: var(--accent-green-light, var(--accent-primary));
}
.ck-chip-emoji { font-size: 0.95rem; line-height: 1; }
.ck-chip-count { font-family: var(--font-mono); font-variant-numeric: tabular-nums; font-weight: 700; font-size: 0.7rem; }
@keyframes ckChipIn { from { transform: scale(0.6); opacity: 0; } to { transform: none; opacity: 1; } }

/* ── Desktop picker (popover above the message) ── */
.ck-picker {
    position: fixed; z-index: 1200;
    padding: 4px;
    border-radius: 999px;
    background: var(--bg-elevated, var(--bg-tertiary));
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-card-hover, 0 10px 30px rgba(0, 0, 0, 0.45));
    animation: ckPop 180ms cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ck-picker.is-closing, .ck-sheet-wrap.is-closing { opacity: 0; transition: opacity 120ms ease; }
@keyframes ckPop { from { opacity: 0; transform: scale(0.85) translateY(6px); } to { opacity: 1; transform: none; } }
.ck-emoji-row { display: flex; gap: 2px; }
.ck-emoji {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: transparent;
    font-size: 1.25rem; line-height: 1;
    cursor: pointer;
    transition: transform 140ms cubic-bezier(0.34, 1.56, 0.64, 1), background 140ms ease;
    -webkit-tap-highlight-color: transparent;
}
.ck-emoji:hover, .ck-emoji:focus-visible { transform: scale(1.22); background: rgba(255, 255, 255, 0.08); outline: none; }
.ck-emoji.is-mine { background: var(--accent-primary-soft, rgba(46, 160, 67, 0.18)); box-shadow: inset 0 0 0 1px rgba(46, 160, 67, 0.5); }

/* ── Phone sheet (long-press): preview, reactions, actions ── */
.ck-sheet-wrap { position: fixed; inset: 0; z-index: 1300; display: flex; align-items: flex-end; justify-content: center; }
.ck-sheet-backdrop { position: absolute; inset: 0; background: rgba(0, 0, 0, 0.5); animation: ckFade 160ms ease; }
@keyframes ckFade { from { opacity: 0; } to { opacity: 1; } }
.ck-sheet {
    position: relative;
    width: 100%; max-width: 520px;
    display: flex; flex-direction: column; gap: 4px;
    padding: 12px 12px calc(12px + env(safe-area-inset-bottom, 0px));
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-bottom: none;
    border-radius: 18px 18px 0 0;
    box-shadow: 0 -12px 40px rgba(0, 0, 0, 0.45);
    animation: ckSheetUp 240ms cubic-bezier(0.22, 1, 0.36, 1);
}
@keyframes ckSheetUp { from { transform: translateY(100%); } to { transform: none; } }
.ck-sheet-preview {
    display: flex; flex-direction: column; gap: 2px;
    padding: 8px 12px; margin-bottom: 4px;
    border-radius: 12px;
    background: var(--bg-tertiary);
    font-size: 0.82rem; color: var(--text-secondary);
}
.ck-sheet-preview b { font-size: 0.74rem; color: var(--text-primary); }
.ck-sheet-preview span { display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }
/* All ten reactions on one row on a normal phone, two rows on a narrow one */
.ck-sheet .ck-emoji-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
    gap: 2px;
    padding: 6px 0 10px;
    margin-bottom: 4px;
    border-bottom: 1px solid var(--border-color);
}
.ck-sheet .ck-emoji { width: 100%; height: 42px; border-radius: 12px; font-size: 1.4rem; }
.ck-sheet-action, .ck-sheet-cancel {
    display: flex; align-items: center; gap: 12px;
    min-height: 48px; padding: 0 14px;
    border: none; border-radius: 12px;
    background: transparent;
    color: var(--text-primary);
    font: inherit; font-size: 0.95rem; font-weight: 600; text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.ck-sheet-action:active, .ck-sheet-cancel:active { background: var(--bg-tertiary); }
.ck-sheet-action svg { color: var(--text-muted); flex-shrink: 0; }
.ck-sheet-action.is-danger, .ck-sheet-action.is-danger svg { color: var(--accent-red-light, #f85149); }
.ck-sheet-cancel { justify-content: center; margin-top: 4px; background: var(--bg-tertiary); }

/* ── Long-press feedback + jump flash ── */
.ck-pressing { transform: scale(0.98); transition: transform 300ms ease; }
.ck-flash { animation: ckFlash 1.5s ease; border-radius: 14px; }
@keyframes ckFlash { 0%, 30% { background: rgba(46, 160, 67, 0.22); } 100% { background: transparent; } }
@media (hover: none) {
    /* Long-press is the menu on phones: no text-selection callout on bubbles */
    .live-msg-bubble, .chat-msg-bubble, .dm-msg-bubble { -webkit-touch-callout: none; -webkit-user-select: none; user-select: none; }
}

/* ── Quoted reply inside a bubble ── */
.ck-quote {
    display: flex; flex-direction: column; gap: 1px;
    width: 100%; max-width: 100%;
    margin: 0 0 6px;
    padding: 5px 9px;
    border: none; border-left: 3px solid var(--accent-primary);
    border-radius: 6px;
    background: rgba(0, 0, 0, 0.22);
    color: var(--text-muted);
    font: inherit; font-size: 0.76rem; text-align: left; line-height: 1.35;
    cursor: pointer;
    white-space: normal;
}
[data-theme="light"] .ck-quote { background: rgba(0, 0, 0, 0.05); }
.ck-quote:hover { background: rgba(0, 0, 0, 0.32); }
.ck-quote-name { font-weight: 700; color: var(--accent-green-light, var(--accent-primary)); font-size: 0.72rem; }
.ck-quote-body { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere; }

/* ── "Replying to" bar over a composer ── */
.ck-replybar {
    display: flex; align-items: center; gap: 10px;
    padding: 7px 10px 7px 12px;
    background: var(--accent-primary-soft, rgba(46, 160, 67, 0.12));
    border-top: 1px solid rgba(46, 160, 67, 0.28);
    animation: ckFade 160ms ease;
}
.ck-replybar[hidden] { display: none; }
.ck-replybar-icon { color: var(--accent-green-light, var(--accent-primary)); display: inline-flex; flex-shrink: 0; }
.ck-replybar-text { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.ck-replybar-label { font-size: 0.7rem; color: var(--text-muted); }
.ck-replybar-label b { color: var(--accent-green-light, var(--accent-primary)); }
.ck-replybar-body { font-size: 0.8rem; color: var(--text-secondary); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ck-replybar-close {
    width: 30px; height: 30px; flex-shrink: 0;
    display: inline-flex; align-items: center; justify-content: center;
    border: none; border-radius: 50%;
    background: transparent; color: var(--text-muted);
    cursor: pointer;
}
.ck-replybar-close:hover { background: rgba(0, 0, 0, 0.2); color: var(--text-primary); }

@media (prefers-reduced-motion: reduce) {
    .ck-chip, .ck-picker, .ck-sheet, .ck-sheet-backdrop, .ck-flash { animation: none; }
}
