/* ============================================================
   VegasBet — Match page live chat (.mch-*)
   Loaded only on the match page, after match-page.css. Third column of
   the page body on desktop (sticky), a bottom sheet behind a pill below
   1280px. Purple accents, no blue — the twelve avatar palettes are
   red → gold → green → teal → magenta → purple on purpose.
   ============================================================ */

@keyframes mchIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes mchSheetUp { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
@keyframes mchFade { from { opacity: 0; } to { opacity: 1; } }
@keyframes mchPop { 0% { transform: scale(1); } 40% { transform: scale(1.35); } 100% { transform: scale(1); } }
@keyframes mchDots { 0%,80%,100% { transform: scale(.55); opacity: .35; } 40% { transform: scale(1); opacity: 1; } }
@keyframes mchNudge { 0%,100% { transform: translateX(0); } 25% { transform: translateX(-4px); } 75% { transform: translateX(4px); } }

/* ── Layout ──────────────────────────────────────────────────
   The match page never had a .right-column widget, so the main grid's
   280px track stood empty. Drop it here and give the page body a third
   column of the same width: the chat lines up with the two cards beside
   it (the owner's mockup) instead of with the carousel above them. */
/* Scoped to the desktop band on purpose: this sheet loads AFTER
   match-page.css/sidebar.css, so an unconditional rule here would outrank
   their narrow-screen rules (1fr at 1180px, the sidebar gone at 1000px). */
@media (min-width: 1281px) {
  .main-layout--match { grid-template-columns: var(--sidebar-sport) 1fr; }
  .match-page-body { grid-template-columns: minmax(0, 1fr) 300px 280px; }
}

.match-chat {
  position: sticky; top: calc(var(--header-height) + 16px);
  /* Sized from the page AT REST, when the panel sits lowest: its top is
     64px header + 14px content padding + 120px carousel + 14px + 20px
     breadcrumb + 16px = 248px down; the floating bet-slip pill and the
     support circle start 92px above the bottom edge (32px offset + 60px);
     12px of clearance. 248 + 92 + 12 = 352 — the composer clears the pill
     before anyone scrolls (owner rule 2026-09-17). Stuck under the header
     the panel is higher still, so it clears it there too. */
  height: clamp(380px, calc(100vh - 352px), 720px);
  display: flex; flex-direction: column; min-width: 0;
  background: linear-gradient(180deg, #1d1d22, #161619);
  border: 1px solid var(--border); border-radius: 15px; overflow: hidden;
  box-shadow: 0 22px 46px -36px rgba(124,58,237,.45);
  font-family: 'Manrope', 'Inter', sans-serif;
}

/* ── Header ─────────────────────────────────────────────────── */
.mch-head {
  display: flex; align-items: center; gap: 10px; flex-shrink: 0;
  padding: 13px 14px 12px; border-bottom: 1px solid rgba(124,58,237,.1);
}
.mch-title {
  display: flex; align-items: center; gap: 8px; min-width: 0;
  font-family: 'Space Grotesk', 'Inter', sans-serif; font-weight: 700;
  font-size: 13.5px; color: #fff; letter-spacing: .3px;
}
.mch-count {
  margin-left: auto; font-variant-numeric: tabular-nums;
  background: rgba(124,58,237,.14); border: 1px solid rgba(168,85,247,.28);
  color: #d9ccff; border-radius: 999px; padding: 2px 8px; font-size: 11.5px; font-weight: 700;
}
.mch-count[hidden] { display: none; }
.mch-close {
  display: none; width: 30px; height: 30px; border-radius: 9px; border: none;
  background: rgba(124,58,237,.12); color: #d9ccff; cursor: pointer;
  align-items: center; justify-content: center; flex-shrink: 0;
}
.mch-close svg { width: 15px; height: 15px; }
.mch-close:hover { background: rgba(124,58,237,.22); }

/* ── Messages ───────────────────────────────────────────────── */
.mch-body {
  position: relative; flex: 1; min-height: 0; overflow-y: auto;
  overscroll-behavior: contain; padding: 8px 8px 10px;
  scrollbar-width: thin; scrollbar-color: rgba(124,58,237,.4) transparent;
}
.mch-body::-webkit-scrollbar { width: 6px; }
.mch-body::-webkit-scrollbar-thumb { background: rgba(124,58,237,.4); border-radius: 3px; }
.mch-list { display: flex; flex-direction: column; gap: 2px; }
.mch-msg {
  display: grid; grid-template-columns: 28px minmax(0, 1fr); gap: 8px;
  padding: 6px 6px; border-radius: 10px; border: 1px solid transparent;
  transition: background .15s;
}
.mch-msg:hover { background: rgba(124,58,237,.06); }
.mch-msg.is-new { animation: mchIn .28s ease-out; }
.mch-msg.is-you { background: rgba(124,58,237,.09); border-color: rgba(124,58,237,.2); }

.mch-avatar {
  width: 28px; height: 28px; border-radius: 50%; flex-shrink: 0; margin-top: 1px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 12px; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.35);
  user-select: none;
}
/* Twelve palettes (hue buckets), none of them blue. */
.mch-av--0  { background: linear-gradient(135deg, #ff6b6b, #b91c1c); }
.mch-av--1  { background: linear-gradient(135deg, #ff8a5b, #c2410c); }
.mch-av--2  { background: linear-gradient(135deg, #ffb347, #b45309); }
.mch-av--3  { background: linear-gradient(135deg, #f9d65c, #a16207); }
.mch-av--4  { background: linear-gradient(135deg, #b5e550, #4d7c0f); }
.mch-av--5  { background: linear-gradient(135deg, #5be584, #15803d); }
.mch-av--6  { background: linear-gradient(135deg, #34d3b8, #0f766e); }
.mch-av--7  { background: linear-gradient(135deg, #7ee8d8, #0d9488); }
.mch-av--8  { background: linear-gradient(135deg, #f472b6, #9d174d); }
.mch-av--9  { background: linear-gradient(135deg, #e879f9, #86198f); }
.mch-av--10 { background: linear-gradient(135deg, #c084fc, #6d28d9); }
.mch-av--11 { background: linear-gradient(135deg, #a78bfa, #5b21b6); }
/* Shape variants. */
.mch-avs--1 { border-radius: 9px; }
.mch-avs--2 { border-radius: 50% 50% 50% 10px; }
.mch-avs--3 { box-shadow: inset 0 0 0 2px rgba(255,255,255,.22); }
.mch-avs--4 { border-radius: 30%; }
.mch-avs--5 { border-radius: 12px 50% 12px 50%; }

.mch-main { min-width: 0; }
.mch-meta { display: flex; align-items: baseline; gap: 7px; min-width: 0; }
.mch-name {
  font-weight: 700; font-size: 12.5px; white-space: nowrap; overflow: hidden;
  text-overflow: ellipsis; max-width: 150px; color: #e6e2f0;
}
.mch-name--0  { color: #ff9b9b; }  .mch-name--1  { color: #ffb08c; }
.mch-name--2  { color: #ffcf8a; }  .mch-name--3  { color: #f7e08f; }
.mch-name--4  { color: #cbea8a; }  .mch-name--5  { color: #8ee8a8; }
.mch-name--6  { color: #7fe3d0; }  .mch-name--7  { color: #a6ece2; }
.mch-name--8  { color: #f9a8d4; }  .mch-name--9  { color: #f0abfc; }
.mch-name--10 { color: #d8b4fe; }  .mch-name--11 { color: #c4b5fd; }
.mch-you-tag {
  font-size: 10px; font-weight: 700; color: #8fe3a4; line-height: 1.5;
  background: rgba(16,185,129,.14); border: 1px solid rgba(16,185,129,.3);
  border-radius: 999px; padding: 0 6px; flex-shrink: 0;
}
.mch-time { font-size: 11px; color: #7a7488; white-space: nowrap; flex-shrink: 0; }
.mch-text {
  margin-top: 2px; font-size: 13px; line-height: 1.4; color: #e6e2f0;
  white-space: pre-wrap; overflow-wrap: anywhere; word-break: break-word;
}
.mch-actions { display: flex; align-items: center; gap: 10px; margin-top: 4px; }
.mch-like {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: none;
  background: none; color: #8884aa; font: inherit; font-size: 11.5px; font-weight: 700;
  cursor: pointer; transition: color .15s;
}
.mch-like svg { width: 13px; height: 13px; fill: none; stroke: currentColor; stroke-width: 2; transition: fill .15s; }
.mch-like:hover { color: #ff7aa8; }
.mch-like[aria-pressed="true"] { color: #ff5c8a; }
.mch-like[aria-pressed="true"] svg { fill: currentColor; }
.mch-like.is-pop svg { animation: mchPop .3s ease-out; }
.mch-review { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 5px; font-size: 11.5px; }
.mch-review-tag {
  display: inline-flex; align-items: center; gap: 4px; padding: 0; border: none;
  background: none; color: #f0b429; font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer;
}
.mch-review-tag svg { width: 13px; height: 13px; }
.mch-review-tag:hover { text-decoration: underline; }
.mch-review-note { color: #7a7488; }

.mch-earlier {
  display: block; margin: 0 auto 8px; padding: 5px 12px; border-radius: 999px;
  background: rgba(124,58,237,.12); border: 1px solid rgba(124,58,237,.28);
  color: #d9ccff; font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer;
  transition: background .15s;
}
.mch-earlier:hover { background: rgba(124,58,237,.22); }
.mch-earlier[hidden] { display: none; }
.mch-empty { padding: 34px 12px; text-align: center; color: #8884aa; font-size: 13px; }
.mch-empty[hidden] { display: none; }
.mch-loading { display: flex; justify-content: center; gap: 5px; padding: 18px 0; }
.mch-loading[hidden] { display: none; }
.mch-loading span { width: 7px; height: 7px; border-radius: 50%; background: #a855f7; animation: mchDots 1.1s infinite ease-in-out; }
.mch-loading span:nth-child(2) { animation-delay: .15s; }
.mch-loading span:nth-child(3) { animation-delay: .3s; }

/* "New messages" — floats over the list, just above the composer. */
.mch-jump {
  position: absolute; left: 50%; bottom: 66px; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 5px; padding: 6px 12px;
  border-radius: 999px; border: 1px solid rgba(168,85,247,.45);
  background: linear-gradient(135deg, #9a4fe0, #7434d0); color: #fff;
  font: inherit; font-size: 11.5px; font-weight: 700; cursor: pointer; z-index: 2;
  box-shadow: 0 10px 24px rgba(124,58,237,.45); animation: mchIn .2s ease-out;
}
.mch-jump svg { width: 12px; height: 12px; }
.mch-jump[hidden] { display: none; }

/* ── Composer ───────────────────────────────────────────────── */
.mch-composer {
  display: flex; align-items: flex-end; gap: 8px; flex-shrink: 0;
  padding: 10px; border-top: 1px solid rgba(124,58,237,.1); background: rgba(12,12,15,.35);
}
.mch-composer[hidden] { display: none; }
.mch-input {
  flex: 1; min-width: 0; resize: none; max-height: 92px; padding: 9px 12px;
  border-radius: 11px; background: #121016; border: 1px solid rgba(124,58,237,.24);
  color: #f0eeff; font: inherit; font-size: 13px; line-height: 1.35; outline: none;
  transition: border-color .15s, box-shadow .15s;
  scrollbar-width: thin; scrollbar-color: rgba(124,58,237,.4) transparent;
}
.mch-input:focus { border-color: rgba(168,85,247,.6); box-shadow: 0 0 0 3px rgba(124,58,237,.15); }
.mch-input::placeholder { color: #6f6a84; }
.mch-input:disabled { opacity: .6; }
.mch-send {
  width: 38px; height: 38px; border-radius: 11px; border: none; flex-shrink: 0;
  background: linear-gradient(135deg, #9a4fe0, #7434d0); color: #fff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .18s, opacity .18s, box-shadow .18s;
}
.mch-send svg { width: 16px; height: 16px; }
.mch-send:hover { transform: translateY(-1px); box-shadow: 0 8px 20px -10px rgba(168,85,247,.8); }
.mch-send:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.mch-login {
  display: block; margin: 10px; padding: 10px; text-align: center; border-radius: 11px;
  background: rgba(124,58,237,.12); border: 1px dashed rgba(168,85,247,.35);
  color: #d9ccff; font-size: 12.5px; font-weight: 700; text-decoration: none; flex-shrink: 0;
  transition: background .15s;
}
.mch-login:hover { background: rgba(124,58,237,.2); }
.mch-login[hidden] { display: none; }
.mch-login.is-nudge { animation: mchNudge .45s ease-in-out; border-style: solid; }
.mch-note { margin: 0 10px 10px; font-size: 11.5px; color: #ff8a8a; flex-shrink: 0; }
.mch-note[hidden] { display: none; }

/* ── "Why is my comment under review" ───────────────────────── */
.mch-review-backdrop {
  position: fixed; inset: 0; z-index: 3200; padding: 16px;
  display: flex; align-items: center; justify-content: center;
  background: rgba(6,6,10,.72); backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  animation: mchFade .18s ease-out;
}
.mch-review-backdrop[hidden] { display: none; }
.mch-review-card {
  position: relative; width: min(460px, 100%); padding: 22px 22px 18px;
  background: linear-gradient(180deg, #1f1f26, #151518);
  border: 1px solid rgba(124,58,237,.3); border-radius: 18px;
  box-shadow: 0 30px 60px rgba(0,0,0,.55); animation: mchSheetUp .22s ease-out;
  font-family: 'Manrope', 'Inter', sans-serif;
}
.mch-review-title { margin: 0 34px 12px 0; font-family: 'Space Grotesk', 'Inter', sans-serif; font-size: 17px; color: #fff; }
.mch-review-card p { margin: 0 0 12px; color: #b7b1c4; font-size: 13.5px; line-height: 1.55; }
.mch-review-close {
  position: absolute; top: 12px; right: 12px; width: 30px; height: 30px;
  border-radius: 9px; border: none; background: rgba(124,58,237,.12); color: #d9ccff;
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.mch-review-close svg { width: 15px; height: 15px; }
.mch-review-close:hover { background: rgba(124,58,237,.22); }
.mch-review-ok {
  margin-top: 6px; width: 100%; padding: 11px; border-radius: 11px; border: none;
  background: linear-gradient(135deg, #9a4fe0, #7434d0); color: #fff;
  font: inherit; font-weight: 700; cursor: pointer; transition: transform .18s;
}
.mch-review-ok:hover { transform: translateY(-1px); }

/* ── Narrow screens: pill + bottom sheet ────────────────────── */
.mch-fab {
  display: none; position: fixed; right: 14px; bottom: 104px; z-index: 1250;
  align-items: center; gap: 7px; padding: 9px 14px 9px 12px; border-radius: 999px;
  border: 1px solid rgba(168,85,247,.45); background: linear-gradient(135deg, #a855f7, #7c3aed);
  color: #fff; font-family: 'Manrope', 'Inter', sans-serif; font-weight: 800; font-size: 12.5px;
  box-shadow: 0 14px 34px rgba(124,58,237,.45); cursor: pointer; transition: transform .2s;
}
/* The owner's img/chat-round.svg, painted white the way the support circle
   paints img/chat.svg (betslip.css .chat-svg-icon). */
.mch-fab-icon { width: 18px; height: 18px; filter: brightness(0) invert(1); pointer-events: none; }
.mch-fab:hover { transform: translateY(-2px); }
.mch-fab-count { background: rgba(0,0,0,.28); border-radius: 999px; padding: 1px 7px; font-size: 11px; font-variant-numeric: tabular-nums; }
.mch-fab-count:empty { display: none; }
.mch-backdrop {
  position: fixed; inset: 0; z-index: 1290; background: rgba(6,6,10,.6);
  backdrop-filter: blur(3px); -webkit-backdrop-filter: blur(3px); animation: mchFade .2s ease-out;
}
.mch-backdrop[hidden] { display: none; }
body.mch-lock { overflow: hidden; }

@media (max-width: 1280px) {
  .match-chat { display: none; }
  .match-chat.is-open {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; top: auto;
    height: min(82vh, 640px); max-height: calc(100vh - 16px); z-index: 1300;
    border-radius: 18px 18px 0 0; animation: mchSheetUp .25s ease-out;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }
  .mch-close { display: flex; }
  .mch-fab:not([hidden]) { display: flex; }
  /* While the support chat is open (match-chat.js watches #chatPopup) the
     pill goes away: its z-index has to beat the bet-slip pill, which puts
     it over the support popup too, and on a phone that popup fills the
     screen right where the pill sits. */
  .mch-fab.is-covered { display: none; }
}
@media (max-width: 768px) {
  /* Above the support circle (56px at bottom 8px) and the bet-slip bar. */
  .mch-fab { right: 8px; bottom: 74px; padding: 8px 12px 8px 10px; }
  .match-chat.is-open { height: 78vh; }
  .mch-name { max-width: 120px; }
}
@media (prefers-reduced-motion: reduce) {
  .mch-msg.is-new, .mch-jump, .mch-review-backdrop, .mch-review-card,
  .mch-backdrop, .match-chat.is-open, .mch-loading span, .mch-like.is-pop svg { animation: none; }
}
