/* Text chat, the team panel and speaking rings. Dark glass, like the rest of the game. */

/* ---- the chat box ---------------------------------------------------------- */
.chat { display: flex; flex-direction: column; gap: 6px; font-size: 14px; line-height: 1.35; color: var(--ink, #e5e7eb); --kb: 0px; }
.chat[hidden] { display: none; }
.chat-log { display: flex; flex-direction: column; gap: 3px; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin; }
.chat-msg { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 6px; padding: 4px 10px; border-radius: 10px; background: #091319d9; overflow-wrap: anywhere; word-break: break-word; max-width: 100%; }
.chat-dot { width: 9px; height: 9px; border-radius: 50%; flex: none; align-self: center; }
.chat-name { font-weight: 800; }
.chat-text { min-width: 0; overflow-wrap: anywhere; }
.chat-msg.mine { background: #12303ad9; }
.chat-msg.ghost { background: #1a1f2ad0; color: #b9c8e8; font-style: italic; text-shadow: 0 0 8px #8fb4ff55; opacity: .92; }
.chat-note { font-size: 12px; font-style: italic; color: #b9c8e8; padding: 0 4px; }
.chat-err { font-size: 13px; font-weight: 700; color: #fecaca; background: #7f1d1dcc; border-radius: 8px; padding: 6px 10px; }
.chat-form { display: flex; align-items: center; gap: 6px; }
.chat-input { flex: 1; min-width: 0; min-height: 44px; font: inherit; font-size: 16px; /* 16px stops phones zooming in */ color: inherit; background: #05090cf0; border: 1px solid #ffffff2e; border-radius: 12px; padding: 8px 12px; }
.chat-input:focus { outline: 2px solid #60a5fa; outline-offset: 1px; }
.chat-count { font: 700 12px ui-monospace, monospace; color: var(--muted, #8b8fa3); min-width: 2.2em; text-align: right; }
.chat-count.warn { color: #fca5a5; }
.chat-send { min-height: 44px; min-width: 64px; padding: 8px 14px; }

/* ---- during a night: a compact overlay, lower left ------------------------- */
.chat[data-phase="play"] { position: absolute; left: 12px; bottom: calc(96px + var(--kb)); z-index: 9; width: min(380px, calc(100% - 24px)); pointer-events: none; }
.chat[data-phase="play"] .chat-log { max-height: 40vh; }
/* closed: only the fresh messages show, then they fade away */
.chat[data-phase="play"]:not(.open) .chat-msg { opacity: 0; max-height: 0; padding-top: 0; padding-bottom: 0; overflow: hidden; transition: opacity .7s ease, max-height .7s ease, padding .7s ease; }
.chat[data-phase="play"]:not(.open) .chat-msg.fresh { opacity: 1; max-height: 8em; padding-top: 4px; padding-bottom: 4px; transition: opacity .2s ease; }
.chat[data-phase="play"]:not(.open) .chat-log { overflow: hidden; }
.chat[data-phase="play"]:not(.open) :is(.chat-form, .chat-note, .chat-err) { display: none; }
/* open: the whole history, with the input */
.chat[data-phase="play"].open { pointer-events: auto; background: #04080bd9; border: 1px solid #ffffff22; border-radius: 14px; padding: 8px; backdrop-filter: blur(4px); }
.chat[data-phase="play"].open .chat-msg { background: transparent; padding: 2px 4px; }
.chat[data-phase="play"].open .chat-msg.mine { background: #12303a80; }

/* phones: fading messages go to the top left under the status line, away from the left thumb; the open box
   sits right above the keyboard */
body.touch .chat[data-phase="play"] { bottom: auto; top: 96px; left: 8px; width: min(300px, 56vw); font-size: 12px; }
body.touch .chat[data-phase="play"].open { position: fixed; top: auto; left: 0; right: 0; bottom: var(--kb); width: auto; max-width: none; border-radius: 14px 14px 0 0; font-size: 14px; padding-bottom: max(8px, env(safe-area-inset-bottom)); z-index: 40; }
body.touch .chat[data-phase="play"].open .chat-log { max-height: 30vh; }

/* ---- lobby and end screen: a normal panel --------------------------------- */
.chat.panel-mode { position: static; width: 100%; background: #0b1519cc; border: 1px solid var(--line, #2a2a3a); border-radius: 14px; padding: 10px; pointer-events: auto; }
.chat.panel-mode .chat-log { min-height: 96px; max-height: 200px; }
.chat.panel-mode .chat-log:empty::before { content: "No messages yet. Say hello."; color: var(--muted, #8b8fa3); font-size: 13px; padding: 4px; }
.chat.panel-mode .chat-msg { background: #ffffff0d; }
.chat.panel-mode .chat-msg.mine { background: #12303a99; }
.chat.panel-mode .chat-msg.ghost { background: #1a1f2acc; }

/* ---- the team panel (voice) ------------------------------------------------ */
.team { display: flex; flex-direction: column; gap: 10px; width: 100%; }
.team-head { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.team-head .btn { min-height: 44px; font-size: 14px; }
.team-mute { grid-column: 1 / -1; min-height: 56px !important; font-size: 18px !important; }
.team-head .btn[aria-pressed="true"].team-mute, .team-head .btn[aria-pressed="true"].team-deaf { background: var(--red, #dc2626); color: #fff; }
.team-head .btn.team-voice[aria-pressed="true"] { background: var(--green, #16a34a); color: #fff; }
.team-head .btn:disabled { opacity: .55; cursor: default; }
.team-list { display: flex; flex-direction: column; gap: 4px; }
.team-row { display: grid; grid-template-columns: 28px minmax(0, 1fr) auto auto minmax(70px, 110px); align-items: center; gap: 8px; padding: 4px 8px; min-height: 44px; border-radius: 10px; background: #ffffff0d; }
.team-row.self { background: #12303a99; grid-template-columns: 28px minmax(0, 1fr) auto; }
.team-row.novoice .team-name, .team-row.away .team-name { opacity: .5; }
.team-row.pmuted .team-vol { opacity: .4; }
.team-ring { display: grid; place-items: center; width: 24px; height: 24px; border-radius: 50%; box-shadow: 0 0 0 2px transparent; transition: box-shadow .12s ease; }
.team-ring.speaking { box-shadow: 0 0 0 3px #4ade80, 0 0 10px #4ade80aa; }
.team-dot { width: 14px; height: 14px; border-radius: 50%; }
.team-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.team-radio { font-size: 15px; }
.team-pmute { width: 44px; height: 44px; font-size: 18px; border: 0; border-radius: 10px; background: #23233a; color: inherit; cursor: pointer; }
.team-pmute[aria-pressed="true"] { background: #7f1d1d; }
.team-vol { width: 100%; min-width: 0; min-height: 44px; accent-color: #60a5fa; }

/* a ring on the HUD or the phone UI can reuse the same class */
.speaking-ring.speaking { box-shadow: 0 0 0 3px #4ade80, 0 0 10px #4ade80aa; }

@media (max-width: 420px) {
  .team-row { grid-template-columns: 28px minmax(0, 1fr) auto auto; }
  .team-vol { grid-column: 1 / -1; min-height: 32px; }
  .team-row.self { grid-template-columns: 28px minmax(0, 1fr) auto; }
}
@media (prefers-reduced-motion: reduce) {
  .chat[data-phase="play"]:not(.open) .chat-msg, .chat[data-phase="play"]:not(.open) .chat-msg.fresh, .team-ring { transition: none; }
}
/* desktop: the chat sits above the minimap, not on it */
body:not(.touch) .chat[data-phase="play"] { bottom: calc(300px + var(--kb)); }
body:not(.touch) .chat[data-phase="play"] .chat-log { max-height: 26vh; }
