@use "../../../styles/mixins";

.AudioPlayer {
  display: flex;
  align-items: center;
  margin-left: auto;

  body.no-page-transitions & {
    transition: none !important;
  }

  > .Button, & > .playback-rate-menu {
    flex-shrink: 0;
    margin: 0.125rem;
  }

  .player-button {
    --color-text-secondary: var(--color-primary);
    --color-text-secondary-rgb: var(--color-primary-shade-rgb);
    --color-primary-shade: var(--color-green);
    --color-white: var(--color-background-own);

    margin: 0.125rem;

    &.smaller .icon {
      margin-top: -0.0625rem;
      font-size: 1.625rem;
    }

    .icon {
      position: absolute;
      margin-top: -0.0625rem;
      font-size: 1.9375rem;

      &.icon-play {
        margin-left: 0.125rem;
      }
    }

    .icon-play,
    .icon-pause {
      transform: scale(1);
      opacity: 1;
      transition: opacity 0.4s, transform 0.6s cubic-bezier(0.34, 1.56, 0.64, 1);
    }

    &.play .icon-pause,
    &.pause .icon-play,
    &.loading .icon-play,
    &.loading .icon-pause {
      transform: scale(0.5);
      opacity: 0;
    }
  }

  .volume-button-wrapper {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;

    .volume-slider-wrapper {
      position: absolute;
      top: 2.625rem;
      width: 8rem;
    }

    .volume-slider-spacer {
      cursor: var(--custom-cursor, default);

      position: absolute;
      bottom: 0;
      transform: translateY(100%);

      width: 8rem;
      height: 1rem;

      visibility: hidden;
    }

    &:hover .volume-slider-spacer,
    .volume-slider-spacer:hover {
      visibility: visible;
    }

    .volume-slider {
      cursor: var(--custom-cursor, default);

      position: absolute;
      bottom: -1rem;
      transform: translateY(100%);

      width: 8rem;
      padding: 0.75rem;
      border-radius: 0.5rem;

      visibility: hidden;
      opacity: 0;
      background: var(--color-background);
      box-shadow: 0 1px 2px var(--color-default-shadow);

      transition: opacity 0.2s ease-in-out, visibility 0.2s ease-in-out;

      .RangeSlider {
        margin: 0;
        input[type="range"] {
          margin-bottom: 0;
        }
      }
    }

    &:hover .volume-slider,
    .volume-slider:hover,
    .volume-slider-spacer:hover + .volume-slider {
      visibility: visible;
      opacity: 1;
    }
  }

  .playback-wrapper {
    position: relative;
  }
  .playback-backdrop {
    position: absolute;
    z-index: calc(var(--z-menu-backdrop) + 1);
    top: 0;
    right: 0;

    width: 5rem;
    height: 4rem;
  }

  .playback-button {
    &.on-top {
      z-index: calc(var(--z-menu-backdrop) + 2);
    }

    &.applied {
      --color-text-secondary: var(--color-primary);
    }

    .playback-button-inner {
      padding: 0.125rem 0.25rem;
      border: 2px solid;
      border-radius: 0.375rem;

      font-size: 0.75rem;
      font-weight: bold;
      font-variant-numeric: tabular-nums;

      transition: 0.15s color ease-out;

      &.small {
        transform: scale(0.83);
      }

      &.tiny {
        transform: scale(0.75);
      }
    }
  }

  &-content {
    cursor: var(--custom-cursor, pointer);

    position: relative;

    overflow: hidden;
    display: flex;
    flex-direction: column;
    flex-shrink: 1;
    justify-content: center;

    max-width: 14rem;
    padding: 0 0.5rem;
    border-radius: var(--border-radius-messages-small);

    &:hover {
      background-color: var(--color-interactive-element-hover);
    }

    .right-column-shown & {
      max-width: 10rem;
    }

    .AudioPlayer & .title {
      overflow: hidden;
      display: block;

      margin-top: 0.125rem;

      font-size: 0.875rem !important;
      font-weight: var(--font-weight-medium);
      line-height: 1rem;
      text-overflow: ellipsis;
      white-space: nowrap;

      body.is-ios & {
        font-size: 0.9375rem !important;
        line-height: 1.125rem;
      }
    }

    .subtitle {
      overflow: hidden;

      margin: 0.125rem 0 0;

      font-size: 0.8125rem !important;
      line-height: 0.9375rem;
      color: var(--color-text-secondary);
      text-overflow: ellipsis;
      white-space: nowrap;

      body.is-ios & {
        font-size: 0.9375rem !important;
        line-height: 1.125rem;
      }
    }

    @media (min-width: 1440px) {
      max-width: 24rem;
      .right-column-shown & {
        max-width: 14rem;
      }
    }
  }

  &.full-width-player {
    @include mixins.header-pane;

    .AudioPlayer-content {
      flex-grow: 1;
      max-width: none;
    }
  }

  .playback-rate-menu .bubble {
    min-width: auto;

    .icon-check, .icon-placeholder {
      margin-right: 0.25rem;
      margin-left: 0.25rem;
    }
  }
}
