@use "../styles";

$textColor: black;
$focusedColor: black;
$animSpeed: 200ms;

.host {
  font-size: 16px;
  padding: 14px 12px;
  position: relative;
  border-radius: 6px;
  min-height: 56px;

  &.filled {
    background-color: rgb(232, 232, 232);
    border-bottom: 1px black;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
  }

  &.standard {
    border-bottom: 1px black;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;

    :global(.mat-input-field-target) {
      padding-top: 16px;
    }

    .placeholderContent {
      translate: 0 8px;
    }
  }

  &.float,
  &.float-always,
  &.float-focus:focus-within {
    .placeholderContent {
      translate: 1px -12px;
      scale: 0.75;
    }

    &.filled.hasPlaceholder {
      :global(.mat-input-field-target) {
        padding-top: 18px;
      }
    }

    &.outlined {
      .placeholderContent {
        background-color: white;
        translate: 1px -26px;
      }
    }
  }

  &.float.float-never {
    .placeholderContent {
      display: none;
    }
  }
}

.content {
  color: $textColor;
  caret-color: $focusedColor;
  border: none;
  background-color: none;

  margin: 0;
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border-radius: inherit;
}

.inputFrame {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  border: 1px solid;
  border-radius: 6px;
  pointer-events: none;
  border-color: $textColor;

  .content:focus-within ~ & {
    border-color: $focusedColor;
    border-width: 2px;
  }
}

.placeholder {
  pointer-events: none;
  position: relative;
  white-space: nowrap;
  flex-grow: 1;
  flex-direction: row;
  align-items: center;
}

.placeholderGhost {
  opacity: 0;
}

.placeholderText {
  color: $textColor;
  opacity: 0.7;

  .content:focus-within ~ .placeholder & {
    color: $focusedColor;
    opacity: 1;
  }
}

.placeholderContent {
  position: absolute;
  padding: 0 4px;
  transition: translate $animSpeed ease-out, scale $animSpeed ease-out, background-color $animSpeed ease-out;
  transform-origin: left;
  left: -4px;
  border-radius: 4px;
}
