/* Anonymous chat + counsellor inbox. Builds on site.css tokens. */

.chat-page {
  background: var(--cream);
}

.chat-wrap {
  width: min(100% - 24px, 860px);
  margin-inline: auto;
  padding-block: clamp(20px, 4vw, 48px) clamp(40px, 6vw, 72px);
}

.chat-intro h1 {
  font-size: clamp(2rem, 4vw + 0.5rem, 3rem);
  max-width: 20ch;
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 7px 14px;
  border-radius: 999px;
  background: var(--white);
  border: 1px solid var(--line);
  font-size: 0.9063rem;
  font-weight: 700;
  color: var(--ink);
}

.pill::before {
  content: "";
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #b9a98b;
}

.pill[data-state="online"]::before {
  background: var(--sage);
  box-shadow: 0 0 0 4px rgba(47, 143, 123, 0.2);
}

.pill[data-state="offline"]::before {
  background: var(--amber);
}

.promise {
  display: grid;
  gap: 12px;
  margin: 24px 0 28px;
  padding: 0;
  list-style: none;
}

.promise li {
  display: flex;
  gap: 12px;
  align-items: flex-start;
}

.promise svg {
  flex: none;
  width: 22px;
  height: 22px;
  margin-top: 2px;
  color: var(--sage);
}

.fine {
  font-size: 0.875rem;
  color: var(--muted);
}

.fine details {
  margin-top: 6px;
}

.fine summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

/* ---------------------------------------------------------------- room */
.room {
  display: flex;
  flex-direction: column;
  height: min(78dvh, 760px);
  min-height: 460px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--white);
  box-shadow: var(--shadow);
}

.room-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--line);
  background: var(--sand);
}

.room-head h1,
.room-head h2 {
  margin: 0;
  font-family: var(--font-body);
  font-size: 1.0625rem;
  font-weight: 800;
  letter-spacing: -0.01em;
}

.room-head p {
  margin: 0;
  font-size: 0.8438rem;
  color: var(--muted);
}

.room-actions {
  display: flex;
  gap: 8px;
}

.btn-quiet {
  min-height: 40px;
  padding: 8px 14px;
  border: 1.5px solid var(--line);
  border-radius: 999px;
  background: var(--white);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 700;
  color: var(--ink);
  cursor: pointer;
}

.btn-quiet:hover {
  border-color: var(--ink);
}

.btn-danger {
  color: var(--danger);
  border-color: #efc4c0;
}

.banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 10px 16px;
  padding: 12px 18px;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.banner[hidden] {
  display: none;
}

.banner--wait {
  background: #fff7e6;
  border-bottom: 1px solid #f3dfb5;
  color: var(--ink);
}

.wait-tips {
  padding: 10px 18px 12px;
  background: #fffaf2;
  border-bottom: 1px solid var(--line);
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--ink-soft);
}

.wait-tips[hidden] {
  display: none;
}

.wait-tips summary {
  cursor: pointer;
  font-weight: 700;
  color: var(--ink);
}

.wait-tips summary:focus-visible {
  outline: 3px solid var(--amber);
  outline-offset: 3px;
  border-radius: 6px;
}

.wait-tips ul {
  display: grid;
  gap: 8px;
  max-height: 34vh;
  margin: 10px 0 0;
  padding-left: 20px;
  overflow-y: auto;
}

.wait-tips strong {
  color: var(--ink);
}

.banner--crisis {
  background: #fdecea;
  border-bottom: 1px solid #f3c6c1;
  color: #5f1a15;
}

.banner--crisis a {
  color: #5f1a15;
  font-weight: 800;
}

.banner--conn {
  background: #eef2fa;
  color: var(--ink-soft);
  font-size: 0.875rem;
  padding-block: 8px;
}

.log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 18px;
  overflow-y: auto;
  overscroll-behavior: contain;
  background: linear-gradient(180deg, #fffdf8, #fff);
}

