/**
 * Mechanic mascot guide — speech bubble, poses, staged bay UX.
 * Hammer frames (optional): drop images and set:
 *   --mech-hammer-a: url("../../assets/shop/jaikey-hammer-1.png");
 *   --mech-hammer-b: url("../../assets/shop/jaikey-hammer-2.png");
 */

.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.mech-guide {
  --mech-orange: #f97316;
  --mech-bubble-bg: #1a1a1f;
  --mech-bubble-border: rgba(249, 115, 22, 0.45);
  margin: 0 0 18px;
}

.mech-row {
  display: flex;
  align-items: flex-end;
  gap: 14px;
  margin-bottom: 16px;
}

.mech-avatar-wrap {
  position: relative;
  flex-shrink: 0;
  width: 96px;
  height: 96px;
}

.mech-avatar-wrap--sm {
  width: 72px;
  height: 72px;
}

.mech-avatar {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  transition: transform 0.25s ease;
}

/* Poses (CSS until custom frames land) */
.mech-avatar-wrap[data-mech-pose="wave"] .mech-avatar {
  animation: mech-wave 1.2s ease-in-out 1;
}

.mech-avatar-wrap[data-mech-pose="listen"] .mech-avatar,
.mech-avatar-wrap[data-mech-pose="keys"] .mech-avatar,
.mech-avatar-wrap[data-mech-pose="error"] .mech-avatar,
.mech-avatar-wrap[data-mech-pose="report"] .mech-avatar,
.mech-avatar-wrap[data-mech-pose="fixed"] .mech-avatar,
.mech-avatar-wrap[data-mech-pose="done"] .mech-avatar {
  /* Stage art is full illustrations — keep stable, soft pop-in */
  animation: mech-pose-in 0.35s ease-out;
}

@keyframes mech-pose-in {
  from {
    opacity: 0.65;
    transform: scale(0.96);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

/* Larger stage art on the main bay row */
.mech-guide .mech-avatar-wrap {
  width: 120px;
  height: 120px;
}

.mech-strip .mech-avatar-wrap--sm {
  width: 88px;
  height: 88px;
}

.mech-avatar-wrap[data-mech-pose="think"] .mech-avatar {
  animation: mech-think 1.4s ease-in-out infinite;
}

.mech-avatar-wrap.is-hammering .mech-avatar {
  animation: mech-hammer 0.45s ease-in-out infinite alternate;
}

/* Optional 2-frame hammer sheet via CSS variables */
.mech-avatar-wrap.is-hammering.has-hammer-frames .mech-avatar {
  animation: mech-hammer-frames 0.4s steps(1) infinite;
}

@keyframes mech-wave {
  0%,
  100% {
    transform: rotate(0deg);
  }
  25% {
    transform: rotate(-6deg) translateY(-2px);
  }
  50% {
    transform: rotate(5deg);
  }
  75% {
    transform: rotate(-4deg);
  }
}

@keyframes mech-think {
  0%,
  100% {
    transform: translateY(0);
    filter: drop-shadow(0 8px 18px rgba(0, 0, 0, 0.45));
  }
  50% {
    transform: translateY(-4px);
    filter: drop-shadow(0 12px 22px rgba(249, 115, 22, 0.25));
  }
}

@keyframes mech-hammer {
  from {
    transform: rotate(-8deg) translateY(0);
  }
  to {
    transform: rotate(10deg) translateY(3px);
  }
}

@keyframes mech-hammer-frames {
  0%,
  49% {
    content: "";
    /* swap background if using frame images on a div */
  }
}

.mech-bubble {
  position: relative;
  flex: 1;
  min-width: 0;
  max-width: 36rem;
  padding: 14px 16px 14px 18px;
  border-radius: 16px 16px 16px 6px;
  background: var(--mech-bubble-bg);
  border: 1px solid var(--mech-bubble-border);
  box-shadow:
    0 0 0 1px rgba(249, 115, 22, 0.08),
    0 12px 28px rgba(0, 0, 0, 0.35);
}

.mech-bubble::before {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 18px;
  width: 14px;
  height: 14px;
  background: var(--mech-bubble-bg);
  border-left: 1px solid var(--mech-bubble-border);
  border-bottom: 1px solid var(--mech-bubble-border);
  transform: rotate(45deg);
}

.mech-bubble-label {
  display: block;
  font-size: 0.65rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mech-orange);
  margin-bottom: 6px;
}

.mech-bubble p,
#mech-speech,
.mech-speech-text {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  line-height: 1.45;
  color: var(--text, #f4f4f5);
}

.mech-bubble-pop {
  animation: mech-bubble-in 0.35s ease-out;
}

@keyframes mech-bubble-in {
  from {
    opacity: 0;
    transform: translateY(6px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* Greet step: robot + type choices only — no manuals */
#mech-bay-root[data-mech-stage="greet"] #mech-stage-paste,
#mech-bay-root[data-mech-stage="greet"] #work-type-hint,
#mech-bay-root[data-mech-stage="greet"] #work-type-free-note,
#mech-bay-root[data-mech-stage="greet"] #input-quota,
#mech-bay-root[data-mech-stage="greet"] #input-actions-note {
  display: none !important;
}

/* Plan / quota chrome must not fight the robot on the bay */
#screen-input #beta-access-home,
#screen-input .bay-plan-strip,
#screen-input #input-quota {
  display: none !important;
}

.mech-type-choices {
  margin-top: 4px;
  justify-content: flex-start;
}

.mech-type-prompt {
  margin: 0 0 10px;
  font-size: 0.9rem;
  color: var(--muted, #a1a1aa);
}

.mech-back-type {
  margin-bottom: 12px;
}

.mech-stage-paste {
  animation: mech-bubble-in 0.3s ease-out;
}

/* Compact strip for running / offer / report */
.mech-strip {
  display: flex;
  align-items: flex-end;
  gap: 12px;
  margin: 0 0 16px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(249, 115, 22, 0.28);
  background:
    radial-gradient(ellipse 50% 80% at 10% 100%, rgba(249, 115, 22, 0.12), transparent 60%),
    rgba(0, 0, 0, 0.25);
}

.mech-strip .mech-bubble {
  box-shadow: none;
  background: rgba(0, 0, 0, 0.35);
}

.mech-strip .mech-bubble::before {
  bottom: 14px;
}

/* Type chips bigger as "choices" under robot */
#mech-bay-root[data-mech-stage="greet"] #type-chips {
  gap: 10px;
}

#mech-bay-root[data-mech-stage="greet"] #type-chips .chip-btn {
  min-height: 44px;
  padding: 10px 16px;
  font-size: 0.95rem;
}

@media (max-width: 640px) {
  .mech-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .mech-avatar-wrap {
    width: 80px;
    height: 80px;
  }

  .mech-bubble::before {
    left: 28px;
    bottom: auto;
    top: -7px;
    border-left: 1px solid var(--mech-bubble-border);
    border-bottom: none;
    border-top: 1px solid var(--mech-bubble-border);
  }
}

@media (prefers-reduced-motion: reduce) {
  .mech-avatar-wrap .mech-avatar,
  .mech-bubble-pop,
  .mech-stage-paste {
    animation: none !important;
  }
}
