/* Floating dock: invitation bubble, launcher and the advisor panel.
 * The panel is the Cortex widget itself (see widget.css), so the page
 * demonstrates the product it sells. */

.dock {
  position: fixed;
  right: 18px;
  bottom: calc(18px + env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  --launcher: 62px;
}

.dock__launcher {
  position: relative;
  width: var(--launcher);
  height: var(--launcher);
  padding: 0;
  border: none;
  cursor: pointer;
  transition: transform .25s var(--ease);
}

.dock__launcher:hover {
  transform: scale(1.06);
}

.dock__launcher.wg-launcher {
  width: var(--launcher);
  height: var(--launcher);
}

.dock__launcher::after {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: var(--r-pill);
  background: var(--nx-cortex);
  opacity: 0;
  z-index: -1;
  animation: nxBreath 2.6s ease-out infinite;
}

.dock__launcher[aria-expanded="true"]::after {
  animation: none;
}

@keyframes nxBreath {
  0% {
    opacity: .55;
    transform: scale(1);
  }

  100% {
    opacity: 0;
    transform: scale(1.5);
  }
}

.dock__launcher-open,
.dock__launcher-close {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .2s var(--ease), transform .25s var(--ease);
}

.dock__launcher-close {
  color: var(--nx-ink);
  opacity: 0;
  transform: rotate(-45deg) scale(.6);
}

.dock__launcher-close .icon {
  --icon-size: 24px;
}

.dock__launcher[aria-expanded="true"] .dock__launcher-open {
  opacity: 0;
  transform: rotate(45deg) scale(.6);
}

.dock__launcher[aria-expanded="true"] .dock__launcher-close {
  opacity: 1;
  transform: none;
}

/* Invitation bubble: to the left of the launcher, centred on it */

.dock__bubble {
  position: absolute;
  right: calc(var(--launcher) + 16px);
  bottom: calc(var(--launcher) / 2);
  transform: translateY(50%);
  width: max-content;
  max-width: 260px;
  background: var(--nx-white);
  border: 1px solid var(--nx-bone-3);
  border-radius: var(--r-lg);
  box-shadow: 0 18px 40px -18px rgba(14, 28, 42, .45);
  padding: 14px 16px;
  display: flex;
  gap: 10px;
  align-items: flex-start;
  animation: nxReveal .35s var(--ease) both;
}

.dock__bubble[hidden] {
  display: none;
}

.dock__bubble-open {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  text-align: left;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.dock__bubble-title {
  font-size: 14.5px;
  font-weight: 700;
  color: var(--nx-ink);
}

.dock__bubble-text {
  font-size: 13.5px;
  color: var(--nx-500);
  line-height: 1.45;
}

.dock__bubble-close {
  background: none;
  border: none;
  cursor: pointer;
  padding: 2px;
  color: var(--nx-400);
  display: flex;
  flex: 0 0 auto;
}

.dock__bubble-close .icon {
  --icon-size: 15px;
}

.dock__bubble-tail {
  position: absolute;
  right: -7px;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-top: -7px;
  background: var(--nx-white);
  border-top: 1px solid var(--nx-bone-3);
  border-right: 1px solid var(--nx-bone-3);
  transform: rotate(45deg);
  display: block;
}

/* Advisor panel (a .wg widget) */

.chat {
  position: fixed;
  right: 18px;
  bottom: calc(18px + 62px + 14px + env(safe-area-inset-bottom));
  z-index: 121;
  width: 360px;
  height: min(540px, calc(100vh - 130px));
  max-height: calc(100vh - 130px);
  animation: nxReveal .3s var(--ease) both;
}

.chat[hidden] {
  display: none;
}

.chat .wg__body {
  overflow-y: auto;
}

.chat .wg__foot[hidden] {
  display: none;
}

@media (max-width: 1080px) {
  .dock {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom));
    --launcher: 58px;
  }

  .chat {
    right: 12px;
    bottom: calc(14px + 58px + 12px + env(safe-area-inset-bottom));
    width: min(420px, calc(100% - 24px));
  }
}

/* Phones: the invitation bubble would cover content, so it is dropped */
@media (max-width: 720px) {
  .dock__bubble {
    display: none;
  }
}

/* Short viewports (landscape phones): give the panel the whole height and
 * drop the launcher while it is open; the panel has its own close control. */
@media (max-height: 560px) {
  .chat {
    top: 12px;
    height: auto;
    max-height: none;
    bottom: calc(12px + env(safe-area-inset-bottom));
  }

  body.is-chat-open .dock {
    display: none;
  }
}
