/* =============================================================================
   ATUM — chat.css
   The 24/7 demo chat. A working front end with no backend: nothing transmits,
   nothing is stored. The DEMO badge in the header is a safety rail, not
   decoration — it must not be removed.
   ========================================================================== */

.chat { position: fixed; right: var(--s4); bottom: var(--s4); z-index: 90; }
@media (min-width: 48rem) { .chat { right: var(--s6); bottom: var(--s6); } }

/* ---------- Launcher ------------------------------------------------------- */

/* The launcher answers to the clock too, and it is the piece of the change a
   visitor is most likely to be looking at, because it is the only thing on a
   paper-coloured page that is already dark. At night it takes the warm rim and
   a faint amber halo; in the day it sits back. Both states declare the same
   two shadows so the list interpolates rather than snapping — one of them is
   simply transparent in the day. Colour only: nothing here moves, which is
   what keeps a fixed-position element out of the reduced-motion argument. */
.chat__launch {
  display: inline-flex;
  align-items: center;
  gap: var(--s3);
  padding: 0.7rem 1rem 0.7rem 0.85rem;
  background: var(--launch-bg);
  color: var(--on-night);
  border: var(--border) solid var(--launch-border);
  border-radius: 999px;
  box-shadow: var(--launch-glow);
  font-size: var(--t-sm);
  font-weight: 600;
  max-width: calc(100vw - 2 * var(--s4));
  transition: background-color var(--ph-ui) var(--ease-dusk) var(--ph-d-ui),
              border-color     var(--ph-ui) var(--ease-dusk) var(--ph-d-ui),
              box-shadow       var(--ph-ui) var(--ease-dusk) var(--ph-d-ui);
}
/* Hover has to be quick, so it overrides the slow phase timing for the two
   properties it touches. Without this a pointer moving on and off the pill
   would drag a 620ms fade behind it. */
.chat__launch:hover {
  background-color: var(--night-800);
  border-color: var(--night-500);
  transition-duration: var(--dur-1);
  transition-delay: 0ms;
}
.chat__launch-label { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* ---------- Panel ---------------------------------------------------------- */

.chat__panel {
  position: fixed;
  right: 0; bottom: 0;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--night-900);
  color: var(--on-night);
  border: var(--border) solid var(--night-700);
  overflow: hidden;
  z-index: 95;
}
@media (min-width: 30rem) {
  .chat__panel {
    right: var(--s4);
    bottom: var(--s4);
    width: min(24rem, calc(100vw - 2 * var(--s4)));
    height: min(38rem, calc(100dvh - 2 * var(--s4)));
    border-radius: var(--radius-lg);
    box-shadow: 0 30px 70px -28px rgb(7 11 22 / 0.75);
  }
}
@media (min-width: 48rem) {
  .chat__panel { right: var(--s6); bottom: var(--s6); width: 24.5rem; }
}
.chat__panel[hidden] { display: none !important; }

@media (prefers-reduced-motion: no-preference) {
  .chat__panel { animation: chat-in var(--dur-2) var(--ease) both; }
  @keyframes chat-in {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
  }
}

.chat__head {
  display: flex;
  align-items: center;
  gap: var(--s3);
  padding: var(--s4);
  border-bottom: var(--border) solid var(--night-700);
  background: var(--night-850);
  flex: none;
}
.chat__id { display: grid; gap: 2px; min-width: 0; }
.chat__name {
  font-weight: 700;
  font-size: var(--t-sm);
  letter-spacing: 0.01em;
  display: flex;
  align-items: center;
  gap: var(--s2);
}
.chat__state {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.07em;
  color: var(--on-night-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chat__state b { color: var(--sun); font-weight: 500; }

.chat__close {
  margin-left: auto;
  flex: none;
  width: 2rem; height: 2rem;
  display: grid; place-items: center;
  border-radius: var(--radius);
  color: var(--on-night-2);
  border: var(--border) solid transparent;
}
.chat__close:hover { background: var(--night-700); color: var(--on-night); }

/* ---------- Message list --------------------------------------------------- */

.chat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--s5) var(--s4);
  display: flex;
  flex-direction: column;
  gap: var(--s4);
  scrollbar-width: thin;
  scrollbar-color: var(--night-600) transparent;
}

