/* Messages: thread list and one thread. Loaded by messages.html after www.css. */

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

.msg-back {
  display: inline-flex;
  align-items: center;
  min-height: 2.75rem;
  margin-bottom: var(--s-2);
  color: var(--gold);
  font-weight: 600;
  text-decoration: none;
}
.msg-back[hidden] { display: none; }

.msg-meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--s-2) var(--s-3);
  margin: 0 0 var(--s-2);
}
.msg-meta[hidden] { display: none; }

.msg-chip {
  display: inline-block;
  padding: 0.1rem 0.6rem;
  border: 1px solid var(--line-2);
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-size: 0.8rem;
  font-weight: 600;
  line-height: 1.5;
}

.msg-status { color: var(--ink-3); font-size: 0.9rem; }

.msg-picker { margin-top: var(--s-3); max-width: 28rem; }
.msg-picker[hidden] { display: none; }

.msg-list { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--s-2); }

.msg-row {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  align-items: center;
  gap: var(--s-3);
  min-height: 3.5rem;
  padding: 0.7rem var(--s-3);
  border: 1px solid var(--line);
  border-radius: 14px;
  background: var(--card);
  color: var(--ink);
  text-decoration: none;
}
.msg-row:hover { border-color: var(--line-2); background: var(--card-hi); }
.msg-row.is-unread { border-color: var(--gold-dim); }

.msg-av {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--ground-3);
  border: 1px solid var(--line-2);
  color: var(--cream);
  font-weight: 700;
}
.msg-av-house { color: var(--gold); }

.msg-main { display: grid; gap: 0.15rem; min-width: 0; }
.msg-line { display: flex; flex-wrap: wrap; align-items: center; gap: 0.25rem var(--s-2); }
.msg-name { font-weight: 700; }
.msg-preview {
  overflow: hidden;
  color: var(--ink-2);
  font-size: 0.95rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.msg-side { display: grid; justify-items: end; gap: 0.3rem; }
.msg-when { color: var(--ink-3); font-size: 0.85rem; white-space: nowrap; }
.msg-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 1.35rem;
  height: 1.35rem;
  padding: 0 0.35rem;
  border-radius: 999px;
  background: var(--gold);
  color: var(--ground);
  font-size: 0.8rem;
  font-weight: 800;
}

.msg-request {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}
.msg-request-acts { display: flex; gap: var(--s-2); }
@media (max-width: 480px) {
  .msg-request-acts .btn { width: auto; }
}

.msg-thread .wrap { max-width: 44rem; }

.msg-turns {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--s-3);
}

.msg-turn { display: flex; }
.msg-turn.is-mine { justify-content: flex-end; }

.msg-bubble {
  max-width: min(88%, 32rem);
  padding: 0.65rem var(--s-3);
  border: 1px solid var(--line);
  border-radius: 16px;
  background: var(--card);
  line-height: 1.5;
  overflow-wrap: anywhere;
}
.is-mine .msg-bubble {
  border-color: var(--gold-dim);
  background: rgba(216, 178, 92, 0.1);
}
.msg-who { margin-bottom: 0.2rem; color: var(--ink-3); font-size: 0.85rem; font-weight: 600; }
.msg-text { white-space: pre-wrap; }
.msg-text a, .msg-foot a { color: var(--gold); text-underline-offset: 0.2em; }
.msg-text a.msg-link {
  display: inline-flex; align-items: center; min-height: 2.75rem;
  font-weight: 650;
}
.msg-join { margin-top: var(--s-2); }

.msg-foot { margin-top: var(--s-4); }

.msg-composer {
  position: sticky;
  bottom: 0;
  margin-top: var(--s-4);
  padding: var(--s-3) 0 calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  background: linear-gradient(to bottom, rgba(10, 21, 18, 0), var(--ground) 0.75rem);
  display: grid;
  gap: var(--s-2);
}
.msg-composer textarea {
  min-height: 3.25rem;
  max-height: 10rem;
  max-width: none;
  resize: none;
}
.msg-composer-row { display: flex; align-items: center; justify-content: space-between; gap: var(--s-3); }
.msg-composer .btn { width: auto; }
.msg-composer .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.msg-count { color: var(--ink-3); font-size: 0.85rem; font-variant-numeric: tabular-nums; }
.msg-count.is-over { color: var(--bad); }
.msg-composer .form-err { margin: 0; min-height: 0; }
.msg-composer .form-err:empty { display: none; }