.bubble {
  max-width: min(82%, 520px);
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 1rem;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.bubble time {
  display: block;
  margin-top: 4px;
  font-size: 0.7188rem;
  opacity: 0.7;
}

.bubble--me {
  align-self: flex-end;
  border-bottom-right-radius: 6px;
  background: var(--ink);
  color: #fff;
}

.bubble--them {
  align-self: flex-start;
  border-bottom-left-radius: 6px;
  background: var(--sand);
  color: var(--ink);
}

.bubble--system {
  align-self: center;
  max-width: 92%;
  padding: 6px 12px;
  border-radius: 999px;
  background: transparent;
  border: 1px dashed var(--line);
  font-size: 0.8438rem;
  color: var(--muted);
  text-align: center;
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px 14px;
  border-top: 1px solid var(--line);
  background: var(--white);
}

.composer textarea {
  flex: 1;
  min-height: 48px;
  max-height: 140px;
  padding: 12px 14px;
  border: 1.5px solid #cfc3ac;
  border-radius: 16px;
  font: inherit;
  line-height: 1.4;
  color: var(--ink);
  resize: none;
}

.composer textarea:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 4px rgba(0, 113, 187, 0.18);
}

.composer textarea:disabled {
  background: #f5f0e6;
}

.composer .btn {
  min-height: 48px;
  padding-inline: 22px;
}

.composer-meta {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 0 18px 10px;
  font-size: 0.8125rem;
  color: var(--muted);
}

.ended {
  display: grid;
  gap: 12px;
  padding: 18px;
  border-top: 1px solid var(--line);
  background: var(--sand);
  text-align: center;
}

.ended[hidden] {
  display: none;
}

.ended .hero-actions {
  justify-content: center;
}

.quick-exit {
  min-height: 44px;
  padding: 10px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font: inherit;
  font-size: 0.9063rem;
  font-weight: 800;
  cursor: pointer;
}

/* Header on the chat pages stays visible on phones: just the logo, a call button and quick exit. */
.chat-page .nav-cta {
  gap: 8px;
}

.chat-page .nav-cta .btn {
  display: inline-flex;
}

.chat-page .nav-cta .short {
  display: none;
}

@media (max-width: 520px) {
  .chat-page .nav-cta .long {
    display: none;
  }

  .chat-page .nav-cta .short {
    display: inline;
  }

  .chat-page .logo span {
    display: none;
  }
}

.quick-exit:hover {
  background: #8f1d17;
}

.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;
}

/* ---------------------------------------------------------------- counsellor inbox */
.inbox-wrap {
  width: min(100% - 24px, 1200px);
  margin-inline: auto;
  padding-block: 20px 56px;
}

.login-card {
  width: min(100%, 460px);
  margin: clamp(24px, 6vw, 72px) auto;
}

.inbox {
  display: grid;
  grid-template-columns: 340px 1fr;
  gap: 18px;
  align-items: start;
}

.inbox-side {
  display: grid;
  gap: 14px;
}

.side-card {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: var(--white);
  box-shadow: var(--shadow-sm);
}

.side-card h2 {
  margin: 0 0 10px;
  font-family: var(--font-body);
  font-size: 0.8125rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--amber-text);
}

.qlist {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.qitem {
  display: block;
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--line);
  border-radius: 14px;
  background: var(--cream);
  font: inherit;
  text-align: left;
  color: var(--ink);
  cursor: pointer;
}

.qitem:hover,
.qitem[aria-current="true"] {
  border-color: var(--ink);
}

