/*
 * Hero demo: a replica of the chat widget and of the agents' app that plays one conversation.
 * Everything is sized in em; .demo-stage sets 1em from the width of its container (cqw), so the
 * whole composition scales as one piece. No images except the logo.
 */

.demo {
  container-type: inline-size;
  width: 100%;
  max-width: 560px;
  --demo-bubble: #efeeec;
  --demo-orange-ink: #b34a0c;
}

.demo-stage {
  position: relative;
  height: 58em;
  font-size: calc(100cqw / 56);
  line-height: 1.35;
}

:where(.demo) p,
:where(.demo) ul {
  margin: 0;
  padding: 0;
}

:where(.demo) ul {
  list-style: none;
}

.demo-sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip-path: inset(50%);
  white-space: nowrap;
  border: 0;
}

.demo :focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 2px;
  border-radius: 6px;
}

/* ------------------------------------------------------------------ widget */

.demo-widget {
  position: absolute;
  left: 0;
  top: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: 32em;
  height: 50em;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  border-radius: 1.6em;
  box-shadow:
    0 0 0 1px rgba(23, 23, 28, 0.04),
    0 2.4em 5em -1.6em rgba(23, 23, 28, 0.28);
}

.demo-widget::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 0.35em;
  background: var(--accent);
}

.demo-w-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1em;
  padding: 1.9em 2em 1.4em;
  border-bottom: 1px solid var(--line);
}

.demo-w-title {
  font-size: 1.7em;
  font-weight: 650;
  line-height: 1.3;
}

.demo-w-sub {
  margin-top: 0.2em;
  color: var(--muted);
  font-size: 1.35em;
}

.demo-w-x {
  flex: none;
  width: 2.4em;
  height: 2.4em;
  margin-top: -0.1em;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
}

.demo-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1em;
  padding: 1.6em 3.2em 1.6em 2em;
  overflow: hidden;
}

.demo-msg {
  display: flex;
}

.demo-msg-visitor {
  justify-content: flex-end;
}

.demo-bubble {
  max-width: 85%;
  padding: 0.9em 1.2em;
  border-radius: 1.4em 1.4em 1.4em 0.4em;
  background: var(--demo-bubble);
  font-size: 1.45em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.demo-msg-visitor .demo-bubble {
  border-radius: 1.4em 1.4em 0.4em 1.4em;
  background: var(--accent);
}

.demo-msg.is-new {
  animation: demo-pop 0.32s ease-out;
}

.demo-w-foot {
  border-top: 1px solid var(--line);
  padding: 1.2em 2.4em 1.6em 2em;
}

.demo-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6em;
  margin-bottom: 1.1em;
}

.demo-chip {
  padding: 0.6em 1.1em;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.25em;
  font-weight: 550;
  line-height: 1.25;
  cursor: pointer;
  transition:
    border-color 0.15s,
    background-color 0.15s;
}

.demo-chip:hover {
  border-color: var(--accent);
  background: #fff6f0;
}

.demo-chips[hidden] {
  display: none;
}

.demo-form {
  display: flex;
  align-items: flex-end;
  gap: 0.8em;
}

/* a text area that wraps and grows to three lines, like the real widget's composer (js sets the height) */
.demo-input {
  flex: 1;
  display: block;
  min-width: 0;
  max-height: calc(3 * 1.35em + 1.5em);
  padding: 0.75em 1em;
  border: 1px solid var(--line);
  border-radius: 0.9em;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: max(1.4em, 16px);
  line-height: 1.35;
  resize: none;
  overflow-y: hidden;
}

.demo-input::placeholder {
  color: #85858e;
}

.demo-input:focus-visible {
  outline: 3px solid var(--ink);
  outline-offset: 1px;
  border-radius: 0.9em;
}

.demo-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 3.8em;
  height: 3.8em;
  padding: 0;
  border: 0;
  border-radius: 0.9em;
  background: var(--accent);
  color: var(--ink);
  cursor: pointer;
}

.demo-send svg {
  width: 2em;
  height: 2em;
  fill: currentColor;
}

.demo-send:disabled {
  background: var(--demo-bubble);
  color: #85858e;
  cursor: default;
}

/* ------------------------------------------------------------------- phone */

