/*
 * Fake stream chat overlay — three looks (Twitch-style, YouTube Live-style,
 * TikTok LIVE-style) driven by data-style on <body>. Platform names describe
 * the look only; no platform artwork is included.
 */

:root {
  --scale: 1;
  --gap: calc(6px * var(--scale));
  --font: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial,
    sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  height: 100%;
}

body {
  font-family: var(--font);
  overflow: hidden;
  background: transparent;
}

body[data-bg="green"] {
  background: #00b140;
}
body[data-bg="blue"] {
  background: #0047bb;
}
body[data-bg="dark"] {
  background: #0e0e10;
}

.chat {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: var(--gap);
  padding: calc(16px * var(--scale));
  overflow: hidden;
}

.msg {
  animation: msg-in 220ms ease-out both;
  overflow-wrap: anywhere;
}

@keyframes msg-in {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .msg {
    animation: none;
  }
}

.avatar {
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  font-weight: 600;
}

/* ---------- Twitch-style: one line per message, colored names ---------- */

[data-style="twitch"] .chat {
  max-width: calc(380px * var(--scale));
  gap: calc(4px * var(--scale));
}

[data-style="twitch"] .msg {
  color: #efeff1;
  font-size: calc(14px * var(--scale));
  line-height: 1.5;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.6);
}

[data-style="twitch"][data-bg="dark"] .msg {
  text-shadow: none;
}

[data-style="twitch"] .name {
  font-weight: 700;
}

[data-style="twitch"] .badge {
  display: inline-grid;
  place-items: center;
  width: calc(18px * var(--scale));
  height: calc(18px * var(--scale));
  margin-right: calc(4px * var(--scale));
  border-radius: calc(3px * var(--scale));
  font-size: calc(10px * var(--scale));
  font-weight: 800;
  color: #fff;
  vertical-align: calc(-3px * var(--scale));
}

[data-style="twitch"] .badge.mod {
  background: #00ad03;
}
[data-style="twitch"] .badge.sub {
  background: #8205b4;
}
[data-style="twitch"] .badge.vip {
  background: #e005b9;
}
[data-style="twitch"] .badge.streamer {
  background: #e91916;
}

[data-style="twitch"] .msg.highlight {
  padding: calc(4px * var(--scale)) calc(8px * var(--scale));
  border-left: calc(3px * var(--scale)) solid #a970ff;
  background: rgb(169 112 255 / 0.18);
}

/* ---------- YouTube Live-style: avatar, gray name, Super Chat cards ---------- */

[data-style="youtube"] .chat {
  max-width: calc(400px * var(--scale));
  gap: calc(8px * var(--scale));
}

[data-style="youtube"] .msg {
  display: flex;
  gap: calc(10px * var(--scale));
  align-items: flex-start;
  color: #fff;
  font-size: calc(13px * var(--scale));
  line-height: 1.45;
  text-shadow: 0 1px 2px rgb(0 0 0 / 0.55);
}

[data-style="youtube"][data-bg="dark"] .msg {
  text-shadow: none;
}

[data-style="youtube"] .avatar {
  width: calc(24px * var(--scale));
  height: calc(24px * var(--scale));
  font-size: calc(11px * var(--scale));
}

[data-style="youtube"] .name {
  margin-right: calc(6px * var(--scale));
  color: rgb(255 255 255 / 0.7);
  font-weight: 500;
}

[data-style="youtube"] .name.member {
  color: #2ba640;
}
[data-style="youtube"] .name.mod {
  color: #5e84f1;
}
[data-style="youtube"] .name.owner {
  padding: 0 calc(5px * var(--scale));
  border-radius: calc(2px * var(--scale));
  background: #ffd600;
  color: #000;
}

[data-style="youtube"] .msg.paid {
  display: block;
  overflow: hidden;
  border-radius: calc(4px * var(--scale));
  text-shadow: none;
}

[data-style="youtube"] .paid-head {
  display: flex;
  gap: calc(10px * var(--scale));
  align-items: center;
  padding: calc(8px * var(--scale)) calc(16px * var(--scale));
  background: var(--paid-head);
  color: var(--paid-ink);
}

[data-style="youtube"] .paid-head .amount {
  font-weight: 600;
}

[data-style="youtube"] .paid-body {
  padding: calc(8px * var(--scale)) calc(16px * var(--scale));
  background: var(--paid-body);
  color: var(--paid-ink);
}

/* ---------- TikTok LIVE-style: translucent bubbles bottom-left ---------- */

[data-style="tiktok"] .chat {
  max-width: calc(320px * var(--scale));
  gap: calc(6px * var(--scale));
  padding-bottom: calc(72px * var(--scale));
}

[data-style="tiktok"] .msg {
  display: flex;
  gap: calc(8px * var(--scale));
  align-items: flex-start;
  align-self: flex-start;
  max-width: 100%;
  padding: calc(5px * var(--scale)) calc(10px * var(--scale))
    calc(5px * var(--scale)) calc(5px * var(--scale));
  border-radius: calc(14px * var(--scale));
  background: rgb(0 0 0 / 0.28);
  color: #fff;
  font-size: calc(13px * var(--scale));
  line-height: 1.35;
}

[data-style="tiktok"] .avatar {
  width: calc(24px * var(--scale));
  height: calc(24px * var(--scale));
  font-size: calc(11px * var(--scale));
}

[data-style="tiktok"] .name {
  display: block;
  color: rgb(255 255 255 / 0.72);
  font-size: calc(12px * var(--scale));
  font-weight: 600;
}

[data-style="tiktok"] .msg.join {
  padding-left: calc(10px * var(--scale));
  color: rgb(255 255 255 / 0.85);
}

[data-style="tiktok"] .msg.gift .text {
  color: #ffd84d;
  font-weight: 600;
}

/*
 * Chroma backgrounds: anything semi-transparent picks up the key color and
 * leaves a fringe after keying, so bubbles go opaque and shadows go away.
 */
[data-bg="green"] .msg,
[data-bg="blue"] .msg {
  text-shadow: none;
}

[data-bg="green"][data-style="tiktok"] .msg,
[data-bg="blue"][data-style="tiktok"] .msg {
  background: #2b2b2b;
}

[data-bg="green"][data-style="twitch"] .chat,
[data-bg="blue"][data-style="twitch"] .chat,
[data-bg="green"][data-style="youtube"] .chat,
[data-bg="blue"][data-style="youtube"] .chat {
  margin: calc(16px * var(--scale));
  border-radius: calc(8px * var(--scale));
  background: #18181b;
  inset: auto 0 0 0;
  max-height: calc(100% - 32px * var(--scale));
}
