// 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.

.ods-modal--overlay {
  display: flex;
  position: fixed;
  z-index: 10;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  align-items: center;
  justify-content: center;
  background: rgba(cv('gray', '900'), 0.75);
}

.ods-modal--dialog {
  position: relative;
  max-width: calc(#{$max-line-length} + #{$spacing-m} + #{$spacing-m});
  max-height: calc(100vh - #{$spacing-m});
  padding: $spacing-m  $spacing-m 0;
  overflow-y: auto;
  border-radius: $base-border-radius;
  background-color: $white;
}

.ods-modal--header {
  display: flex;
  flex-direction: column;
}

.ods-modal--close {
  align-self: flex-end;
  width: $base-font-size;
  height: $base-font-size;
  margin-bottom: $spacing-xs;
  padding: 0;
  border: 0;
  background-color: transparent;
  background-image: get-icon('close', $text-body);
  background-repeat: no-repeat;
  background-position: center;
}

.ods-modal--title {
  margin-top: 0;
  margin-bottom: 0;
  color: $text-heading;
  font-size: $size-title-4;
  font-weight: 600;
  line-height: $title-line-height;
}

.ods-modal--content {
  padding: $spacing-xs 0 $spacing-l;
  font-size: $size-body-base;
}

.ods-modal--footer {
  display: flex;
  justify-content: flex-end;
  padding-bottom: $spacing-m;
}

// Animations

@keyframes overlay-in {
  from {
    opacity: 0;
  }

  to {
    opacity: 1;
  }
}

@keyframes overlay-out {
  from {
    opacity: 1;
  }

  to {
    opacity: 0;
  }
}

@keyframes dialog-in {
  from {
    transform: scale(0.7);
    opacity: 0;
  }

  to {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes dialog-out {
  from {
    transform: scale(1);
    opacity: 1;
  }

  to {
    transform: scale(0.7);
    opacity: 0;
  }
}

.ods-modal {
  display: none;

  &.is-open {
    display: block;
  }

  &[aria-hidden='false'] {
    .ods-modal--overlay {
      animation: overlay-in $base-duration $base-timing;
    }

    .ods-modal--dialog {
      animation: dialog-in $base-duration $base-timing;
    }
  }

  &[aria-hidden='true'] {
    .ods-modal--overlay {
      animation: overlay-out $base-duration $base-timing;
    }

    &[aria-hidden='true'] .ods-modal--dialog {
      animation: dialog-out $base-duration $base-timing;
    }
  }
}
