/* The chat dock (#7111, web/chat.js) + the in-fight block (#7403, web/chat-fight.js).
   Plan docs/plans/2026-09-24-party-finder-and-chat.md §5 / §6. Forge-Glass (ADR-0013): one gold
   accent, glass, dark only. Party lines are green like the client's PARTY chat (ChatType.java:12),
   room lines the default ink, system lines muted.

   Layout: #chatDock is a sibling of #app. The collapsed line is fixed right above the tab bar
   (bottom: --dock-bottom, set by app.js from the #chatDockSpace spacer) and its height is reserved
   in the shell through --chat-dock-h (WS_APP.setDockHeight), so it never overlays the viewport —
   the vitals, the party strip, the raid skill bar (#7491) stay uncovered. The sheet is placed by
   chat.js (bottom / max-height): above the line, above the raid skill bar, or on the keyboard. */

#chatDock[hidden],
.chat-dock [hidden] {
  display: none !important;
}

.chat-dock {
  --chat-party: #93d595;
  --chat-party-soft: rgba(147, 213, 149, 0.82);
  --chat-gutter: max(10px, calc(50% - 230px));
}

/* ---- the collapsed line ---------------------------------------------------------------- */
.chat-bar {
  position: fixed;
  left: var(--chat-gutter);
  right: var(--chat-gutter);
  bottom: calc(var(--dock-bottom, 0px) + 4px);
  z-index: 12;
  height: 34px;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 4px 0 0;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: rgba(14, 15, 20, 0.88);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
.chat-open {
  flex: 1 1 auto;
  min-width: 0;
  height: 100%;
  display: flex;
  align-items: center;
  gap: 7px;
  padding: 0 6px 0 10px;
  border: 0;
  background: transparent;
  color: var(--ink);
  font: inherit;
  font-size: 12.5px;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.chat-ic {
  flex: 0 0 auto;
  display: inline-flex;
  color: var(--accent);
}
.chat-line1 {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--chat-party-soft);
}
.chat-bar.room .chat-line1 {
  color: var(--ink);
}
.chat-bar.sys .chat-line1 {
  color: var(--ink-muted);
  font-style: italic;
}
.chat-tag {
  color: var(--ink-muted);
  margin-right: 4px;
}
.chat-tag:empty {
  display: none;
}
.chat-lname {
  font-weight: 700;
  color: var(--chat-party);
  margin-right: 4px;
}
.chat-bar.room .chat-lname {
  color: var(--accent-strong);
}
.chat-lname:empty {
  display: none;
}
.chat-chev {
  flex: 0 0 auto;
  color: var(--ink-muted);
  font-size: 11px;
}
.chat-badge {
  flex: 0 0 auto;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: var(--accent);
  color: var(--on-accent, #000);
  font-size: 10.5px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  box-shadow: 0 0 8px rgba(201, 162, 75, 0.45);
}
.chat-barw {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
}
.chat-barw:empty {
  display: none;
}

/* ---- the sheet (peek / typing) --------------------------------------------------------- */
.chat-sheet {
  position: fixed;
  left: var(--chat-gutter);
  right: var(--chat-gutter);
  bottom: calc(var(--dock-bottom, 0px) + 42px);
  z-index: 13;
  max-height: 45vh;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 10px 10px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: rgba(14, 15, 20, 0.93);
  box-shadow: var(--shadow-soft);
  animation: chat-up 0.18s var(--ease, ease-out);
}
@keyframes chat-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: none;
  }
}
.chat-slot:empty {
  display: none;
}
.chat-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  min-height: 30px;
}
.chat-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  font-family: var(--font-display);
  font-size: 16px;
  color: var(--chat-party);
}
.chat-title.c-room {
  color: var(--accent-strong);
}
.chat-tabs {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  gap: 4px;
}
.chat-tab {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  height: 28px;
  padding: 0 11px;
  border-radius: 14px;
  border: 1px solid var(--glass-border);
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}
.chat-tab[aria-selected="true"] {
  border-color: rgba(201, 162, 75, 0.55);
  background: rgba(201, 162, 75, 0.12);
  color: var(--accent-strong);
}
.chat-tab.c-party[aria-selected="true"] {
  color: var(--chat-party);
}
.chat-tab .chat-badge {
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  font-size: 10px;
}
.chat-iconbtn {
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--ink-muted);
  font: inherit;
  font-size: 14px;
  cursor: pointer;
}
.chat-iconbtn:hover {
  color: var(--ink);
  background: rgba(255, 255, 255, 0.05);
}
.chat-sound {
  color: var(--accent);
}
.chat-sound.off {
  color: var(--ink-muted);
  opacity: 0.7;
}

