<template>
  <div class="play">
    <div class="play__layout">
      <div :class="['play__layout-playground', cssLayoutClass ]">
        <Quote :text="quote" />
        <Sources :sources="sources" :selectable="selectable" />
      </div>
      <div class="play__layout-right-column">
        <PlayerList :players="players" />
        <ConfirmButton v-if="selectable"/>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  computed: {
    cssLayoutClass() {
      if (this.$store.state.game.phase === 'reveal-start') {
        return 'play__layout-playground__fade-out'
      } else if (this.$store.state.game.phase === 'reveal-show-count') {
        return 'play__layout-playground__fade-in'
      }

      return
    },
    gamePhase() {
      return this.$store.state.game.phase
    },
    quote() {
      return this.$store.state.round.quote
    },
    sources() {
      return this.$store.state.round.sources
    },
    players() {
      return this.$store.state.players.players
    },
    selectable() {
      const userId = this.$store.state.engine.user.id
      const selection = this.$store.state.round.selections[userId]

      if (this.$store.state.game.phase != 'select-quote') return false
      if (typeof selection === 'undefined') return true
      return !selection
    },
  },
}
</script>

<style lang="scss">
html,
body,
#__nuxt,
#__layout,
.layout-default,
.page-play {
  height: 100%;
}

.play {
  position: relative;
  width: 100%;
  height: 100%;

  &__layout {
    display: flex;
    width: 100%;
    height: 100%;
    perspective: 1200px;

    &-playground {
      position: relative;
      flex-grow: 1;

      &__fade-out {
        animation: play-fade-out .5s ease-in-out;
        animation-fill-mode: forwards;
      }

      &__fade-in {
        animation: play-fade-in .5s linear;
        animation-fill-mode: forwards;
      }
    }

    &-right-column {
      width: 200px;
      margin: 16px 16px 0 0;
    }

  }

}
@keyframes play-fade-out {
  to   { opacity: 0; }
}
@keyframes play-fade-in {
  0%   { opacity: 0; }
  90%  { opacity: 100%; }
}
</style>
