// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only

.CallingButton {
  @mixin icon($path) {
    @include color-svg($path, $color-white);
    height: 20px;
    width: 20px;
    border: none;
  }

  &__icon {
    align-items: center;
    border-radius: 52px;
    border: none;
    display: flex;
    height: 52px;
    justify-content: center;
    outline: none;
    width: 52px;
    margin-inline: 6px;

    @mixin calling-button-icon($icon, $background-color, $icon-color) {
      background-color: $background-color;

      div {
        @include color-svg($icon, $icon-color);
        height: 24px;
        width: 24px;
      }
    }

    @mixin calling-button-icon-highlighted($icon) {
      @include calling-button-icon($icon, $color-gray-15, $color-gray-90);
    }

    @mixin calling-button-icon-regular($icon) {
      @include calling-button-icon($icon, $color-gray-60, $color-gray-15);
      backdrop-filter: blur(10px);
    }

    @mixin calling-button-icon-disabled($icon) {
      @include calling-button-icon($icon, $color-gray-60, $color-gray-15);
      opacity: 0.4;
    }

    &--audio {
      $icon: '../images/icons/v3/mic/mic-slash-fill-light.svg';
      &--on {
        @include calling-button-icon-regular(
          '../images/icons/v3/mic/mic-fill-light.svg'
        );
      }
      &--off {
        @include calling-button-icon-highlighted($icon);
      }
      &--disabled {
        @include calling-button-icon-disabled($icon);
      }
    }

    &--video {
      $icon: '../images/icons/v3/video/video-slash-fill-light.svg';
      &--on {
        @include calling-button-icon-regular(
          '../images/icons/v3/video/video-fill-light.svg'
        );
      }
      &--off {
        @include calling-button-icon-highlighted($icon);
      }
      &--disabled {
        @include calling-button-icon-disabled($icon);
      }
    }

    &--hangup {
      @include calling-button-icon(
        '../images/icons/v3/phone/phone-down-fill-light.svg',
        $color-accent-red,
        $color-white
      );
    }

    &--ring {
      $icon: '../images/icons/v3/bell/bell-slash-fill.svg';
      &--on {
        @include calling-button-icon-regular(
          '../images/icons/v3/bell/bell-ring-fill-light.svg'
        );
      }
      &--off {
        @include calling-button-icon-highlighted($icon);
      }
      &--disabled {
        @include calling-button-icon-disabled($icon);
      }
    }

    &--presenting {
      $icon: '../images/icons/v3/share_screen/share_screen-fill-light.svg';
      &--on {
        @include calling-button-icon-highlighted($icon);
      }
      &--off {
        @include calling-button-icon-regular($icon);
      }
      &--disabled {
        @include calling-button-icon-disabled($icon);
      }
    }
  }

  &__participants {
    @include icon('../images/icons/v3/group/group.svg');
    display: inline-block;

    &--container {
      @include button-reset;
      border: none;
      color: $color-white;
    }

    &--shown {
      background-color: $color-gray-75;
      border-radius: 16px;
      padding-block: 6px;
      padding-inline: 8px;
    }

    &--count {
      @include font-body-2;
      margin-inline-start: 5px;
      vertical-align: top;
    }
  }

  &__settings {
    @include icon('../images/icons/v3/tune/tune.svg');
  }

  &__grid-view {
    @include icon('../images/icons/v3/grid/grid.svg');
  }

  &__speaker-view {
    @include icon('../images/icons/v3/speaker_view/speaker_view.svg');
  }

  &__pip {
    @include icon('../images/icons/v3/pip/pip.svg');
  }

  &__cancel {
    @include icon('../images/icons/v3/x/x.svg');
  }

  &__container {
    display: inline-flex;
    flex-direction: column;
    margin-inline: 6px;
    max-width: 64px;

    transition: margin-inline-start 0.3s ease-out, opacity 0.3s ease-out;
    @media (prefers-reduced-motion) {
      transition: none;
    }

    &--hidden {
      margin-inline-start: -100px;
      opacity: 0;
      pointer-events: none;

      // The container could be wider than 100px depending on the label. Hiding the label
      //  ensures that the above `margin-left` will completely hide the button.
      .CallingButton__label {
        display: none;
      }
    }
  }

  &__label {
    @include font-subtitle;
    margin-top: 8px;
    text-align: center;
    color: $color-white;
    @include calling-text-shadow;
    user-select: none;
  }
}
