/* me89x FX: animated emoji, stickers, GIFs, reactions and message motion. Uses the messenger theme tokens. */

/* ---------- Media in messages ---------- */

.message-bubble.fx-media { padding: 0; background: transparent !important; box-shadow: none; line-height: 1; font-size: inherit; }
.message-bubble.fx-media::before,
.message-bubble.fx-media::after { display: none; }

.fx-slot { display: inline-block; vertical-align: bottom; }
.fx-sticker-slot { width: 168px; height: 168px; }
.fx-big-row { display: inline-flex; gap: 2px; align-items: flex-end; }
.fx-big { width: 112px; height: 112px; cursor: pointer; }
.fx-big-2 { width: 88px; height: 88px; }
.fx-big-3 { width: 72px; height: 72px; }

.fx-lottie,
.fx-video,
.fx-image { display: block; width: 100%; height: 100%; object-fit: contain; }
.fx-lottie canvas { width: 100% !important; height: 100% !important; }
.fx-fallback,
.fx-static-emoji { display: grid; place-items: center; width: 100%; height: 100%; font-size: 64px; line-height: 1; }
.fx-big-2 .fx-static-emoji { font-size: 52px; }
.fx-big-3 .fx-static-emoji { font-size: 44px; }
.fx-emoji-sticker { cursor: pointer; }
.fx-emoji-sticker .fx-static-emoji { font-size: 104px; }
.fx-credit { font-size: 10px; text-align: center; }
.fx-missing { width: auto; height: auto; padding: 8px 12px; border-radius: 10px; background: var(--soft); color: var(--muted); font-size: 12px; }

.message-row.fx-enter .fx-static-emoji { animation: fx-emoji-pop .7s cubic-bezier(.2, 1.6, .4, 1) both; }

.message-bubble.fx-gif-bubble { padding: 3px; overflow: hidden; line-height: 0; }
.fx-gif { position: relative; display: inline-block; max-width: min(280px, 64vw); }
.fx-gif video,
.fx-gif img { display: block; max-width: 100%; max-height: 300px; border-radius: 9px; background: var(--soft); }
.fx-gif-badge { position: absolute; left: 7px; top: 7px; padding: 1px 6px; border-radius: 8px; background: #0007; color: #fff; font: 700 10px/16px sans-serif; letter-spacing: .5px; }

.fx-gif-save {
  position: absolute;
  right: 7px;
  top: 7px;
  padding: 3px 8px;
  border: 0;
  border-radius: 10px;
  background: #000a;
  color: #fff;
  font-size: 11px;
  line-height: 16px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s;
}

.fx-gif:hover .fx-gif-save,
.fx-gif-save:focus-visible { opacity: 1; }

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

.message-main { position: relative; }
.fx-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 4px; }
.message-row.mine .fx-reactions { justify-content: flex-end; }
.fx-reactions[hidden] { display: none; }

.fx-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 26px;
  padding: 0 9px 0 6px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: var(--paper);
  color: var(--purple-dark, var(--ink));
  font-size: 12px;
  cursor: pointer;
  transition: transform .15s, background .15s;
}

.fx-chip:hover { transform: scale(1.06); }
.fx-chip.mine { border-color: var(--purple); background: var(--purple); color: #fff; }
.fx-chip-emoji { font-size: 15px; line-height: 1; }
.fx-chip b { font-weight: 700; }
.fx-chip.fx-pop { animation: fx-chip-pop .55s cubic-bezier(.2, 1.8, .4, 1); }

.fx-react-open {
  position: absolute;
  top: 2px;
  right: -30px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: var(--paper);
  color: var(--muted);
  font-size: 14px;
  cursor: pointer;
  opacity: 0;
  transition: opacity .15s, transform .15s;
}

.message-row.mine .fx-react-open { right: auto; left: -30px; }
.message-row:hover .fx-react-open,
.fx-react-open:focus-visible { opacity: 1; }
.fx-react-open:hover { transform: scale(1.12); color: var(--purple); }

.fx-reaction-menu {
  position: fixed;
  z-index: 70;
  display: flex;
  gap: 2px;
  max-width: min(330px, calc(100vw - 16px));
  overflow-x: auto;
  overscroll-behavior: contain;
  scrollbar-width: none;
  padding: 6px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--paper);
  box-shadow: 0 10px 35px #3d284d33;
  animation: fx-menu-in .18s ease-out;
}

.fx-reaction-menu button {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: none;
  font-size: 22px;
  cursor: pointer;
  transition: transform .12s, background .12s;
}

.fx-reaction-menu button:hover { transform: scale(1.25); background: var(--soft); }
.fx-reaction-menu .fx-lottie { width: 30px; height: 30px; }

/* ---------- Motion and effects ---------- */

.message-row.fx-enter .message-main { animation: fx-in-left .38s cubic-bezier(.2, .9, .3, 1.15) both; transform-origin: left bottom; }
.message-row.mine.fx-enter .message-main { animation-name: fx-in-right; transform-origin: right bottom; }

.fx-overlay { position: fixed; z-index: 60; pointer-events: none; }
.fx-overlay.flip { transform: scaleX(-1); }

.fx-particle {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 61;
  display: grid;
  place-items: center;
  line-height: 1;
  object-fit: contain;
  pointer-events: none;
  will-change: transform, opacity;
}

