<template>
  <div class="final">
    <div class="final__container">
      <div class="final__table-outer-border">
        <div class="final__table-head">
          <div class="final__title">{{ title }}</div>
        </div>
        <div class="final__table-body">
          <table class="final__table">
            <tr class="final__table-row" v-for="player in players" :key="player.id">
              <td class="final__table-col-name">{{ player.name }}</td>
              <td class="final__table-col-score">{{ player.score }}</td>
            </tr>
          </table>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  computed: {
    title() {
      return 'Team Banana Mania'
    },
    players() {
      var players = [...this.$store.state.players.players]
      players.sort((a, b) => {
        return b.score - a.score
      })
      return players
    },
  },
}
</script>

<style lang="scss">
.final {
  display: flex;
  width: 100%;
  height: 100%;
  align-items: center;
  justify-content: center;

  &__container {
    margin: 64px 0;
    width: 600px;
    min-height: 600px;
  }

  &__table-outer-border {
    display: flex;
    flex-direction: column;
    position: relative;
    width: 100%;
    height: 100%;
    padding: 4px;
    border-radius: 32px;
    background: linear-gradient(45deg, #8060c0 0, #8060c0 68%, #ffffff 70%, #8060c0 72%, #8060c0 100%);
    background-size: 1000% 1000%;
    animation: finals-gradient 10s linear infinite 5s;

    &::after {
      content: '';
      display: block;
      position: absolute;
      left: 0;
      top: 0;
      width: 100%;
      height: 100%;
      background: linear-gradient(45deg, rgba(128, 96, 192, 0) 50%, #402080 60%);
      background-size: 1000% 1000%;
      animation: finals-gradient__fade-in 5s ease forwards;
    }
  }

  &__table-head {
    display: flex;
    width: 100%;
    height: 100px;
    align-items: center;
    justify-content: center;
    background-color: #402080;
    border-radius: 32px 32px 0 0;
    margin-bottom: 4px;
  }

  &__title {
    color: #ffffff;
    font-family: "Wendy One";
    font-size: 48px;
  }

  &__table-body {
    width: 100%;
    height: 100%;
    background-color: #402080;
    border-radius: 0 0 32px 32px;
    color: #ffffff;
    font-family: Dosis;
    font-size: 32px;

  }
  &__table {
      width: 100%;
      padding: 64px;

    &-row {
      opacity: 0;
      animation: finals-text 1s ease forwards;
      &:nth-child(1) { animation-delay: 5.5s; }
      &:nth-child(2) { animation-delay: 4.5s; }
      &:nth-child(3) { animation-delay: 3.5s; }
      &:nth-child(4) { animation-delay: 2.4s; }
      &:nth-child(5) { animation-delay: 2.2s; }
      &:nth-child(6) { animation-delay: 2s; }
      &:nth-child(7) { animation-delay: 1.9s; }
      &:nth-child(8) { animation-delay: 1.8s; }
      &:nth-child(9) { animation-delay: 1.7s; }
      &:nth-child(10) { animation-delay: 1.6s; }
      &:nth-child(11) { animation-delay: 1.5s; }
      &:nth-child(12) { animation-delay: 1.4s; }
      &:nth-child(13) { animation-delay: 1.3s; }
      &:nth-child(14) { animation-delay: 1.2s; }
      &:nth-child(15) { animation-delay: 1.1s; }
      &:nth-child(16) { animation-delay: 1s; }
    }

    &-col-name {
      max-width: 300px;
      white-space: nowrap;
      overflow: hidden;
    }

    &-col-score {
      text-align: right;
    }
  }
}

@keyframes finals-gradient__fade-in {
  0% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

@keyframes finals-gradient {
  0% { background-position: 130% 50%; }
  10% { background-position: 130% 50%; }
  90% { background-position: 0% 50%; }
  100% { background-position: 0% 50%; }
}
@keyframes finals-text {
  0% { opacity: 0; }
  100% { opacity: 100%; }
}
</style>
