.GrowingTextarea {
  display: block;
  width: 100%;
  position: relative;
  transition: 0.3s ease-in-out;

  &.bordered {
    box-sizing: border-box;
    padding: 16px 12px;
    border-radius: 2px;
    border: 2px solid var(--black-100);
    background: var(--white-500);
  }

  &.hasFieldName {
    padding-top: 24px;
  }

  .fieldName {
    @include font-size(1.2rem);

    position: absolute;
    top: 6px;
    left: 12px;
    color: var(--black-400);
  }

  .growWrap {
    display: grid;
    width: 100%;

    &::after {
      content: attr(data-replicated-value);
      visibility: hidden;
      transition: height 0.3s linear;
    }

    .textInput {
      background: var(--background-color);
      border: none;
      color: var(--default-color);
      margin-bottom: 0;
      resize: none;
      overflow: hidden;

      &::placeholder {
        color: #858585;
      }

      &:focus,
      &:focus-visible,
      &:active {
        border: none;
        outline: none;
        box-shadow: none;
      }
    }

    &::after,
    & .textInput {
      /* Identical styling required!! */
      white-space: pre-wrap;
      word-wrap: break-word;
      overflow: hidden;
      line-height: 1.2;
      grid-area: 1 / 1 / 2 / 2;
      width: 100%;
      padding: 0;
      margin: 0;
    }
  }

  .maxLength {
    color: var(--default-color);
    opacity: 1;
    position: absolute;
    z-index: 1;
    right: 0.6rem;
    bottom: -1.2rem;
    font-size: 1.1rem;
    border: 3px solid rgba(#ccc, 0.5);
    padding: 0.5rem;
    border-radius: 1.3rem;
    line-height: 1;
    user-select: none;
    transition: opacity 0.3s ease-in-out;
    background: var(--white-500);

    &.visible {
      opacity: 1;
    }

    &.limited {
      animation: blink 0.8s;
      animation-iteration-count: 2;
    }
  }

  &.bordered .maxLength {
    opacity: 1;
    font-weight: 500;
    border: unset;
    bottom: 0;
  }
}

@keyframes blink {
  50% {
    border-color: #000;
  }
}