.qitem strong {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.qitem small {
  display: block;
  margin-top: 4px;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.qitem--crisis {
  border-color: #e9a29b;
  background: #fff5f4;
}

.tag {
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--danger);
  color: #fff;
  font-size: 0.6875rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.tag--new {
  background: var(--blue);
}

.empty {
  margin: 0;
  font-size: 0.9375rem;
  color: var(--muted);
}

.inbox-main .room {
  height: min(74dvh, 720px);
}

.inbox-empty {
  display: grid;
  place-items: center;
  height: 360px;
  border: 2px dashed var(--line);
  border-radius: 24px;
  color: var(--muted);
  text-align: center;
  padding: 24px;
}

.preview-card {
  display: grid;
  gap: 14px;
  align-content: center;
  height: 100%;
  padding: 28px;
  text-align: center;
}

.guide ul {
  margin: 0;
  padding-left: 1.1em;
  font-size: 0.9063rem;
}

.guide li {
  margin-bottom: 6px;
}

@media (max-width: 900px) {
  .inbox {
    grid-template-columns: 1fr;
  }

  .inbox-main .room {
    height: 80dvh;
  }
}

@media (max-width: 560px) {
  .inbox-wrap {
    width: min(100% - 16px, 860px);
    padding-block: 8px 16px;
  }

  /* The intro gets a comfortable 16px gutter; the chat room itself stretches back out to 8px. */
  .chat-wrap {
    width: min(100% - 32px, 860px);
    padding-block: 12px 24px;
  }

  .chat-wrap .room {
    margin-inline: -8px;
  }

  /* Fill the screen under the 72px header so focusing the box never scrolls the room out of view. */
  .room {
    height: calc(100dvh - 72px - 24px);
    min-height: 420px;
    border-radius: 18px;
  }

  .room-head {
    flex-wrap: wrap;
  }

  .bubble {
    max-width: 90%;
  }
}

.inbox > * {
  min-width: 0;
}

/* Contact details offer + dialog */
.contact-offer {
  margin-top: 24px;
  padding: 18px 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--sand);
}

.contact-offer p {
  margin: 0 0 12px;
}

.modal-body {
  max-height: calc(100dvh - 110px);
  padding: 20px 24px 24px;
  overflow-y: auto;
}

.modal-body .field {
  margin-bottom: 14px;
}

.modal-body textarea {
  width: 100%;
  resize: vertical;
}

.modal-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 14px;
  margin: 16px 0;
}

.check {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin: 4px 0 12px;
  font-size: 0.9375rem;
  line-height: 1.45;
}

.check input {
  flex: none;
  width: 20px;
  height: 20px;
  margin-top: 2px;
}

/* ---------------------------------------------------------------- phones */
@media (max-width: 560px) {
  /* Header: logo, Call and Quick exit stay on one line */
  .chat-page .nav {
    gap: 8px;
  }

  .chat-page .nav-cta .btn,
  .quick-exit {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.9375rem;
    white-space: nowrap;
  }

  .chat-intro h1 {
    margin-top: 12px;
  }

  .promise {
    gap: 10px;
    margin: 20px 0 24px;
  }

  .chat-intro .form-card {
    padding: 20px 18px;
  }

  .contact-offer {
    margin-top: 20px;
    padding: 16px;
  }

  .contact-offer .btn {
    width: 100%;
  }

  .callout-emergency {
    margin-top: 20px;
    padding: 16px;
  }

  /* Room: tighter bars so the conversation keeps most of the screen */
  .room-head {
    padding: 12px 14px;
  }

  .banner {
    gap: 10px;
    padding: 12px 14px;
    font-size: 0.9063rem;
  }

  .banner--wait .btn {
    width: 100%;
  }

  .wait-tips {
    padding: 10px 14px;
  }

  .wait-tips ul {
    max-height: 30vh;
  }

  .log {
    gap: 8px;
    padding: 14px 12px;
  }

  .bubble {
    padding: 9px 13px;
  }

  .composer {
    gap: 8px;
    padding: 10px 12px max(12px, env(safe-area-inset-bottom));
  }

  .composer .btn {
    padding-inline: 18px;
  }

  /* Phones have no Shift+Enter, so drop that hint and keep the character count */
  .composer-meta {
    justify-content: flex-end;
    padding: 0 14px 8px;
  }

  .composer-meta span:first-child {
    display: none;
  }

  .ended {
    padding: 16px 14px max(16px, env(safe-area-inset-bottom));
  }

  .ended .hero-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .ended .hero-actions .btn,
  .ended .hero-actions .btn-quiet {
    width: 100%;
  }

  /* Contact details pop-up */
  dialog.modal {
    width: calc(100% - 16px);
    max-height: calc(100dvh - 16px);
    border-radius: 20px;
  }

  .modal-body {
    padding: 16px 16px 20px;
  }

  .modal-actions .btn {
    flex: 1 1 100%;
  }

  .modal-actions .btn-quiet {
    flex: 1 1 100%;
  }

  .modal-body textarea {
    min-height: 88px;
  }
}
