<script setup>
defineEmits(['closeModal'])
defineProps(['label', 'permanent'])
</script>

<template>
  <div class="modal-container">
    <div class="modal-content shadow">
      <div v-if="!permanent" class="modal-content__title">
        <div class="headline">
          <span>{{ label }}</span>
        </div>
        <button class="button primary" type="button" @click="$emit('closeModal')">
          <font-awesome-icon icon="fa-solid fa-xmark" />
        </button>
      </div>
      <slot />
    </div>
  </div>
</template>

<style scoped>
.modal-container {
  overflow: hidden;
  position: fixed;
  background-color: hsl(var(--clr-background) / 0.8);
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  padding: var(--spacing);
  height: auto;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1;
}

@media (min-width: 48em) {

}

.modal-content {
  overflow-y: auto;
  background-color: hsl(var(--clr-content));
  width: min(50em, 100%);
  height: 100%;
  display: flex;
  flex-direction: column;
  border-radius: var(--radius);
}

@media (min-width: 48em) {
  .modal-content {
    overflow: hidden;
    height: 90%;
  }
}

.modal-content__title {
  padding: var(--spacing);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
</style>