/* ------------------------------------------------------------------
   Support chat — floating launcher + conversation panel.
   Bottom-left: the trailing corner for an RTL page, and clear of the
   engine film on the right of the hero.
------------------------------------------------------------------ */
.support {
  --support-gap: max(20px, env(safe-area-inset-bottom));

  position: fixed;
  left: max(20px, env(safe-area-inset-left));
  bottom: var(--support-gap);
  z-index: 60;
  display: none;
  flex-direction: column;
  align-items: flex-start;
  gap: 14px;
  /* Lay the stack out physically (launcher pinned to the left corner);
     the content inside stays RTL. */
  direction: ltr;
}
.support > * { direction: rtl; }
.js .support { display: flex; }

/* ---------- Launcher ------------------------------------------------- */
.support__launcher {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  padding: 0;
  border: 1px solid rgb(210 172 104 / 0.45);
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #1a2233, #050a14 70%);
  box-shadow: 0 14px 36px rgb(0 0 0 / 0.55), 0 0 0 1px rgb(255 255 255 / 0.04) inset;
  color: var(--color-gold-soft);
  cursor: pointer;
  transition: transform 0.35s var(--ease-out), border-color 0.3s, box-shadow 0.3s;
  -webkit-tap-highlight-color: transparent;
}
.support__launcher:hover {
  transform: translateY(-2px);
  border-color: rgb(228 201 153 / 0.8);
  box-shadow: 0 18px 40px rgb(0 0 0 / 0.6), 0 0 24px rgb(210 172 104 / 0.25);
}
.support__launcher:active { transform: scale(0.95); }

/* A soft ring invites the first click, then stops. */
.support__launcher::before {
  content: "";
  position: absolute;
  inset: -1px;
  border: 1px solid var(--color-gold);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
}
.support.is-inviting .support__launcher::before {
  animation: support-ring 2.6s var(--ease-out) 3;
}
@keyframes support-ring {
  0% { opacity: 0.7; scale: 1; }
  100% { opacity: 0; scale: 1.6; }
}

.support__launcher-icon {
  grid-area: 1 / 1;
  display: grid;
  transition: opacity 0.25s, rotate 0.35s var(--ease-out), scale 0.35s var(--ease-out);
}
.support__launcher-icon svg,
.support__close svg,
.support__send svg {
  fill: none;
  stroke: currentColor;
  stroke-width: 1.7;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.support__launcher-icon svg { width: 24px; height: 24px; }
.support__launcher-icon--open {
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 50%;
}
.support__launcher-icon img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.support__launcher { border-width: 2px; }
.support__launcher-icon--close { opacity: 0; rotate: -90deg; scale: 0.6; }
.support.is-open .support__launcher-icon--open { opacity: 0; rotate: 90deg; scale: 0.6; }
.support.is-open .support__launcher-icon--close { opacity: 1; rotate: 0deg; scale: 1; }

/* ---------- Teaser --------------------------------------------------- */
/* A small bubble above the launcher that says what it's for. */
.support__teaser {
  position: relative;
  max-width: min(300px, calc(100vw - 40px));
  margin-bottom: 2px;
  transform-origin: 0 100%;
  animation: support-in 0.5s var(--ease-out) both;
}
.support__teaser[hidden] { display: none; }
.support__teaser.is-leaving { animation: support-out 0.2s ease-in both; }
/* Tail pointing down at the launcher. */
.support__teaser::after {
  content: "";
  position: absolute;
  left: 22px;
  bottom: -6px;
  width: 12px;
  height: 12px;
  rotate: 45deg;
  border-right: 1px solid rgb(210 172 104 / 0.35);
  border-bottom: 1px solid rgb(210 172 104 / 0.35);
  background: #0c1322;
}

.support__teaser-body {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 12px 16px;
  padding-inline-end: 38px;
  border: 1px solid rgb(210 172 104 / 0.35);
  border-radius: 16px;
  background: linear-gradient(to bottom, #111a2b, #0c1322);
  box-shadow: 0 16px 40px -8px rgb(0 0 0 / 0.65);
  font-family: var(--font-sans);
  text-align: start;
  color: var(--color-text);
  cursor: pointer;
  transition: border-color 0.25s, transform 0.3s var(--ease-out);
}
.support__teaser-body:hover {
  border-color: rgb(228 201 153 / 0.7);
  transform: translateY(-2px);
}
.support__teaser-avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border: 1px solid rgb(210 172 104 / 0.5);
  border-radius: 50%;
  object-fit: cover;
}
.support__teaser-text {
  display: grid;
  gap: 2px;
}
.support__teaser-body strong {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-gold-soft);
}
.support__teaser-body span {
  text-wrap: balance;
  font-size: 13px;
  line-height: 1.7;
  color: rgb(238 241 245 / 0.75);
}

.support__teaser-close {
  position: absolute;
  top: 8px;
  left: 8px;
  display: grid;
  place-items: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--color-text-muted);
  cursor: pointer;
}
.support__teaser-close:hover { background: rgb(255 255 255 / 0.08); color: var(--color-text); }
.support__teaser-close svg {
  width: 13px;
  height: 13px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* ---------- Panel ---------------------------------------------------- */
.support__panel {
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 40px));
  height: min(560px, calc(100svh - 120px));
  overflow: hidden;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 22px;
  background: linear-gradient(to bottom, #0b1220, #04070f);
  box-shadow: 0 30px 80px -10px rgb(0 0 0 / 0.75);
  transform-origin: 0 100%;
}
.support__panel[hidden] { display: none; }
.support__panel.is-entering { animation: support-in 0.38s var(--ease-out) both; }
.support__panel.is-leaving { animation: support-out 0.22s ease-in both; }
@keyframes support-in {
  from { opacity: 0; transform: translateY(12px) scale(0.94); }
}
@keyframes support-out {
  to { opacity: 0; transform: translateY(10px) scale(0.96); }
}