@keyframes fx-in-left { from { opacity: 0; transform: translate(-14px, 18px) scale(.86); } to { opacity: 1; transform: none; } }
@keyframes fx-in-right { from { opacity: 0; transform: translate(10px, 26px) scale(.86); } to { opacity: 1; transform: none; } }
@keyframes fx-emoji-pop { from { transform: scale(.2) rotate(-25deg); } to { transform: none; } }
@keyframes fx-chip-pop { 40% { transform: scale(1.35); } }
@keyframes fx-menu-in { from { opacity: 0; transform: translateY(8px) scale(.94); } }
@keyframes fx-panel-in { from { opacity: 0; transform: translateY(10px); } }


/* ---------- Emoji, sticker and GIF panel ---------- */

.fx-panel {
  position: fixed;
  z-index: 50;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--paper);
  color: var(--ink);
  box-shadow: 0 14px 40px #3d284d33;
  animation: fx-panel-in .18s ease-out;
}

.fx-tabs { display: flex; flex-shrink: 0; gap: 4px; padding: 7px 8px 0; border-bottom: 1px solid var(--line); }

.fx-tabs button {
  flex: 1;
  padding: 7px 4px 8px;
  border: 0;
  border-bottom: 2px solid transparent;
  background: none;
  color: var(--muted);
  font-weight: 700;
  font-size: 12px;
  cursor: pointer;
}

.fx-tabs button.active { border-bottom-color: var(--purple); color: var(--purple); }
.fx-body { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.fx-scroll { flex: 1; min-height: 0; overflow-y: auto; padding: 4px 8px 8px; scrollbar-width: thin; }
.fx-scroll h4 { position: sticky; top: -4px; z-index: 1; margin: 0; padding: 7px 2px 5px; background: var(--paper); color: var(--muted); font-size: 11px; font-weight: 700; }

.fx-strip {
  display: flex;
  flex-shrink: 0;
  gap: 2px;
  overflow-x: auto;
  padding: 4px 6px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  scrollbar-width: none;
}

.fx-strip button {
  display: grid;
  flex-shrink: 0;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 3px;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 19px;
  cursor: pointer;
}

.fx-strip button:hover { background: var(--soft); }
.fx-strip .fx-lottie,
.fx-strip .fx-image,
.fx-strip .fx-video { width: 28px; height: 28px; }

.fx-emoji-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(36px, 1fr)); }

.fx-emoji-grid button {
  height: 38px;
  padding: 0;
  border: 0;
  border-radius: 9px;
  background: none;
  font-size: 24px;
  cursor: pointer;
  transition: transform .1s;
}

.fx-emoji-grid button:hover { background: var(--soft); transform: scale(1.15); }

.fx-sticker-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(66px, 1fr)); gap: 2px; }

.fx-cell {
  aspect-ratio: 1;
  padding: 4px;
  border: 0;
  border-radius: 10px;
  background: none;
  cursor: pointer;
  transition: background .12s, transform .12s;
}

.fx-cell:hover { background: var(--soft); transform: scale(1.06); }
.fx-classic { font-size: 40px; line-height: 1; }
.fx-note { margin: 10px 4px; color: var(--muted); font-size: 12px; line-height: 1.5; }

.fx-gif-tools { display: flex; flex-shrink: 0; gap: 6px; padding: 8px 8px 4px; }
.fx-panel .fx-search { flex: 1; min-width: 0; height: 32px; padding: 4px 10px; border-radius: 16px; font-size: 12px; }

.fx-upload {
  display: inline-flex;
  flex-direction: row;
  flex-shrink: 0;
  align-items: center;
  margin: 0;
  padding: 0 12px;
  height: 32px;
  border-radius: 16px;
  background: var(--soft);
  color: var(--purple);
  font-size: 12px;
  cursor: pointer;
}

.fx-gif-grid { columns: 2; column-gap: 4px; }
.fx-gif-grid .fx-note { column-span: all; }
.fx-gif-cell { position: relative; display: block; width: 100%; margin: 0 0 4px; padding: 0; border: 0; border-radius: 8px; overflow: hidden; background: var(--soft); break-inside: avoid; cursor: pointer; }
.fx-gif-cell > button:first-child { display: block; width: 100%; padding: 0; border: 0; background: none; cursor: pointer; }
.fx-gif-cell video,
.fx-gif-cell img { display: block; width: 100%; height: 100%; object-fit: cover; }

.fx-gif-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: #000a;
  color: #fff;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
}

.fx-gif-cell:hover .fx-gif-remove,
.fx-gif-remove:focus-visible { opacity: 1; }

@media (max-width: 640px) {
  .fx-sticker-slot { width: 140px; height: 140px; }
  .fx-big { width: 96px; height: 96px; }
  .fx-big-2 { width: 76px; height: 76px; }
  .fx-big-3 { width: 62px; height: 62px; }
  .fx-emoji-sticker .fx-static-emoji { font-size: 86px; }
  .fx-react-open { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .message-row.fx-enter .message-main,
  .message-row.fx-enter .fx-static-emoji,
  .fx-chip.fx-pop,
  .fx-panel,
  .fx-reaction-menu { animation: none; }
}
