<script setup lang="ts">
import { ref } from "vue";

const isExpanded = ref(false);

const toggle = (): void => {
  isExpanded.value = !isExpanded.value;
};
</script>

<template>
  <div class="quickfacts" :class="{ open: isExpanded }">
    <h3 class="quickfacts__head" @click.prevent="toggle">Quickfacts</h3>
    <div class="quickfacts__list">
      <slot></slot>
    </div>
  </div>
</template>

<style lang="scss">
.quickfacts {
  position: relative;

  background: var(--quickfacts-background);

  margin: 1rem 0;
  border-radius: 1rem;

  box-shadow: var(--container-box-shadow);

  overflow: hidden;

  &:before {
    display: block;

    content: "";
    position: absolute;
    top: 1.375rem;
    right: 1.375rem;

    transform: rotate(180deg);
    transition: 0.3s all ease-in-out;

    border: {
      right: 0.625rem solid transparent;
      bottom: 0.625rem solid #fff;
      left: 0.625rem solid transparent;
    }
  }

  &.open:before {
    transform: rotate(0deg);
  }

  &.open & {
    &__list {
      max-height: 25rem;
      border-top: 0.125rem solid var(--color-quickfacts-border);
      padding: 1.5rem;
    }
  }

  &__head {
    font-size: 1.125rem;
    margin: 0;
    border: 0;
    padding: 0.75rem 1.5rem;
    transition: 0.3s all ease-in-out;
    cursor: pointer;
  }

  &__list {
    max-height: 0rem;
    padding: 0 1.5rem;
    transition: 0.3s all ease-in-out;

    ul {
      margin: 0;
      padding: 0 0.5rem;
    }

    li {
      margin: 0 0 0 1rem;
      padding: 0;
    }
  }
}
</style>