.support__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  border-bottom: 1px solid rgb(255 255 255 / 0.06);
}
.support__avatar {
  position: relative;
  display: grid;
  flex: none;
  place-items: center;
  width: 38px;
  height: 38px;
  overflow: hidden;
  border: 1px solid rgb(210 172 104 / 0.5);
  border-radius: 50%;
  background: #0c1322;
}
.support__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.support__heading { flex: 1; min-width: 0; }
.support__title {
  font-size: 15px;
  font-weight: 500;
  line-height: 1.4;
}
.support__subtitle {
  font-size: 12px;
  line-height: 1.5;
  color: var(--color-text-muted);
}
.support__close {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: rgb(255 255 255 / 0.04);
  color: var(--color-text-muted);
  cursor: pointer;
  transition: background-color 0.2s, color 0.2s;
}
.support__close:hover { background: rgb(255 255 255 / 0.09); color: var(--color-text); }
.support__close svg { width: 16px; height: 16px; }

/* ---------- Conversation -------------------------------------------- */
.support__log {
  display: flex;
  flex: 1;
  flex-direction: column;
  gap: 10px;
  padding: 16px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgb(255 255 255 / 0.12) transparent;
}

.support__row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: support-msg 0.35s var(--ease-out) both;
}
.support__row--user { flex-direction: row-reverse; }
@keyframes support-msg {
  from { opacity: 0; transform: translateY(10px) scale(0.97); }
}

.support__row .support__avatar {
  width: 28px;
  height: 28px;
}

.support__bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.85;
  overflow-wrap: anywhere;
}
.support__row--bot .support__bubble {
  border: 1px solid rgb(255 255 255 / 0.08);
  border-end-start-radius: 6px;
  background: rgb(255 255 255 / 0.05);
}
.support__row--user .support__bubble {
  border-end-end-radius: 6px;
  background: linear-gradient(135deg, #e4c999, #b88d48);
  color: #160f05;
  box-shadow: 0 8px 22px -6px rgb(210 172 104 / 0.45);
}
.support__bubble a { color: var(--color-gold-soft); }
.support__bubble a[dir="ltr"] { white-space: nowrap; unicode-bidi: isolate; }

.support__typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px 15px;
}
.support__typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgb(238 241 245 / 0.6);
  animation: support-dot 0.9s ease-in-out infinite;
}
.support__typing i:nth-child(2) { animation-delay: 0.15s; }
.support__typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes support-dot {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-3px); }
}

.support__chips {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-inline-start: 36px;
  animation: support-msg 0.35s var(--ease-out) both;
}
.support__chip {
  padding: 7px 13px;
  border: 1px solid rgb(210 172 104 / 0.38);
  border-radius: 999px;
  background: rgb(210 172 104 / 0.06);
  font: 500 13px/1.4 var(--font-sans);
  color: var(--color-gold-soft);
  text-decoration: none;
  cursor: pointer;
  transition: background-color 0.2s, border-color 0.2s;
}
.support__chip:hover {
  border-color: rgb(228 201 153 / 0.7);
  background: rgb(210 172 104 / 0.14);
}

/* ---------- Composer ------------------------------------------------- */
.support__composer {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 12px;
  padding: 6px 6px 6px 6px;
  padding-inline-start: 14px;
  border: 1px solid rgb(255 255 255 / 0.09);
  border-radius: 14px;
  background: rgb(255 255 255 / 0.04);
  transition: border-color 0.2s;
}
.support__composer:focus-within { border-color: rgb(210 172 104 / 0.5); }
.support__input {
  flex: 1;
  min-width: 0;
  border: 0;
  background: none;
  font: 400 14px/1.6 var(--font-sans);
  color: var(--color-text);
  outline: none;
}
.support__input::placeholder { color: rgb(238 241 245 / 0.35); }
.support__send {
  display: grid;
  flex: none;
  place-items: center;
  width: 36px;
  height: 36px;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: var(--color-gold-soft);
  color: #160f05;
  cursor: pointer;
  transition: opacity 0.2s, transform 0.2s;
}
.support__send:disabled { opacity: 0.3; cursor: default; }
.support__send:not(:disabled):hover { transform: scale(1.06); }
/* The icon points right; flip it to point along the RTL reading direction. */
.support__send svg { width: 16px; height: 16px; scale: -1 1; }

/* ---------- Small screens: a sheet above the launcher ---------------- */
@media (max-width: 480px) {
  .support { left: 14px; --support-gap: max(14px, env(safe-area-inset-bottom)); }
  .support__launcher { width: 54px; height: 54px; }
  .support__panel {
    width: calc(100vw - 28px);
    height: min(600px, calc(100svh - 100px));
  }
}

@media (prefers-reduced-motion: reduce) {
  .support__panel.is-entering,
  .support__panel.is-leaving,
  .support__row,
  .support__chips,
  .support.is-inviting .support__launcher::before,
  .support__teaser,
  .support__teaser.is-leaving { animation: none; }
  .support__typing i { animation: none; opacity: 0.6; }
}
