/* The ending: the robot leaves the background, wakes up, walks in from the
   side and points at the contact details. robot-walk.js sets the pose through
   the variables below; the transitions here keep every move soft. */
#bot.out {
  z-index: 3;
}
#bot.out > .bot-stage > svg {
  transition: none;
}
#bot.out .bot-stage {
  animation: none;
}
#bot.out .ground {
  opacity: 0.09;
}
#bot.out .glass {
  fill-opacity: 1;
  stroke-opacity: 1;
}

#bot.out [data-part='head'],
#bot.out [data-part='visor'],
#bot.out [data-part='mic'],
#bot.out [data-part='antenna'] {
  transform: translateY(var(--lift, 0px)) rotate(var(--head, 0deg)) !important;
  transform-origin: 300px 300px !important;
  transition: transform 0.24s cubic-bezier(0.3, 1.4, 0.5, 1);
}
/* The face. Each eyelid comes down over its eye, lower at the outer corner
   when it droops; the mouth swaps between a smile, a flat line and a yawn. */
#bot.out .eye {
  transform: scaleY(var(--eye, 1)) !important;
  clip-path: polygon(
    0 calc(var(--lid-l, 0%) + var(--slant, 0%)),
    100% var(--lid-l, 0%),
    100% 100%,
    0 100%
  );
  transition:
    transform 0.12s ease-out,
    clip-path 0.28s ease-out;
}
#bot.out .eye + .eye {
  clip-path: polygon(
    0 var(--lid-r, 0%),
    100% calc(var(--lid-r, 0%) + var(--slant, 0%)),
    100% 100%,
    0 100%
  );
}
#bot .flat,
#bot .yawn {
  stroke: #3aa5ff;
  stroke-linecap: round;
}
#bot .flat {
  fill: none;
  stroke-width: 5;
  opacity: var(--flat, 0);
  transition: opacity 0.2s;
}
#bot .yawn {
  fill: #0a1826;
  stroke-width: 4;
  transform-box: fill-box;
  transform-origin: center;
  transform: scale(var(--yawn, 0));
  transition: transform 0.3s cubic-bezier(0.3, 1.3, 0.5, 1);
}
#bot.out .smile {
  opacity: var(--smile, 1);
  transition: opacity 0.2s;
}
#bot.out .eyes {
  transform: translate(calc(var(--gaze, 0) * 1px), 0);
  transition: transform 0.25s ease-out;
}

#bot .wave,
#bot .wave-fore {
  transition: transform 0.45s cubic-bezier(0.3, 1.5, 0.5, 1);
}
#bot.out [data-part='armL'] .wave {
  transform: rotate(var(--arm-l, 0deg));
}
#bot.out [data-part='armR'] .wave {
  transform: rotate(var(--arm-r, 0deg));
}
#bot.out [data-part='armL'] .wave-fore {
  transform: rotate(var(--fore-l, 0deg));
}
#bot.out [data-part='armR'] .wave-fore {
  transform: rotate(var(--fore-r, 0deg));
}
#bot.out [data-part='legL'] {
  transform: rotate(var(--leg-l, 0deg)) !important;
  transform-origin: 256px 590px !important;
}
#bot.out [data-part='legR'] {
  transform: rotate(var(--leg-r, 0deg)) !important;
  transform-origin: 344px 590px !important;
}

/* While walking the script moves every frame, so nothing lags behind it. */
#bot.walking .wave,
#bot.walking .wave-fore,
#bot.walking [data-part='head'],
#bot.walking [data-part='visor'],
#bot.walking [data-part='mic'],
#bot.walking [data-part='antenna'] {
  transition: none;
}

/* Still asleep: lights off. Then the antenna lamp flickers on. */
#bot.asleep .eye,
#bot.asleep .lamp {
  fill: #5f7f9e;
}
#bot.asleep .smile,
#bot.asleep .flat {
  stroke: #5f7f9e;
}
#bot.asleep .core {
  stroke: #7f9bb6;
}
#bot.asleep .eyes {
  filter: none;
}
#bot.boot .lamp {
  animation: bot-boot 0.15s steps(1) infinite;
}

#bot.pointing [data-part='armR'] .wave-fore {
  animation: bot-point 1.3s ease-in-out infinite;
}

@keyframes bot-boot {
  50% {
    fill: #3aa5ff;
  }
}
@keyframes bot-point {
  50% {
    transform: rotate(-9deg);
  }
}
