@use '../../sass/abstracts' as *;

@mixin smallHeader {
  height: $site-header-small-height;
  @include media-breakpoint-up(md) {
    margin-bottom: calc(
      #{$site-header-height} - #{$site-header-small-height}
    ); // prevent hacky jump when decreasing header
  }
  #{$component-prefix}compact-header {
    &__content {
      height: $site-header-small-height;
    }

    &__logo-image {
      height: 1.375rem;
      width: 6.25rem;
    }
  }
}

#{$component-prefix}compact-header {
  font-family: $font-family-body;
  left: 0;
  width: 100%;
  height: $site-header-height;
  background-color: $white;
  z-index: 600;
  box-sizing: border-box;
  transition: all $transition-effect $transition-duration;

  .container,
  .container-fluid {
    align-items: center;
    justify-content: space-between;
    @extend %flexbox;
  }

  &__content {
    align-items: center;
    @extend %flexbox;
    height: $site-header-height;

    /* 
    search ipnut
  */
    #{$object-prefix}input-search {
      display: none;
      white-space: nowrap;

      &--header,
      &--header input {
        height: 2.5rem !important;

        border-radius: 1.25rem;
      }

      @include media-breakpoint-up(lg) {
        display: inline-block;
      }
    }

    &--center {
      @include media-breakpoint-up(sm) {
        -webkit-box-flex: 0;
        flex: 0 1 auto;
        position: absolute;
        top: 0;
        left: 50%;
        -webkit-transform: translateX(-50%);
        transform: translateX(-50%);
      }

      a {
        display: flex;
      }
    }

    &--right {
      flex: 0 1 auto;
    }
  }

  &__logo-image {
    height: 2rem;
    width: 8.75rem;
    transition: all $transition-effect $transition-duration;
  }

  &__button {
    color: $sodra-black !important;
    text-decoration: none;
    white-space: nowrap;
    background: transparent;
    border: none;
    cursor: pointer;
    overflow: visible;
    position: relative;
    display: inline-flex;
    white-space: nowrap;

    &--yellow .c-compact-header__button-icon {
      background-color: $yellow;

      &:hover {
        background-color: darken($yellow, 10);
      }
    }
  }

  &__button-icon {
    @include border-radius(1.25rem);
    background-color: $light-grey;
    font-size: 1.5rem !important;
    vertical-align: middle;
    min-width: 2.5rem;
    line-height: 2.5rem;
    min-height: 2.5rem;
    box-sizing: border-box;
    text-align: center;
    display: inline-block;
    top: 0;
    transition: all $transition-effect $transition-duration;

    &:hover {
      background-color: darken($light-grey, 10);
    }

    &.has-active-animation {
      background-color: $green-50;
    }
  }
  &__button-badge {
    background: $red;
    height: 1.25rem;
    width: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: $white;
    position: absolute;
    top: 0;
    right: -0.625rem;
    @include body-small;
    @include border-radius(50%);
    transition: all 0.25s ease;

    &.has-active-animation {
      height: 2rem;
      width: 2rem;
      font-size: 1rem;
    }
  }

  &__button-label {
    display: none;
    @include label-medium;
    padding-left: 0.25rem;
    line-height: initial;
    height: 2.5rem;
    float: right;
    align-items: center;
    justify-content: center;
    @include media-breakpoint-up(md) {
      display: flex;
    }
  }

  &__button-sub-label {
    font-weight: normal;
    color: $sodra-black-40;
  }

  /* 
    components
  */
  #{$component-prefix}search-form {
    display: none;
    white-space: nowrap;

    @include media-breakpoint-up(md) {
      display: inline-block;
    }

    &__input {
      line-height: 2.5rem !important;
      height: 2.5rem !important;
    }
  }

  &[stuck] {
    position: -webkit-sticky;
    position: sticky;
    top: -1px;
    @include smallHeader();

    &.has-pinned-sidebar-left #{$component-prefix}compact-header {
      @include media-breakpoint-up(md) {
        left: $sidebar-width;
        right: 0;
        width: auto;
      }
    }
  }

  @include media-breakpoint-down(md) {
    @include smallHeader();
  }
}

/**
 * ----------------------------------------
 * animation pulsate-fwd
 * ----------------------------------------
 */
@keyframes pulsate-fwd {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
