---
interface Props {
  prefix: string;
  kicker: string;
  title: string;
  intro: string;
  moreParagraphs?: string[];
  introMaxWidth?: string;
  followIntroMaxWidth?: string;
  moreMaxHeight?: string;
}

const {
  prefix,
  kicker,
  title,
  intro,
  moreParagraphs = [],
  introMaxWidth = "72ch",
  followIntroMaxWidth = "68ch",
  moreMaxHeight = "18rem",
} = Astro.props;
---

<div
  class="glossary-portal-hero glossary-page-hero"
  data-glossary-portal-hero
  style={`--portal-hero-intro-max-w:${introMaxWidth}; --portal-hero-follow-intro-max-w:${followIntroMaxWidth}; --portal-hero-more-max-h:${moreMaxHeight};`}
>
  <p class="glossary-portal-hero__kicker">{kicker}</p>
  <h1>{title}</h1>

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

  {moreParagraphs.length > 0 && (
    <div class="glossary-portal-hero__collapsible">
      <div
        class="glossary-portal-hero__more"
        id={`${prefix}-hero-more`}
        data-glossary-portal-more
        aria-hidden="false"
      >
        {moreParagraphs.map((paragraph) => (
          <p class="glossary-portal-hero__intro">{paragraph}</p>
        ))}
      </div>

      <button
        class="glossary-portal-hero__toggle"
        id={`${prefix}-hero-toggle`}
        data-glossary-portal-toggle
        type="button"
        aria-controls={`${prefix}-hero-more`}
        aria-expanded="false"
        hidden
      >
        lire la suite
      </button>
    </div>
  )}
</div>

<style>
  .glossary-portal-hero{
    position: sticky;
    top: calc(var(--sticky-header-h, 0px) + var(--page-gap, 12px));
    z-index: 11;
    margin: 0 0 24px;
    padding: 18px 18px 20px;
    border: 1px solid rgba(127,127,127,0.18);
    border-radius: 28px;
    background:
      linear-gradient(180deg, rgba(0,0,0,0.60), rgba(0,0,0,0.92)),
      radial-gradient(900px 240px at 20% 0%, rgba(0,217,255,0.08), transparent 60%);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: grid;
    row-gap: 14px;
    transition:
      margin-bottom 180ms ease,
      border-radius 180ms ease,
      padding 180ms ease,
      row-gap 180ms ease;
  }

  .glossary-portal-hero__kicker{
    margin: 0;
    font-size: 12px;
    letter-spacing: .08em;
    text-transform: uppercase;
    opacity: .72;
  }

  .glossary-portal-hero h1{
    margin: 0;
    font-size: clamp(2.2rem, 4vw, 3.15rem);
    line-height: 1.02;
    letter-spacing: -.04em;
    font-weight: 850;
    transition: font-size 180ms ease;
  }

  .glossary-portal-hero__intro{
    margin: 0;
    max-width: var(--portal-hero-intro-max-w);
    font-size: 1.04rem;
    line-height: 1.55;
    opacity: .94;
    transition:
      font-size 180ms ease,
      line-height 180ms ease,
      max-width 180ms ease;
  }

  .glossary-portal-hero__collapsible{
    display: grid;
    row-gap: 6px;
  }

  .glossary-portal-hero__more{
    display: grid;
    row-gap: 14px;
    max-height: var(--portal-hero-more-max-h);
    overflow: hidden;
    opacity: 1;
    transition:
      max-height 220ms ease,
      opacity 180ms ease;
  }

  .glossary-portal-hero__toggle{
    display: none;
    align-self: flex-start;
    width: fit-content;
    margin: 0;
    padding: 0;
    border: 0;
    background: transparent;
    color: inherit;
    font: inherit;
    font-size: 11px;
    line-height: 1.2;
    letter-spacing: .01em;
    opacity: .56;
    cursor: pointer;
    text-decoration: underline;
    text-underline-offset: .12em;
    text-decoration-thickness: 1px;
  }

  .glossary-portal-hero__toggle:hover{
    opacity: .84;
  }

  .glossary-portal-hero__toggle:focus-visible{
    outline: 2px solid rgba(0,217,255,0.24);
    outline-offset: 4px;
    border-radius: 4px;
  }

  .glossary-portal-hero__toggle[hidden]{
    display: none !important;
  }

  @media (max-width: 860px){
    .glossary-portal-hero{
      position: static;
      border-radius: 22px;
      margin-bottom: 20px;
      padding: 14px 14px 16px;
      row-gap: 12px;
    }

    .glossary-portal-hero__intro{
      max-width: none;
    }

    .glossary-portal-hero__more{
      max-height: none;
      opacity: 1;
      overflow: visible;
    }

    .glossary-portal-hero__toggle{
      display: none !important;
    }
  }
</style>