/* =========================================================================
   Phoenix chat: a round button in the corner and a small chat panel.
   Same look as the app. The phoenix only flaps while it is thinking,
   so it costs nothing while it waits.
   ========================================================================= */

.pf-fab {
  position: fixed; right: 20px; bottom: 20px; z-index: 60;
  display: flex; align-items: center; gap: 4px; height: 56px; padding: 0 18px 0 4px;
  border-radius: 999px; background: var(--card); border: 1px solid rgba(57, 245, 138, .45);
  color: var(--ink); font-weight: 600; font-size: 15px;
  box-shadow: 0 0 0 1px rgba(57, 245, 138, .12), 0 10px 30px rgba(0, 0, 0, .45), 0 0 22px rgba(57, 245, 138, .18);
}
.pf-fab:hover { border-color: var(--neon-green); color: var(--neon-green); }
.pf-fab { touch-action: none; cursor: grab; transition: left .28s cubic-bezier(.2, .9, .3, 1.1), top .28s cubic-bezier(.2, .9, .3, 1.1); }
.pf-fab.pf-dragging { transition: none; cursor: grabbing; transform: scale(1.06); box-shadow: 0 0 0 2px var(--neon-green), 0 18px 40px rgba(0, 0, 0, .55); }
.pf-nudge { transition: left .28s, top .28s; }
.pf-fab-label { white-space: normal; }
.pf-open .pf-fab { display: none; }

/* only on the home page and inside the app, never over sign-in or loading */
body:not([data-screen="landing"]):not([data-screen="app"]) .pf-fab,
body:not([data-screen="landing"]):not([data-screen="app"]) .pf-panel { display: none !important; }

/* the loading-screen phoenix, shrunk */
.pf-art { position: relative; width: 48px; height: 48px; flex-shrink: 0; display: block; }
.pf-art .phoenix { position: absolute; left: 0; top: 0; transform: scale(.5); transform-origin: 0 0; }
.pf-art-sm { width: 40px; height: 40px; }
.pf-art-sm .phoenix { transform: scale(.4167); }
.pf-art .phoenix *, .pf-art .phoenix { animation-play-state: paused !important; }
.busy .pf-art .phoenix *, .pf-fab:hover .pf-art .phoenix * { animation-play-state: running !important; }

.pf-panel {
  position: fixed; right: 20px; bottom: 20px; z-index: 61;
  width: 380px; max-width: calc(100vw - 24px); height: min(600px, calc(100vh - 40px));
  display: flex; flex-direction: column;
  background: var(--paper); border: 1px solid var(--line); border-radius: 18px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .75), 0 0 0 1px rgba(57, 245, 138, .08);
  overflow: hidden;
}
.pf-panel[hidden] { display: none; }

.pf-head { display: flex; align-items: center; gap: 10px; padding: 10px 10px 10px 12px; border-bottom: 1px solid var(--line); background: var(--card); }
.pf-title { display: flex; flex-direction: column; line-height: 1.15; margin-right: auto; }
.pf-title b { font-family: var(--head); font-size: 17px; font-weight: 600; color: var(--ink); }
.pf-title small { font-family: var(--mono); font-size: 12px; color: var(--good); }
.pf-icon { width: 40px; height: 40px; display: grid; place-items: center; border-radius: 10px; color: var(--muted); }
.pf-icon:hover { color: var(--ink); background: var(--surface-2); }

.pf-log { flex: 1; min-height: 0; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.pf-msg { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.55; }
.pf-msg p { white-space: pre-wrap; overflow-wrap: anywhere; }
.pf-bot { align-self: flex-start; background: var(--card-2); color: var(--ink); border-bottom-left-radius: 4px; }
.pf-me { align-self: flex-end; background: rgba(57, 245, 138, .14); color: var(--ink); border: 1px solid rgba(57, 245, 138, .3); border-bottom-right-radius: 4px; }
.pf-err { color: var(--warn); }

.pf-typing { display: flex; gap: 5px; padding: 14px; }
.pf-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: pf-dot 1s ease-in-out infinite; }
.pf-typing i:nth-child(2) { animation-delay: .15s; }
.pf-typing i:nth-child(3) { animation-delay: .3s; }
@keyframes pf-dot { 0%, 100% { opacity: .3; transform: translateY(0); } 50% { opacity: 1; transform: translateY(-3px); } }

.pf-starters { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 14px 10px; }
.pf-starters[hidden] { display: none; }
.pf-chip { padding: 8px 12px; min-height: 36px; border-radius: 999px; border: 1px solid var(--line); background: var(--card); color: var(--ink); font-size: 13px; font-weight: 500; }
.pf-chip:hover { border-color: rgba(57, 245, 138, .5); color: var(--neon-green); }

