// Copyright 2018-Present Okta, Inc.

// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at

// http://www.apache.org/licenses/LICENSE-2.0

// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

@mixin is-visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

@mixin outline($outline-cv: $focus-ring-primary, $radius: 4px) {
  outline: 0;
  box-shadow: 0 0 0 $radius $outline-cv;
}

@mixin input-baseline {
  display: block;
  position: relative;
  width: 100%;
  max-width: $max-line-length;
  margin: 0;
  padding: $spacing-xs-em $spacing-s-em;
  transition-property: border-color, background-color, box-shadow;
  transition-duration: $base-duration;
  transition-timing-function: $base-timing;
  border: 1px solid $border-color-ui;
  border-radius: $base-border-radius;
  background-color: $white;
  box-shadow: 0 0 0 0 cv('blue', '000');
  color: $text-body;
  font-family: $body-font-family;
  font-size: $size-body-base;
  line-height: $base-line-height;

  &:hover,
  &:focus,
  &.is-ods-input-hover,
  &.is-ods-input-focus {
    border-color: cv('blue');
  }

  &:focus,
  &.is-ods-input-focus {
    @include outline;
  }

  &:disabled {
    opacity: 1;
    color: $text-body;
    cursor: not-allowed;
  }

  &:disabled,
  &[readonly] {
    border-color: $border-input-disabled;
    background-color: $bg-input-disabled;

    &:hover {
      border-color: $border-input-disabled;
    }
  }

  &[data-invalid] {
    border-color: $color-danger-base;

    &:focus {
      @include outline($focus-ring-danger);
    }
  }

  &::placeholder {
    color: $text-sub;
  }
}
