<template>
  <div class="nsfw-warning">
    <div class="nsfw-warning__background"></div>
    <div class="nsfw-warning__message">
      <div>
        <h2><slot name="heading"></slot></h2>
        <p><slot name="message"></slot></p>

        <div class="btn-container">
          <btn href="#" class="positive" @click.prevent="confirmNsfw(true)">
            <slot name="yes"></slot>
          </btn>

          <btn href="#" class="negative" @click.prevent="confirmNsfw(false)">
            <slot name="no"></slot>
          </btn>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import btn from "@/components/Button.vue";

export default {
  components: { btn },
  methods: {
    confirmNsfw(input) {
      this.$root.nsfw = input;
      this.$root.isConfirmedHorny = input;
      this.$root.isWarn = false;
      document.body.classList.toggle("scroll-lock");
    },
  },
};
</script>

<style lang="scss">
@import "@/scss/_variables.scss";
@import "@/scss/_mixins.scss";

.nsfw-warning {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;

  z-index: 9001;

  backdrop-filter: blur(1em);
  background-color: rgba(#000, 0.5);

  display: flex;
  flex-flow: row nowrap;
  justify-content: center;

  padding: 2em;
  text-align: center;
  overflow: auto;

  &__background {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: 0;
  }

  &__message {
    flex: 0 1 30em;

    display: flex;
    flex-flow: row wrap;
    justify-content: center;
    align-content: center;

    margin: auto;
    border: 0.25em solid $bg-color-warning;
    border-radius: 1em;
    padding: 1em;

    z-index: 9002;

    background-color: $bg-color-dark;

    > * {
      flex: 0 1 100%;
    }
  }
}

.btn-container {
  display: flex;
  flex-flow: row wrap;
  justify-content: space-around;
  align-items: center;
}

.btn {
  flex: 0 1 100%;
  margin: 0.75em 0;

  &.positive {
    @include button($btn-color-positive);
  }

  &.negative {
    @include button($btn-color-negative);
  }
}
</style>
