/* Duonexia Phone System — "Messages" card and photo overlay. Uses the tokens from style.css:
   my messages on the vermillion-tinted --accent-soft, theirs on --surface-2, mono labels. */

.chat-peer { display: inline-flex; align-items: center; gap: 8px; min-width: 0; }
.chat-with { font: 700 15px var(--font-display); letter-spacing: -0.02em; color: var(--text); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-tabs { flex-wrap: wrap; margin: -4px 0 12px; }
.chat-tabs button[aria-pressed="true"] { color: var(--text); border-color: var(--line-3); background: var(--surface-2); }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0; border: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap;
}

.chat-thread {
  max-height: 360px; min-height: 140px; overflow-y: auto; overscroll-behavior: contain;
  margin: 0 -8px; padding: 2px 8px;
  border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.chat-more { display: block; margin: 10px auto 2px; }
.chat-list { list-style: none; margin: 0; padding: 10px 0; display: flex; flex-direction: column; gap: 6px; }

.chat-day {
  display: flex; align-items: center; gap: 10px; margin: 8px 0 2px;
  font: 500 10px var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--text-3);
}
.chat-day::before, .chat-day::after { content: ""; flex: 1; height: 1px; background: var(--line); }

.chat-msg { display: flex; flex-direction: column; max-width: 84%; }
/* Only messages that arrive live animate in; history loads still. */
.chat-msg.new { animation: rise 0.25s var(--ease); }
.chat-msg.mine { align-self: flex-end; align-items: flex-end; }
.chat-msg.theirs { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 8px 11px 5px; border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  background: var(--surface-2); user-select: text; overflow-wrap: anywhere;
}
.mine .chat-bubble { background: var(--accent-soft); border-color: rgb(255 90 31 / 0.32); border-bottom-right-radius: var(--radius); }
.theirs .chat-bubble { border-bottom-left-radius: var(--radius); }
.chat-text { margin: 0; white-space: pre-wrap; font-size: 13.5px; line-height: 1.45; }
.chat-time { display: block; margin-top: 3px; text-align: right; font: 400 10px var(--font-mono); letter-spacing: 0.04em; color: var(--text-3); }
.chat-read { margin-top: 3px; font: 500 9.5px var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase; color: var(--ok); }

.chat-photo-btn { display: block; padding: 0; border-radius: var(--radius); }
.chat-photo-btn:focus-visible { outline: 1.5px solid var(--accent); outline-offset: 2px; }
.chat-photo {
  display: block; max-width: 240px; max-height: 240px; min-width: 48px; min-height: 36px; margin: 2px 0 4px;
  border-radius: var(--radius); background: var(--void-2); cursor: zoom-in; transition: filter 0.15s;
}
.chat-photo:not([src]) { width: 160px; height: 110px; animation: blink 1.2s infinite; }
.chat-photo:hover { filter: brightness(1.08); }
.chat-photo-missing { display: block; font: 400 11.5px var(--font-mono); color: var(--err); }

.chat-error { margin: 10px 0 0; color: var(--err); font-size: 12.5px; }

.chat-composer { display: flex; align-items: flex-end; gap: 8px; margin-top: 12px; }
.chat-composer textarea {
  flex: 1; min-width: 0; min-height: 40px; max-height: 120px; resize: none; user-select: text;
  padding: 9px 12px; font: 400 13.5px/1.45 var(--font-body); color: var(--text);
  background: var(--surface-2); border: 1px solid var(--line-2); border-radius: var(--radius-lg);
  transition: border-color 0.15s;
}
.chat-composer textarea::placeholder { color: var(--text-3); }
.chat-composer textarea:focus { outline: none; border-color: var(--line-3); }
.chat-composer textarea:focus-visible { border-color: var(--accent); }
.chat-composer .icon-btn { border: 1px solid var(--line-2); }
/* style.css hides disabled icon buttons (dialer backspace); here it only dims while sending. */
.chat-composer .icon-btn:disabled { visibility: visible; opacity: 0.4; cursor: default; }
.chat-composer svg { width: 18px; height: 18px; }
.chat-send {
  width: 40px; height: 40px; flex: none; display: grid; place-items: center;
  border-radius: var(--radius-lg); background: var(--accent); color: var(--on-accent);
  transition: filter 0.15s, transform 0.15s var(--ease);
}
.chat-send:hover { filter: brightness(1.08); }
.chat-send:active { transform: scale(0.96); }
.chat-send:disabled { opacity: 0.4; cursor: default; filter: none; transform: none; }
.chat-sending {
  margin: 8px 0 0; font: 500 10px var(--font-mono); letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--accent-2); animation: blink 1s infinite;
}

.team .who .badge { margin-left: 8px; vertical-align: 2px; }

.chat-viewer {
  position: fixed; inset: 0; z-index: 45; display: grid; place-items: center; padding: 28px;
  background: rgb(7 9 12 / 0.9); backdrop-filter: blur(6px); cursor: zoom-out; animation: rise 0.2s var(--ease);
}
.chat-viewer-close { position: absolute; top: 18px; right: 18px; background: var(--surface); }
.chat-viewer img { max-width: 100%; max-height: calc(100vh - 56px); border-radius: var(--radius); box-shadow: 0 24px 70px rgb(0 0 0 / 0.55); }
