<template>
  <div class="page-index__page">
    <TitleBox />
    <div class="page-index__action-box">
      <div class="page-index__space" />
      <div class="page-index__login">
        <LoginBox />
      </div>
      <div class="page-index__separator" />
      <div class="page-index__create-team">
        <Button :border="false" @click="createTeam">{{ $t('create-team') }}</Button>
      </div>
      <div class="page-index__space" />
    </div>
    <div class="page-index__about">
      <a 
        href="https://www.sirlab.de/linux/games/knowyt/"
        target="_blank" rel="noopener"
      >
      <Button :border="false">
        <div class="page-index__about-text">{{ $t('about') }}</div>
      </Button>
      
      </a>
    </div>
    <CopyrightNotice />
    <CreateTeamDialog v-if="showCreateTeamDialog" @close="closeCreateTeamDialog" />
  </div>
</template>

<script setup lang="ts">
import { ref } from 'vue'
import useAuth from '@/composables/useAuth'
import useI18n from '@/composables/useI18n'
import CopyrightNotice from '../components/CopyrightNotice.vue';

const { $t } = useI18n({
  'create-team': { en: 'Create Team ...', de: 'Team erstellen ...' },
  'about': { en: 'about the game', de: 'Über das Spiel' },
})

await useAuth().authenticateAndLoadUserInfo([''])

const showCreateTeamDialog = ref(false)
const createTeam = () => { showCreateTeamDialog.value = true }
const closeCreateTeamDialog = () => { showCreateTeamDialog.value = false }
</script>

<style lang="scss">
@import '~/assets/css/components';

body {
  background-color: $background-primary-color;
  color: $text-primary-color;

  margin: 0;
}

.page-index {
  &__page {
    display: flex;
    flex-direction: column;
  }

  &__action-box {
    display: flex;
    width: 100%;
    height: 120px;

    @media (max-width: $phone-max-width) {
      margin: 32px 0 0 0;
    }
  }

  &__login,
  &__create-team {
    width: 320px;
    align-self: center;

    @media (max-width: $phone-max-width) {
      width: auto;
    }
  }

  &__create-team {
    @media (max-width: $phone-max-width) {
      display: none;
    }
  }

  &__separator {
    width: 1px;
    margin: 0 48px;
    border-left: $box-primary-border;

    @media (max-width: $phone-max-width) {
      display: none;
    }
  }

  &__space {
    flex-grow: 1;
  }

  &__about {
    margin: 48px 0;
    align-self: center;
  }
}
</style>