*,
*:before,
*:after {
  padding: 0;
  margin: 0;
  box-sizing: border-box;
  outline: none;
  line-height: 1;
  text-decoration: none;
  font-family: system-ui;
}
*::selection {
  background-color: #a0a0ff;
}
body {
  display: grid;
  place-items: center;
  height: 100vh;
  background-color: #47759a;
}
form {
  --hidden: url(https://cdn-icons-png.flaticon.com/512/7794/7794218.png);
  --show: url("https://cdn-icons-png.flaticon.com/512/1445/1445372.png");
  color: #222;
  width: 300px;
  max-width: 400px;
  height: 400px;
  max-height: 500px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  background-color: #efefef;
  border-radius: 16px;
  border: 2px solid #000;
  h1 {
    text-align: center;
    border-bottom: 2px solid #000;
    padding: 1em 0;
  }
  div {
    position: relative;
    margin: 0 2em;
    label {
      position: absolute;
      top: 30%;
      left: 0;
      font-weight: 800;
    }
    input:not([type="checkbox"]) {
      background: transparent;
      border: none;
      border-bottom: 2px solid #a0a0ff;
      width: 100%;
      height: 2.5em;
      font-size: 20px;
      &:focus-within,
      &:not(:placeholder-shown) {
        border-color: #5050ff;
        & + label {
          color: #5050ff;
          span {
            top: -1.5em;
          }
        }
        &:not(:focus) {
          &:invalid {
            border-color: #c00;
            & + label {
              color: #c00;
              animation: Shake 0.2s both;
            }
          }
          &:valid {
            border-color: #5a5;
            & + label {
              color: #5a5;
            }
          }
        }
      }
    }
    show {
      position: absolute;
      top: 25%;
      right: 0;
      width: 20px;
      height: 20px;
      label {
        cursor: pointer;
        top: 0;
        width: 100%;
        height: 100%;
        background-position: center center;
        background-repeat: no-repeat;
        background-size: cover;
        background-image: var(--hidden);
      }
      input {
        display: none;
        &:checked + label {
          background-image: var(--show);
        }
      }
    }
  }
  button {
    font-size: 20px;
    height: 2.5em;
    border: none;
    background-color: #5050ff;
    color: #fff;
    margin: 0 1em;
    cursor: pointer;
    &:hover {
      background-color: #6f6fff;
    }
  }
  h6 {
    text-align: center;
    margin-bottom: 1em;
  }
  a {
    color: #6f6fff;
  }
}

.wave {
  position: absolute;
  span {
    position: relative;
    top: 0;
    left: 0;
    transition-property: top;
    transition-duration: 0.25s;
    transition-timing-function: ease-out;
  }
}

@keyframes Shake {
  to,
  50%,
  from {
    left: 0;
  }
  25%,
  75% {
    left: 2%;
  }
}
