@import "../../../../../../../public/css/variables";
@import "../../../../../../../public/css/functions";
@import "../../../../../../../public/css/mixins";
@import "~material-components-web/material-components-web";

.ng-svg-filter-distorted {
  position: absolute;
  visibility: hidden;
  width: 1px;
  height: 1px;
}

.ng-button-distorted,
.ng-button-distorted__bg {
  .safari & {
    -webkit-filter: none !important;
    filter: none !important;
  }
}

:host(.ng-button-distorted),
.ng-button-distorted {
  display: inline-block;
  min-width: 200px;
  height: 44px;
  border-radius: 5px;
  cursor: pointer;

  .ng-button-distorted__model {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
    z-index: 0;
    position: relative;
    max-width: inherit;
    min-width: inherit;
    width: inherit;
    max-height: inherit;
    min-height: inherit;
    height: inherit;
    margin: 0;
    padding: 0;
    outline: 0;
    border: 0;
    border-radius: inherit;
    background: transparent none;
    box-shadow: none;
    cursor: pointer;
    user-select: none;
    -webkit-appearance: none;
  }

  .ng-button-distorted__container {
    z-index: -1;
    position: relative;
    display: block;
    max-width: inherit;
    min-width: inherit;
    width: inherit;
    max-height: inherit;
    min-height: inherit;
    height: inherit;
    border-radius: inherit;
    pointer-events: none;
    @include transform(translateZ(0));
    @include transition(all 0.1s ease-out);
  }

  .ng-button-distorted__bg {
    z-index: 2;
    overflow: hidden;
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: transparent none;
    border-radius: inherit;
    box-shadow: none;
    @include transition(background-color 0.1s ease-out);
    -webkit-font-smoothing: antialiased;
  }

  .ng-button-distorted__ink {
    background: transparent none;
    @include transition(background-color 0.1s ease-out);
  }

  .ng-button-distorted__label {
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    max-width: inherit;
    min-width: inherit;
    width: inherit;
    max-height: inherit;
    min-height: inherit;
    height: inherit;
    padding: 0 16px;
    border-radius: inherit;

    @include knk-font-default;
    @include mdc-button-ink-color($knk-color-primary);
    font-size: 20px;
    line-height: 1.6;
    text-transform: initial;
    white-space: nowrap;
    text-decoration: none;
    user-select: none;
  }

  &::ng-deep .ng-button-distorted__icon {
    display: inline-block;
    margin-left: 5px;
    margin-right: 5px;
    font-size: 125%;
    vertical-align: top;
  }

  .ng-button-distorted__icon {
    display: inline-block;
    margin-left: 5px;
    margin-right: 5px;
    font-size: 125%;
    vertical-align: top;
  }

  &::ng-deep svg.ng-button-distorted__icon {
    @include mdc-button__icon-svg_;
  }

  svg.ng-button-distorted__icon {
    @include mdc-button__icon-svg_;
  }

  &[disabled],
  &[ng-reflect-disabled="true"] {
    cursor: default;
    pointer-events: none;
  }

  &[disabled] .ng-button-distorted__model:disabled,
  &[ng-reflect-disabled="true"] .ng-button-distorted__model:disabled {
    background: transparent none;
    cursor: default;
    pointer-events: none;
  }

  &[disabled] .ng-button-distorted__model:disabled .ng-button-distorted__label,
  &[ng-reflect-disabled="true"] .ng-button-distorted__model:disabled .ng-button-distorted__label {
    @include mdc-button-ink-color($knk-color-grey);
  }
}

:host(.ng-button-distorted.ng-button-distorted--outlined),
.ng-button-distorted.ng-button-distorted--outlined {
  .ng-button-distorted__bg {
    @include mdc-button--outlined_;
    @include mdc-button-outline-width(1px);
    @include mdc-button-outline-color($knk-color-primary);
  }

  .ng-button-distorted__label {
    @include mdc-button-ink-color($knk-color-primary);
  }
}

:host(.ng-button-distorted.ng-button-distorted--outlined.ng-button-distorted--greyed),
.ng-button-distorted.ng-button-distorted--outlined.ng-button-distorted--greyed {
  .ng-button-distorted__bg {
    @include mdc-button-outline-color($knk-color-grey);
  }

  .ng-button-distorted__label {
    @include mdc-button-ink-color($knk-color-grey);
  }
}

