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

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

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

  &__container {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;

    .usa-input .usa-input__choices label {
      max-width: 62rem;
    }
  }

  &__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;
    }
  }

  &__body {
    background-color: $color-white;
    padding: $gap * 1.5;
    width: 100%;
    overflow-y: auto;
    overflow-x: hidden;
    -ms-overflow-style: scrollbar;

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

    h1,
    h2 {
      @include h3;
    }

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

    .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;
        }
      }
    }

    .action-group {
      background-color: $color-gray-lightest;
      padding: $gap * 2;
      margin: ($gap * 5) (-$gap * 1.5) (-$gap * 1.5);
    }

    .form-row {
      margin: 0;
    }
  }

  &__dismiss {
    position: absolute;
    top: $gap;
    right: $gap;

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

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

  .usa-button {
    min-width: 17rem;
  }

  .usa-input {
    .checkbox {
      margin-left: 3rem;
    }
  }

  input[type="checkbox"] {
    + label::before {
      margin-left: -3rem;
    }
  }
}

.modal--dismissable {
  .modal__body {
    padding-top: $gap * 3.5;
  }
}