/* the log */
.chat-log {
  flex: 1 1 auto;
  min-height: 64px;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 2px 2px 2px 0;
  scrollbar-width: thin;
}
.chat-empty {
  margin: auto 0;
  padding: 10px 0;
  text-align: center;
  color: var(--ink-muted);
  font-size: 12.5px;
}
.chat-l {
  display: flex;
  max-width: 100%;
  font-size: 13px;
  line-height: 1.35;
}
.chat-bub {
  max-width: 86%;
  min-width: 0;
  padding: 4px 9px 5px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.035);
  border: 1px solid rgba(255, 255, 255, 0.05);
}
.chat-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.chat-name {
  font-weight: 700;
  font-size: 12px;
  color: var(--chat-party);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.chat-time {
  flex: 0 0 auto;
  margin-left: auto;
  font-size: 10.5px;
  color: var(--ink-muted);
  opacity: 0.8;
}
.chat-text {
  overflow-wrap: anywhere;
  word-break: break-word;
  white-space: pre-wrap;
  color: var(--chat-party-soft);
}
.chat-l.c-room .chat-text {
  color: var(--ink);
}
.chat-l.c-room .chat-name {
  color: var(--accent-strong);
}
/* own lines aligned apart */
.chat-l.own {
  justify-content: flex-end;
}
.chat-l.own .chat-bub {
  background: rgba(201, 162, 75, 0.08);
  border-color: rgba(201, 162, 75, 0.2);
}
.chat-l.own .chat-name {
  color: var(--accent);
}
/* quick phrases and pings */
.chat-l.k-quick .chat-text {
  font-weight: 600;
}
.chat-l.k-ping .chat-bub {
  border-color: rgba(201, 162, 75, 0.45);
  background: rgba(201, 162, 75, 0.1);
}
.chat-l.k-ping .chat-text {
  color: var(--accent-strong);
  font-weight: 600;
}
.chat-pingic {
  color: var(--accent);
}
/* a line naming me */
.chat-l.mention .chat-bub {
  border-color: rgba(201, 162, 75, 0.6);
  box-shadow: inset 3px 0 0 var(--accent);
}
/* system lines: muted, centred, like the client's system messages */
.chat-l.k-system {
  justify-content: center;
  align-items: baseline;
  gap: 6px;
  padding: 1px 6px;
  font-size: 12px;
  text-align: center;
}
.chat-l.k-system .chat-text {
  color: var(--ink-muted);
  font-style: italic;
}
.chat-l.k-system .chat-time {
  margin-left: 0;
}

/* the error / wait line */
.chat-err {
  flex: 0 0 auto;
  font-size: 12px;
  color: #e0857f;
  padding: 0 2px;
}

/* the input */
.chat-form {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
}
.chat-input {
  flex: 1 1 auto;
  min-width: 0;
  height: 40px;
  padding: 0 12px;
  border-radius: 11px;
  border: 1px solid var(--glass-border);
  background: rgba(255, 255, 255, 0.05);
  color: var(--ink);
  font-family: var(--font-body);
  font-size: 16px; /* no iOS zoom on focus */
  outline: none;
}
.chat-input:focus {
  border-color: rgba(201, 162, 75, 0.55);
  box-shadow: 0 0 0 2px rgba(201, 162, 75, 0.15);
}
.chat-input::placeholder {
  color: var(--ink-muted);
  opacity: 0.8;
}
.chat-count {
  flex: 0 0 auto;
  font-size: 10.5px;
  color: var(--ink-muted);
}
.chat-count:empty {
  display: none;
}
.chat-count.full {
  color: #e0857f;
}
.chat-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  border-radius: 11px;
  background: var(--accent);
  color: var(--on-accent, #000);
  cursor: pointer;
  box-shadow: 0 0 12px rgba(201, 162, 75, 0.3);
}
.chat-send:disabled {
  opacity: 0.35;
  box-shadow: none;
  cursor: default;
}

/* ---- chat-fight (#7403, web/chat-fight.js) --------------------------------------------- */

/* chips: the role chips on the line, the full row in the sheet */
.chat-chip {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 30px;
  padding: 0 12px;
  border-radius: 15px;
  border: 1px solid rgba(201, 162, 75, 0.4);
  background: rgba(201, 162, 75, 0.07);
  color: var(--accent-strong);
  font: inherit;
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.chat-chip:active:not(:disabled) {
  background: rgba(201, 162, 75, 0.22);
}
.chat-chip:disabled {
  opacity: 0.45;
  cursor: default;
}
.chat-chip.ping {
  border-color: rgba(201, 162, 75, 0.7);
  background: rgba(201, 162, 75, 0.14);
}
.chat-chip-ok {
  display: none;
  color: var(--ok, #93d595);
}
.chat-chip.sent {
  opacity: 1;
  border-color: rgba(147, 213, 149, 0.55);
}
.chat-chip.sent .chat-chip-ok {
  display: inline;
}
.chat-rolechips {
  display: flex;
  gap: 4px;
}
.chat-rolechips .chat-chip {
  height: 26px;
  padding: 0 9px;
  border-radius: 13px;
  font-size: 12px;
}
.chat-tools {
  min-width: 0;
}
.chat-chiprow {
  display: flex;
  gap: 6px;
  overflow-x: auto;
  overscroll-behavior-x: contain;
  scrollbar-width: none;
  padding-bottom: 1px;
}
.chat-chiprow::-webkit-scrollbar {
  display: none;
}

/* the mini fight line at the sheet's top */
.chat-fightline {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 10px;
  padding: 5px 8px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.03);
  font-size: 11px;
}
.chat-fightline.low {
  border-color: rgba(181, 81, 76, 0.8);
  animation: cf-flash 0.9s ease-in-out infinite;
}
@keyframes cf-flash {
  0%,
  100% {
    box-shadow: inset 0 0 0 rgba(181, 81, 76, 0);
  }
  50% {
    box-shadow: inset 0 0 14px rgba(181, 81, 76, 0.55);
  }
}
.cf-me,
.cf-target {
  min-width: 0;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
}
.cf-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.cf-l {
  flex: 0 0 18px;
  color: var(--ink-muted);
  font-weight: 600;
  font-size: 10px;
}
.cf-bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.08);
  overflow: hidden;
}
.cf-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: 3px;
  transition: width 0.25s ease;
}
.cf-bar.hp .cf-fill,
.cf-bar.thp .cf-fill {
  background: var(--hp, #b5514c);
}
.cf-bar.mp .cf-fill {
  background: var(--mp, #5c86c0);
}
.cf-n {
  flex: 0 0 30px;
  text-align: right;
  color: var(--ink);
  font-size: 10.5px;
}
.cf-tname {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
  color: var(--ink);
  font-weight: 600;
}
.cf-target.none .cf-tname {
  color: var(--ink-muted);
  font-weight: 400;
}

/* a ping pulses the sender's card in the hunt party strip (WS_APP.pulsePartyMember, #7088) */
#huntPartyStrip .hparty-card.pinged {
  border-color: var(--accent);
  animation: chat-ping-pulse 0.75s ease-in-out 4;
}
@keyframes chat-ping-pulse {
  0%,
  100% {
    box-shadow: 0 0 0 rgba(201, 162, 75, 0);
  }
  50% {
    box-shadow: 0 0 12px rgba(201, 162, 75, 0.75), inset 0 0 8px rgba(201, 162, 75, 0.3);
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-sheet,
  .chat-fightline.low,
  #huntPartyStrip .hparty-card.pinged {
    animation: none;
  }
}
