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

@use '../mixins';
@use '../variables';

@mixin audio-icon($name, $icon, $color) {
  &--#{$name}::before {
    @include mixins.color-svg('../images/icons/#{$icon}.svg', $color, false);
    & {
      -webkit-mask-size: 100%;
    }
  }
}

@mixin all-audio-icons($color) {
  @include audio-icon(play, v3/play/play-fill, $color);
  @include audio-icon(pause, v3/pause/pause-fill, $color);
  @include audio-icon(pending, v2/audio-spinner-arc-22, $color);
}

.MiniPlayer {
  position: absolute;
  top: 0;
  inset-inline: 0;
  z-index: calc(variables.$z-index-above-above-base + 1);
  display: flex;
  align-items: center;
  gap: 18px;
  padding-block: 8px;
  padding-inline: 16px;
  margin-top: calc(52px + var(--title-bar-drag-area-height));
  text-align: start;

  @include mixins.light-theme {
    background-color: variables.$color-gray-02;
  }
  @include mixins.dark-theme {
    background-color: variables.$color-gray-75;
  }

  &--flow {
    margin-top: 0;
    position: relative;
  }

  &__playback-button {
    @include mixins.button-reset;

    &::before {
      display: block;
      width: 14px;
      height: 14px;
      content: '';
    }

    @include mixins.light-theme {
      @include all-audio-icons(variables.$color-gray-60);
    }

    @include mixins.dark-theme {
      @include all-audio-icons(variables.$color-gray-15);
    }

    &--pending::before {
      animation: rotate 1000ms linear infinite;
    }
  }

  &__state {
    flex: 1;
  }

  &__middot {
    padding-block: 0;
    padding-inline: 5px;
  }

  &__close-button {
    @include mixins.button-reset;

    & {
      border-radius: 4px;
      height: 16px;
      width: 16px;
    }

    &::before {
      content: '';
      display: block;
      width: 100%;
      height: 100%;

      @include mixins.light-theme {
        @include mixins.color-svg(
          '../images/icons/v3/x/x.svg',
          variables.$color-gray-75
        );
      }

      @include mixins.dark-theme {
        @include mixins.color-svg(
          '../images/icons/v3/x/x.svg',
          variables.$color-gray-15
        );
      }
    }

    @include mixins.light-theme {
      &:hover,
      &:focus {
        background: variables.$color-gray-02;
      }
      &:active {
        background: variables.$color-gray-05;
      }
    }
    @include mixins.dark-theme {
      &:hover,
      &:focus {
        background: variables.$color-gray-80;
      }
      &:active {
        background: variables.$color-gray-75;
      }
    }
  }
}
