/* Chat and participants */

/* Noto Color Emoji 2D v2.057, Unicode 18.0; see assets/licenses. */
@font-face {
  font-family: "Rudelguck Emoji";
  src: url("/assets/fonts/noto-color-emoji.woff2") format("woff2");
  font-display: swap;
}

.chat,
.chat-composer {
  --chat-emoji-fonts: "Rudelguck Emoji", "Apple Color Emoji", "Segoe UI Emoji", "Noto Color Emoji";
}

.chat {
  grid-area: chat;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid #34373f;
}

.chat-main {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  overflow: hidden;
}

.users-pane {
  flex: 0 0 clamp(120px, 25%, 180px);
  min-width: 0;
  display: flex;
  flex-direction: column;
  background: #1d2026;
  border-right: 1px solid #363a44;
}

.users-list {
  margin: 0;
  padding: 6px 0 5px;
  list-style: none;
  overflow-y: auto;
  min-height: 0;
}

.users-list li {
  padding: 5px 9px 5px var(--room-gutter);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 12px;
  cursor: default;
}

.users-list .user-host {
  color: #eac17b;
  font-weight: 600;
}

.conversation {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.history-more {
  align-self: flex-start;
  margin: 4px 10px;
  padding: 4px 7px;
  font-size: 12px;
  color: #bcc4d5;
}

.chat-messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
  list-style: none;
  padding: 8px 11px;
  margin: 0;
  overflow-wrap: anywhere;
  font-size: 13px;
}

.chat-entry {
  padding: 4px 0;
  line-height: 1.5;
}

.chat-text {
  white-space: pre-wrap;
}

.chat-text,
.chat-composer::after,
.chat-composer textarea {
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", var(--chat-emoji-fonts), sans-serif;
}

participant-name {
  color: attr(data-name-color type(<color>), inherit);
}

/* Older browsers use a copy of this rule for each user-selected hex color. */
[data-name-color=""] {
  color: inherit;
}

.chat-sender,
.user-name {
  font-weight: 600;
}

.host-crown {
  display: inline-block;
  margin-inline-start: .3em;
  font: .9em/1 var(--chat-emoji-fonts), sans-serif;
  vertical-align: middle;
  position: relative;
  inset-block-start: -.12em;
}

.chat-composer {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  border-top: 1px solid #343740;
  background: var(--panel-background);
}

.chat-composer::after,
.chat-composer textarea {
  grid-area: 1 / 1;
  display: block;
  width: 100%;
  min-width: 0;
  min-height: 34px;
  max-height: 116px;
  overflow-y: auto;
  resize: none;
  padding: 6px 10px;
  border: 0;
  border-radius: 0;
  background: var(--panel-background);
  color: #eceef3;
  font-size: 13px;
  line-height: 21px;
}

/* The mirror gives wrapped text and trailing newlines their natural height. */
.chat-composer::after {
  content: attr(data-draft) " ";
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  visibility: hidden;
  overflow: hidden;
}

.chat-composer textarea:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 1px #788eae;
}

.chat-emoji-picker {
  position: relative;
  grid-area: 1 / 2;
  align-self: end;
}

.chat-emoji-picker summary {
  display: grid;
  place-items: center;
  width: 38px;
  min-height: 34px;
  color: #b8c4d6;
  cursor: pointer;
  list-style: none;
  font-size: 20px;
}

.chat-emoji-picker summary::-webkit-details-marker {
  display: none;
}

.chat-emoji-picker summary:hover,
.chat-emoji-picker[open] summary {
  color: #f2f4f8;
}

.chat-emoji-panel {
  position: absolute;
  right: 6px;
  bottom: calc(100% + 6px);
  z-index: 42;
  width: min(330px, calc(100vw - 12px));
  border: 1px solid #424650;
  border-radius: 8px;
  background: #1a1c22;
  box-shadow: 0 6px 22px #0008;
  padding: 8px;
}

.chat-emoji-search {
  width: 100%;
  font-size: 12px;
}

.chat-emoji-categories,
.chat-emoji-grid {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
}

.chat-emoji-categories {
  margin-top: 5px;
  margin-bottom: 5px;
  border-bottom: 1px solid #343740;
}

.chat-emoji-categories button {
  display: grid;
  place-items: center;
  padding: 0;
  min-height: 34px;
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 4px 4px 0 0;
  color: #a9b4c5;
}

.chat-emoji-categories button[aria-pressed="true"] {
  border-bottom-color: #bbcbe8;
  color: #f2f4f8;
}

.chat-emoji-categories button:hover:not(:disabled) {
  background: transparent;
  color: #f2f4f8;
}

.chat-emoji-categories svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.65;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-emoji-grid {
  grid-auto-rows: 34px;
  max-height: min(240px, 35dvh);
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-gutter: stable both-edges;
}

.chat-emoji-grid button {
  display: grid;
  place-items: center;
  min-width: 0;
  min-height: 0;
  padding: 0;
  border: 0;
  white-space: nowrap;
  font: 19px/1 var(--chat-emoji-fonts), sans-serif;
}

.chat-emoji-grid button:hover:not(:disabled) {
  background: transparent;
}

.chat-emoji-panel button:focus-visible {
  outline-offset: -2px;
}

.chat-emoji-empty {
  margin: 12px 4px;
  color: #b8c4d6;
  font-size: 12px;
}

@media (max-width: 600px) {
  .users-pane {
    flex-basis: 125px;
  }
}

.inline-emote { height: 1.65em; max-width: 4em; object-fit: contain; vertical-align: middle; }
.custom-emote-picker { margin-top: 8px; }
.custom-emote-picker > span { color: #b8c4d6; font-size: 12px; }
.custom-emote-picker > div { display: flex; flex-wrap: wrap; max-height: 80px; overflow: auto; }
.custom-emote-picker button { display: grid; place-items: center; width: 34px; height: 34px; padding: 3px; }
.custom-emote-picker img { width: 100%; height: 100%; object-fit: contain; }
