<template>
  <div class="auth">
    <div class="auth__content" ref="modalRef">
      <slot></slot>
    </div>
  </div>
</template>

<script setup lang="ts">
import {onClickOutside} from '@vueuse/core';

const appStore = useAppStore();

const closeModal = () => {
  appStore.unsetActiveAuthState();
};

const modalRef = ref(null);
onClickOutside(modalRef, () => closeModal());
</script>

<style lang="scss" scoped>
.auth {
  position: fixed;
  z-index: 3;
  width: 100vw;
  height: 100vh;
  top: 0;
  right: 0;
  left: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(3px);
  background-color: rgba(0, 0, 0, 0.4);

  &__content {
    position: absolute;
    z-index: 2;
    top: 125px;
    background-color: $white;
    width: 600px;
    padding: 30px;
    border-radius: $default_border_radius;
  }
}

@media (max-width: 1000px) {
  .auth {
    &__content {
      width: 85%;
    }
  }
}

@media (max-width: 500px) {
  .auth {
    &__content {
      padding: 20px 30px;
    }
  }
}
</style>