const { Section, SectionHead, Button, Badge, TextLink } = window.GEMAdvisoryDesignSystem_b1bc4f;

function InsightsScreen({ go }) {
  const d = window.siteData.insights;
  const toContact = (e) => { e.preventDefault(); go("contact"); };
  return (
    <>
      <Section style={{ background: "var(--gradient-wash-diagonal)" }}>
        <SectionHead eyebrow="Insights" title="Notes from the work" lede={d.lede} style={{ marginBottom: 0 }} />
      </Section>

      <Section size="tight">
        {d.items.map((it) => (
          <article
            key={it.title}
            data-grid2
            style={{
              display: "grid",
              gridTemplateColumns: "minmax(0, 5fr) minmax(0, 6fr)",
              gap: "var(--gap-grid)",
              alignItems: "start",
              paddingTop: 28,
              borderTop: "1px solid var(--rule-strong)",
            }}
          >
            <a
              href={it.href}
              target="_blank"
              rel="noopener"
              aria-label={"Open the PDF: " + it.title}
              style={{ display: "block", borderBottom: "none" }}
            >
              <div
                style={{
                  overflow: "hidden",
                  borderRadius: "var(--radius-media)",
                  border: "1px solid var(--rule)",
                  background: "var(--stone)",
                }}
              >
                <img src={it.cover} alt={it.coverAlt} style={{ display: "block", width: "100%", height: "auto" }} />
              </div>
            </a>

            <div>
              <div style={{ display: "flex", gap: 12, alignItems: "center", flexWrap: "wrap", marginBottom: 16 }}>
                <Badge tone="green">{it.kind}</Badge>
                <span style={{ fontSize: "var(--size-small)", color: "var(--text-muted)" }}>
                  {it.date} &middot; PDF, {it.pages} pages
                </span>
              </div>
              <h2 style={{ fontSize: "var(--size-section)", lineHeight: "var(--leading-section)", margin: "0 0 8px", maxWidth: "20ch" }}>
                {it.title}
              </h2>
              <p style={{ fontFamily: "var(--font-display)", fontSize: "var(--size-subhead)", lineHeight: "var(--leading-subhead)", color: "var(--pine)", margin: "0 0 22px", maxWidth: "40ch" }}>
                {it.subtitle}
              </p>
              <p style={{ margin: "0 0 18px", maxWidth: "58ch" }}>{it.summary}</p>
              <p
                style={{
                  margin: "0 0 22px",
                  maxWidth: "58ch",
                  fontSize: "var(--size-body-sm)",
                  color: "var(--text-caption)",
                  paddingLeft: 16,
                  borderLeft: "var(--border-width-accent) solid var(--accent-bar)",
                }}
              >
                {it.finding}
              </p>
              <p style={{ fontSize: "var(--size-small)", color: "var(--text-muted)", margin: "0 0 26px", maxWidth: "58ch" }}>
                {it.authors}
              </p>
              <div style={{ display: "flex", gap: 14, flexWrap: "wrap" }}>
                <Button href={it.href} target="_blank" rel="noopener">
                  Read the playbook
                </Button>
                <a
                  href={it.href}
                  download
                  style={{
                    alignSelf: "center",
                    fontSize: "var(--size-ui)",
                    color: "var(--text-link)",
                  }}
                >
                  Download PDF
                </a>
              </div>
            </div>
          </article>
        ))}
      </Section>

      <Section tone="panel" size="tight" style={{ background: "var(--gradient-panel)" }}>
        <div data-grid2 style={{ display: "grid", gridTemplateColumns: "1fr auto", gap: "var(--gap-grid)", alignItems: "end" }}>
          <SectionHead eyebrow={d.more.eyebrow} title={d.more.title} lede={d.more.body} style={{ marginBottom: 0 }} />
          <TextLink href="#contact" onClick={toContact}>{d.more.cta}</TextLink>
        </div>
      </Section>

      <Section tone="field" size="tight" style={{ background: "var(--gradient-field)" }}>
        <div style={{ display: "flex", gap: 24, alignItems: "center", justifyContent: "space-between", flexWrap: "wrap" }}>
          <SectionHead tone="onGreen" style={{ marginBottom: 0 }} eyebrow="Get in touch" title="Let's talk" />
          <Button variant="onGreen" href="#contact" onClick={toContact}>
            Contact Abby
          </Button>
        </div>
      </Section>
    </>
  );
}

Object.assign(window, { InsightsScreen });