.pf-form { display: flex; gap: 8px; align-items: flex-end; padding: 10px 12px; border-top: 1px solid var(--line); }
.pf-form textarea {
  flex: 1; resize: none; min-height: 44px; max-height: 120px; padding: 11px 12px; border-radius: 12px;
  background: var(--bg); border: 1px solid var(--line); color: var(--ink); font-size: 14px; line-height: 1.4;
}
.pf-form textarea:focus { outline: none; border-color: rgba(57, 245, 138, .55); }
.pf-send { width: 44px; height: 44px; padding: 0; flex-shrink: 0; border-radius: 12px; }
.pf-foot { padding: 0 14px 12px; font-size: 11px; line-height: 1.45; color: var(--muted); font-family: var(--mono); }
.pf-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 620px) {
  .pf-fab { right: 14px; bottom: 14px; height: 52px; padding: 0 4px; width: 52px; justify-content: center; }
  .pf-fab-label { display: none; }
  .pf-fab .pf-art { width: 44px; height: 44px; }
  .pf-fab .pf-art .phoenix { transform: scale(.4583); }
  .pf-panel { right: 0; bottom: 0; width: 100vw; max-width: 100vw; height: 100%; height: 100dvh; border-radius: 0; border: none; }
  .pf-form textarea { font-size: 16px; }   /* stops iPhones zooming in */
}

/* ------------------------------ live badge ------------------------------ */
.pf-fab-label { display: flex; flex-direction: column; gap: 1px; line-height: 1.15; text-align: left; max-width: 110px; }
.pf-fab-label b { font-weight: 600; font-size: 15px; white-space: nowrap; }
.pf-fab-label small { font-family: var(--mono); font-size: 10px; font-weight: 400; color: var(--good); white-space: normal; overflow-wrap: break-word; letter-spacing: 0; }
.pf-fab { padding-right: 16px; }
.pf-live {
  position: absolute; right: 1px; top: 3px; width: 11px; height: 11px; border-radius: 50%;
  background: var(--neon-green); border: 2px solid var(--card);
  box-shadow: 0 0 0 0 rgba(57, 245, 138, .6); animation: pf-live 2s ease-out infinite;
}
.pf-live-dot { display: inline-block; width: 7px; height: 7px; border-radius: 50%; background: var(--neon-green); margin-right: 6px; vertical-align: 1px; box-shadow: 0 0 6px rgba(57, 245, 138, .7); }
@keyframes pf-live { 0% { box-shadow: 0 0 0 0 rgba(57, 245, 138, .55); } 70%, 100% { box-shadow: 0 0 0 7px rgba(57, 245, 138, 0); } }

/* 7 seconds of wing flapping when the pop-up appears */
.pf-fab.flap .pf-art .phoenix * { animation-play-state: running !important; }
.pf-fab.flap { border-color: var(--neon-green); box-shadow: 0 0 0 1px rgba(57, 245, 138, .25), 0 10px 30px rgba(0, 0, 0, .45), 0 0 30px rgba(57, 245, 138, .35); }

/* ------------------------ "Got any RFQ questions?" ------------------------ */
.pf-nudge {
  position: fixed; right: 20px; bottom: 88px; z-index: 60; max-width: min(260px, calc(100vw - 32px));
  display: flex; align-items: flex-start; gap: 4px;
  background: var(--card); border: 1px solid rgba(57, 245, 138, .45); border-radius: 16px 16px 4px 16px;
  box-shadow: 0 14px 40px rgba(0, 0, 0, .55), 0 0 20px rgba(57, 245, 138, .15);
  transform-origin: 100% 100%;
}
.pf-nudge[hidden] { display: none; }
.pf-nudge.pf-pop { animation: pf-pop .45s cubic-bezier(.2, 1.6, .4, 1) both; }
@keyframes pf-pop { 0% { opacity: 0; transform: scale(.4) translateY(10px); } 100% { opacity: 1; transform: scale(1) translateY(0); } }
.pf-nudge-open { display: flex; flex-direction: column; gap: 3px; padding: 12px 4px 12px 14px; text-align: left; color: var(--ink); min-height: 44px; }
.pf-nudge-open b { font-family: var(--head); font-size: 16px; font-weight: 600; }
.pf-nudge-open small { font-size: 12px; color: var(--muted); line-height: 1.35; overflow-wrap: break-word; }
.pf-nudge-open:hover b { color: var(--neon-green); }
.pf-nudge-x { width: 36px; height: 36px; margin: 4px 4px 0 0; display: grid; place-items: center; border-radius: 10px; color: var(--muted); flex-shrink: 0; }
.pf-nudge-x:hover { color: var(--ink); background: var(--surface-2); }
.pf-open .pf-nudge { display: none; }
body:not([data-screen="landing"]):not([data-screen="app"]) .pf-nudge { display: none !important; }

@media (max-width: 620px) {
  .pf-fab { padding: 0 4px; width: 52px; }
  .pf-fab-label { display: none; }
  .pf-nudge { right: 14px; bottom: 76px; }
  .pf-live { right: 0; top: 1px; }
}
@media (prefers-reduced-motion: reduce) {
  .pf-nudge.pf-pop { animation-duration: .01s; }
  .pf-live { animation: none; }
}
