/* Game chat, Discord style (templates/chat-page.html.twig, js/chat.js). */
.lsx-chat {
  --chat-bg: #313338;
  --chat-side: #2b2d31;
  --chat-deep: #1e1f22;
  --chat-hover: rgba(4, 4, 5, 0.07);
  --chat-line: rgba(255, 255, 255, 0.06);
  --chat-text: #dbdee1;
  --chat-muted: #949ba4;
  --chat-faint: #6d6f78;
  --chat-accent: #5865f2;
  --chat-accent-2: #a855f7;
  --chat-green: #23a55a;
  --chat-red: #f23f43;
  --chat-mention: rgba(250, 168, 26, 0.1);

  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  height: min(80vh, 820px);
  min-height: 480px;
  overflow: hidden;
  border-radius: 14px;
  background: var(--chat-bg);
  color: var(--chat-text);
  font-size: 0.95rem;
  line-height: 1.375;
  box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.04), 0 24px 60px -20px rgba(88, 101, 242, 0.45), 0 8px 24px rgba(0, 0, 0, 0.35);
}
.lsx-chat *, .lsx-chat *::before, .lsx-chat *::after { box-sizing: border-box; }
.lsx-chat a { color: #00a8fc; }
.lsx-chat button { font: inherit; color: inherit; }

/* Left rail: the game ("server") and its channels. */
.lsx-chat__rail {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  padding: 1rem 0.75rem;
  background:
    radial-gradient(1px 1px at 20% 30%, rgba(255, 255, 255, 0.5), transparent),
    radial-gradient(1px 1px at 70% 60%, rgba(255, 255, 255, 0.35), transparent),
    radial-gradient(1.5px 1.5px at 40% 85%, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1px 1px at 85% 15%, rgba(255, 255, 255, 0.45), transparent),
    linear-gradient(180deg, #232533 0%, var(--chat-side) 40%);
}
.lsx-chat__server {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-2));
  color: #fff !important;
  font-size: 1.5rem;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 0 22px rgba(124, 92, 255, 0.55);
  transition: border-radius 0.2s, transform 0.2s;
}
.lsx-chat__server:hover, .lsx-chat__server:focus-visible { border-radius: 18px; transform: translateY(-1px); }
.lsx-chat__server-name {
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--chat-line);
  color: #f2f3f5;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lsx-chat__channels { display: grid; gap: 2px; }
