---
/**
 * "Share feedback" trigger button, rendered in the right-hand page sidebar
 * (PageSidebar.astro) directly under the subscribe form. Opens the global
 * FeedbackModal singleton (rendered from the Footer) via window.__raOpenFeedback.
 */
---

<button
  type="button"
  class="ra-fb-trigger"
  id="ra-fb-open"
  aria-haspopup="dialog"
  aria-controls="ra-fb-modal"
>
  <svg aria-hidden="true" width="15" height="15" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
    <path d="M21 15a2 2 0 0 1-2 2H7l-4 4V5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2z"></path>
  </svg>
  <span>Share feedback</span>
</button>

<script>
(function () {
  function wire() {
    const btn = document.getElementById("ra-fb-open");
    if (!btn || btn.dataset.wired) return;
    btn.dataset.wired = "1";
    btn.addEventListener("click", () => {
      if (typeof window.__raOpenFeedback === "function") window.__raOpenFeedback();
    });
  }
  if (document.readyState === "loading") {
    document.addEventListener("DOMContentLoaded", wire);
  } else {
    wire();
  }
  document.addEventListener("astro:page-load", wire);
})();
</script>
