Edit in JSFiddle

<form method="post" id="login-form" class="login-form" autocomplete="off">
  <h1 class="a11y-hidden">Login form</h1>
  <figure aria-hidden="true">
    <div class="person-body"></div>
    <div class="neck skin"></div>
    <div class="head skin">
      <div class="eyes"></div>
      <div class="mouth"></div>
    </div>
    <div class="hair"></div>
    <div class="ears"></div>
    <div class="shirt-1"></div>
    <div class="shirt-2"></div>
  </figure>
  <div aria-live="polite" class="error-message" id="error-message"></div>
  <div>
    <label class="required">
      <span>Username</span>
      <input type="text" name="username" id="username" placeholder="Username" required />
    </label>
  </div>
  <div>
    <label class="required">
      <span>Password</span>
      <input type="password" name="password" id="password" placeholder="Password" required minlength="8" />
    </label>
  </div>
  <div>
    <label>
      <input type="checkbox" name="show-password" id="show-password" class="a11y-hidden" />
      <span class="checkbox-label">Show Password</span>
    </label>
  </div>
  <input type="submit" value="Log In" name="submit" id="submit" />
  <div class="forgot-password">
    <a href="#">Forgot password?</a>
  </div>
</form>

html, body {
  align-items: center;
  background: #f2f4f8;
  border: 0;
  display: flex;
  font-family: Helvetica, Arial, sans-serif;
  font-size: 16px;
  height: 100%;
  justify-content: center;
  margin: 0;
  padding: 0;
}

.a11y-hidden {
  position: absolute;
  left: -1000em;
}

form {
  --background: rgba(255, 255, 255, 1);
  --border: rgba(0, 0, 0, 0.125);
  --borderDark: rgba(0, 0, 0, 0.25);
  --borderDarker: rgba(0, 0, 0, 0.5);
  --borderRadius: 0.125rem;
  --bgColorH: 0;
  --bgColorS: 0%;
  --bgColorL: 98%;
  --fgColorH: 210;
  --fgColorS: 50%;
  --fgColorL: 38%;
  --errorMessage: #dd0000;
  --errorBackground: #fff5f5;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: var(--borderRadius);
  box-shadow: 0 1rem 1rem -0.75rem var(--border);
  padding: 1rem;
}

.error-message {
  background: var(--errorBackground);
  border: 1px solid var(--errorMessage);
  border-radius: var(--borderRadius);
  color: var(--errorMessage);
  font-size: 0.825rem;
  padding: 0.25rem 0.5rem;
}

.error-message:empty {
  display: none;
}

input {
  border: 1px solid var(--border);
  border-radius: var(--borderRadius);
  box-sizing: border-box;
  font-size: 1rem;
  height: 2.25rem;
  line-height: 1.25rem;
  margin-top: 0.25rem;
  outline: 1px dashed transparent;
  outline-offset: 2px;
  padding: 0.25rem 0.5rem;
  transition: all 0.25s;
  width: 15rem;
}

input:focus {
  outline: 1px dashed hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}

label {
  display: inline-block;
}

label span {
  color: var(--borderDarker);
  display: block;
  font-size: 0.825rem;
  margin-top: 1rem;
  transition: color 0.25s;
}

label.required span::after {
  content: "*";
  color: var(--errorMessage);
  margin-left: 0.125rem;
}

label:hover span {
  color: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
}

label:hover input,
label:hover span.checkbox-label::before {
  border-color: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
}

label:hover input[type="checkbox"]:checked + span.checkbox-label::after {
  background: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
}

label:focus-within span,
label.state-focus span {
  color: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}

label input:focus,
label:focus-within input,
label:focus-within span.checkbox-label::before,
label.state-focus input,
label.state-focus span.checkbox-label::before {
  border-color: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}

label:focus-within input[type="checkbox"]:checked + span.checkbox-label::after,
label.state-focus input[type="checkbox"]:checked + span.checkbox-label::after {
  background: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}


label.state-error span {
  color: var(--errorMessage);
}

label.state-error input {
  border-color: var(--errorMessage);
}

input[type="submit"] {
  color: hsl(var(--bgColorH), var(--bgColorS), var(--bgColorL));
  background: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
  font-size: 0.75rem;
  font-weight: bold;
  margin-top: 1rem;
  padding-left: 0;
  text-transform: uppercase;
  transition: all 0.125s;
}

