<script>
  import {createEventDispatcher} from 'svelte';

  const dispatch = createEventDispatcher();

  function handleRetry() {
    dispatch('retry');
  }

  function handleBackToStart() {
    dispatch('restart')
  }
  
</script>

<div class="gameover-screen">
  <img src ='/assets/gameover.png' alt="gameover-img" class="gameover-img">
  <h1>Game Over</h1>
  <div class="buttons">
    <button on:click={handleRetry}>Retry</button>
    <button on:click={handleBackToStart}>Back to Start</button>
  </div>
</div>

<style>
  .gameover-screen {
    display: flex;
    flex-direction: column;
    justify-content: center;
    height: 100%;
    width: 100%;
    background-color: #210140;
    color: #18a48e;
    padding: 20px;
  }

  .buttons {
    display: flex;
    justify-content: center;
    align-items: center;
    margin-top: 20px;
    gap: 80px;
  }

  button {
    position: relative;
    display: block;
    margin: 0;
    padding: 4px;
    width: fit-content;
    cursor: pointer;
    font-size: 1.2rem;
    text-align: center;
    background-color: transparent;
    color: white;
    border: none;
    font-family: 'Aztec';
  }

  button::before,
  button::after {
    content: "";
    position: absolute;
    top: 50%;
    width: 24px;
    height: 24px;
    background-image: url("/assets/obstacle.png");
    background-size: cover;
    opacity: 0;
    transform: translateY(-50%);
  }

  button::before {
    left: -30px;
  }

  button::after {
    right: -30px;
  }

  button:hover::before,
  button:hover::after {
    opacity: 1;
  }

  h1 {
    text-align: center;
    margin: 20px;
  }

  .gameover-img {
    width: 600px;
    height: auto;
    align-self: center;
  }
</style>