@import 'settings';

//
// jQuery UI Dialog
// --------------------------------------------------

//
// jQuery UI Dialog 1.11.4
// http://jqueryui.com
//
// Copyright jQuery Foundation and other contributors
// Released under the MIT license.
// http://jquery.org/license
// http://api.jqueryui.com/dialog/#theming
//

@keyframes fadein {
  from {
    opacity: 0;
  }
  to {
    opacity: $modal-backdrop-opacity;
  }
}

@keyframes fadein_scale {
  from {
    opacity: 0;
    transform: translateY(-30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.ui-front {
  z-index: 100;
}

/* Overlays */
.ui-widget-overlay {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: $zindex-modal-background;
  background-color: #edeff5;
  opacity: .9;
  animation: fadein 0.3s;
}

.ui-helper-hidden-accessible {
  border: 0;
  clip: rect(0 0 0 0);
  height: 1px;
  margin: -1px;
  overflow: hidden;
  padding: 0;
  position: absolute;
  width: 1px;
}

// General modal window styles */
.ui-dialog:not(.ui-dialog-off-canvas)[role='dialog'] {
  margin: 0;
  padding: 0;
  border: 0;
  border-radius: .625rem;
  background-color: $modal-content-bg;
  background-clip: padding-box;
  backface-visibility: hidden;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
  overflow-x: hidden;
  overflow-y: auto;
  z-index: $zindex-modal;
  font-family: 'montserrat', sans-serif;
  animation: fadein_scale 0.5s ease-out;

  &:hover,
  &:focus {
    box-shadow: 0 3px 9px rgba(0, 0, 0, 0.5);
  }

  @media(max-width: 767px) {
    width: auto !important;
    min-width: 92%;
    max-width: 92%;
  }

  .ui-dialog-titlebar {
    position: relative;
    width: 100%;
    padding: 1.25rem 1.5rem 1rem;
    border: 0;
    border-radius: 0;
    background: #1b1b1d;

    .ui-dialog-title {
      max-width: 500px;
      margin: 0;
      padding-right: 2rem;
      font-size: 1.125rem;
      font-weight: normal;
      line-height: 27px;
      color: #fff;
      white-space: nowrap;
      overflow: hidden;
      text-overflow: ellipsis;
    }

    .ui-dialog-titlebar-close {
      position: absolute;
      width: 1.75rem;
      height: 1.75rem;
      top: 50%;
      margin: 0;
      font-size: 0;
      background: 0 0;
      border: none;
      outline: none;
      opacity: 1;
      cursor: pointer;
      appearance: none;
      transform: translateY(-50%);

      [dir='ltr'] & {
        right: 1.125rem;
      }

      [dir='rtl'] & {
        left: 1.125rem;
      }

      > span {
        display: none;
      }

      &:before {
        content: '';
        display: block;
        width: 100%;
        height: 100%;
        margin: auto;

        position: absolute;
        top: 0;
        right: 0;
        background-repeat: no-repeat;
        background-position: center;
        background-image: url('../images/icons/icon-close_white.svg');

        text-indent: 0;
        transform: scale(1);
        transition: 0.3s;
      }

      &:hover:before {
        transform: scale(1.2);
      }
    }
  }

  .ui-button-icon-only {
    text-indent: -9999px;
    white-space: nowrap;
  }

  .ui-dialog-content {
    position: relative;
    flex: 1 1 auto;
    height: auto !important;
    padding: 1rem 1.25rem;
    box-shadow: none;
    overflow: auto;
    max-height: 70vh !important;
  }

  // Update position for the ajax throbber.
  .btn {
    position: relative;

    .ajax-throbber {
      position: absolute;
      margin-left: 0 !important;
      margin-right: 0 !important;
      right: -2px;
    }
  }

  // Remove extra borders on the hidden buttons
  // on the delete comment form
  .comment-post-comment-delete-form,
  .comment-comment-delete-form {
    &.is_modal {
      .form-actions {
        .btn {
          border: 0 !important;
        }
      }
    }
  }

  .ui-dialog-titlebar .ui-dialog-titlebar-close {
    font-size: 0;
    cursor: pointer;
    background: 0 0;
    border: none;
    outline: none;
    appearance: none;
    opacity: 1;
    margin: 0;
    width: 1.75rem;
    height: 1.75rem;
    top: 50%;
    transform: translateY(-50%);

    > span {
      display: none;
    }

    &:before {
      content: '';
      display: block;
      width: 100%;
      height: 100%;
      margin: auto;

      position: absolute;
      top: 0;
      right: 0;
      background-repeat: no-repeat;
      background-position: center;
      background-image: url('../images/icons/icon-close_white.svg');

      text-indent: 0;
      transform: scale(1);
      transition: 0.3s;
    }

    &:hover:before {
      transform: scale(1.2);
    }
  }
}

.ui-dialog-titlebar {
  display: flex;
  align-items: center;
  justify-content: normal;
  padding: 12px 1rem;
  border-bottom: 1px solid $gray-lighter;
}

.ui-dialog-title {
  font-family: $headings-font-family;
  font-weight: $headings-font-weight;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 1rem;
  line-height: 1.625rem;
}

.ui-button-icon-only {
  text-indent: -9999px;
  white-space: nowrap;
}

.ui-dialog-content {
  position: relative;
  overflow: auto;
  box-shadow: none;
  flex: 1 1 auto;
  padding: 1rem;

  @include for-phone-only {
    max-height: 60vh !important; // make sure the height doesn't stretch beyond the height of th e screen including the browser toolbar
  }
}

// Kill the scroll on the body
.modal-open {
  overflow: hidden;
}

// Container that the modal scrolls within
.modal {
  display: none;
  overflow: hidden;
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: $zindex-modal;
  -webkit-overflow-scrolling: touch;

  // Prevent Chrome on Windows from adding a focus outline. For details, see
  // https://github.com/twbs/bootstrap/pull/10951.
  outline: 0;

  // When fading in the modal, animate it to slide down
  &.fade .modal-dialog {
    transform: translate(0, -25%);
    transition: transform 0.3s ease-out;
  }
  &.in .modal-dialog {
    transform: translate(0, 0);
  }
}

.modal-open .modal {
  overflow-x: hidden;
  overflow-y: auto;
}

// Shell div to position the modal with bottom padding
.modal-dialog {
  position: relative;
  width: auto;
  margin: 10px;
}

// Actual modal
.modal-content {
  position: relative;
  background-color: $modal-content-bg;
  border: 1px solid $modal-content-fallback-border-color; //old browsers fallback (ie8 etc)
  border: 1px solid $modal-content-border-color;
  border-radius: 12px;
  box-shadow: 0 3px 9px rgba(0, 0, 0, .5);
  background-clip: padding-box;
  // Remove focus outline from opened modal
  outline: 0;
}

// Small modal
.social-dialog {
  &.ui-dialog {
    max-width: 320px;
    @media(min-width: 900px) {
      max-width: 400px;
    }
  }

  .ui-dialog-content {
    padding: 2rem 1rem;

    @media(min-width: 900px) {
      padding: 2rem 2.5rem 2.5rem;
    }

  }
  .ui-dialog-buttonpane,
  .ui-dialog-titlebar {
    display: none;
  }

  .ui-dialog-message-title {
    margin: 0 0 1.5rem;

    strong {
      font-weight: bold;
    }

  }

  p {
    line-height: 1.3;
  }

  small {
    display: block;
    color: #777;
    margin-bottom: 2rem;
  }

  .form-actions {
    display: flex;
    justify-content: space-between;
    flex: 0 0 50%;
    margin-bottom: 0;
  }

  .btn {
    padding: 0.5rem 2rem !important;
    width: 100% !important;
    height: auto !important;
  }

  .btn + .btn {
    margin-left: 1rem;
  }
  .pull-left {
    order: -1;
    margin-left: 0 !important;
    margin-right: 1rem;
  }

}

.ui-dialog-buttonpane {
  .ui-dialog--narrow & {
    padding: 0 1rem 1rem;
  }
}
