---
interface Props {
  id: string;
  title: string;
  count?: string;
  intro?: string;
  final?: boolean;
  className?: string;
}

const {
  id,
  title,
  count,
  intro,
  final = false,
  className,
} = Astro.props;
---

<section class:list={["glossary-portal-section", final && "glossary-portal-section--final", className]}>
  <div class="glossary-portal-section__head">
    <h2 id={id}>{title}</h2>
    {count && <span class="glossary-portal-section__count">{count}</span>}
  </div>

  {intro && <p class="glossary-portal-section__intro">{intro}</p>}

  <slot />
</section>

<style>
  .glossary-portal-section{
    margin-top: 34px;
    scroll-margin-top: calc(var(--sticky-offset-px, 96px) + 28px);
  }

  .glossary-portal-section h2{
    scroll-margin-top: calc(var(--sticky-offset-px, 96px) + 28px);
  }

  .glossary-portal-section__head{
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 10px;
    position: static;
  }

  .glossary-portal-section__count{
    font-size: 13px;
    opacity: .72;
    white-space: nowrap;
  }

  .glossary-portal-section__intro{
    max-width: 78ch;
    margin: 0;
    opacity: .92;
  }

  .glossary-portal-section--final{
    margin-top: 42px;
  }
</style>