<template>
    <RouterView />
    <div id="modals"></div>
</template>

<script setup lang="ts">
import { useUserStore, useUIStore } from "@/store";

const userStore = useUserStore();
const uiStore = useUIStore();

init();
function init() {
    userStore.loadData();

    const savedTheme = localStorage.getItem("theme");
    if (savedTheme) {
        uiStore.setTheme(savedTheme);
    } else {
        if (window.matchMedia && window.matchMedia("(prefers-color-scheme: dark)").matches) {
            uiStore.setTheme("dark");
        } else {
            uiStore.setTheme("light");
        }
    }
}
</script>

<style lang="scss">
@import "@/styles/themes.scss";

html,
body {
    height: 100%;
}
html {
    font-size: 2vw;

    @media (min-width: 500px) {
        font-size: 10px;
    }
}
body {
    background: color("main-background");

    font-size: r(22);
    font-family: Roboto, sans-serif;
    font-weight: normal;
    color: color("main-color");

    @media (min-width: 500px) {
        width: 500px;
        margin: 0 auto;
        border: 1px solid grey;
    }
}

a {
    color: inherit;
    text-decoration: none;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

.fa-icon {
    width: 100%;
    height: 100%;
}

.app {
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;

    &__view {
        $__view: &;
        position: relative;
        flex: 1;
        overflow-x: hidden;
        overflow-y: auto;

        &--transition-direction {
            &--left {
                #{$__view}--transition {
                    &-enter-from {
                        transform: translateX(-100vw);
                    }
                    &-leave-to {
                        transform: translateX(100vw);
                    }
                }
            }

            &--right {
                #{$__view}--transition {
                    &-enter-from {
                        transform: translateX(100vw);
                    }
                    &-leave-to {
                        transform: translateX(-100vw);
                    }
                }
            }
        }

        &--transition {
            &-enter-active,
            &-leave-active {
                transition: all 0.18s linear;
            }
        }
    }

    &__navigation-bar {
        flex: 0 1;
    }
}
</style>