:host(.ng-button-distorted.ng-button-distorted--filled),
.ng-button-distorted.ng-button-distorted--filled {
  .ng-button-distorted__bg {
    @include mdc-button--filled_;
    @include mdc-button-container-fill-color($knk-color-primary);
  }

  .ng-button-distorted__ink {
    @include mdc-button-container-fill-color($knk-color-primary);
  }

  .ng-button-distorted__label {
    @include mdc-button-ink-color(#ffffff);
  }

  &:hover .ng-button-distorted__bg,
  &:hover .ng-button-distorted__ink {
    // box-shadow: 0 2px 9px 0 rgba($knk-color-primary, 1);
    box-shadow: none;
  }

  &:hover .ng-button-distorted__label {
    @include mdc-button-ink-color(darken(#ffffff, 10%));
  }

  &:active .ng-button-distorted__bg,
  &:active .ng-button-distorted__ink {
    @include mdc-button-container-fill-color(shade($knk-color-primary, 25%));
    box-shadow: none;
  }

  &:active .ng-button-distorted__label {
    @include mdc-button-ink-color(#ffffff);
  }

  &[disabled] .ng-button-distorted__model:disabled .ng-button-distorted__bg,
  &[disabled] .ng-button-distorted__model:disabled .ng-button-distorted__ink,
  &[ng-reflect-disabled="true"] .ng-button-distorted__model:disabled .ng-button-distorted__bg,
  &[ng-reflect-disabled="true"] .ng-button-distorted__model:disabled .ng-button-distorted__ink {
    @include mdc-button-container-fill-color(#d6dadb);
    box-shadow: none;
  }

  &[disabled] .ng-button-distorted__model:disabled .ng-button-distorted__label,
  &[ng-reflect-disabled="true"] .ng-button-distorted__model:disabled .ng-button-distorted__label {
    @include mdc-button-ink-color(#87898a);
  }
}

:host(.ng-button-distorted.ng-button-distorted--filled.ng-button-distorted--greyed),
.ng-button-distorted.ng-button-distorted--filled.ng-button-distorted--greyed {
  .ng-button-distorted__bg,
  .ng-button-distorted__ink {
    @include mdc-button-container-fill-color($knk-color-grey);
  }

  .ng-button-distorted__label {
    @include mdc-button-ink-color(#ffffff);
  }

  &:hover .ng-button-distorted__bg,
  &:hover .ng-button-distorted__ink {
    // box-shadow: 0 2px 9px 0 rgba($knk-color-grey, 1);
    box-shadow: none;
  }

 &:hover .ng-button-distorted__label {
    @include mdc-button-ink-color(darken(#ffffff, 10%));
  }

  &:active .ng-button-distorted__bg,
  &:active .ng-button-distorted__ink {
    @include mdc-button-container-fill-color(shade($knk-color-grey, 25%));
    box-shadow: none;
  }

  &:active .ng-button-distorted__label {
    @include mdc-button-ink-color(#ffffff);
  }
}

:host(.ng-button-distorted.ng-button-distorted--rounded),
.ng-button-distorted.ng-button-distorted--rounded {
  border-radius: 30px;
}

:host(.ng-button-distorted.ng-button-distorted--transparent),
.ng-button-distorted.ng-button-distorted--transparent {
  .ng-button-distorted__bg,
  .ng-button-distorted__label {
    opacity: 0.5;
  }
}

:host(.ng-button-distorted),
.ng-button-distorted {
  .ng-button-distorted__bg,
  .circle {
    // @include animation(hue-rotate 10s linear infinite);
  }

  .circle {
    position: absolute;
    width: 22px;
    height: 22px;
    border-radius: 15px;

    &.top-left {
      top: 11px;
      left: 11px;
    }

    &.bottom-right {
      bottom: 11px;
      right: 11px;
    }
  }
}

@keyframes hue-rotate {
  from {
    -webkit-filter: hue-rotate(0);
    -moz-filter: hue-rotate(0);
    -ms-filter: hue-rotate(0);
    filter: hue-rotate(0);
  }
  to {
    -webkit-filter: hue-rotate(360deg);
    -moz-filter: hue-rotate(360deg);
    -ms-filter: hue-rotate(360deg);
    filter: hue-rotate(360deg);
  }
}