.msg { display: grid; gap: var(--s2); max-width: 100%; }
.msg__bubble {
  padding: var(--s3) var(--s4);
  border-radius: var(--radius-lg);
  font-size: var(--t-sm);
  line-height: 1.55;
  max-width: 19rem;
  overflow-wrap: anywhere;
}
.msg__bubble p { max-width: none; }
.msg__bubble p + p { margin-top: var(--s3); }
.msg__bubble strong { color: var(--on-night); font-weight: 650; }

.msg--bot .msg__bubble {
  background: var(--night-800);
  border: var(--border) solid var(--night-700);
  color: var(--on-night-2);
  border-bottom-left-radius: 2px;
}
.msg--you { justify-items: end; }
.msg--you .msg__bubble {
  background: var(--sun);
  color: var(--night-900);
  border-bottom-right-radius: 2px;
  font-weight: 500;
}
.msg--you .msg__bubble strong { color: var(--night-900); }

.msg__meta {
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.06em;
  color: var(--on-night-3);
  font-variant-numeric: tabular-nums;
}

.msg__list { margin-top: var(--s3); display: grid; gap: var(--s2); }
.msg__list li { position: relative; padding-left: var(--s5); }
.msg__list li::before {
  content: '';
  position: absolute;
  left: 0; top: 0.65em;
  width: 0.6rem; height: 2px;
  background: var(--sun);
}

/* typing indicator — reduced motion swaps the dots for a word */
.typing { display: flex; align-items: center; gap: 5px; padding: var(--s3) var(--s4); }
.typing__word { display: none; font-family: var(--font-mono); font-size: var(--t-2xs); letter-spacing: 0.09em; text-transform: uppercase; color: var(--on-night-3); }
.typing__d { width: 6px; height: 6px; border-radius: 50%; background: var(--on-night-3); }
@media (prefers-reduced-motion: no-preference) {
  .typing__d { animation: typing 1.1s var(--ease) infinite; }
  .typing__d:nth-child(2) { animation-delay: 140ms; }
  .typing__d:nth-child(3) { animation-delay: 280ms; }
}
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.45; }
  30%           { transform: translateY(-4px); opacity: 1; }
}
@media (prefers-reduced-motion: reduce) {
  .typing__d { display: none; }
  .typing__word { display: block; }
}

/* ---------- Quick replies -------------------------------------------------- */

.chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: var(--s2);
  padding: 0 var(--s4) var(--s3);
  flex: none;
}
.chat__quick:empty { display: none; }
.qr {
  padding: 0.4rem 0.7rem;
  border: var(--border) solid var(--night-500);
  border-radius: 999px;
  font-size: var(--t-xs);
  font-weight: 600;
  color: var(--on-night);
  background: transparent;
  transition: background var(--dur-1) var(--ease), border-color var(--dur-1) var(--ease);
}
.qr:hover { background: var(--night-700); border-color: var(--on-night-3); }
.qr--go { border-color: var(--sun-deep); color: var(--sun); }
.qr--go:hover { background: rgb(232 145 46 / 0.14); }

/* ---------- Composer ------------------------------------------------------- */

.chat__form {
  display: flex;
  gap: var(--s2);
  padding: var(--s3) var(--s4) var(--s4);
  border-top: var(--border) solid var(--night-700);
  background: var(--night-850);
  flex: none;
}
.chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 0.55rem 0.7rem;
  background: var(--night-900);
  border: var(--border) solid var(--night-600);
  border-radius: var(--radius);
  color: var(--on-night);
  font-size: var(--t-sm);
}
.chat__input::placeholder { color: var(--on-night-3); }
.chat__input:focus { border-color: var(--sun-deep); }
.chat__send {
  flex: none;
  width: 2.35rem;
  display: grid; place-items: center;
  background: var(--sun);
  color: var(--night-900);
  border-radius: var(--radius);
  transition: background var(--dur-1) var(--ease);
}
.chat__send:hover { background: var(--sun-hi); }

.chat__foot {
  padding: 0 var(--s4) var(--s3);
  font-family: var(--font-mono);
  font-size: var(--t-2xs);
  letter-spacing: 0.05em;
  color: var(--on-night-3);
  text-align: center;
  flex: none;
  background: var(--night-850);
}
