@import '../jnt-variables';
@import '../layout/responsive';
@import '../elements/icon';
@import '../jnt-hosts';
@import '../jnt-utils';
@import '../jnt-functions';

@keyframes jnt-scale-in {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(.9);
  }
}
@keyframes jnt-scale-out {
  0% {
    transform: scale(.9);
  }
  100% {
    transform: scale(1);
  }
}
@mixin jnt-modal($passed: (), $context: null, $strategy: 'changes') {
  $defs: (
    z-index: (
      overlay: 1,
      modal: 2
    )
  );
  $vars: $passed;
  $declare: false;
  $wrapper: null;
  @if $jnt-ng-deep {
    $wrapper: '::ng-deep';
  }
  @if $passed == () or $strategy == 'merge' {
    $vars: recursive-map-merge($defs, $passed);
    $declare: true;
  }
  #{if($context, $context, $jnt-modal-host)} {
    @if $declare {
      @include reset-default();
      display: block;
      @include max-for-tablet() {
        position: fixed;
        z-index: 2;
        width: 100%;
        max-width: 100%;
        max-height: 100vh;
        overflow-y: auto;
        padding: $jnt-gutter-small;
        box-sizing: border-box;
        &[data-windows='true'] {
          @include jnt-scrollbar();
        }
      }
    }
  }
  #{$context} #{$wrapper} [data-overlay][child-of=jnt-modal-host] {
    @if $declare {
      position: fixed;
      background-color: rgba(0, 0, 0, .4);
      width: 100%;
      height: 100vh;
      left: 0;
      top: 0;
      bottom: 0;
      right: 0;
    }
    @if map-has-key($vars, z-index) {
      $z-index: map-get($vars, z-index);
      z-index: map-get($z-index, overlay);
    }
  }
  #{$context} #{$wrapper} [data-modal][child-of=jnt-modal-host] {
    @if $declare {
      transform: scale(1);
      position: fixed;
      min-width: max-content;
      max-width: 100%;
      max-height: 100%;
      top: 100%;
    }
    @if map-has-key($vars, z-index) {
      $z-index: map-get($vars, z-index);
      z-index: map-get($z-index, modal);
    }
    @include max-for-tablet() {
      @if $declare {
        min-width: 100%;
        position: relative;
        top: 0 !important;
        left: 0 !important;
        transform: none !important;
      }
    }
    [data-title][child-of=jnt-modal-host] {
      @if $declare {
        border-top-left-radius: $jnt-corner-normal;
        border-top-right-radius: $jnt-corner-normal;
        padding: $jnt-gutter-normal;
        background-color: $jnt-page-background;
        font-size: 18px;
        [data-text][child-of=jnt-modal-host] {
          color: $jnt-primary-text-color;
          font-weight: $jnt-font-weight-bold;
        }
      }
    }
    [data-content][child-of=jnt-modal-host] {
      @if $declare {
        padding: $jnt-gutter-normal;
        font-size: $jnt-font-size-base;
        box-sizing: border-box;
        overflow: auto;
        &[data-windows='true'] {
          @include jnt-scrollbar();
        }
        @include max-for-tablet() {
          overflow: visible;
          max-height: none !important;
        }
      }
    }
  }
}
@if $jnt-debug {
  @debug 'modal compiled';
}
