$fixed-footer-height: 5rem + $gap * 4;

body {
  &.modal-open {
    overflow-y: hidden;
  }
}

.modal {
  position: fixed;
  z-index: 6;
  left: 0;
  right: 0;
  top: 0;
  bottom: 0;
  background-color: $color-overlay;

  .modal__container {
    height: 100vh;
    max-height: 100vh;
  }

  .modal__dialog {
    padding: $gap;
    margin: 0 auto;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    max-width: 80rem;
    max-height: 100%;
    position: relative;

    @include media($medium-screen) {
      padding: $gap * 2;
    }

    @include media($large-screen) {
      padding: $gap * 4;
    }

    .modal__body {
      background-color: $color-white;
      padding: $gap * 2;
      width: 100%;
      border-radius: 5px;
      overflow-y: auto;
      -ms-overflow-style: scrollbar;

      @include ie-only {
        max-height: calc(100vh - #{$gap * 8});
      }

      @include media($medium-screen) {
        padding: $gap * 5;
      }

      h1,
      h2 {
        @include h3;
      }

      > :first-child {
        margin-top: 0;
      }

      .modal__dismiss {
        position: absolute;
        top: $gap;
        right: $gap;
        width: 8rem;

        @include media($medium-screen) {
          top: $gap * 2;
          right: $gap * 2;
        }

        @include media($large-screen) {
          top: $gap * 4;
          right: $gap * 4;
        }
      }

      .block-list {
        margin: -$gap * 2;
        padding-bottom: $fixed-footer-height;

        @include media($medium-screen) {
          margin: -$gap * 4;
        }

        .block-list__header {
          border-top: 0;
        }

        .block-list__item {
          &:last-child {
            border: 0;
          }
        }

        .block-list__footer {
          height: $fixed-footer-height;
          margin: 0;
          padding: 0 ($gap * 2);
          display: flex;
          justify-content: space-between;
          position: absolute;
          bottom: $gap;
          left: $gap;
          right: $gap;
          background: $color-white;
          border-top: 1px solid $color-gray-light;

          @include media($medium-screen) {
            bottom: $gap * 2;
            left: $gap * 2;
            right: $gap * 2;
          }

          @include media($large-screen) {
            bottom: $gap * 4;
            left: $gap * 4;
            right: $gap * 4;
          }

          .action-group {
            margin: 0;
          }
        }
      }
    }
  }

  &.modal--dismissable {
    .modal__body {
      > :first-child {
        margin-right: 8rem;
      }
    }
  }

  &.wide {
    .modal__dialog {
      max-width: 90rem;
    }

    .modal__body {
      padding-left: 4rem;
      padding-right: 4rem;
    }
  }

  .modal__form {
    .modal__form--header {
      margin-bottom: 4rem;

      h1 {
        margin-bottom: 0;
      }

      .icon-link {
        padding-top: 0.5rem;
        padding-left: 0;
        margin-left: 0;
      }
    }

    .progress-menu ul {
      width: 40%;
      margin-left: 30%;
      font-size: 2rem;

      .progress-menu__item::before {
        width: 2.8rem;
        height: 2.8rem;
        margin-left: -1.25rem;
      }

      .progress-menu__item--complete::before {
        content: url("#{$asset-path}/icons/checkmark-alt.svg");
        padding-top: 0.4rem;
      }
    }

    .form-row {
      margin-top: 0;
      margin-bottom: 0;

      .form-col {
        .usa-input {
          margin-bottom: 1.5rem;
        }
      }
    }

    .icon-link--default {
      font-size: 1.7rem;
    }

    .usa-button {
      margin-left: 2rem;

      &[type="button"]:disabled {
        background-color: $color-gray-lighter;
        opacity: inherit;
      }
    }

    .modal__form--padded {
      padding-left: 5%;
      padding-right: 5%;

      .usa-input .usa-input__choices select {
        max-width: 100%;
      }
    }
  }
}