input[type="submit"]:focus,
input[type="submit"]:hover {
  background: hsl(var(--fgColorH), var(--fgColorS), calc(var(--fgColorL) * 0.85));
}

input[type="submit"]:active {
  background: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}

input[type="checkbox"] + span {
  margin-top: 0.25rem;
  padding-left: 1.25rem;
  position: relative;
}

input[type="checkbox"] + span::before {
  content: "";
  display: block;
  position: absolute;
  top: 0;
  left: 0;
  width: 0.75rem;
  height: 0.75rem;
  border: 1px solid var(--borderDark);
  border-radius: var(--borderRadius);
  transition: all 0.25s;
  outline: 1px dashed transparent;
  outline-offset: 2px;
}

input[type="checkbox"]:focus + span::before {
  outline: 1px dashed hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
  outline-offset: 2px;
}

input[type="checkbox"]:checked + span::after {
  content: "";
  display: block;
  position: absolute;
  top: 0.1875rem;
  left: 0.1875rem;
  width: 0.375rem;
  height: 0.375rem;
  border: 1px solid var(--borderDark);
  border-radius: var(--borderRadius);
  transition: all 0.25s;
  outline: 1px dashed transparent;
  outline-offset: 2px;
  background: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
}

.forgot-password {
  margin-top: 0.125rem;
  text-align: center;
}

.forgot-password a {
  color: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
  font-size: 0.825rem;
  text-align: center;
  margin-top: 0.25rem;
  outline: 1px dashed transparent;
  outline-offset: 2px;
  display: inline;
  transition: 0.25s;
}

.forgot-password a:focus {
  color: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
  outline: 1px dashed hsl(var(--fgColorH), calc(var(--fgColorS) * 2), calc(var(--fgColorL) * 1.15));
}

.forgot-password a:hover {
  color: hsl(var(--fgColorH), var(--fgColorS), calc(var(--fgColorL) * 0.85));
}

/** PERSON */
figure {
  --skinH: 30;
  --skinS: 100%;
  --skinL: 87%;
  --hair: rgb(180, 70, 60);
  background: hsl(var(--fgColorH), calc(var(--fgColorS) * 2), 95%);
  border: 1px solid rgba(0, 0, 0, 0.0625);
  border-radius: 50%;
  height: 0;
  margin: auto auto;
  margin-bottom: 2rem;
  padding-top: 60%;
  position: relative;
  width: 60%;
  overflow: hidden;
}

figure div {
  position: absolute;
  transform: translate(-50%, -50%);
}

figure .skin {
  background: hsl(var(--skinH), var(--skinS), var(--skinL));
  box-shadow: inset 0 0 3rem hsl(var(--skinH), var(--skinS), calc(var(--skinL) * 0.95));
}

figure .head {
  top: 40%;
  left: 50%;
  width: 60%;
  height: 60%;
  border-radius: 100%;
  box-shadow: 0 -0.175rem 0 0.125rem var(--hair);
}

figure .ears {
  top: 47%;
  left: 50%;
  white-space: nowrap;
}

figure .ears::before,
figure .ears::after {
  content: "";
  background: hsl(var(--skinH), var(--skinS), var(--skinL));
  border-radius: 50%;
  width: 1rem;
  height: 1rem;
  display: inline-block;
  margin: 0 2.1rem;
}

figure .head .eyes {
  top: 55%;
  left: 50%;
  white-space: nowrap;
  transition: all 0.25s;
}

@-webkit-keyframes blink {
  0%, 90%, 100% {
    height: 10px;
  }
  95% {
    height: 0;
  }
}

@keyframes blink {
  0%, 90%, 100% {
    height: 10px;
  }
  95% {
    height: 0px;
  }
}

figure .head .eyes::before,
figure .head .eyes::after {
  content: "";
  background: var(--borderDarker);
  border-radius: 50%;
  width: 10px;
  height: 10px;
  display: inline-block;
  margin: 0 0.5rem;
  -webkit-animation: blink 5s infinite;
  animation: blink 5s infinite;
  transition: all 0.25s;
}

figure .head .eyes.closed::before,
figure .head .eyes.closed::after {
  height: 0.125rem;
  animation: none;
}

figure .head .mouth {
  border: 0.125rem solid transparent;
  border-bottom: 0.125rem solid var(--borderDarker);
  width: 25%;
  border-radius: 50%;
  transition: all 0.333s;
  top: 75%;
  left: 50%;
  height: 10%;
}

