/* "Discuss a project" messenger (assets/js/messenger.js). Hand-written, not
   built by vite. A full-screen sheet on phones, a panel in the corner on wide
   screens; the header is a strip of the services departures board. */

.dmr-chat {
  --dmr-chat-night: hsl(225, 12%, 7%);
  --dmr-chat-ink: hsl(40, 30%, 94%);
  --dmr-chat-amber: hsl(40, 96%, 60%);
  --dmr-chat-go: hsl(146, 62%, 52%);
  --dmr-chat-mono: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  position: fixed;
  inset: 0;
  display: none;
  flex-direction: column;
  width: 100%;
  max-width: none;
  height: 100%;
  max-height: none;
  margin: 0;
  padding: 0;
  overflow: hidden;
  border: 0;
  background: var(--background);
  color: var(--foreground);
  font-size: 1rem;
}

.dmr-chat[open] {
  display: flex;
  animation: dmr-chat-in 220ms cubic-bezier(0.2, 0.7, 0.2, 1);
}

@keyframes dmr-chat-in {
  from { opacity: 0; transform: translateY(1.5rem); }
}

.dmr-chat::backdrop {
  background: rgba(8, 9, 12, 0.45);
}

.dmr-chat__head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 0.875rem;
  align-items: center;
  padding: 1rem 1rem 0.875rem;
  padding-top: max(1rem, env(safe-area-inset-top));
  background: var(--dmr-chat-night);
  color: var(--dmr-chat-ink);
}

.dmr-chat__face {
  display: block;
  width: 2.75rem;
  height: 2.75rem;
  overflow: hidden;
  border-radius: 50%;
  background: hsl(225, 9%, 18%);
  box-shadow: 0 0 0 2px var(--dmr-chat-night), 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.dmr-chat__face img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.dmr-chat__who p {
  margin: 0;
}

.dmr-chat__kicker {
  color: var(--dmr-chat-amber);
  font: 600 0.625rem/1.3 var(--dmr-chat-mono);
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

[dir="rtl"] .dmr-chat__kicker {
  letter-spacing: 0;
}

.dmr-chat__name {
  font-weight: 700;
  font-size: 1.0625rem;
  line-height: 1.3;
}

.dmr-chat__presence {
  font-size: 0.8125rem;
  line-height: 1.35;
  opacity: 0.75;
}

.dmr-chat__presence.is-online {
  color: var(--dmr-chat-go);
  opacity: 1;
}

.dmr-chat__presence.is-online::before {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  margin-inline-end: 0.375rem;
  border-radius: 50%;
  background: currentColor;
  content: '';
}

.dmr-chat__close {
  display: grid;
  place-items: center;
  width: 2.5rem;
  height: 2.5rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.08);
  color: inherit;
  cursor: pointer;
}

.dmr-chat__close:hover,
.dmr-chat__close:focus-visible {
  background: rgba(255, 255, 255, 0.16);
}

.dmr-chat__list {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
  padding: 1.25rem 1rem 0.5rem;
  overscroll-behavior: contain;
}

.dmr-chat__msg {
  max-width: 85%;
  padding: 0.625rem 0.875rem;
  border-radius: 1rem;
  line-height: 1.45;
  overflow-wrap: anywhere;
}

.dmr-chat__msg.is-studio {
  align-self: flex-start;
  border-end-start-radius: 0.25rem;
  background: color-mix(in srgb, var(--foreground) 7%, var(--background));
}

.dmr-chat__msg.is-visitor {
  align-self: flex-end;
  border-end-end-radius: 0.25rem;
  background: var(--dmr-chat-amber);
  color: hsl(225, 20%, 8%);
}

.dmr-chat__text {
  margin: 0;
  white-space: pre-wrap;
}

.dmr-chat__file {
  display: block;
  margin-top: 0.375rem;
  color: inherit;
  font-size: 0.875rem;
}

.dmr-chat__typing {
  min-height: 1.25rem;
  margin: 0;
  padding: 0 1rem;
  font-size: 0.8125rem;
  opacity: 0.65;
}

.dmr-chat__form {
  display: grid;
  gap: 0.625rem;
  margin: 0;
  padding: 0.75rem 1rem 1rem;
  padding-bottom: max(1rem, env(safe-area-inset-bottom));
  border-top: 1px solid var(--border);
}

.dmr-chat__identity {
  display: grid;
  gap: 0.5rem;
}

.dmr-chat__identity[hidden] {
  display: none;
}

.dmr-chat__field {
  display: grid;
  gap: 0.25rem;
  margin: 0;
  font-size: 0.8125rem;
  opacity: 0.9;
}

.dmr-chat__field input,
.dmr-chat__input {
  box-sizing: border-box;
  width: 100%;
  margin: 0;
  padding: 0.625rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 0.625rem;
  background: var(--background);
  color: var(--foreground);
  font: inherit;
  font-size: 1rem;
  line-height: 1.4;
  -webkit-appearance: none;
  appearance: none;
}

.dmr-chat__field input:focus,
.dmr-chat__input:focus {
  outline: none;
  border-color: var(--dmr-chat-amber);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--dmr-chat-amber) 30%, transparent);
}

.dmr-chat__row {
  display: flex;
  gap: 0.5rem;
  align-items: flex-end;
}

.dmr-chat__input {
  flex: 1;
  min-height: 2.75rem;
  max-height: 10rem;
  resize: none;
}

.dmr-chat__send {
  display: grid;
  flex: none;
  place-items: center;
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: var(--dmr-chat-amber);
  color: hsl(225, 20%, 8%);
  cursor: pointer;
}

[dir="rtl"] .dmr-chat__send svg {
  transform: scaleX(-1);
}

.dmr-chat__send:disabled {
  opacity: 0.55;
  cursor: progress;
}

.dmr-chat__send:focus-visible,
.dmr-chat__close:focus-visible {
  outline: 2px solid var(--dmr-chat-amber);
  outline-offset: 2px;
}

.dmr-chat__note {
  margin: 0;
  font-size: 0.8125rem;
}

.dmr-chat__note:empty {
  display: none;
}

@media (min-width: 45rem) {
  .dmr-chat {
    inset: auto 1.5rem 1.5rem auto;
    width: 24rem;
    height: min(38rem, calc(100vh - 3rem));
    border: 1px solid var(--border);
    border-radius: 1rem;
    box-shadow: 0 30px 70px -20px rgba(0, 0, 0, 0.55);
  }

  [dir="rtl"] .dmr-chat {
    inset: auto auto 1.5rem 1.5rem;
  }

  .dmr-chat::backdrop {
    background: rgba(8, 9, 12, 0.2);
  }
}

@media (prefers-reduced-motion: reduce) {
  .dmr-chat[open] {
    animation: none;
  }
}
