/* ──────────────────────────────────────────────────────────────────
   AI Co-pilot - the jelly-UFO mascot + the chat panel (js/ai-copilot.js)
   ──────────────────────────────────────────────────────────────────
   One brand mascot (a translucent purple jellyfish-UFO that casts a spotlight),
   used as the floating launcher + the panel header mark + (later) the nav beacon.
   Mobile = bottom sheet; desktop = bottom-right corner dock. Purple only; all
   animation is transform/opacity (cheap) and killed under prefers-reduced-motion.
   Colours/fonts come from the app tokens (assets/style.css) - never re-declared. */

/* ── Jelly-UFO mascot ─────────────────────────────────────────────── */
.cp-ufo { position: relative; width: 64px; height: 78px; flex: none; }
.cp-ufo.float { animation: cpFloat 4s ease-in-out infinite; }
.cp-ufo .glow { position: absolute; left: 50%; top: 30px; transform: translate(-50%,-50%); width: 84px; height: 84px; border-radius: 50%;
  background: radial-gradient(circle, rgba(155,114,255,.5), transparent 62%); filter: blur(3px); animation: cpGlow 3.2s ease-in-out infinite; z-index: 0; }
/* Medusa bell: a tall translucent umbrella dome (the elliptical /-radii make the
   top domed and the bottom wide) with a frilly scalloped skirt (::after) hanging
   over the tentacles - a real jellyfish silhouette, not a flat saucer. */
.cp-ufo .bell { position: absolute; left: 50%; top: 2px; transform: translateX(-50%); width: 54px; height: 39px; z-index: 2;
  border-radius: 50% 50% 40% 40% / 66% 66% 40% 40%;
  background: radial-gradient(130% 138% at 50% 12%, rgba(234,226,255,.95), rgba(178,142,255,.86) 42%, rgba(134,100,224,.74) 72%, rgba(108,76,200,.55));
  box-shadow: 0 0 20px 4px rgba(155,114,255,.5), inset 0 5px 10px rgba(255,255,255,.5), inset 0 -13px 17px rgba(86,56,168,.5);
  animation: cpPulse 2.4s ease-in-out infinite; }
.cp-ufo .bell::before { content: ""; position: absolute; left: 21%; top: 11%; width: 32%; height: 22%; border-radius: 50%; background: rgba(255,255,255,.78); filter: blur(1.5px); }
.cp-ufo .bell::after { content: ""; position: absolute; left: 2px; right: 2px; bottom: -4px; height: 9px;
  background: radial-gradient(circle at 50% 0, rgba(138,102,212,.9) 4.6px, transparent 5.1px) 0 0 / 10px 9px repeat-x; }
