* {
  color-scheme: dark;
  box-sizing: border-box;
}
a {
  text-decoration: none;
  color: #f2f2f2;
}

/*
simples
ao add display: flex o 100% de background fica +rapido
*/

.menu{
    display: flex;
    justify-content: space-around;
    align-items: center;
}

.menu a {
  background: linear-gradient(0deg, slateblue, slateblue) no-repeat right bottom /
    0 var(--bg-h); /*joga tudo para uma variavel*/
  transition: background-size 350ms; /* velocidade */
  --bg-h: 100%; /*para full-background change to 100% ou use .under class */
}

.menu a:where(:hover, :focus-visible) {
  background-size: 100% var(--bg-h);
  background-position-x: left; /*direção */
}
/*
ou usar uma classe para forcar o inline
*/
.under {
  --bg-h: 2px !important;
}


/*
e.g 2: input div underline
*/

form {
    display: flex;
}

.inputField{
    position: relative;
}

.underline::before {
    content: '';
    position: absolute;
    height: 1px;
    width: 100%;
    bottom: -5px;
    left: 0;
    background: rgba(0, 0, 0, 0.2); /* não é necessário - timeline for line */
}

.underline::after {
    content: '';
    position: absolute;
    height: 1px;
    width: 100%;
    bottom: -5px;
    left: 0;
    background: linear-gradient(45deg, #8e2de2, #4a00e0);
    transform: scaleX(0);
    transition: all .3s ease-in-out;
    transform-origin: left;
}
input:focus ~ .underline::after {
    transform: scaleX(1);
}

input {
    outline: none;
    font-size: 0.9rem;
    color: #f2f2f2;
}

input::placeholder {
    color: rgba(red, blue, yellow);
}

/*
e.g 3
*/
:root{
  --red-color: #ee0606dc;
}

.menu3 li {
  display: inline-block;
  padding: 1rem;
  color: var(--red-color);
  font-size: 1rem;
  position: relative;
}

li {
  list-style: none;
}

.menu3 li a::after{
  content: '';
  position: absolute;  
  bottom: 0.7rem;
  width: 0;
  left: 0;
  height: 0.2rem;
  background: var(--red-color);
  transition: all 300ms ease-in-out;
}

.menu3 li a:hover::after{
  width: 100%;
}