.demo-phone {
  position: absolute;
  z-index: 2;
  right: 0;
  top: 4em;
  width: 26em;
  aspect-ratio: 26 / 54;
}

.demo-frame {
  box-sizing: border-box;
  width: 100%;
  height: 100%;
  padding: 1em;
  background: #121216;
  border-radius: 4.6em;
  box-shadow: 0 3em 6em -2.4em rgba(23, 23, 28, 0.5);
}

.demo-screen {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #fff;
  color: var(--ink);
  border-radius: 3.6em;
  isolation: isolate;
}

.demo-island {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 1em;
  width: 7em;
  height: 2.1em;
  transform: translateX(-50%);
  background: #000;
  border-radius: 99px;
}

.demo-status {
  position: absolute;
  z-index: 4;
  inset: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.2em;
  padding: 0.4em 2.3em 0;
}

.demo-clock {
  font-size: 1.1em;
  font-weight: 650;
}

.demo-sys {
  width: 4.8em;
  height: auto;
  fill: var(--ink);
  stroke: var(--ink);
  stroke-width: 0;
}

.demo-sys rect[fill="none"] {
  stroke-width: 1.1;
  opacity: 0.45;
}

.demo-batt {
  fill: #34c759;
}

/* views */

.demo-view {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding-top: 4.2em;
  background: #fff;
  transition: transform 0.45s cubic-bezier(0.3, 0.7, 0.2, 1);
}

.demo-convo {
  background: #fff;
  transform: translateX(101%);
}

.is-convo .demo-convo {
  transform: none;
}

.is-convo .demo-inbox {
  transform: translateX(-24%);
}

/* inbox */

.demo-inbox-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9em 1.6em 0.9em;
}

.demo-inbox-title {
  font-size: 1.5em;
  font-weight: 750;
  letter-spacing: -0.01em;
}

.demo-me {
  position: relative;
  display: grid;
  place-items: center;
  width: 2.7em;
  height: 2.7em;
  border-radius: 50%;
  background: #d8f0ea;
  color: #0f5a4f;
  font-size: 0.9em;
  font-weight: 700;
}

.demo-me i {
  position: absolute;
  right: -0.1em;
  bottom: -0.1em;
  width: 0.9em;
  height: 0.9em;
  border-radius: 50%;
  background: #7c7c84;
  border: 0.15em solid #fff;
}

.demo-seg {
  display: flex;
  gap: 0.2em;
  margin: 0 1.6em;
  padding: 0.25em;
  background: #f0efec;
  border-radius: 1em;
  font-size: 0.95em;
  font-weight: 650;
  color: #5b5b64;
}

.demo-seg span {
  flex: 1;
  padding: 0.65em 0.2em;
  border-radius: 0.8em;
  text-align: center;
  white-space: nowrap;
}

.demo-seg .is-on {
  background: #fff;
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 23, 28, 0.12);
}

.demo-seg em {
  font-style: normal;
  font-weight: 700;
  color: #77777f;
}

.demo-seg .is-on em {
  color: var(--demo-orange-ink);
}

.demo-filters {
  display: flex;
  gap: 0.6em;
  padding: 1em 1.6em;
  border-bottom: 1px solid var(--line);
  font-size: 0.9em;
  font-weight: 650;
}

.demo-filters span {
  display: inline-flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.55em 0.9em;
  border: 1px solid var(--line);
  border-radius: 99px;
  white-space: nowrap;
}

.demo-filters i {
  width: 0.5em;
  height: 0.5em;
  margin-top: -0.25em;
  border-right: 0.12em solid currentColor;
  border-bottom: 0.12em solid currentColor;
  transform: rotate(45deg);
}

.demo-rows {
  flex: 1;
  overflow: hidden;
}

.demo-row {
  display: grid;
  grid-template-rows: 1fr;
}

.demo-row-clip {
  min-height: 0;
  overflow: hidden;
}

.demo-row-new {
  grid-template-rows: 0fr;
  opacity: 0;
  transition:
    grid-template-rows 0.45s cubic-bezier(0.3, 0.7, 0.2, 1),
    opacity 0.4s 0.1s;
}

.is-row .demo-row-new {
  grid-template-rows: 1fr;
  opacity: 1;
}

.demo-row-in {
  display: flex;
  gap: 1.1em;
  align-items: flex-start;
  margin: 0 1.6em;
  padding: 1.1em 0 1.1em;
  border-bottom: 1px solid var(--line);
}

