/* The website chat widget (sup-wg) for automation 03, and the Nordvik Home store palette.
   Shared by the hero's store mock (.sup-store), the live demo and the train demo. These
   selectors are global on purpose: this is a component, not a section. Everything is in em,
   so the caller scales the whole widget with --wg-fs (14px by default).
   Static and reduced-motion states turn every animation and transition off. */

/* Nordvik Home palette: a fictional store's light brand, used only inside these components */
.sup-wg,
.sup-store {
  --nv-paper: #f5f2ec;
  --nv-card: #ffffff;
  --nv-ink: #1c2320;
  --nv-muted: #6b716d;
  --nv-line: #e3ded4;
  --nv-pine: #2c4a3e;
  --nv-pine-2: #3a5e4f;
  --nv-tint: #e2ebe6;
  --nv-ok: #2f8a5b;
}

/* ---------- Widget frame ---------- */

.sup-wg {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  font-family: var(--font-sans);
  font-size: var(--wg-fs, 14px);
  line-height: 1.45;
  text-align: left;
  color: var(--nv-ink);
  background: var(--nv-paper);
  border-radius: 1.15em;
  border: 1px solid rgba(255, 255, 255, 0.06);
  box-shadow:
    0 2.4em 4.8em -1.6em rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(0, 0, 0, 0.25);
  overflow: hidden;
}

/* Header: store brand on pine */

.sup-wg-head {
  display: flex;
  align-items: center;
  gap: 0.7em;
  flex: none;
  padding: 0.9em 1em;
  background: var(--nv-pine);
  color: #fff;
}

.sup-wg-av {
  display: grid;
  place-items: center;
  flex: none;
  width: 2.3em;
  height: 2.3em;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.14);
  font-family: var(--font-display);
  font-size: 1.05em;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.sup-wg-who {
  display: flex;
  flex: 1;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}

.sup-wg-name {
  font-size: 0.95em;
  font-weight: 600;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sup-wg-sub {
  display: inline-flex;
  align-items: center;
  gap: 0.45em;
  margin-top: 0.15em;
  font-size: 0.74em;
  opacity: 0.82;
  white-space: nowrap;
}

.sup-wg-dot {
  display: inline-block;
  flex: none;
  width: 0.5em;
  height: 0.5em;
  border-radius: 50%;
  background: var(--nv-ok);
  box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9);
}

.sup-wg-subt {
  overflow: hidden;
  text-overflow: ellipsis;
}

.sup-wg-min {
  display: inline-flex;
  flex: none;
  margin-left: auto;
  font-size: 1.1em;
  opacity: 0.7;
}

.sup-wg-min svg {
  width: 1em;
  height: 1em;
}

/* Conversation */

/* The frame and body are painted in their final colour from the first frame: no transition
   may run on either background (no grey flash before the paper colour). */
.sup-wg,
.sup-wg-body {
  transition: none;
}

.sup-wg-body {
  position: relative;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  background: transparent;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 2.2em);
  mask-image: linear-gradient(to bottom, transparent 0, #000 2.2em);
}

.sup-wg-list {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  gap: 0.55em;
  padding: 0.9em 0.9em 0.6em;
  will-change: transform;
}

.sup-wg-sys {
  align-self: center;
  margin-bottom: 0.2em;
  padding: 0.25em 0.75em;
  border-radius: 999px;
  background: rgba(28, 35, 32, 0.05);
  font-size: 0.7em;
  color: var(--nv-muted);
}

