// Lightning Design System 2.264.0-beta.1
// Copyright (c) 2015-present, salesforce.com, inc. All rights reserved
// Licensed under BSD 3-Clause - see LICENSE.txt or git.io/sfdc-license

/**
 * @summary Global actions component wrapper
 * @selector .slds-global-actions
 * @restrict .slds-global-header ul
 */
.slds-global-actions {
  display: flex;
  align-items: center;
}

/**
 * @summary List item for each global action
 * @selector .slds-global-actions__item
 * @restrict .slds-global-actions li
 */
.slds-global-actions__item {
  margin-left: $spacing-xx-small;
  margin-right: $spacing-xx-small;

  .slds-button_icon {
    color: $brand-header-contrast-weak;
  }
}

/**
 * @summary The actionable button inside of a global actions list item
 * @selector .slds-global-actions__item-action
 * @restrict .slds-global-actions__item button
 */
.slds-global-actions__item-action {
  transition: color 200ms linear;

  &:hover:not(:disabled),
  &:focus {
    color: $brand-header-contrast-weak-active;
  }

  &:active {
    animation: click-icon 120ms cubic-bezier(1, 1.9, 0.94, 0.98);
  }

  &:active:not(:disabled) {
    color: $brand-header-contrast;
  }
}

@keyframes click-icon {

  25% {
    transform: scale(0.94, 0.94);
  }

  100% {
    transform: scale(0.98, 0.98);
  }
}

/**
 * @summary User profile action icon
 * @selector .slds-global-actions__avatar
 * @restrict .slds-global-actions__item-action
 */
.slds-global-actions__avatar {
  box-shadow: $brand-header-contrast-weak-active 0 0 0 0;
  border-radius: $border-radius-circle;
  border: 0;
  margin-left: $spacing-x-small;
  transition: transform 80ms ease-out, box-shadow 0.1s linear;

  &:hover {
    box-shadow: $brand-header-contrast-weak-active 0 0 0 2px;
  }

  &:focus {
    box-shadow: var(--slds-g-shadow-outset-focus-1);
    outline: 0;
  }

  &.slds-global-actions__item-action:focus-visible {
    box-shadow: var(--slds-g-shadow-outset-focus-1);
  }
}

/**
 * @summary Favorites action button group
 * @selector .slds-global-actions__favorites
 * @restrict .slds-global-actions__item div
 */
.slds-global-actions__favorites {
  display: inline-flex;
  margin-right: $spacing-x-small;
}

/**
 * @summary Star icon inside of favorites button group
 * @selector .slds-global-actions__favorites-action
 * @restrict .slds-global-actions__favorites button
 */
.slds-global-actions__favorites-action {
  border-color: $brand-header-contrast-weak;

  &:hover {
    border-color: $brand-header-contrast;
  }

  .slds-button__icon {
    @include square(1rem);
    transition: transform 200ms ease-out;
  }

  &:hover:not(:disabled) .slds-button__icon {
    transform: scale(1.1, 1.1);
    transform-origin: 60% 40%;
  }

  /**
   * @summary Selected/clicked state on favorites button
   * @selector .slds-is-selected
   * @restrict .slds-global-actions__favorites-action
   */
  &.slds-is-selected {
    background-color: $brand-header-contrast-cool;
    border-color: $brand-header-contrast-cool;

    &:hover,
    &:focus {
      background-color: $brand-header-contrast-cool-active;
      border-color: $brand-header-contrast-cool-active;
    }

    .slds-button__icon {
      animation: click-favorites-icon 600ms cubic-bezier(0.46, 0.32, 0, 0.98);
    }
  }

  /**
   * @summary Disabled state on favorites button
   * @selector .slds-is-disabled
   * @restrict .slds-global-actions__favorites-action
   */
  &:disabled,
  &.slds-is-disabled {
    color: var(--slds-g-color-neutral-base-80, #{$brand-header-contrast-weak-disabled});
    border-color: var(--slds-g-color-border-base-1, #{$brand-header-contrast-weak-disabled});
  }
}

/**
 * @summary More dropdown icon inside of favorites button group
 * @selector .slds-global-actions__favorites-more
 * @restrict .slds-global-actions__favorites button
 */
.slds-global-actions__favorites-more {
  padding-left: $spacing-xxx-small;
  padding-right: $spacing-xxx-small;
  border-color: $brand-header-contrast-weak;

  &:hover {
    border-color: $brand-header-contrast;
  }
}

// Animation for favorites action icon
@keyframes click-favorites-icon {

  25% {
    transform: scale(0.85, 0.85) rotate(15deg);
  }

  75% {
    transform: scale(1.2, 1.2) rotate(0deg);
  }

  100% {
    transform: scale(1, 1) rotate(0deg);
  }
}


/**
 * @summary Task action icon
 * @selector .slds-global-actions__task
 * @restrict .slds-global-actions__item-action
 */
.slds-global-actions__task {
  @include square(1.25rem);
  background: $brand-header-contrast-weak;
  position: relative;
  top: -1px;

  &:hover {
    background: $brand-header-contrast-weak-active;
  }

  &:active {
    background: $brand-header-contrast;
  }

  &.slds-global-actions__item-action,
  &.slds-global-actions__item-action:hover,
  &.slds-global-actions__item-action:active {
    color: var(--slds-g-color-neutral-base-100, #{$color-gray-1});
  }

  &.slds-global-actions__item-action:focus-visible {
    box-shadow: var(--slds-g-shadow-outset-focus-1);
  }

  .slds-button__icon {
    @include square(1rem);
  }
}

/**
 * @summary Notification action icon
 * @selector .slds-global-actions__notifications
 * @restrict .slds-global-actions__item-action
 */
.slds-global-actions__notifications {
  position: relative;

  &.slds-incoming-notification {
    animation: bell 0.8s ease-in-out;
  }
}

/**
 * @summary Notification counter badge
 * @selector .slds-notification-badge
 * @restrict .slds-global-actions__item span
 */
.slds-notification-badge {
  display: inline-flex;
  justify-content: center;
  align-content: center;
  align-items: center;
  position: absolute;
  top: rem(4px * -1);
  right: rem(4px * -1);
  background: $brand-header-contrast-warm;
  color: var(--slds-g-color-neutral-base-100, #{$color-gray-1});
  border-radius: $border-radius-pill;
  min-width: 1rem;
  min-height: 1rem;
  text-align: center;
  font-size: $font-size-1;
  padding: 0 $spacing-xxx-small;
  opacity: 0;
  pointer-events: none;

  &.slds-show-notification {
    animation: ding 0.8s ease-out;
    opacity: 1;
    transition-delay: 0.5s;
    transform-origin: rem(19px) 0;
  }
}

// Badge Animation
@keyframes ding {

  75% {
    transform: scale(0.5, 0.5);
  }

  85% {
    transform: scale(1.5, 1.5);
  }

  100% {
    transform: scale(1, 1);
  }
}

// Notification Bell Animation
@keyframes bell {

  45% {
    transform: rotate(15deg);
  }

  57% {
    transform: rotate(-15deg);
  }

  70% {
    transform: rotate(7deg);
  }

  77% {
    transform: rotate(-5deg);
  }
}
