/* People drawn as characters (app/art/people/character.ts): one colour in crayon, from the brand's
   countryside palette, and cream eyes, no gloss, as clear at 16px as at 128. A character on another
   surface sets --char-eye to it. */
:root{--char-green:#6A8128;--char-blue:#4793C6;--char-purple:#8E7CB0;--char-pink:#D2636B;--char-black:#453622;--char-grey:#B8A891}
:root[data-theme="dark"]{--char-black:#6E655B;--char-grey:#9C9282}

.char{flex:none;vertical-align:middle;overflow:visible;transform-origin:50% 90%}
.char-body{fill:var(--body)}
/* the crayon carries the colour just past the outline, so the grain reaches the edge */
.char-body{stroke:var(--body);stroke-width:2.6;stroke-linejoin:round}
.char-rim{fill:none;stroke:#fff;stroke-opacity:.26;stroke-width:2.4;stroke-dasharray:5 2.4;stroke-linecap:round;stroke-linejoin:round}
/* A mouth that only comes when they react: gone while they wait, there when they got what they came
   for or did not. */
.char-mouth{transition:opacity .25s ease-out}
.char-idle .char-mouth-reacts,.char-arrive .char-mouth-reacts,.char-thinking .char-mouth-reacts{opacity:0}
.char-eye{fill:var(--char-eye,#FFF6E2);transform-box:fill-box;transform-origin:50% 50%}
.char-smile{fill:none;stroke:var(--char-eye,#FFF6E2);stroke-linecap:round}

/* A character attends to a pointer that comes near (app/art/people/gaze.ts writes the values on its
   seat). The seat tilts as a turning head would and the eyes travel further than the body does, which
   is what gives a drawing its depth. The four --g numbers carry the pull into the body's own turn and
   lean, and --room holds it to what keeps the eyes clear of the body's edge. With the pointer right
   beside it each nature takes its own small pose, and eases out of it as it eased in. */
.char-seat{
  transform:perspective(320px) rotateX(var(--tilt-x,0deg)) rotateY(var(--tilt-y,0deg)) translateY(var(--lift,0%)) rotate(var(--nod,0deg)) scale(var(--press,1));
  transition:transform var(--quick,.2s) cubic-bezier(.34,1.4,.64,1);
}
.char-gaze{
  transform:translate(calc((var(--gaze-x,0px)*var(--ga,1) + var(--gaze-y,0px)*var(--gb,0))*var(--room,1)),calc((var(--gaze-x,0px)*var(--gc,0) + var(--gaze-y,0px)*var(--gd,1))*var(--room,1))) scale(var(--wide,1));
  transform-box:fill-box;transform-origin:50% 50%;transition:transform var(--quick,.2s) ease-out;
}
.char-eager[data-near]{--lift:-12%;--press:1.08}
.char-warm[data-near]{--nod:-8deg;--press:1.05}
.char-shy[data-near]{--press:.88}
.char-slow[data-near]{--lift:-4%;--press:1.04}

/* Each state standing still: where its motion ends, and all a person who asked for less motion sees. */
.char-thinking{transform:perspective(400px) rotateY(-12deg)}
.char-thinking .char-look{transform:translate(-4px,-1px)}
.char-joined .char-look{transform:translateY(-1.5px)}
.char-let-down{transform:scale(1.03,.95)}
.char-let-down .char-look{transform:translateY(2.5px)}

/* The body moves by one transform animation at a time, which the browser runs off the main thread.
   Measured on 200 characters: breathing written with the scale property cost 76ms of main thread a
   second and a second transform animation chained after a moment cost 190ms; one alone costs 1ms. So
   a moment (arrive, joined, let-down) plays once and rests in its pose with the eyes still blinking,
   and the person breathes again when the screen sets them back to idle. */
@media (prefers-reduced-motion:no-preference){
  .char{animation:char-breathe var(--breathe) ease-in-out var(--lag) infinite}
  .char-eye{animation:char-blink var(--blink) ease-in-out var(--lag) infinite}
  .char-idle .char-look{animation:char-wander calc(var(--blink) * 1.9) ease-in-out var(--lag) infinite}
  .char-arrive{animation:char-pop .5s ease-out calc(var(--lag) * -.02) both}
  .char-thinking{animation:char-turn 3.2s ease-in-out var(--lag) infinite}
  .char-thinking .char-look{animation:char-glance 3.2s ease-in-out var(--lag) infinite}
  .char-joined{animation:char-hop .72s both}
  .char-joined .char-look{animation:char-lift .4s ease-out .2s backwards}
  .char-joined .char-eye{animation:none}
  .char-let-down{animation:char-shake .6s ease-in-out}
  .char-let-down .char-look{animation:char-sink .7s ease-in-out .3s backwards}
}
@keyframes char-breathe{50%{transform:scale(.975,1.045)}}
@keyframes char-blink{0%,94%,100%{transform:none}97%{transform:scaleY(.1)}}
@keyframes char-wander{0%,36%,64%,100%{transform:none}44%,56%{transform:translate(3px,-1px)}}
@keyframes char-pop{from{transform:scale(0)}60%{transform:scale(1.08)}80%{transform:scale(.98)}to{transform:none}}
@keyframes char-turn{0%,10%,90%,100%{transform:perspective(400px) rotateY(0)}22%,42%{transform:perspective(400px) rotateY(-16deg)}58%,78%{transform:perspective(400px) rotateY(16deg)}}
@keyframes char-glance{0%,10%,90%,100%{transform:translate(0,0)}22%,42%{transform:translate(-6px,-1px)}58%,78%{transform:translate(5px,-1px)}}
@keyframes char-hop{
  0%{transform:translateY(0) scale(1,1)}
  16%{transform:translateY(0) scale(1.07,.9);animation-timing-function:ease-out}
  42%{transform:translateY(-16%) scale(.95,1.06);animation-timing-function:ease-in}
  64%{transform:translateY(0) scale(1,1)}
  76%{transform:translateY(0) scale(1.05,.94)}
  100%{transform:translateY(0) scale(1,1)}
}
@keyframes char-lift{from{transform:none}}
@keyframes char-shake{0%{transform:none}15%{transform:translateX(-5%)}35%{transform:translateX(4%)}55%{transform:translateX(-2.5%)}75%{transform:translateX(1%)}}
@keyframes char-sink{from{transform:none}}