.demo-av {
  flex: none;
  display: grid;
  place-items: center;
  width: 3em;
  height: 3em;
  border-radius: 50%;
  font-size: 1em;
  font-weight: 700;
}

.demo-av-s {
  width: 2.2em;
  height: 2.2em;
  font-size: 0.8em;
}

.demo-av-1 {
  background: #dfe8fb;
  color: #1f4aa8;
}
.demo-av-2 {
  background: #d3efe9;
  color: #0f5a4f;
}
.demo-av-3 {
  background: #f7e8c8;
  color: #7a5200;
}
.demo-av-4 {
  background: #dcefd9;
  color: #1f5a2b;
}
.demo-av-new {
  background: #ebebef;
  color: var(--ink);
}

.demo-row-body {
  flex: 1;
  min-width: 0;
}

.demo-row-top,
.demo-row-prev {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.8em;
}

.demo-name {
  font-size: 1.1em;
  font-weight: 650;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-time {
  flex: none;
  font-size: 0.9em;
  color: #6b6b73;
}

.demo-time.is-new {
  color: var(--demo-orange-ink);
  font-weight: 700;
}

.demo-prev {
  min-width: 0;
  margin-top: 0.15em;
  font-size: 1em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-prev.is-read {
  color: #6b6b73;
}

.demo-dot {
  flex: none;
  width: 0.95em;
  height: 0.95em;
  border-radius: 50%;
  background: var(--accent);
}

.demo-you {
  display: inline-block;
  margin-top: 0.5em;
  padding: 0.2em 0.9em;
  border: 1px solid var(--line);
  border-radius: 99px;
  font-size: 0.85em;
  font-weight: 650;
}

/* banner */

.demo-banner {
  position: absolute;
  z-index: 6;
  left: 0.9em;
  right: 0.9em;
  top: 3.6em;
  display: flex;
  gap: 0.8em;
  align-items: center;
  padding: 0.9em 1.1em;
  background: rgba(250, 250, 250, 0.94);
  backdrop-filter: blur(14px);
  border-radius: 2em;
  box-shadow:
    0 0.1em 0 rgba(23, 23, 28, 0.05),
    0 1.2em 2.4em -0.6em rgba(23, 23, 28, 0.35);
  transform: translateY(-160%);
  opacity: 0;
  transition:
    transform 0.5s cubic-bezier(0.3, 0.8, 0.2, 1),
    opacity 0.3s;
}

.demo-banner img {
  flex: none;
  width: 2.8em;
  height: 2.8em;
  border-radius: 0.7em;
}

.demo-banner-text {
  flex: 1;
  min-width: 0;
}

.demo-banner-top {
  display: flex;
  justify-content: space-between;
  gap: 0.6em;
  font-size: 1em;
}

.demo-banner-top span {
  color: #6b6b73;
  font-size: 0.9em;
}

.demo-banner-sub {
  font-size: 0.85em;
  color: #3b3b43;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.is-banner .demo-banner {
  transform: none;
  opacity: 1;
}

.is-convo .demo-banner {
  transform: translateY(-160%);
  opacity: 0;
}

/* conversation */

.demo-convo-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1em;
  padding: 0.8em 1.2em 1em;
  border-bottom: 1px solid var(--line);
}

.demo-back,
.demo-dots {
  flex: none;
  width: 2.2em;
  height: 2.2em;
  fill: none;
  stroke: var(--ink);
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.demo-dots {
  fill: var(--ink);
  stroke: none;
}

.demo-convo-who {
  text-align: center;
}

.demo-convo-name {
  font-size: 1.15em;
  font-weight: 650;
}

.demo-convo-state {
  font-size: 0.9em;
  color: #6b6b73;
}

.demo-convo-thread {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 1em;
  padding: 1.2em 1.2em;
  background: #f5f4f2;
  overflow: hidden;
}

.demo-day {
  align-self: center;
  padding: 0.25em 0.9em;
  border-radius: 99px;
  background: #ebeae7;
  color: #5b5b64;
  font-size: 0.85em;
  font-weight: 600;
}

.demo-c-row {
  display: flex;
  align-items: flex-end;
  gap: 0.7em;
}

.demo-c-row > div {
  min-width: 0;
}

.demo-c-bubble {
  display: inline-block;
  max-width: 100%;
  padding: 0.9em 1.2em;
  border-radius: 1.6em;
  background: #fff;
  font-size: 1.1em;
  line-height: 1.4;
  overflow-wrap: anywhere;
}

.demo-c-meta {
  margin-top: 0.3em;
  padding: 0 0.3em;
  color: #6b6b73;
  font-size: 0.85em;
}

.demo-c-out {
  display: none;
  flex-direction: column;
  align-items: flex-end;
}

.demo-c-out .demo-c-meta {
  text-align: right;
}

.demo-c-mine {
  background: var(--accent);
  border-bottom-right-radius: 0.5em;
}

.demo-c-typing {
  display: flex;
  gap: 0.35em;
  padding: 1.05em 1.3em;
  background: #ffe3d2;
}

.demo-c-typing i {
  width: 0.55em;
  height: 0.55em;
  border-radius: 50%;
  background: var(--demo-orange-ink);
  animation: demo-dot 1s infinite ease-in-out;
}

.demo-c-typing i:nth-child(2) {
  animation-delay: 0.15s;
}
.demo-c-typing i:nth-child(3) {
  animation-delay: 0.3s;
}

.is-typing .demo-typing {
  display: flex;
  animation: demo-pop 0.3s ease-out;
}

.is-reply .demo-typing {
  display: none;
}

.is-reply .demo-c-agent {
  display: flex;
  animation: demo-pop 0.3s ease-out;
}

.demo-convo-foot {
  padding: 0.9em 1.2em 1.6em;
  border-top: 1px solid var(--line);
  background: #fff;
}

.demo-tabs {
  display: inline-flex;
  padding: 0.2em;
  border-radius: 0.9em;
  background: #f0efec;
  font-size: 0.85em;
  font-weight: 650;
  color: #5b5b64;
}

.demo-tabs span {
  padding: 0.55em 1em;
  border-radius: 0.7em;
}

.demo-tabs .is-on {
  background: #fff;
  color: var(--ink);
}

.demo-reply {
  display: flex;
  align-items: center;
  gap: 0.7em;
  margin-top: 0.9em;
}

.demo-reply-in {
  flex: 1;
  min-width: 0;
  padding: 0.8em 1.1em;
  border: 1px solid var(--line);
  border-radius: 99px;
  color: #7a7a83;
  font-size: 0.95em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.demo-reply-go {
  flex: none;
  display: grid;
  place-items: center;
  width: 2.8em;
  height: 2.8em;
  border-radius: 50%;
  background: #ffd3b8;
}

.demo-reply-go svg {
  width: 1.5em;
  height: 1.5em;
  fill: none;
  stroke: #fff;
  stroke-width: 2.4;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* ------------------------------------------------------------- note, reset */

.demo-foot {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 16px;
  min-height: 40px;
  margin-top: 12px;
}

.demo-reset {
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 0.875rem;
  font-weight: 650;
  cursor: pointer;
  transition: border-color 0.15s;
}

.demo-reset:hover {
  border-color: var(--accent);
}

.demo-reset[hidden] {
  display: none;
}

/* ------------------------------------------------------------- animations */

@keyframes demo-pop {
  from {
    opacity: 0;
    transform: translateY(0.8em) scale(0.97);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes demo-dot {
  0%,
  70%,
  100% {
    opacity: 0.35;
    transform: translateY(0);
  }
  35% {
    opacity: 1;
    transform: translateY(-0.2em);
  }
}

@media (prefers-reduced-motion: reduce) {
  .demo *,
  .demo *::before,
  .demo *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ narrow column */

@container (max-width: 480px) {
  .demo-stage {
    height: 66em;
    font-size: calc(100cqw / 40);
    clip-path: inset(-4em -4em 0 -4em);
  }

  .demo-widget {
    left: 0.8em;
    width: 29em;
    height: 43em;
  }

  .demo-w-head {
    padding: 1.6em 1.6em 1.2em;
  }

  .demo-thread {
    padding: 1.2em 1.6em;
  }

  .demo-w-foot {
    padding: 1em 1.6em 1.8em;
  }

  .demo-phone {
    top: 41.5em;
    width: 22em;
  }

  .demo-frame {
    font-size: 0.846em;
  }
}
