@import "variables";

.playerAndSeekContainer {
  width: 100%;
  height: 48px;
  display: flex;
  flex-direction: column;
  z-index: -1;
  position: relative;
  background-color: $bg0;
}

.mobilePlayerWrapper {
  outline: none;
  height: inherit;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: white;
  transition: 0.15s linear;
  padding: 0 10px;

  &:active {
    background-color: $bg11;
  }

  svg {
    font-size: 18px;
  }

  button {
    width: 30px;
    height: 30px;

    &:hover,
    &:active {
      color: $primaryLight;
    }
  }

  // Override track-info component
  // Disable artist anchors in mobile mini player
  a {
    cursor: default;
    pointer-events: none;

    &:hover {
      text-decoration: none;
    }
  }
}

.desktopPlayerWrapper {
  display: none;
  width: calc(100vw - 230px);
  height: 100%;
  color: white;
  padding: 0 5px;
  align-items: center;
  box-sizing: border-box;

  .playerImage {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;

    height: 72px;
    min-width: 72px;
    margin-right: 15px;

    img {
      max-height: 100%;
    }
  }

  .ytImage {
    height: 72px;
    min-width: 120px;
  }

  .playerRightControls {
    flex: 1;
    position: relative;
    align-items: center;
    justify-content: flex-end;
    display: flex;
    height: 10px;

    > button {
      display: none;
    }

    svg {
      font-size: 16px;
    }
  }
}

.youtubeContainer {
  display: none;
  overflow: hidden;
  opacity: 0;
  z-index: 1;

  position: fixed;
  left: 0;
  top: 75px;
  width: 100vw;
  padding-bottom: 56.25%;

  iframe {
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    bottom: 0;

    pointer-events: none;
  }
}

.youtubeNotExpanded {
  animation: youtubeFadeOut 450ms;
}

.youtubeExpanded {
  display: block;
  animation: youtubeFadeIn 450ms;
  opacity: 1;
}

.nowPlaying {
  display: flex;
  justify-content: center;
  width: inherit;
  text-align: center;
  overflow: hidden;

  > :last-child,
  > div > div {
    width: 100%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }
}

.centerControls {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 20px;
  width: 100%;
}

.mobileCenterControls {
  @extend .centerControls;
  box-sizing: border-box;
  position: relative;

  & > button:first-child {
    margin-right: auto;

    &:hover {
      ~ .mobileVolume {
        animation: fadeInFromNone 0.3s linear;
        display: block;
      }
    }
  }

  .mobileVolume {
    position: absolute;
    height: 10px;
    width: 5px;
    bottom: 40px;
    left: 25px;
    transform: rotate(-90deg);
    display: none;

    &:hover {
      display: block;
    }
  }

  & > button:last-child {
    margin-left: auto;
  }
}

.enabledButton {
  position: relative;
  color: $primaryLight;

  &::after {
    position: absolute;
    content: "";
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 3px;
    height: 3px;
    border-radius: 5px;
    background-color: $primaryLight;
  }
}

.backPlayForwardWrapper {
  min-width: 200px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  // Back button
  button:first-of-type {
    margin-left: 10px;
    height: 30px;
    width: 30px;
  }

  // Play button
  button:nth-of-type(2) {
    height: 50px;
    width: 50px;
    margin: 0 10px;
  }

  // Forward button
  button:last-of-type {
    margin-right: 10px;
    height: 30px;
    width: 30px;
  }
}