/* /support: the message you just sent lands here, above the form. */
.ticket-thread { margin: var(--s-3) 0 var(--s-4); }
.ticket-thread[hidden], #ticketTopicField[hidden], #ticketNew[hidden] { display: none; }
.ticket-thread .msg-foot { margin-top: var(--s-3); }

/* Filters, long-press select, bulk bar. */
.msg-filters {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-2) var(--s-3);
}
.msg-filter-set { display: flex; flex-wrap: wrap; gap: var(--s-2); }
.msg-filter { width: auto; }
.msg-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  min-height: 2.75rem;
  padding: 0 var(--s-3);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: transparent;
  color: var(--ink-2);
  font: inherit;
  font-weight: 650;
  cursor: pointer;
}
.msg-filter[aria-pressed="true"] {
  border-color: var(--gold-dim);
  background: rgba(216, 178, 92, 0.14);
  color: var(--cream);
}
.msg-filter-n { color: var(--gold); font-variant-numeric: tabular-nums; }
.msg-select-btn { width: auto; min-height: 2.75rem; }
.msg-select-btn[hidden] { display: none; }

.msg-toast {
  margin: 0;
  padding: var(--s-2) var(--s-3);
  border: 1px solid var(--gold-dim);
  border-radius: 12px;
  background: rgba(216, 178, 92, 0.1);
}
.msg-toast[hidden] { display: none; }
.msg-undo {
  min-height: 2.75rem;
  padding: 0 var(--s-2);
  border: 0;
  background: none;
  color: var(--gold);
  font: inherit;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 0.2em;
  cursor: pointer;
}

.msg-row {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: pan-y;
}
.msg-check { display: none; }
.msg-list.is-selecting .msg-row { grid-template-columns: auto auto minmax(0, 1fr) auto; }
.msg-list.is-selecting .msg-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1.6rem;
  height: 1.6rem;
  border: 2px solid var(--line-2);
  border-radius: 8px;
  background: var(--ground);
}
.msg-row.is-picked { border-color: var(--gold); background: var(--card-hi); }
.msg-row.is-picked .msg-check { border-color: var(--gold); background: var(--gold); }
.msg-row.is-picked .msg-check::after {
  content: "";
  width: 0.35rem;
  height: 0.7rem;
  margin-top: -0.1rem;
  border: solid var(--ground);
  border-width: 0 3px 3px 0;
  transform: rotate(45deg);
}

.msg-bulk {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4) calc(var(--s-3) + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--gold-dim);
  background: var(--ground);
  box-shadow: 0 -8px 24px rgba(0, 0, 0, 0.35);
}
.msg-bulk[hidden] { display: none; }
.msg-bulk-count { font-weight: 700; }
.msg-bulk-acts { display: flex; gap: var(--s-2); }
.msg-bulk .btn { width: auto; }
.msg-bulk .btn:disabled { opacity: 0.5; cursor: not-allowed; }
.msg-selecting main { padding-bottom: 5rem; }

/* Thread: reply hint, send confirmation, read-only notice. */
#msgThreadActions[hidden] { display: none; }
.msg-replyhint { margin: 0; color: var(--ink-3); }
.msg-ok { margin: 0; color: var(--gold); font-weight: 650; }
.msg-ok[hidden] { display: none; }
.msg-readonly { margin-top: var(--s-4); }
.msg-readonly p { margin: 0 0 var(--s-2); }

/* Phones: keep the filters and the first rows on the first screen. */
@media (max-width: 560px) {
  #msgHead { padding-block: var(--s-4) var(--s-3); }
  #msgHead h1 { margin-bottom: var(--s-2); }
  #msgLead { display: none; }
  #inbox.sec { padding-block: var(--s-4); }
}
