<template>

    <main>
        <div class="error">
            <h1 class="error__title">{{ errorMessage }}</h1>
            <div class="error__separator" aria-hidden="true"></div>
            <div class="error__emoticon" aria-hidden="true">¯\(°_o)/¯</div>
            <button class="error__button" @click="$emit('handleError')">
                <span class="error__button-text">Retourner à la page d'accueil</span>
                <svg class="error__button-icon" aria-hidden="true" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" xmlns="http://www.w3.org/2000/svg">
                    <path d="M 2 8.7 L 12 1 L 22 8.7 L 22 20.8 C 22 22.016 21.006 23 19.778 23 L 4.222 23 C 2.995 23 2 22.016 2 20.8 L 2 8.7 Z"/>
                    <polyline points="8.667 23 8.667 12 15.333 12 15.333 23"/>
                </svg>
            </button>
        </div>
    </main>

</template>

<script setup>

    // --------------------------------------------------
    // DATA
    // --------------------------------------------------

    const props = defineProps({
        errorMessage: String
    });
    const emit = defineEmits([
        'handleError'
    ]);

</script>

<style lang="scss" scoped>

    // --------------------------------------------------
    // STYLE
    // --------------------------------------------------

    main {
        padding: 2rem;
    }

    .error {
        display: flex;
        flex-direction: column;
        justify-content: center;
        align-items: center;
        min-width: 30vw;
        text-align: center;

        &__title {
            opacity: 0;
            margin: 0 2rem;
            animation: fade-in-from-bottom 400ms ease-in-out 600ms forwards;
        }

        &__separator {
            width: 0;
            height: 1px;
            margin: 0.5rem 0;
            background-color: var(--accent-color);
            animation: expand-width 400ms ease-in-out 200ms forwards;
        }

        &__emoticon {
            opacity: 0;
            margin: 0 2rem;
            font-family: var(--title-font-family);
            font-size: var(--h1-font-size);
            font-weight: var(--medium-font-weight);
            animation: fade-in-from-top 400ms ease-in-out 600ms forwards;
        }

        &__button {
            margin: 6rem 2rem 0 2rem;

            &-icon {
                display: none;
            }
        }

    }
    
    @media screen and (min-width: $tablet-media-query) {

        .error {

            &__button {
                @include button-with-icon;
            }
        }
    }

</style>