figure .head .mouth.errors-1 {
  top: 61%;
  width: 35%;
  height: 40%;
}

figure .head .mouth.errors-0 {
  top: 53%;
  width: 45%;
  height: 55%;
}

figure .hair {
  top: 40%;
  left: 50%;
  width: 66.66%;
  height: 66.66%;
  border-radius: 100%;
  overflow: hidden;
}

figure .hair::before {
  content: "";
  display: block;
  position: absolute;
  width: 100%;
  height: 100%;
  background: var(--hair);
  border-radius: 50%;
  top: -60%;
  left: -50%;
  box-shadow: 4rem 0 var(--hair);
}

figure .neck {
  width: 10%;
  height: 40%;
  top: 62%;
  left: 50%;
  background: hsl(var(--skinH), var(--skinS), calc(var(--skinL) * 0.94));
  border-radius: 0 0 2rem 2rem;
  box-shadow: 0 0.25rem var(--border);
}

figure .person-body {
  width: 60%;
  height: 100%;
  border-radius: 50%;
  background: red;
  left: 50%;
  top: 126%;
  background: hsl(var(--fgColorH), var(--fgColorS), var(--fgColorL));
}

figure .shirt-1,
figure .shirt-2 {
  width: 12%;
  height: 7%;
  background: hsl(var(--bgColorH), var(--bgColorS), var(--bgColorL));
  top: 76%;
  left: 36.5%;
  transform: skew(-10deg) rotate(15deg);
}

figure .shirt-2 {
  left: 52.5%;
  transform: skew(10deg) rotate(-15deg);
}
// show password interactivity
document.querySelector("#show-password").addEventListener("input", function() {
  document.querySelector("#password").type = this.checked ? "text" : "password";
  document.querySelector(".eyes").className = `eyes ${this.checked && " closed"}`;
});

// focus within the label input
const labels = document.querySelectorAll("#login-form label input");
for (let x = 0; x < labels.length; x++) {
	labels[x].addEventListener("focus", function() {
  	this.parentNode.classList.add("state-focus");
  });
  
  labels[x].addEventListener("blur", function() {
  	this.parentNode.classList.remove("state-focus");
  });
}

// form submission = validation
document.querySelector(".login-form").addEventListener("submit", function(e) {
  let errorMessage = "";
  const error = document.querySelector("#error-message");
  const username = document.querySelector("#username");
  const password = document.querySelector("#password");
  
  error.textContent = "";

  // check password length
  if (password.value.length < 8) {
  	errorMessage = "Password is mandatory";
    password.parentNode.classList.add("state-error");
    password.focus();
  // check email length
  } else if (username.value.length < 5) {
  	errorMessage = "Username is too short (min 5 chars)";
    username.parentNode.classList.add("state-error");
    username.focus();
  } 
  
  if (errorMessage != "") {
  	error.textContent = errorMessage;
    e.preventDefault();
  }
  
  // prevent form submission anyway for demo purposes
  e.preventDefault();
});

// remove state error on blur
function removeError(e) {
	e.target.parentNode.classList.remove("state-error");
  document.querySelector("#error-message").textContent = "";
}
function checkStatus(e) {
	removeError(e);
  const invalidFields = document.querySelectorAll("input:invalid").length;
  document.querySelector(".mouth").className = `mouth errors-${invalidFields}`;
}
document.querySelector("#password").addEventListener("input", checkStatus);
document.querySelector("#username").addEventListener("input", checkStatus);

// move eyes following username input 
function moveEyes(e) {
	const eyes = document.querySelector(".eyes");
  const length = e.target.value.length;
  // this is a bit trickier because the eyes already have a translation!
  eyes.style.transform = `translate(calc(-50% + ${Math.min(length/2 - 7, 7)}px), calc(-50% + 0.1875rem))`;
  // eyes.style.marginTop = "0.25rem";
  // eyes.style.marginLeft = `${Math.min(length/2 - 7, 7)}px`;
}
document.querySelector("#username").addEventListener("focus", moveEyes);
document.querySelector("#username").addEventListener("input", moveEyes);
document.querySelector("#username").addEventListener("blur", function() {
	document.querySelector(".eyes").style.transform = "translate(-50%, -50%)";
});