.sup-wg-msg {
  display: flex;
  flex-direction: column;
  max-width: 86%;
  animation: sup-wg-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sup-wg-msg--in {
  align-self: flex-start;
  align-items: flex-start;
  transform-origin: bottom left;
}

.sup-wg-msg--out {
  align-self: flex-end;
  align-items: flex-end;
  transform-origin: bottom right;
}

.sup-wg-msg--cont {
  margin-top: -0.25em;
}

.sup-wg-bubble {
  display: block;
  padding: 0.62em 0.85em;
  border-radius: 1.05em;
  font-size: 0.93em;
  line-height: 1.4;
  white-space: normal;
  overflow-wrap: anywhere;
}

.sup-wg-msg--in .sup-wg-bubble {
  background: var(--nv-card);
  color: var(--nv-ink);
  border: 1px solid var(--nv-line);
  border-bottom-left-radius: 0.3em;
  box-shadow: 0 1px 1px rgba(28, 35, 32, 0.04), 0 3px 8px -4px rgba(28, 35, 32, 0.12);
}

.sup-wg-msg--out .sup-wg-bubble {
  background: var(--nv-pine);
  color: #fff;
  border-bottom-right-radius: 0.3em;
  box-shadow: 0 2px 6px -3px rgba(44, 74, 62, 0.45);
}

.sup-wg-text {
  display: inline;
}

.sup-wg-link {
  display: block;
  margin-top: 0.35em;
  color: var(--nv-pine);
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 0.18em;
  word-break: break-all;
}

.sup-wg-link svg {
  display: inline-block;
  width: 0.95em;
  height: 0.95em;
  margin-left: 0.2em;
  vertical-align: -0.1em;
}

.sup-wg-time {
  margin-top: 0.25em;
  padding: 0 0.2em;
  font-size: 0.68em;
  line-height: 1;
  color: var(--nv-muted);
}

/* Source chip: which document the answer came from */

.sup-wg-src {
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin-top: 0.4em;
  padding: 0.3em 0.7em 0.3em 0.55em;
  border-radius: 999px;
  background: var(--nv-tint);
  color: var(--nv-pine);
  border: 1px solid rgba(44, 74, 62, 0.16);
  font-size: 0.74em;
  font-weight: 500;
  line-height: 1.3;
  opacity: 0;
  transform: translateY(0.3em);
  transition: opacity 0.35s cubic-bezier(0.22, 1, 0.36, 1), transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.sup-wg-src svg {
  display: block;
  flex: none;
  width: 1em;
  height: 1em;
}

.sup-wg-src b {
  font-weight: 600;
}

.sup-wg-src.is-on {
  opacity: 1;
  transform: none;
  animation: sup-wg-src-flash 1.2s ease-out;
}

/* Typing bubble */

.sup-wg-msg--typing .sup-wg-bubble {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  padding: 0.7em 0.85em;
}

.sup-wg-msg--typing i {
  width: 0.42em;
  height: 0.42em;
  border-radius: 50%;
  background: var(--nv-muted);
  animation: sup-wg-dot 1.2s infinite ease-in-out;
}

.sup-wg-msg--typing i:nth-child(2) {
  animation-delay: 0.15s;
}

.sup-wg-msg--typing i:nth-child(3) {
  animation-delay: 0.3s;
}

/* Time jump divider */

.sup-wg-jump {
  align-self: center;
  display: inline-flex;
  align-items: center;
  gap: 0.4em;
  margin: 0.2em 0;
  padding: 0.3em 0.8em;
  border-radius: 999px;
  background: rgba(28, 35, 32, 0.06);
  color: var(--nv-muted);
  font-size: 0.72em;
  animation: sup-wg-in 0.34s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.sup-wg-jump svg {
  width: 1.2em;
  height: 1.2em;
  flex: none;
}

.sup-wg-clock-hand {
  transform-origin: 12px 12px;
  animation: sup-wg-clock 1.3s cubic-bezier(0.22, 1, 0.36, 1) both;
}

/* Quick-reply buttons (rare) */

.sup-wg-btns {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: 0.4em;
}

.sup-wg-btn {
  display: inline-flex;
  align-items: center;
  padding: 0.35em 0.8em;
  border-radius: 999px;
  border: 1px solid var(--nv-pine);
  background: transparent;
  color: var(--nv-pine);
  font-size: 0.8em;
  font-weight: 500;
  line-height: 1.3;
  transition: background-color 0.2s, color 0.2s, opacity 0.3s;
}

.sup-wg-btn.is-pressed {
  background: var(--nv-pine);
  color: #fff;
}

.sup-wg-btns.is-used .sup-wg-btn {
  opacity: 0.45;
}

.sup-wg-btns.is-used .sup-wg-btn.is-pressed {
  opacity: 1;
}

/* Input bar */

.sup-wg-input {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5em;
  flex: none;
  padding: 0.6em 0.7em;
  background: #fff;
  border-top: 1px solid var(--nv-line);
}

.sup-wg-field {
  position: relative;
  display: flex;
  align-items: center;
  flex: 1;
  min-width: 0;
  height: 2.3em;
  padding: 0 0.9em;
  border-radius: 999px;
  background: var(--nv-paper);
  font-size: 0.85em;
  color: var(--nv-ink);
}

.sup-wg-typed-clip {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.sup-wg-typed {
  display: inline-block;
  white-space: nowrap;
}

.sup-wg-typed:not(:empty)::after {
  content: "";
  display: inline-block;
  width: 1.5px;
  height: 1.05em;
  margin-left: 1px;
  vertical-align: -0.15em;
  background: var(--nv-pine);
  animation: sup-wg-caret 1s steps(2) infinite;
}

.sup-wg-ph {
  position: absolute;
  left: 0.9em;
  right: 0.9em;
  top: 50%;
  transform: translateY(-50%);
  color: var(--nv-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: none;
}

.sup-wg.is-composing .sup-wg-ph {
  display: none;
}

.sup-wg-send {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 2.3em;
  height: 2.3em;
  border-radius: 50%;
  background: var(--nv-pine);
  color: #fff;
  transition: background-color 0.2s;
}

.sup-wg-send svg {
  width: 1.1em;
  height: 1.1em;
  margin-left: -0.1em;
}

.sup-wg.is-composing .sup-wg-send {
  background: var(--nv-pine-2);
}

/* ---------- Keyframes ---------- */

@keyframes sup-wg-in {
  from {
    opacity: 0;
    transform: translateY(0.5em) scale(0.94);
  }
}

@keyframes sup-wg-dot {
  0%,
  60%,
  100% {
    opacity: 0.3;
  }
  30% {
    opacity: 1;
  }
}

@keyframes sup-wg-caret {
  to {
    visibility: hidden;
  }
}

@keyframes sup-wg-src-flash {
  0% {
    box-shadow: 0 0 0 0 rgb(255 255 255 / 0.75);
  }
  100% {
    box-shadow: 0 0 0 0.55em rgb(255 255 255 / 0);
  }
}

@keyframes sup-wg-clock {
  0% {
    transform: rotate(-720deg);
  }
  100% {
    transform: rotate(0);
  }
}

/* Static (seeked end states): nothing animates or transitions */

.sup-wg.is-static .sup-wg-msg,
.sup-wg.is-static .sup-wg-jump,
.sup-wg.is-static .sup-wg-src,
.sup-wg.is-static .sup-wg-clock-hand,
.sup-wg.is-static .sup-wg-msg--typing i,
.sup-wg.is-static .sup-wg-typed::after {
  animation: none !important;
  transition: none !important;
}

/* Reduced motion: same as static */

@media (prefers-reduced-motion: reduce) {
  .sup-wg .sup-wg-msg,
  .sup-wg .sup-wg-jump,
  .sup-wg .sup-wg-src,
  .sup-wg .sup-wg-clock-hand,
  .sup-wg .sup-wg-msg--typing i,
  .sup-wg .sup-wg-typed::after {
    animation: none !important;
    transition: none !important;
  }
}