.expandedPlayer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;

  z-index: 1;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  right: 0;

  color: $textbg;
  background-color: rgba($bg2, 0.8);
  backdrop-filter: blur(5px);
  text-align: center;
  overflow: hidden;

  > * {
    margin-bottom: 10px;
  }

  .expandedPlayerHeader {
    display: flex;
    justify-content: flex-start;
    align-self: stretch;
    height: 65px;
    padding: 20px 20px 0 20px;
    box-sizing: border-box;

    svg {
      font-size: 25px;
    }
  }

  .expandedPlayerImageWrapper {
    position: relative;
    width: calc(100vw - 20px);
    padding-top: 100%;
    height: auto;

    > div {
      position: absolute;
      top: 0;
      left: 0;
      right: 0;
      bottom: 0;
      width: inherit;
      height: inherit;
    }
  }

  .expandedYtImage {
    @extend .expandedPlayerImageWrapper;
    width: 100vw;
    padding-top: 56.25%;
    height: auto;
  }

  .seekBarWrapper {
    width: 100%;
    display: flex;
    justify-content: center;
    align-items: center;

    > span:first-of-type,
    > span:last-of-type {
      padding: 0 10px;
    }
  }

  .mobileBackPlayForwardWrapper {
    @extend .backPlayForwardWrapper;
    justify-content: center;

    // Back and forward buttons
    button {
      height: 40px !important;
      width: 40px !important;
    }

    // Play button
    button:nth-of-type(2) {
      height: 70px !important;
      width: 70px !important;
      margin: 0 20px;
    }
  }
}

.desktopExpandPlayerButton {
  transition: 0.3s linear;
  display: none;
}

.desktopExpandPlayerButtonYT {
  @extend .desktopExpandPlayerButton;
}

@media (min-width: 800px) {
  .playerAndSeekContainer {
    height: 81px;
    z-index: 1;

    .mobilePlayerWrapper {
      display: none;
    }

    .desktopPlayerWrapper {
      display: flex;
    }
  }

  .youtubeActive {
    opacity: 1;
    display: block;
  }

  .youtubeContainer {
    bottom: 85px;
    left: 5px;
    top: auto;
    position: absolute;
    width: 200px;
    height: 200px;
    padding-bottom: 0;
    border-radius: 7px;
  }

  .hiddenYoutubePlayer {
    bottom: -200px;
  }

  .ytExpandedContainer {
    // Used to calculate center of yt container in desktop mode
    pointer-events: none;
    position: fixed;
    left: 230px;
    top: 0;
    right: 0;
    bottom: 80px;
  }

  .youtubeExpanded {
    position: absolute;
    padding-bottom: 56.25%;
    width: 100%;
    height: auto;
    border-radius: 0;
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
  }

  .nowPlaying {
    justify-content: flex-start;
    align-items: center;
    text-align: left;

    flex: 1;
  }

  .expandedPlayer {
    box-sizing: border-box;
    left: 230px;
    bottom: 80px;
    width: calc(100vw - 230px); // width of sidebar
    height: calc(100vh - 80px); // height of player footer
    z-index: -2;

    > * {
      margin-bottom: 0;
    }

    .expandedPlayerHeader {
      display: none;
    }

    .expandedPlayerImageWrapper {
      width: calc(100vw - 230px);
      top: 50%;
      left: 50%;
      transform: translate(-50%, -50%);

      > div {
        border-color: transparent;
        border-radius: 0;
      }
    }

    .expandedYtImage {
    }

    .mobileBackPlayForwardWrapper,
    .seekBarWrapper,
    .mobileCenterControls {
      display: none;
    }
  }

  .centerControls {
    width: auto;
  }

  .desktopExpandPlayerButton {
    display: block;
    position: fixed;
    left: 252px;
    bottom: 20px;
    border-radius: 50%;
    font-size: 25px;
    width: 40px;
    height: 40px;
    z-index: 8;
    transition: 250ms linear;
    opacity: 0;
    background-color: $bg14;

    svg {
      color: white;
    }

    &:hover {
      opacity: 1;
    }
  }

  .desktopMinimizePlayerButton {
    bottom: calc(100vh - 80px + 15px);
  }

  .desktopExpandPlayerButtonYT {
    left: 275px;
  }

  .headerExpandButton {
    opacity: 1;
    bottom: calc(100vh - 80px + 15px);
  }
}

@media (min-width: 900px) {
  .desktopPlayerWrapper {
    .playerRightControls button {
      display: inline;
      width: 25px;
      margin-right: 5px;
    }
  }
}

@media (min-width: 800px) {
  .expandedPlayer {
    .nowPlaying {
      display: none;
    }
  }
}

@keyframes youtubeFadeIn {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

@keyframes youtubeFadeOut {
  0% {
    opacity: 0;
  }
  30% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}
