// Reusable press / news article layout. Same quiet, technical voice as the
// rest of the site. A release page renders <NewsArticle .../> and passes its
// body as children. Body styling is scoped to .news-body so releases only need
// plain <p>, <h2>, <ul>, <blockquote> — no inline styles per paragraph.
//
// Absolute asset paths (/assets/...) so this works at any URL depth
// (e.g. /news/Some_Release/).

function NewsArticle({ tag = 'News', date, title, dek, heroImage, lead, contact, children }) {
  return (
    <>
      <style>{`
        .news-body { max-width: 720px; }
        .news-body > p { font-size: 17px; line-height: 1.72; color: var(--fg-2); margin: 0 0 22px; }
        .news-body > p:first-child { color: var(--fg-1); }
        .news-body > h2 {
          font-size: 24px; font-weight: 700; letter-spacing: -0.015em; line-height: 1.2;
          color: var(--fg-1); margin: 44px 0 14px;
        }
        .news-body > ul { margin: 0 0 22px; padding-left: 22px; }
        .news-body > ul > li { font-size: 17px; line-height: 1.7; color: var(--fg-2); margin: 0 0 10px; }
        .news-body blockquote {
          margin: 32px 0; padding: 4px 0 4px 24px;
          border-left: 3px solid var(--accent);
          font-size: 20px; line-height: 1.5; letter-spacing: -0.012em;
          color: var(--fg-1); font-weight: 500;
        }
        .news-body blockquote cite {
          display: block; margin-top: 14px;
          font: 600 13px var(--font-mono); letter-spacing: 0.02em;
          color: var(--fg-3); font-style: normal;
        }
        .news-body a { border-bottom: 1px solid rgba(16,200,128,0.45); padding-bottom: 1px; }
        .news-body hr { border: none; border-top: 1px solid var(--border-1); margin: 40px 0; }
      `}</style>

      {/* Hero */}
      <section className="flat" style={{ padding: '112px 0 48px' }}>
        <div className="container" style={{ maxWidth: 820 }}>
          <a href="/news" style={{
            display: 'inline-flex', alignItems: 'center', gap: 8,
            fontFamily: 'var(--font-mono)', fontSize: 12, color: 'var(--fg-3)',
            textDecoration: 'none', letterSpacing: '0.04em', marginBottom: 28,
          }}>← Newsroom</a>
          <div style={{ display: 'flex', alignItems: 'center', gap: 14, marginBottom: 18 }}>
            <span className="eyebrow" style={{ color: 'var(--accent)', alignSelf: 'flex-start' }}>{tag}</span>
            {date && (
              <span style={{ fontFamily: 'var(--font-mono)', fontSize: 12.5, color: 'var(--fg-3)', letterSpacing: '0.06em', textTransform: 'uppercase' }}>{date}</span>
            )}
          </div>
          <h1 style={{
            fontSize: 'clamp(34px, 4vw, 56px)', lineHeight: 1.07, fontWeight: 700,
            letterSpacing: '-0.025em', color: 'var(--fg-1)', margin: 0, maxWidth: 800,
          }}>{title}</h1>
          {dek && (
            <p style={{ fontSize: 19, lineHeight: 1.6, color: 'var(--fg-2)', margin: '22px 0 0 0', maxWidth: 720 }}>{dek}</p>
          )}
        </div>
      </section>

      {heroImage && (
        <section className="flat" style={{ padding: '0 0 8px' }}>
          <div className="container" style={{ maxWidth: 820 }}>
            <img src={heroImage} alt="" style={{
              width: '100%', height: 'auto', display: 'block', borderRadius: 4,
              border: '1px solid var(--border-1)',
            }}/>
          </div>
        </section>
      )}

      {/* Body */}
      <section className="flat" style={{ padding: '32px 0 72px' }}>
        <div className="container" style={{ maxWidth: 820 }}>
          {lead}
          <div className="news-body">{children}</div>

          {/* Press contact — standard on every release */}
          <div style={{
            marginTop: 56, padding: 28,
            border: '1px solid var(--border-1)', borderRadius: 4,
            background: 'var(--bg-elev-1)', maxWidth: 720,
            display: 'flex', justifyContent: 'space-between', alignItems: 'center',
            flexWrap: 'wrap', gap: 16,
          }}>
            <div style={{ display: 'flex', flexDirection: 'column', gap: 4 }}>
              <div style={{ fontSize: 15, fontWeight: 600, color: 'var(--fg-1)' }}>Media contact</div>
              <div style={{ fontSize: 13.5, color: 'var(--fg-3)' }}>{contact ? contact.name : 'For briefings or quotes, say "press" in the subject.'}</div>
            </div>
            <a href={contact ? 'mailto:' + contact.email : 'mailto:connect@eightbyzero.com?subject=Press'} style={{
              fontFamily: 'var(--font-mono)', fontSize: 14.5, color: 'var(--accent)',
              textDecoration: 'none', borderBottom: '1px solid rgba(16,200,128,0.45)', paddingBottom: 2,
            }}>{contact ? contact.email : 'connect@eightbyzero.com'}</a>
          </div>
        </div>
      </section>
    </>
  );
}

// Standard press-release boilerplate. Truthful, reusable across releases —
// pulled from the site's own About copy. Drop <AboutBoilerplate/> at the end
// of any release body.
function AboutBoilerplate() {
  return (
    <>
      <hr/>
      <h2 style={{ fontSize: 18, margin: '0 0 12px' }}>About EightbyZero</h2>
      <p style={{ fontSize: 15, color: 'var(--fg-3)', lineHeight: 1.65 }}>
        EightbyZero is the intelligent data layer for group insurance — an
        agentic integration layer that connects employer data to carriers and
        TPAs. Founded in Montréal and incubated out of the Diagram ecosystem,
        EightbyZero makes carrier, TPA, and employer dataflows adaptive and
        AI-ready. Learn more at <a href="https://eightbyzero.com">eightbyzero.com</a>.
      </p>
    </>
  );
}

window.NewsArticle = NewsArticle;
window.AboutBoilerplate = AboutBoilerplate;
