/* Motion tokens and keyframes from transitions.dev's Error state shake. */
:root {
  --shake-distance: 6px;
  --shake-overshoot: 4px;
  --shake-dur-a: 80ms;
  --shake-dur-b: 60ms;
  --shake-ease: cubic-bezier(0.22, 1, 0.36, 1);
  --revert-hold: 3000ms;
  --revert-dur: 280ms;
}

.t-input {
  transition: border-color var(--revert-dur) ease-out;
}

.t-input.is-error {
  border-color: var(--app-danger, var(--red)) !important;
  transition-duration: 150ms;
}

.t-input.is-error:focus,
:is(#main, #modal) .t-input.is-error:focus {
  box-shadow: 3px 3px 0 var(--app-danger, var(--red));
}

.t-error-msg {
  color: var(--app-danger, var(--red));
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--revert-dur) ease-out, visibility 0s linear var(--revert-dur);
}

.t-error-msg:empty {
  margin: 0;
}

.t-input-wrap.is-error .t-error-msg {
  opacity: 1;
  visibility: visible;
  transition-delay: 0s;
}

.t-input.is-shaking {
  will-change: transform;
  animation: t-input-shake calc(var(--shake-dur-a) * 2 + var(--shake-dur-b) * 2) linear;
}

/* The stops correspond to cumulative segments of 80, 80, 60 and 60 ms. */
@keyframes t-input-shake {
  0% { transform: translateX(0); animation-timing-function: var(--shake-ease); }
  28.57% { transform: translateX(var(--shake-distance)); animation-timing-function: var(--shake-ease); }
  57.14% { transform: translateX(calc(var(--shake-distance) * -1)); animation-timing-function: var(--shake-ease); }
  78.57% { transform: translateX(var(--shake-overshoot)); animation-timing-function: var(--shake-ease); }
  100% { transform: translateX(0); }
}

@media (prefers-reduced-motion: reduce) {
  .t-input,
  .t-input.is-shaking,
  .t-error-msg,
  .t-input-wrap.is-error .t-error-msg {
    animation: none;
    transition: none;
    will-change: auto;
  }
}
