/* Chat (chat.js), shared by the lobby (index.html) and the game: a parchment
   panel like the in-game ones. Self-contained — it defines its own ink and
   parchment values, because the lobby doesn't load the game's theme.css.
   Needs fonts.css for EB Garamond (falls back to Georgia). */

.ic-chat {
  /* Player names: darker inks of the banner colours, readable on parchment. */
  --ic-red: #a3271c;
  --ic-blue: #2b5a9a;
  --ic-green: #2e6b3a;
  --ic-yellow: #7f5c06;
  --ic-purple: #64398f;
  --ic-orange: #9a4a16;
  --chat-ink-strong: #1f1309;
  --chat-ink: #3a2612;
  --chat-ink-head: #6a1e0e;
  --chat-ink-muted: #5a4429;
  --chat-rule-rgb: 112, 76, 36;
  position: fixed;
  z-index: 40;
  width: 340px;
  max-width: calc(100vw - 24px);
  border: 0;
  border-radius: 5px;
  background:
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220'%3E%3Cfilter id='f'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.9' numOctaves='3' stitchTiles='stitch'/%3E%3CfeColorMatrix values='0 0 0 0 .35 0 0 0 0 .24 0 0 0 0 .1 0 0 0 .09 0'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23f)'/%3E%3C/svg%3E"),
    radial-gradient(ellipse at 50% 45%, transparent 55%, rgba(120, 80, 30, 0.2) 100%),
    radial-gradient(ellipse at 50% 35%, rgba(255, 251, 236, 0.6), transparent 70%),
    #e8d9b2;
  box-shadow:
    inset 0 0 0 1px rgba(92, 60, 26, 0.75),
    inset 0 0 0 4px rgba(255, 248, 228, 0.35),
    inset 0 0 0 5px rgba(112, 76, 36, 0.35),
    0 12px 22px -6px rgba(0, 0, 0, 0.5),
    0 3px 6px rgba(0, 0, 0, 0.3);
  color: var(--chat-ink);
  font: 15.5px/1.4 "EB Garamond", Georgia, serif;
}
.ic-chat[hidden],
.ic-chat button[hidden],
.ic-chat-collapsed .ic-chat-body {
  display: none !important;
}
.ic-chat header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  color: var(--chat-ink-head);
  font: 600 15.5px/1.2 "EB Garamond", Georgia, serif;
  cursor: move;
  touch-action: none;
  user-select: none;
}
.ic-chat-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}
.ic-chat header .ic-chat-actions button {
  width: 28px;
  height: 28px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 3px;
  background: none;
  color: var(--chat-ink-muted);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  opacity: 0.5;
  transition: opacity 140ms ease-out;
}
.ic-chat header .ic-chat-actions button:hover,
.ic-chat header .ic-chat-actions button:focus-visible {
  opacity: 1;
  background: rgba(var(--chat-rule-rgb), 0.15);
}
.ic-chat header .ic-chat-actions button:focus-visible {
  outline: 2px solid var(--chat-ink-head);
  outline-offset: 1px;
}
/* Drawn icons in faded ink, centred in their 28px buttons: a chevron that
   points down when collapsed (expand) and up when open, and a thin cross. */
.ic-chat-toggle::before {
  content: "";
  width: 7px;
  height: 7px;
  margin-top: -4px;
  border-right: 1.5px solid currentColor;
  border-bottom: 1.5px solid currentColor;
  transform: rotate(45deg);
  transition: transform 150ms ease-out, margin 150ms ease-out;
}
.ic-chat-toggle[aria-expanded="true"]::before {
  margin-top: 4px;
  transform: rotate(-135deg);
}
.ic-chat-close { position: relative; }
.ic-chat-close::before,
.ic-chat-close::after {
  content: "";
  position: absolute;
  top: 13px;
  left: 8px;
  width: 12px;
  height: 1.5px;
  background: currentColor;
  border-radius: 1px;
}
.ic-chat-close::before { transform: rotate(45deg); }
.ic-chat-close::after { transform: rotate(-45deg); }
.ic-chat-body {
  border-top: 1px solid rgba(var(--chat-rule-rgb), 0.4);
}
.ic-chat-log {
  height: 180px;
  overflow: auto;
  padding: 8px 12px;
  scrollbar-color: rgba(var(--chat-rule-rgb), 0.6) transparent;
}
.ic-chat-log p {
  margin: 0 0 7px;
  color: var(--chat-ink);
  font-size: 14.5px;
  line-height: 1.5;
}
/* The message field takes the width, Send sits at the right end of the
   same line, both inset from the panel's ruled edge. */
.ic-chat form {
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 7px 9px 9px;
  border-top: 1px solid rgba(var(--chat-rule-rgb), 0.4);
}
.ic-chat-recipient {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 0 2px;
  color: var(--chat-ink-muted);
  font-size: 13.5px;
  font-weight: 600;
}
.ic-chat-recipient select,
.ic-chat input,
.ic-chat form input {
  border: 0;
  border-radius: 3px;
  background: rgba(255, 250, 234, 0.6);
  color: var(--chat-ink-strong) !important;
  -webkit-text-fill-color: var(--chat-ink-strong) !important;
  caret-color: var(--chat-ink-strong) !important;
  font: inherit;
}
.ic-chat-recipient select { max-width: 116px; }
.ic-chat form input {
  flex: 1;
  min-width: 0;
  padding: 7px 9px;
  box-shadow: inset 0 0 0 1px rgba(var(--chat-rule-rgb), 0.45);
  font-size: 14.5px;
}
.ic-chat input::placeholder {
  color: var(--chat-ink-muted);
  -webkit-text-fill-color: var(--chat-ink-muted);
}
.ic-chat form button {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px;
  border: 0;
  border-radius: 3px;
  background: radial-gradient(circle at 40% 30%, #a94535, #6b2018 70%);
  box-shadow: inset 0 0 0 1px rgba(40, 8, 6, 0.6), 0 1px 2px rgba(66, 37, 15, 0.4);
  color: #fff2cf;
  font: 600 14.5px/1 "EB Garamond", Georgia, serif;
  letter-spacing: 0.04em;
  cursor: pointer;
}
.ic-chat form button:hover { filter: brightness(1.1); }
.ic-chat form button:focus-visible {
  outline: 2px solid var(--chat-ink-head);
  outline-offset: 2px;
}
.ic-chat ::selection { background: rgba(106, 30, 14, 0.22); }