.cp-ufo .eyes { position: absolute; left: 50%; top: 23px; transform: translateX(-50%); display: flex; gap: 13px; z-index: 3; }
.cp-ufo .eyes i { width: 8px; height: 9px; border-radius: 50%; position: relative;
  background: radial-gradient(circle at 38% 30%, #ffffff, #f1ebff 50%, #cdbcff); box-shadow: 0 0 8px #e6dcff; animation: cpBlink 4.2s ease-in-out infinite; }
.cp-ufo .eyes i::after { content: ""; position: absolute; left: 1.5px; top: 1px; width: 3px; height: 3px; border-radius: 50%; background: #fff; } /* catchlight glint - alive, not blank */
/* little smile - the single biggest "cute, not rude" lever */
.cp-ufo .mouth { position: absolute; left: 50%; top: 31px; transform: translateX(-50%); width: 9px; height: 4.5px; z-index: 3;
  border: 1.6px solid rgba(92,60,172,.6); border-top: 0; border-radius: 0 0 9px 9px; }
/* soft blush cheeks */
.cp-ufo .blush { position: absolute; top: 25px; width: 8px; height: 5px; border-radius: 50%; z-index: 3;
  background: radial-gradient(circle, rgba(255,140,198,.5), transparent 70%); filter: blur(.5px); }
.cp-ufo .blush.l { left: 11px; } .cp-ufo .blush.r { right: 11px; }
.cp-ufo .tent { position: absolute; left: 50%; top: 40px; transform: translateX(-50%); width: 50px; height: 30px; z-index: 2; }
.cp-ufo .tent i { position: absolute; top: 0; width: 3px; border-radius: 0 0 3px 3px; transform-origin: top center;
  background: linear-gradient(rgba(196,178,255,.95), rgba(155,114,255,0)); animation: cpSway 2.8s ease-in-out infinite; }
.cp-ufo .tent i:nth-child(1){ left: 6px;  height: 20px; animation-delay: 0s; }
.cp-ufo .tent i:nth-child(2){ left: 16px; height: 27px; animation-delay: .35s; }
.cp-ufo .tent i:nth-child(3){ left: 24px; height: 24px; animation-delay: .7s; }
.cp-ufo .tent i:nth-child(4){ left: 33px; height: 27px; animation-delay: 1.05s; }
.cp-ufo .tent i:nth-child(5){ left: 43px; height: 19px; animation-delay: 1.4s; }
.cp-ufo .beam { position: absolute; left: 50%; top: 48px; transform: translateX(-50%); width: 46px; height: 30px; z-index: 1;
  background: linear-gradient(to bottom, rgba(176,142,255,.55), rgba(155,114,255,0) 86%); clip-path: polygon(28% 0, 72% 0, 100% 100%, 0 100%);
  filter: blur(.7px); animation: cpBeam 3s ease-in-out infinite; }
@keyframes cpFloat { 0%,100%{ transform: translateY(0); } 50%{ transform: translateY(-6px); } }
@keyframes cpPulse { 0%,100%{ transform: translateX(-50%) scaleY(1) scaleX(1); } 50%{ transform: translateX(-50%) scaleY(.9) scaleX(1.07); } }
@keyframes cpSway  { 0%,100%{ transform: rotate(-9deg); } 50%{ transform: rotate(9deg); } }
@keyframes cpGlow  { 0%,100%{ opacity: .45; transform: translate(-50%,-50%) scale(.9); } 50%{ opacity: .85; transform: translate(-50%,-50%) scale(1.12); } }
@keyframes cpBeam  { 0%,100%{ opacity: .4; } 50%{ opacity: .8; } }
@keyframes cpBlink { 0%,92%,100%{ transform: scaleY(1); } 96%{ transform: scaleY(.12); } }

/* Small inline mark (panel header). A CLIPPED wrapper that transform-scales the
   whole mascot - so its glow + bell-shadow can't poke out past the header (the
   old per-child overrides let the haze bleed up into the nav). No float/beam. */
.cp-ufo-mini { display: inline-block; width: 30px; height: 34px; overflow: hidden; flex: none; }
.cp-ufo-mini .cp-ufo { transform: scale(.44); transform-origin: top left; }
.cp-ufo-mini .cp-ufo .beam { display: none; }

/* ── Launcher (the floating pet) ──────────────────────────────────── */
.cp-launch { position: fixed; right: 16px; bottom: calc(var(--bottom-nav-h, 0px) + 16px); z-index: 1200;
  width: 64px; height: 70px; display: flex; align-items: flex-start; justify-content: center; cursor: pointer;
  background: none; border: none; padding: 0; -webkit-tap-highlight-color: transparent; }
.cp-launch:focus-visible { outline: 2px solid var(--purple); outline-offset: 4px; border-radius: 16px; }
.cp-launch .cp-badge { position: absolute; right: 0; top: 4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 9px;
  background: var(--purple); color: #0a0d14; font: 800 10px var(--mono); display: flex; align-items: center; justify-content: center; z-index: 5; }
.cp-launch[hidden] { display: none; }

/* ── Panel ────────────────────────────────────────────────────────── */
.cp-backdrop { position: fixed; inset: 0; background: rgba(4,6,10,.55); z-index: 1290; opacity: 0; transition: opacity .2s; }
.cp-backdrop.open { opacity: 1; }
.cp-panel { position: fixed; z-index: 1300; background: var(--bg-card); border: 1px solid var(--border3);
  display: flex; flex-direction: column; box-shadow: 0 -20px 60px rgba(0,0,0,.5); }
.cp-panel[hidden] { display: none; }

/* desktop: corner dock */
@media (min-width: 861px) {
  .cp-panel { right: 18px; bottom: 18px; width: 384px; max-height: min(620px, 80vh); border-radius: 16px; box-shadow: 0 24px 70px rgba(0,0,0,.55); }
  .cp-backdrop { display: none; }
  .cp-grip { display: none; }
  /* shrink the floating pet 10% on desktop (origin bottom-right keeps it cornered;
     the float animation lives on the inner .cp-ufo, so it's untouched). */
  .cp-launch { transform: scale(.9); transform-origin: bottom right; }
}
/* mobile: bottom sheet */
@media (max-width: 860px) {
  .cp-panel { left: 0; right: 0; bottom: 0; border-radius: 20px 20px 0 0; max-height: 82vh; border-bottom: none;
    padding-bottom: calc(env(safe-area-inset-bottom, 0px)); animation: cpSheetUp .24s cubic-bezier(.2,.8,.2,1); }
  @keyframes cpSheetUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
  /* 90% of users are on mobile - shrink the floating pet 15% so it sits lighter
     in the corner. Scale the launcher itself (origin bottom-right keeps it in the
     corner); the float animation lives on the inner .cp-ufo, so it's untouched. */
  .cp-launch { transform: scale(.75); transform-origin: bottom right; }
}

.cp-grip { width: 38px; height: 4px; border-radius: 2px; background: var(--border3); margin: 10px auto 4px; }
.cp-head { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-bottom: 1px solid var(--border); }
.cp-head .cp-ufo-mini { margin: 0 -1px; }
.cp-head .t { font-weight: 700; font-size: 14.5px; color: var(--text-hi); line-height: 1.2; }
.cp-head .t small { display: block; font-weight: 500; font-size: 11px; color: var(--text-lo); }
.cp-credits { margin-left: auto; display: inline-flex; align-items: center; gap: 5px; background: var(--purple-dim, rgba(155,114,255,.12));
  border: 1px solid rgba(155,114,255,.3); color: var(--purple); font: 700 11px var(--mono); padding: 4px 9px; border-radius: 999px; white-space: nowrap; }
.cp-credits .dot { width: 6px; height: 6px; border-radius: 50%; background: var(--purple); box-shadow: 0 0 6px var(--purple); }
.cp-close { margin-left: 8px; background: none; border: none; color: var(--text-lo); cursor: pointer; display: flex; padding: 4px; }
.cp-close svg { width: 18px; height: 18px; fill: currentColor; }

.cp-msgs { flex: 1; overflow-y: auto; padding: 14px; display: flex; flex-direction: column; gap: 12px; }
.cp-m { max-width: 88%; padding: 10px 13px; border-radius: 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.cp-m.user { align-self: flex-end; background: var(--purple); color: #0a0d14; font-weight: 600; border-bottom-right-radius: 5px; }
.cp-m.ai { align-self: flex-start; background: var(--bg-card2, #161a25); border: 1px solid var(--border); color: var(--text-md); border-bottom-left-radius: 5px; }
.cp-m.ai .cp-foot { display: flex; gap: 8px; margin-top: 9px; font: 600 10px var(--mono); color: var(--text-lo); }
.cp-m.ai .cp-foot .chip { background: var(--bg-card); border: 1px solid var(--border); border-radius: 6px; padding: 2px 7px; }
.cp-m a.cp-link { color: var(--purple); font-weight: 700; text-decoration: none; border-bottom: 1px solid rgba(155,114,255,.4); }
/* Readability: emphasise the meaningful tokens in an answer. Flow words use the
   app flow tokens so admin colour overrides apply; numbers brighten, exchanges
   take the brand accent, wallet addresses go mono. */
.cp-m.ai .cp-h-num { color: var(--text-hi); font-weight: 700; }
.cp-m.ai .cp-h-in  { color: var(--flow-in);  font-weight: 600; }
.cp-m.ai .cp-h-out { color: var(--flow-out); font-weight: 600; }
/* linkified tokens: clickable, no underline, dotted hint on hover */
.cp-m.ai a.cp-h-link { text-decoration: none; cursor: pointer; border-bottom: 1px dashed transparent; }
.cp-m.ai a.cp-h-link:hover { border-bottom-color: currentColor; }
.cp-m.ai .cp-h-cex  { color: var(--purple); font-weight: 600; }
.cp-m.ai .cp-h-tok  { color: var(--accent-2, var(--purple)); font-weight: 700; white-space: nowrap; }
.cp-m.ai .cp-h-ico { display: inline-flex; vertical-align: -3px; margin-right: 3px; }
.cp-m.ai .cp-h-ico img, .cp-m.ai .cp-h-ico span { width: 14px !important; height: 14px !important; border-radius: 50%; }
.cp-m.ai .cp-h-page { color: var(--purple); font-weight: 600; }
.cp-m.ai .cp-h-addr { font-family: var(--mono); font-size: 12.5px; color: var(--text-hi); }
.cp-m.err { align-self: flex-start; background: var(--bg-card2); border: 1px solid var(--flow-out); color: var(--text-md); }
.cp-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 12px 14px; }
.cp-typing i { width: 7px; height: 7px; border-radius: 50%; background: var(--purple); opacity: .5; animation: cpType 1.1s ease-in-out infinite; }
.cp-typing i:nth-child(2){ animation-delay: .2s; } .cp-typing i:nth-child(3){ animation-delay: .4s; }
@keyframes cpType { 0%,100%{ opacity: .35; transform: translateY(0); } 50%{ opacity: 1; transform: translateY(-3px); } }

.cp-sugg { display: flex; gap: 7px; padding: 0 14px 4px; flex-wrap: wrap; }
.cp-sugg button { font: 600 11.5px var(--font); color: var(--text-md); background: var(--bg-card2); border: 1px solid var(--border);
  border-radius: 999px; padding: 6px 11px; cursor: pointer; }
.cp-sugg button:hover { border-color: var(--border3); color: var(--text-hi); }

.cp-ask { display: flex; align-items: center; gap: 8px; margin: 10px 14px 14px; background: var(--bg-card2); border: 1px solid var(--border3); border-radius: 12px; padding: 8px 10px 8px 13px; }
.cp-ask input { flex: 1; background: none; border: none; outline: none; color: var(--text-hi); font: 400 14px var(--font); min-width: 0; }
.cp-ask input::placeholder { color: var(--text-lo); }
.cp-ask .cp-send { width: 32px; height: 32px; flex: none; border: none; border-radius: 9px; background: var(--purple); display: flex; align-items: center; justify-content: center; cursor: pointer; }
.cp-ask .cp-send:disabled { opacity: .4; cursor: default; }
.cp-ask .cp-send svg { width: 16px; height: 16px; fill: #0a0d14; }

/* locked / guest state */
.cp-lock { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 10px; padding: 22px 18px 26px; }
.cp-lock .cp-ufo { margin-bottom: 4px; }
.cp-lock h4 { margin: 0; font-size: 16px; color: var(--text-hi); }
.cp-lock p { margin: 0; font-size: 13px; color: var(--text-md); max-width: 270px; line-height: 1.5; }
.cp-lock .cp-cta { margin-top: 6px; background: var(--purple); color: #0a0d14; font-weight: 700; font-size: 14px; border: none; border-radius: 11px; padding: 11px 22px; cursor: pointer; }
.cp-lock .cp-alt { font-size: 12px; color: var(--text-lo); background: none; border: none; cursor: pointer; }

@media (prefers-reduced-motion: reduce) {
  .cp-ufo.float, .cp-ufo .bell, .cp-ufo .tent i, .cp-ufo .glow, .cp-ufo .beam, .cp-ufo .eyes i,
  .cp-panel, .cp-typing i { animation: none !important; }
}
