// Media query used to create responsive classes
@mixin pf-media-query($point) {
  @if $point == "" or $point == null or $point == "base" {
    @content;
  }

  @else if $point == "sm" {
    @media screen and (min-width: $pf-global--breakpoint--sm) {
      @content;
    }
  }

  @else if $point == "md" {
    @media screen and (min-width: $pf-global--breakpoint--md) {
      @content;
    }
  }

  @else if $point == "lg" {
    @media screen and (min-width: $pf-global--breakpoint--lg) {
      @content;
    }
  }

  @else if $point == "xl" {
    @media screen and (min-width: $pf-global--breakpoint--xl) {
      @content;
    }
  }

  @else if $point == "2xl" {
    @media screen and (min-width: $pf-global--breakpoint--2xl) {
      @content;
    }
  }
}

// Create single prop / value classes, optionally add responsive suffix
// @group mixins
// @moduleType mixin
// @parameter: {Suffix} xs, sm, md, lg, xl, base or null
// @usage: @include pf-utility-builder(class-name, base sm md lg xl);
// ===============================================================================================
//
// ## Example sass map:
// this must be used when order matters or a cluster of similar utilties need to overwrite each other
//
// Justify content options
// $pf-u-flex-options: (
//   flex-none:  (flex none),
//   flex-1:     (flex 1)
// );
//
// non-responsive, base only                @include pf-utility-builder($sass-map)
// responsive, including all breakpoints    @include pf-utility-builder($sass-map, $pf-global--breakpoint-list)
//
// ## Passing individual utilities values
// ===============================================================================================
// Example individual utility:
// @include pf-utility-builder(flex-fill flex "1 1 auto", $pf-global--breakpoint-list);

@mixin pf-utility-builder($props, $breakpoints: null) {
  // if $class-name is a map

  // stylelint-disable
  @if type-of($props) == map {
    @each $class, $val in $props {
      $property: nth($val, 1);
      $value: #{nth($val, 2) !important};

      .pf-u-#{$class} {
        #{$property}: #{$value};
      }
    }

    // if breakpoints are requested
    @if $breakpoints != null {
      @each $breakpoint in $breakpoints {
        $suffix: -on-#{$breakpoint};

        @include pf-media-query($breakpoint) {
          @each $class, $val in $props {
            $property: nth($val, 1);
            $value: #{nth($val, 2) !important};

            .pf-u-#{$class}#{$suffix} {
              #{$property}: #{$value};
            }
          }
        }
      }
    }
  }

  @else if type-of($props) == list {
    $class: nth($props, 1);
    $property: nth($props, 2);
    $value: nth($props, 3) !important;

    .pf-u-#{$class} {
      #{$property}: #{$value};
    }

    @if $breakpoints != null {
      @each $breakpoint in $breakpoints {
        $suffix: -on-#{$breakpoint};

        .pf-u-#{$class}#{$suffix} {
          @include pf-media-query($breakpoint) {
            #{$property}: #{$value};
          }
        }
      }
    }
  }
}
// stylelint-enable

@mixin pf-u-screen-reader {
  position: fixed;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@mixin pf-u-visible {
  position: static;
  overflow: visible;
  clip: auto;
  white-space: normal;
  border: inherit;
}

@mixin pf-t-light($color: "--pf-global--Color--100") {
  color: var(#{$color});

  @extend %pf-t-light;
}

@mixin pf-t-dark($color: "--pf-global--Color--100") {
  color: var(#{$color});

  @extend %pf-t-dark;
}

@mixin pf-text-overflow {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

@mixin pf-overflow-hide-scroll {
  &::-webkit-scrollbar {
    display: none;
  } // hides scrollbars in Chrome

  scrollbar-width: none; // hides scrollbars in Firefox 64 and up
  -ms-overflow-style: -ms-autohiding-scrollbar; // auto hides scrollbars in Edge
}

@mixin pf-hidden-visible($val: "block") {
  // stylelint-disable-next-line
  --pf-hidden-visible--visible--Display: #{$val};

  @extend %pf-hidden-visible;
}

@mixin pf-m-redhat-font {
  .pf-m-redhat-font {
    @content;
  }
}

// Apply media query if value is passed
@mixin pf-apply-breakpoint($breakpoint, $breakpoint-map: $pf-global--breakpoint-name-map) {
  @if ($breakpoint == "null" or $breakpoint == "base" or $breakpoint == "") {
    @content;
  }

  @else {
    $breakpoint: pf-breakpoint-value($breakpoint);

    @media (min-width: $breakpoint) {
      @content;
    }
  }
}

@mixin pf-emit-properties($map) {
  @each $prop, $value in $map {
    #{$value}: #{$prop};
  }
}