.lsx-chat__channels-label, .lsx-chat__members-label {
  padding: 0 0.5rem 0.35rem;
  color: var(--chat-muted);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.lsx-chat__channel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.5rem;
  border-radius: 6px;
  color: var(--chat-muted) !important;
  text-decoration: none;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.lsx-chat__channel i { width: 1rem; color: var(--chat-faint); text-align: center; }
.lsx-chat__channel:hover { background: rgba(255, 255, 255, 0.04); color: var(--chat-text) !important; }
.lsx-chat__channel.is-active { background: rgba(255, 255, 255, 0.08); color: #fff !important; font-weight: 600; }

/* Main column. */
.lsx-chat__main { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; min-width: 0; min-height: 0; }
.lsx-chat__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-height: 48px;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.25);
  box-shadow: 0 1px 0 rgba(4, 4, 5, 0.2), 0 1.5px 0 rgba(6, 6, 7, 0.05), 0 2px 0 rgba(4, 4, 5, 0.05);
}
.lsx-chat__hash { color: var(--chat-faint); font-size: 1.1rem; }
.lsx-chat__title { margin: 0; color: #f2f3f5; font-size: 1rem; font-weight: 700; white-space: nowrap; }
.lsx-chat__topic {
  flex: 1;
  min-width: 0;
  padding-left: 0.75rem;
  margin-left: 0.25rem;
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--chat-muted);
  font-size: 0.85rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.lsx-chat__members-toggle {
  margin-left: auto;
  padding: 0.35rem 0.5rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--chat-muted) !important;
  cursor: pointer;
}
.lsx-chat__members-toggle:hover, .lsx-chat__members-toggle[aria-pressed="true"] { color: #f2f3f5 !important; }

.lsx-chat__body { position: relative; display: grid; grid-template-columns: minmax(0, 1fr) 220px; grid-template-rows: minmax(0, 1fr); min-height: 0; }
.lsx-chat.hide-members .lsx-chat__body { grid-template-columns: minmax(0, 1fr); }
.lsx-chat.hide-members .lsx-chat__members { display: none; }

.lsx-chat__scroll {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding-bottom: 1rem;
  scrollbar-width: thin;
  scrollbar-color: #1a1b1e transparent;
}
.lsx-chat__scroll::-webkit-scrollbar { width: 8px; }
.lsx-chat__scroll::-webkit-scrollbar-thumb { border-radius: 4px; background: #1a1b1e; }

.lsx-chat__spacer { flex: 1 0 0; }
.lsx-chat__welcome { padding: 1rem 1rem 0.5rem; }
.lsx-chat__welcome[hidden] { display: none; }
.lsx-chat__welcome-icon {
  display: grid;
  place-items: center;
  width: 68px;
  height: 68px;
  margin-bottom: 0.5rem;
  border-radius: 50%;
  background: #41434a;
  color: #fff;
  font-size: 2rem;
}
.lsx-chat__welcome h2 { margin: 0.25rem 0; color: #f2f3f5; font-size: 1.9rem; font-weight: 800; }
.lsx-chat__welcome p { margin: 0; color: var(--chat-muted); }

.lsx-chat__older {
  align-self: center;
  margin: 0.75rem;
  padding: 0.3rem 0.9rem;
  border: 0;
  border-radius: 999px;
  background: var(--chat-deep);
  color: var(--chat-muted) !important;
  font-size: 0.8rem;
  cursor: pointer;
}
.lsx-chat__older[hidden] { display: none; }
.lsx-chat__older:hover { color: #fff !important; }

.lsx-chat__messages { margin: 0; padding: 0; list-style: none; }

/* Date dividers. */
.lsx-chat__divider {
  display: flex;
  align-items: center;
  margin: 1.5rem 1rem 0.5rem;
  color: var(--chat-muted);
  font-size: 0.75rem;
  font-weight: 600;
}
.lsx-chat__divider::before, .lsx-chat__divider::after { content: ''; flex: 1; height: 1px; background: rgba(255, 255, 255, 0.08); }
.lsx-chat__divider span { padding: 0 0.5rem; }

/* A message. Grouped ones hide the avatar and name. */
.lsx-chat__msg {
  position: relative;
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  margin-top: 1.0625rem;
  padding: 0.125rem 3rem 0.125rem 0;
  animation: lsx-chat-in 0.18s ease-out;
}
.lsx-chat__msg.is-grouped { margin-top: 0; }
.lsx-chat__msg:hover { background: rgba(2, 2, 2, 0.06); }
.lsx-chat__msg.is-pending .lsx-chat__text { color: var(--chat-faint); }
.lsx-chat__msg.is-mention { background: var(--chat-mention); box-shadow: inset 2px 0 0 #f0b232; }
.lsx-chat__msg.is-mention:hover { background: rgba(250, 168, 26, 0.08); }
@keyframes lsx-chat-in { from { opacity: 0; transform: translateY(4px); } }

.lsx-chat__gutter { display: flex; justify-content: center; padding-top: 2px; }
.lsx-chat__avatar {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 25%, rgba(255, 255, 255, 0.35), transparent 55%), var(--avatar, var(--chat-accent));
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  user-select: none;
}
.lsx-chat__time-small { display: none; padding-top: 0.2rem; color: var(--chat-faint); font-size: 0.68rem; white-space: nowrap; }
.lsx-chat__msg.is-grouped .lsx-chat__avatar, .lsx-chat__msg.is-grouped .lsx-chat__head { display: none; }
.lsx-chat__msg.is-grouped:hover .lsx-chat__time-small { display: block; }

.lsx-chat__head { display: flex; align-items: baseline; flex-wrap: wrap; gap: 0.25rem 0.5rem; }
.lsx-chat .lsx-chat__name { font-weight: 600; text-decoration: none; cursor: pointer; }
.lsx-chat .lsx-chat__name:hover, .lsx-chat .lsx-chat__name:focus-visible { text-decoration: underline; }
.lsx-chat__avatar-link { display: block; border-radius: 50%; transition: transform 0.15s; }
.lsx-chat__avatar-link:hover, .lsx-chat__avatar-link:focus-visible { transform: scale(1.06); }
.lsx-chat__time { color: var(--chat-faint); font-size: 0.75rem; }
.lsx-chat__tag {
  align-self: center;
  padding: 0 0.3rem;
  border-radius: 4px;
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-2));
  color: #fff;
  font-size: 0.62rem;
  font-weight: 700;
  line-height: 1.4;
}

.lsx-chat__text { color: var(--chat-text); white-space: pre-wrap; overflow-wrap: anywhere; }
.lsx-chat__text.is-jumbo { font-size: 2.6rem; line-height: 1.2; }
.lsx-chat__text code {
  padding: 0.1em 0.3em;
  border-radius: 4px;
  background: var(--chat-deep);
  color: #e3e5e8;
  font-size: 0.85em;
}
.lsx-chat__mention {
  padding: 0 2px;
  border-radius: 3px;
  background: rgba(88, 101, 242, 0.3);
  color: #c9cdfb;
  font-weight: 500;
}
.lsx-chat__spoiler {
  border-radius: 4px;
  background: #1e1f22;
  color: transparent;
  cursor: pointer;
  transition: background 0.1s;
}
.lsx-chat__spoiler:hover { background: #26272b; }
.lsx-chat__spoiler.is-shown { background: rgba(255, 255, 255, 0.1); color: inherit; cursor: auto; }

.lsx-chat__text:empty { display: none; }
.lsx-chat__attachment { display: block; width: fit-content; max-width: min(400px, 100%); margin-top: 0.25rem; overflow: hidden; border-radius: 8px; }
.lsx-chat__attachment img { display: block; max-width: 100%; max-height: 300px; height: auto; transition: filter 0.15s; }
.lsx-chat__attachment:hover img { filter: brightness(1.08); }

/* Hover toolbar. */
.lsx-chat__tools {
  position: absolute;
  top: -16px;
  right: 1rem;
  display: none;
  padding: 2px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 8px;
  background: var(--chat-bg);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
}
.lsx-chat__msg:hover .lsx-chat__tools, .lsx-chat__msg:focus-within .lsx-chat__tools { display: flex; }
.lsx-chat__tool {
  padding: 0.3rem 0.45rem;
  border: 0;
  border-radius: 6px;
  background: transparent;
  color: var(--chat-muted) !important;
  cursor: pointer;
}
.lsx-chat__tool:hover { background: rgba(255, 255, 255, 0.07); color: #fff !important; }
.lsx-chat__tool.is-danger:hover { color: var(--chat-red) !important; }

/* "New messages" pill. */
.lsx-chat__jump {
  position: absolute;
  bottom: 0.75rem;
  left: 50%;
  z-index: 2;
  padding: 0.35rem 1rem;
  border: 0;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--chat-accent), var(--chat-accent-2));
  color: #fff !important;
  font-size: 0.8rem;
  font-weight: 600;
  box-shadow: 0 6px 20px rgba(88, 101, 242, 0.5);
  transform: translateX(-50%);
  cursor: pointer;
  animation: lsx-chat-in 0.2s ease-out;
}
.lsx-chat__jump[hidden] { display: none; }

.lsx-chat__loading { display: flex; justify-content: center; gap: 6px; margin: auto; padding: 2rem; }
.lsx-chat__loading span { width: 10px; height: 10px; border-radius: 50%; background: var(--chat-accent); animation: lsx-chat-bounce 1.2s infinite ease-in-out; }
.lsx-chat__loading span:nth-child(2) { animation-delay: 0.15s; }
.lsx-chat__loading span:nth-child(3) { animation-delay: 0.3s; }

/* Member list. */
.lsx-chat__members { padding: 1rem 0.5rem; overflow-y: auto; background: var(--chat-side); }
.lsx-chat__members ul { margin: 0; padding: 0; list-style: none; }
.lsx-chat .lsx-chat__member { display: flex; align-items: center; gap: 0.6rem; padding: 0.3rem 0.5rem; border-radius: 6px; color: inherit; text-decoration: none; }
.lsx-chat__member:hover { background: rgba(255, 255, 255, 0.05); }
.lsx-chat__member .lsx-chat__avatar { width: 32px; height: 32px; font-size: 0.85rem; }
.lsx-chat__member-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 500; }
.lsx-chat__dot {
  position: absolute;
  right: -2px;
  bottom: -2px;
  width: 13px;
  height: 13px;
  border: 3px solid var(--chat-side);
  border-radius: 50%;
  background: var(--chat-green);
}

/* Composer. */
.lsx-chat__composer { padding: 0 1rem 0.25rem; }
.lsx-chat__box {
  position: relative;
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem 0.6rem 1rem;
  border-radius: 10px;
  background: #383a40;
  transition: box-shadow 0.15s;
}
.lsx-chat__box:focus-within { box-shadow: 0 0 0 1px rgba(88, 101, 242, 0.6), 0 0 18px rgba(88, 101, 242, 0.25); }
.lsx-chat__box.is-locked { justify-content: center; margin-bottom: 1.5rem; color: var(--chat-muted); }
.lsx-chat__box textarea {
  flex: 1;
  min-height: 24px;
  max-height: 200px;
  padding: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  color: var(--chat-text);
  font: inherit;
  line-height: 1.5;
}
.lsx-chat__box textarea::placeholder { color: var(--chat-faint); }
.lsx-chat__emoji-btn {
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--chat-muted) !important;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
  transition: transform 0.15s, color 0.15s;
}
.lsx-chat__emoji-btn:hover, .lsx-chat__emoji-btn[aria-expanded="true"] { color: #f0b232 !important; transform: scale(1.15) rotate(-8deg); }
.lsx-chat__emoji {
  position: absolute;
  right: 0;
  bottom: calc(100% + 8px);
  z-index: 3;
  display: grid;
  grid-template-columns: repeat(6, 40px);
  gap: 2px;
  padding: 0.5rem;
  border-radius: 10px;
  background: var(--chat-side);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.45);
}
.lsx-chat__emoji[hidden] { display: none; }
.lsx-chat__emoji button {
  height: 40px;
  border: 0;
  border-radius: 6px;
  background: transparent;
  font-size: 1.35rem;
  cursor: pointer;
}
.lsx-chat__emoji button:hover { background: rgba(255, 255, 255, 0.08); }
.lsx-chat__emoji button:last-child { font-size: 0.85rem; font-weight: 800; color: #f0b232 !important; }

.lsx-chat__status { display: flex; justify-content: space-between; gap: 1rem; min-height: 1.5rem; padding: 0.15rem 0.25rem; font-size: 0.78rem; }
.lsx-chat__typing { display: flex; align-items: center; gap: 0.4rem; color: var(--chat-text); }
.lsx-chat__typing-dots { display: inline-flex; gap: 3px; }
.lsx-chat__typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--chat-text); animation: lsx-chat-bounce 1.2s infinite ease-in-out; }
.lsx-chat__typing-dots i:nth-child(2) { animation-delay: 0.15s; }
.lsx-chat__typing-dots i:nth-child(3) { animation-delay: 0.3s; }
.lsx-chat__error { color: var(--chat-red); }

@keyframes lsx-chat-bounce {
  0%, 60%, 100% { opacity: 0.35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

@media (prefers-reduced-motion: reduce) {
  .lsx-chat *, .lsx-chat *::before { animation: none !important; transition: none !important; }
}

/* Phones: no rail, member list over the messages. */
@media (max-width: 900px) {
  .lsx-chat { grid-template-columns: minmax(0, 1fr); height: calc(100vh - 140px); border-radius: 10px; }
  .lsx-chat__rail { display: none; }
  .lsx-chat__body { grid-template-columns: minmax(0, 1fr); }
  .lsx-chat__members { position: absolute; inset: 0 0 0 auto; z-index: 3; width: 240px; box-shadow: -8px 0 24px rgba(0, 0, 0, 0.4); }
  .lsx-chat__msg { grid-template-columns: 56px minmax(0, 1fr); padding-right: 0.75rem; }
  .lsx-chat__topic { display: none; }
  .lsx-chat__composer { padding: 0 0.5rem 0.25rem; }
}
