/* ShiftHands hero mascot: a mini ShiftHands chat with the live 3D plush mascot.
   Self-contained: every rule is scoped under .hm. Colors mirror the app's dark theme (src/theme.ts).
   Palette: Facebook dark surfaces + Meta blue (tokens from /site/fonts.css, with fallbacks so the
   component still works standalone). No green, no purple, no orange. */
.hm {
  --hm-bg: var(--sh-card, #242526);
  --hm-bubble: var(--sh-raised, #3A3B3C);
  --hm-card: rgba(58, 59, 60, 0.94);
  --hm-pill: var(--sh-raised, #3A3B3C);
  --hm-field: var(--sh-raised, #3A3B3C);
  --hm-line: var(--sh-line-2, rgba(255, 255, 255, 0.12));
  --hm-text: var(--sh-text, #E4E6EB);
  --hm-muted: var(--sh-text-2, #B0B3B8);
  --hm-accent: var(--sh-blue-fb, #1877F2);
  --hm-accent-text: var(--sh-blue-text, #4599FF);
  --hm-accent-soft: var(--sh-blue-soft, rgba(8, 102, 255, 0.14));
  --hm-blue: var(--sh-blue, #0866FF);
  --hm-blue-dim: #1B3F7A;
  --hm-ring: #f5f3f6;
  --hm-focus: var(--sh-blue-text, #4599FF);
  --hm-avatar: 96px;
  --hm-height: 540px;

  position: relative;
  box-sizing: border-box;
  width: 100%;
  max-width: 460px;
  height: var(--hm-height);
  margin: 0 auto;
  overflow: hidden;
  border-radius: 24px;
  background: var(--hm-bg);
  color: var(--hm-text);
  box-shadow: 0 30px 80px -30px rgba(0, 0, 0, 0.8), 0 0 0 1px rgba(255, 255, 255, 0.06);
  font-family: var(--sh-font, "Figtree", -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, Arial, sans-serif);
  font-size: 15px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  contain: layout paint;
  isolation: isolate;
  text-align: left;
}
.hm *, .hm *::before, .hm *::after { box-sizing: border-box; }

/* corner buttons (decorative, like the app's sidebar / new-chat corners) */
.hm-corner {
  position: absolute; top: 14px; z-index: 4;
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--hm-pill); display: grid; place-items: center;
  color: var(--hm-text); pointer-events: none;
}
.hm-corner svg { width: 17px; height: 17px; }
.hm-corner.l { left: 14px; }
.hm-corner.r { right: 14px; }

/* header: floating avatar + two-line name card + Live tag */
.hm-head {
  position: absolute; left: 0; right: 0; top: 0; z-index: 3;
  display: flex; flex-direction: column; align-items: center;
  padding-top: 36px; pointer-events: none;
}
.hm-avatar {
  position: relative; width: var(--hm-avatar); height: var(--hm-avatar); flex: none;
  border-radius: 50%; background: var(--hm-ring);
}
/* the sprite canvas overhangs the circle (the renders pop out of the top), canvas units 224 x 296, circle at y 72 */
.hm-avatar canvas, .hm-avatar .hm-poster {
  position: absolute;
  left: 0; top: calc(var(--hm-avatar) * -72 / 216);
  width: calc(var(--hm-avatar) * 224 / 216); height: calc(var(--hm-avatar) * 296 / 216);
  pointer-events: none;
}
.hm-avatar .hm-poster img { position: absolute; display: block; max-width: none; }
.hm-avatar .hm-poster img[hidden] { display: none; }
.hm-avatar canvas[hidden], .hm-avatar .hm-poster[hidden] { display: none; }
.hm-sparkle { position: absolute; inset: 0; overflow: visible; opacity: 0; pointer-events: none; }
.hm-sparkle.on { animation: hm-sparkle 780ms ease-out both; }
@keyframes hm-sparkle { 0% { opacity: 0; } 28% { opacity: 1; } 100% { opacity: 0; } }

.hm-card {
  margin-top: -5px; position: relative; z-index: 1;
  padding: 6px 16px 7px; border-radius: 16px; background: var(--hm-card);
  display: flex; flex-direction: column; align-items: center; min-width: 150px; max-width: 250px;
}
.hm-name { font-size: 15.5px; font-weight: 600; line-height: 1.3; white-space: nowrap; }
.hm-status { display: flex; align-items: center; gap: 5px; font-size: 13.5px; color: var(--hm-muted); line-height: 1.35; white-space: nowrap; }
.hm-status svg { width: 13px; height: 13px; flex: none; }
.hm-status .hm-ic-work { display: none; }
.hm[data-state="working"] .hm-status .hm-ic-work { display: block; color: var(--hm-accent-text); }
.hm[data-state="working"] .hm-status .hm-ic-idle { display: none; }
.hm[data-state="working"] .hm-status-text { color: var(--hm-text); }

.hm-live {
  margin-top: 7px; display: inline-flex; align-items: center; gap: 5px;
  height: 21px; padding: 0 8px; border-radius: 11px;
  background: var(--hm-accent-soft); border: 0.5px solid var(--hm-accent);
  color: var(--hm-accent-text); font-size: 11.5px; font-weight: 600;
}
.hm-live i { width: 6px; height: 6px; border-radius: 50%; background: var(--hm-accent); }

/* messages: fixed box, newest at the bottom, no layout shift */
.hm-msgs {
  position: absolute; left: 0; right: 0; top: 210px; bottom: 84px; z-index: 1;
  -webkit-mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
  mask-image: linear-gradient(to bottom, transparent 0, #000 28px);
  display: flex; flex-direction: column; justify-content: flex-end; gap: 12px;
  padding: 0 18px 8px; overflow: hidden;
}
.hm-empty { margin: 0 auto 6px; max-width: 280px; text-align: center; font-size: 13.5px; line-height: 1.45; color: var(--hm-muted); }
.hm-row { display: flex; }
.hm-row.me { justify-content: flex-end; }
.hm-bubble {
  max-width: 84%; padding: 9px 14px; border-radius: 20px;
  font-size: 14.5px; line-height: 1.45; overflow-wrap: anywhere;
}
.hm-row.me .hm-bubble { background: var(--hm-blue); color: #fff; border-bottom-right-radius: 6px; }
.hm-row.agent .hm-bubble { background: var(--hm-bubble); color: var(--hm-text); max-width: 92%; border-bottom-left-radius: 6px; }
.hm-usage { margin-top: 8px; font-size: 11.5px; line-height: 1.4; color: var(--hm-muted); }
.hm-usage b { font-weight: 600; color: var(--hm-accent-text); }
.hm-caret { display: inline-block; width: 7px; height: 1em; margin-left: 1px; vertical-align: -2px; background: var(--hm-accent); border-radius: 1px; animation: hm-blink 0.9s steps(1) infinite; }
@keyframes hm-blink { 50% { opacity: 0; } }
.hm-dots { display: inline-flex; gap: 4px; padding: 3px 0; }
.hm-dots i { width: 6px; height: 6px; border-radius: 50%; background: var(--hm-muted); animation: hm-dot 1.1s infinite ease-in-out; }
.hm-dots i:nth-child(2) { animation-delay: 0.15s; }
.hm-dots i:nth-child(3) { animation-delay: 0.3s; }
@keyframes hm-dot { 0%, 80%, 100% { opacity: 0.3; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }
.hm-enter { animation: hm-in 260ms ease-out both; }
@keyframes hm-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* floating composer */
.hm-composer {
  position: absolute; left: 14px; right: 14px; bottom: 14px; z-index: 3;
  display: flex; align-items: center; gap: 6px;
  min-height: 56px; padding: 8px 8px 8px 18px; border-radius: 30px;
  background: var(--hm-field); box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  margin: 0;
}
.hm-composer:focus-within { box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45), 0 0 0 2px var(--hm-focus); }
.hm-input {
  flex: 1; min-width: 0; height: 40px; margin: 0; padding: 0;
  border: 0; outline: 0; background: transparent; color: var(--hm-text);
  font: inherit; font-size: 16px; /* 16px: no iOS zoom on focus */
}
.hm-input::placeholder { color: var(--hm-muted); opacity: 1; }
.hm-input.ghost { color: var(--hm-muted); }
.hm-send {
  flex: none; width: 40px; height: 40px; border-radius: 50%; border: 0; padding: 0; margin: 0;
  display: grid; place-items: center; cursor: pointer;
  background: var(--hm-blue-dim); color: rgba(255, 255, 255, 0.6);
  transition: background-color 0.15s, color 0.15s;
}
.hm-send svg { width: 18px; height: 18px; }
.hm-send.ready { background: var(--hm-blue); color: #fff; }
.hm-send:focus-visible { outline: 2px solid var(--hm-focus); outline-offset: 2px; }
.hm-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }

@media (max-width: 480px) {
  .hm { --hm-avatar: 84px; --hm-height: 520px; border-radius: 20px; }
  .hm-head { padding-top: 32px; }
  .hm-msgs { top: 190px; bottom: 78px; padding: 0 12px 8px; }
  .hm-composer { left: 10px; right: 10px; bottom: 10px; }
  .hm-corner { top: 10px; width: 32px; height: 32px; }
  .hm-corner.l { left: 10px; }
  .hm-corner.r { right: 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .hm-enter, .hm-sparkle.on, .hm-caret, .hm-dots i { animation: none; }
  .hm-sparkle.on { opacity: 0; }
  .hm-dots i { opacity: 0.7; }
}
