$modal-size-medium: 480px !default;
$modal-size-large: 960px !default;

// Placed on the body, when the modal is opened.
// Locks the body from being scrolled.

.modal-is-open {
  overflow: hidden;
}

.modal {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: $z-index-modals;
  display: none;

  &.has-overlay {
    min-height: 100%;
    background-color: rgba(#000, 0.7);
  }

  &.is-open {
    display: block;
  }

  &.is-static {
    display: block;
    position: relative;

    > .modal__box {
      height: auto;
    }
  }
}

.modal__box {
  margin: 0 auto;
  position: relative;
  height: 100%;
  overflow: auto;
}

.modal__box--panel {
  background-color: #fff;
  padding: 1em 0;

  img {
    display: block;
    max-width: 100%;
  }
}

.modal__box--size-w-medium {
  max-width: $modal-size-medium;
}

.modal__box--size-h-medium {
  @media (min-width: $modal-size-medium) {
    height: auto;
    overflow: hidden;

    .modal__content {
      max-height: 60vh;
      overflow-x: hidden;
      overflow-y: auto;
    }
  }
}

.modal__box--size-h-large {
  @media (min-width: $modal-size-large) {
    height: auto;
    overflow: hidden;

    .modal__content {
      max-height: 60vh;
      overflow-x: hidden;
      overflow-y: auto;
    }
  }
}

.modal__box--size-w-large {
  max-width: $modal-size-large;
}

.modal__head,
.modal__content,
.modal__foot {
  padding-left: 1.5em;
  padding-right: 1.5em;

  *:first-child:not(.row):not(.col) {
    margin-top: 0;
  }

  *:last-child:not(.row):not(.col) {
    margin-bottom: 0;
  }
}

.modal__head {
  position: relative;
  padding-bottom: 1em;
  margin-bottom: 1em;
  border-bottom: 1px solid $colour-grey-lightmid;
}

.modal__content--centered {
  text-align: center;

  img {
    margin: 0 auto;
  }
}

.modal__close {
  position: absolute;
  top: 1em;
  right: 1em;
  z-index: 1;

  &.in-head {
    top: 1.4em;
    right: 1.4em;
  }
}

.modal--fs-menu {
  position: fixed;
  width: 100%;
  height: 100%;
  overflow-y: scroll;
  background-color: #fff;
  top: 0;
  left: 0;
  padding-top: 73px;

  .nav--chrome {
    box-shadow: none;
    border: 0;
    border-top: 1px solid $colour-grey-light;
    display: block;
  }

  .nav__link--chrome {
    padding: 0.5em 1.5em;
  }

  .modal__content {
    padding: 0;
  }
}

.modal-fs-menu-container {
  height: 100%;
  overflow: hidden;

  .header {
    position: fixed;
    width: 100%;
    top: 0;
    left: 0;
    z-index: $z-index-modals + 1;
  }

  .header__hamburger-icon {
    display: none;
  }

  .header__hamburger-close {
    display: inline-block;
  }
}

@mixin modal-panel-min() {
  border-radius: 6px;
  margin-top: $column-gutter * 2;
  margin-bottom: $column-gutter * 2;

  .modal__head,
  .modal__content,
  .modal__foot {
    padding-left: 2em;
    padding-right: 2em;

    &--fat {
      padding-left: 4em;
      padding-right: 4em;
    }

    &--tall {
      padding-top: 2em;
      padding-bottom: 2em;
    }
  }
}

@media (min-width: $modal-size-medium) {
  .modal__box--panel.modal__box--size-w-medium {
    @include modal-panel-min();
  }
}

@media (min-width: $modal-size-large) {
  .modal__box--panel.modal__box--size-w-large {
    @include modal-panel-min();
  }
}
