/* @label.en Call to action
   @description.en A link asking the reader to act - book a meeting, enroll - as a pill that breathes slowly,
   pointing on the way the text reads; larger as a heading. Keep the link alone in its block.

   @label.he קריאה לפעולה
   @description.he קישור שמזמין את הקורא לפעול - לקבוע פגישה, להירשם - ככפתור מעוגל שנושם לאט, עם חץ
   בכיוון הקריאה; גדול יותר בכותרת. הקישור לבד בבלוק.

   @example
   <p class="block-style-call-to-action"><a href="#">קביעת מועד: שיעור פרטי</a></p> */
@layer components {
  /* The banner's pill, at the weight of zohar's light headings. The link stands in the block itself, or
     inside an element's attachment (a booking button). */
  .lexxy-content p.block-style-call-to-action, .lexxy-content h2.block-style-call-to-action, .lexxy-content h3.block-style-call-to-action {
    > a, > action-text-attachment > a {
      display: inline-flex;
      align-items: center;
      gap: 0.6em;
      max-inline-size: 100%;
      padding: 0.6em 1.5em;
      border-radius: 2em;
      background: var(--color-brand);
      color: var(--color-on-brand);
      font-weight: 500;
      letter-spacing: 0.01em;
      line-height: 1.35;
      text-decoration: none;
      text-wrap: balance;
      transition: background var(--transition);

      /* Points on, the way the text reads; a WhatsApp link wears its own mark there instead. */
      &:not([href*="wa.me/"], [href*="whatsapp.com"], [href*="/whatsapp"])::after { content: "→"; transition: translate var(--transition); }
      &:not([href*="wa.me/"], [href*="whatsapp.com"], [href*="/whatsapp"]):dir(rtl)::after { content: "←"; }
      &:is([href*="wa.me/"], [href*="whatsapp.com"], [href*="/whatsapp"])::after { margin: 0; background-color: currentColor; }

      &:hover { background: color-mix(in oklab, var(--color-brand) 86%, var(--color-text)); }
      &:hover::after { translate: 0.25em 0; }
      &:dir(rtl):hover::after { translate: -0.25em 0; }
      &:focus-visible { outline: 2px solid var(--color-brand); outline-offset: 3px; }
    }
  }

  .lexxy-content p.block-style-call-to-action { margin-block: 1.75rem; }

  /* As a heading it keeps the heading's light weight and size, and drops the section rule above it. */
  .lexxy-content h2.block-style-call-to-action, .lexxy-content h3.block-style-call-to-action {
    > a, > action-text-attachment > a { padding: 0.45em 1.4em; font-weight: 400; }
  }
  .page .lexxy-content > h2.block-style-call-to-action:not(:first-child)::before { display: none; }

  /* A slow breath of brand around the pill, about six seconds in and out - a breathing teacher's
     button. It rests while it's pointed at, and for whoever asks for less motion. */
  @media (prefers-reduced-motion: no-preference) {
    .lexxy-content p.block-style-call-to-action, .lexxy-content h2.block-style-call-to-action, .lexxy-content h3.block-style-call-to-action {
      > a, > action-text-attachment > a {
        animation: zohar-cta-breath 6s ease-in-out infinite;
        &:is(:hover, :focus-visible) { animation: none; }
      }
    }
    @keyframes zohar-cta-breath {
      0%, 100% { box-shadow: 0 0 0 0 color-mix(in oklab, var(--color-brand) 0%, transparent); }
      45% { box-shadow: 0 0 0 0.4em color-mix(in oklab, var(--color-brand) 17%, transparent); }
    }
  }
}
