<script setup lang="ts">
interface Props {
  cols?: number
}

defineProps<Props>()
</script>

<template>
  <details class="quickfacts">
    <summary class="quickfacts__head">Quickfacts</summary>
    <div class="quickfacts__list" :class="[`cols-${cols}`]">
      <slot></slot>
    </div>
  </details>
</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;
  transition: 0.3s all ease-in-out;

  &: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);
  }

  &__head {
    font-family: var(--font-family-headings);
    font-size: 1.125rem;
    list-style: none;
    margin: 0;
    border: 0;
    padding: 0.75rem 1.5rem;
    cursor: pointer;

    &::-webkit-details-marker {
      display: none;
    }
  }

  &__list {
    border-top: 0.125rem solid var(--color-quickfacts-border);
    padding: 1.5rem;

    &.cols-2 ul {
      columns: var(--quickfacts-cols-double);
    }

    &.cols-3 ul {
      columns: var(--quickfacts-cols-triple);
    }

    &.cols-4 ul {
      columns: var(--quickfacts-cols-quadruple);
    }

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

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