/* Bot face (templates/_botface.html, static/botface.js): the logo robot as a
   status glyph. One SVG, four states on data-state:
     running   indigo head, mint antenna, eyes open (blink + glance via JS)
     building  sun antenna blinking, eyes sweeping left and right
     stopped   grey head, eyes shut, "z z" drifting up (asleep)
     crashed   coral head, X eyes
   Size with width/height on .botface. Colours are app.css tokens. Reusable:
   link this file, import the macro, include botface.js for the eye motion. */

.botface { width: 40px; height: 40px; flex: none; overflow: visible; display: block; --bf-head: #5b5bd6; --bf-off: #a7a5c4; }
[data-theme="dark"] .botface { --bf-off: #5d5e7a; }
.botface .bf-head { fill: var(--bf-head); transition: fill 240ms var(--ease, ease); }
.botface .bf-visor { fill: #fff; }
.botface .bf-ant, .botface .bf-dot { fill: var(--mint); transition: fill 240ms var(--ease, ease); }
.botface .bf-eyes { transform: translateX(var(--bf-look, 0px)); transition: transform 320ms cubic-bezier(0.3, 0.7, 0.2, 1); }
.botface .bf-eye { fill: var(--bf-head); transform-box: fill-box; transform-origin: center; transition: transform 90ms ease-out; }
.botface .bf-lid, .botface .bf-x, .botface .bf-zz { display: none; fill: none; stroke-linecap: round; stroke-linejoin: round; }
.botface .bf-lid { stroke: var(--bf-off); stroke-width: 2.6; }
.botface .bf-x { stroke: #b42f2f; stroke-width: 2.6; }
.botface .bf-zz { stroke: var(--muted); stroke-width: 1.8; }
.botface.is-blink .bf-eye { transform: scaleY(0.12); }

/* building: sun antenna, the dot blinks, eyes sweep */
.botface[data-state="building"] :is(.bf-ant, .bf-dot) { fill: var(--sun); }
.botface[data-state="building"] .bf-dot { animation: bf-dot 0.9s steps(2, jump-none) infinite; }
.botface[data-state="building"] .bf-eyes { animation: bf-sweep 1.6s ease-in-out infinite; }

/* stopped: asleep */
.botface[data-state="stopped"] { --bf-head: var(--bf-off); }
.botface[data-state="stopped"] :is(.bf-ant, .bf-dot) { fill: var(--bf-off); }
.botface[data-state="stopped"] .bf-eyes { display: none; }
.botface[data-state="stopped"] :is(.bf-lid, .bf-zz) { display: block; }
.botface[data-state="stopped"] .bf-zz path { animation: bf-zz 2.8s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.botface[data-state="stopped"] .bf-zz path + path { animation-delay: 1.4s; }

/* crashed */
.botface[data-state="crashed"] { --bf-head: var(--coral); }
.botface[data-state="crashed"] :is(.bf-ant, .bf-dot) { fill: var(--coral); }
.botface[data-state="crashed"] .bf-eyes { display: none; }
.botface[data-state="crashed"] .bf-x { display: block; }
.botface[data-state="crashed"] .bf-head { animation: bf-shake 0.42s ease-in-out 1; transform-box: fill-box; transform-origin: center; }

@keyframes bf-dot { from { opacity: 1; } to { opacity: 0.25; } }
@keyframes bf-sweep { 0%, 100% { transform: translateX(-3.4px); } 50% { transform: translateX(3.4px); } }
@keyframes bf-zz { 0% { opacity: 0; transform: translate(-2px, 3px) scale(0.7); } 30%, 60% { opacity: 1; } 100% { opacity: 0; transform: translate(2px, -3px) scale(1); } }
@keyframes bf-shake { 0%, 100% { transform: none; } 25% { transform: translateX(-1.5px); } 75% { transform: translateX(1.5px); } }

@media (prefers-reduced-motion: reduce) {
  .botface .bf-eyes, .botface .bf-eye, .botface .bf-head { transition: none; }
  .botface[data-state] :is(.bf-dot, .bf-eyes, .bf-zz path, .bf-head) { animation: none; }
  .botface[data-state="stopped"] .bf-zz path { opacity: 1; }
}
