"""Generate Iowa Farmer Data Collection Strategy PDF — English version."""
import os
from reportlab.lib.pagesizes import A4
from reportlab.lib.units import cm
from reportlab.lib.colors import HexColor, white
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_LEFT, TA_CENTER, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    PageBreak, HRFlowable
)
from reportlab.pdfbase import pdfmetrics
from reportlab.pdfbase.ttfonts import TTFont

# Register fonts
FONTS_DIR = "C:/Windows/Fonts"
pdfmetrics.registerFont(TTFont('Arial', os.path.join(FONTS_DIR, 'arial.ttf')))
pdfmetrics.registerFont(TTFont('ArialBold', os.path.join(FONTS_DIR, 'arialbd.ttf')))
pdfmetrics.registerFont(TTFont('ArialItalic', os.path.join(FONTS_DIR, 'ariali.ttf')))
pdfmetrics.registerFont(TTFont('ArialBI', os.path.join(FONTS_DIR, 'arialbi.ttf')))
pdfmetrics.registerFontFamily('Arial', normal='Arial', bold='ArialBold', italic='ArialItalic', boldItalic='ArialBI')

# Colors
C_ORANGE = HexColor('#e8792b')
C_GREEN = HexColor('#27ae60')
C_RED = HexColor('#c0392b')
C_PURPLE = HexColor('#8e44ad')
C_BLUE = HexColor('#2980b9')
C_GRAY = HexColor('#666666')
C_DARK = HexColor('#1a1f26')
C_LIGHT_GREEN = HexColor('#e8f5e9')
C_LIGHT_RED = HexColor('#fde8e8')
C_LIGHT_ORANGE = HexColor('#fef3e2')
C_LIGHT_PURPLE = HexColor('#f3e8fd')
C_LIGHT_BLUE = HexColor('#e8f0fd')

# Styles
sTitle = ParagraphStyle('Title', fontName='ArialBold', fontSize=22, textColor=C_ORANGE, alignment=TA_CENTER, spaceAfter=4, leading=28)
sSubtitle = ParagraphStyle('Sub', fontName='Arial', fontSize=11, textColor=C_GRAY, alignment=TA_CENTER, spaceAfter=20)
sH1 = ParagraphStyle('H1', fontName='ArialBold', fontSize=16, textColor=C_DARK, spaceBefore=16, spaceAfter=8, leading=20)
sH2 = ParagraphStyle('H2', fontName='ArialBold', fontSize=13, textColor=C_DARK, spaceBefore=10, spaceAfter=6, leading=17)
sH3 = ParagraphStyle('H3', fontName='ArialBold', fontSize=11, textColor=C_ORANGE, spaceBefore=8, spaceAfter=4, leading=15)
sBody = ParagraphStyle('Body', fontName='Arial', fontSize=10, textColor=HexColor('#333333'), alignment=TA_JUSTIFY, spaceAfter=6, leading=14)
sSmall = ParagraphStyle('Small', fontName='Arial', fontSize=9, textColor=HexColor('#444444'), spaceAfter=4, leading=13)
sBullet = ParagraphStyle('Bullet', fontName='Arial', fontSize=10, textColor=HexColor('#333333'), leftIndent=16, spaceAfter=3, leading=14, bulletIndent=4)
sScript = ParagraphStyle('Script', fontName='ArialItalic', fontSize=9.5, textColor=HexColor('#2d5a3a'), spaceAfter=6, leading=14, leftIndent=10, rightIndent=10)
sScriptLabel = ParagraphStyle('SLabel', fontName='ArialBold', fontSize=9, textColor=C_GREEN, spaceAfter=2, leftIndent=10)
sFooter = ParagraphStyle('Footer', fontName='Arial', fontSize=8, textColor=C_GRAY, alignment=TA_CENTER)
sTag = ParagraphStyle('Tag', fontName='ArialBold', fontSize=8, textColor=C_PURPLE)
sConf = ParagraphStyle('Conf', fontName='Arial', fontSize=9, textColor=C_GRAY, alignment=TA_CENTER, leading=14)


def sec_hdr(num, title, subtitle=""):
    elems = [Paragraph(f'<font color="#e8792b"><b>{num}</b></font>  {title}', sH1)]
    if subtitle:
        elems.append(Paragraph(f'<i><font color="#888888">{subtitle}</font></i>', sSmall))
    return elems


def card(icon, title, body, tags=None):
    elems = [
        Paragraph(f'<b><font color="#e8792b">{icon}</font> {title}</b>', sH3),
        Paragraph(body, sBody),
    ]
    if tags:
        elems.append(Paragraph('  |  '.join(f'<font color="#8e44ad"><b>[{t}]</b></font>' for t in tags), sTag))
    elems.append(Spacer(1, 6))
    return elems


def build_pdf():
    out = "C:/Users/wsu/Downloads/viz/farmer-data-strategy.pdf"
    doc = SimpleDocTemplate(out, pagesize=A4, topMargin=1.5*cm, bottomMargin=1.5*cm, leftMargin=2*cm, rightMargin=2*cm,
                            title="Iowa Farmer Data Collection Strategy", author="Cargill Agricultural Data Initiative")
    story = []

    # ===== TITLE PAGE =====
    story.append(Spacer(1, 60))
    story.append(Paragraph("IOWA FARMER<br/>DATA COLLECTION STRATEGY", sTitle))
    story.append(Spacer(1, 8))
    story.append(Paragraph("Trust Psychology + Right Incentives = Data for Cargill", sSubtitle))
    story.append(HRFlowable(width="60%", thickness=2, color=C_ORANGE, spaceAfter=20, spaceBefore=10))
    story.append(Paragraph("Confidential  |  Cargill Agricultural Data Initiative  |  April 2026", sConf))
    story.append(Spacer(1, 40))

    story.append(Paragraph("<b>TABLE OF CONTENTS</b>", ParagraphStyle('TOC', fontName='ArialBold', fontSize=13, textColor=C_DARK, alignment=TA_CENTER, spaceAfter=12)))
    for i, item in enumerate([
        "Iowa Farmer Psychology — Why They Hide Data",
        "Strategy 1: Trojan Horse — Give Before You Ask",
        "Strategy 2: Social Proof &amp; Community",
        "Strategy 3: Indirect Data Collection",
        "Strategy 4: Incentives That Work in the Midwest",
        "Communication Rules (DO / DON'T)",
        "Conversion Funnel",
        "Ready-to-Use Scripts",
        "Launch Timeline",
    ], 1):
        story.append(Paragraph(f'<font color="#e8792b"><b>{i}.</b></font>  {item}', sBody))

    story.append(PageBreak())

    # ===== PSYCHOLOGY =====
    story.append(Paragraph('<font color="#8e44ad"><b>IOWA FARMER PSYCHOLOGY</b></font>', sH1))
    story.append(Paragraph('<i>Why they hide crop data</i>', sSmall))
    story.append(Spacer(1, 8))

    psych = [
        ("Neighbor competition", "If a neighbor knows your yield, they know how you're doing. Crop data = salary."),
        ("Fear of price manipulation", "\"If Cargill knows my yield, they'll lower the purchase price.\" Grain buyer = potential adversary."),
        ("Distrust of corporations", "Cargill = Big Ag. Farmers have seen data used against them (insurance, loans, land prices)."),
        ("Cultural tradition of secrecy", "Father didn't share, grandfather didn't share. \"None of your business\" is a Midwest cultural norm."),
        ("Tech skepticism", "Average Iowa farmer age is 57. Forms, apps, logins = barriers they don't want to deal with."),
        ("No time", "Harvest season = 16-hour days. Any survey = \"leave me alone.\""),
    ]
    tdata = [['#', 'Factor', 'Description']]
    for i, (f, d) in enumerate(psych, 1):
        tdata.append([str(i), Paragraph(f'<b>{f}</b>', sSmall), Paragraph(d, sSmall)])
    t = Table(tdata, colWidths=[20, 110, 320])
    t.setStyle(TableStyle([
        ('FONTNAME', (0,0),(-1,0),'ArialBold'), ('FONTSIZE', (0,0),(-1,0), 9),
        ('BACKGROUND', (0,0),(-1,0), C_PURPLE), ('TEXTCOLOR', (0,0),(-1,0), white),
        ('ALIGN', (0,0),(0,-1),'CENTER'), ('VALIGN', (0,0),(-1,-1),'TOP'),
        ('ROWBACKGROUNDS', (0,1),(-1,-1), [C_LIGHT_PURPLE, white]),
        ('GRID', (0,0),(-1,-1), 0.5, HexColor('#dddddd')),
        ('TOPPADDING', (0,0),(-1,-1), 6), ('BOTTOMPADDING', (0,0),(-1,-1), 6),
        ('LEFTPADDING', (0,0),(-1,-1), 6), ('RIGHTPADDING', (0,0),(-1,-1), 6),
    ]))
    story.append(t)

    # ===== STRATEGY 1 =====
    story.append(PageBreak())
    for e in sec_hdr("1", "TROJAN HORSE — GIVE BEFORE YOU ASK", "Reciprocity principle: people give to those who gave first"):
        story.append(e)
    story.append(Spacer(1, 6))

    for elems in [
        card("A)", "Free Weather + Soil Dashboard",
            "Offer farmers a <b>free app</b> with weather forecasts, soil moisture, GDD (Growing Degree Days) for their county. "
            "After 2-3 weeks of use, <b>gently ask for data</b>: \"To improve forecasts for YOUR field, tell us what you grow.\" "
            "<b>Key:</b> Data is collected gradually, in small portions — not all at once.",
            ["Reciprocity", "Requires development"]),
        card("B)", "Benchmark Report — \"How You Compare to Your County\"",
            "Top currency: <b>\"How much are neighbors getting?\"</b> Farmers are dying of curiosity but will never ask a neighbor directly. "
            "Offer: <b>\"Enter your yield and get an anonymous report: your yield vs county/state average.\"</b> "
            "<b>Psychology:</b> Curiosity &gt; Privacy. People give data to learn how they compare.",
            ["Curiosity gap", "STRONGEST TECHNIQUE"]),
        card("C)", "Free Profit Calculator",
            "Simple tool: <b>enter yield + acres + input costs and see P&amp;L per acre, break-even price, optimal sell time</b>. "
            "Farmer enters real data for themselves; we <b>aggregate it anonymously</b>. They get value, we get data. "
            "<b>Bonus:</b> Calculator from Cargill = Cargill as helper, not enemy.",
            ["Utility exchange", "Win-win"]),
    ]:
        for e in elems: story.append(e)

    # ===== STRATEGY 2 =====
    story.append(PageBreak())
    for e in sec_hdr("2", "SOCIAL PROOF &amp; COMMUNITY", "Farmers do what other farmers do"):
        story.append(e)
    story.append(Spacer(1, 6))

    for elems in [
        card("A)", "County Leaderboard (Anonymous)",
            "<b>\"Polk County: 47 farmers already shared. Story County: 23.\"</b> "
            "Competition between counties. Farmers don't want to be the \"lagging county.\" Neighboring county already participates = FOMO. "
            "<b>Reward:</b> County with most participation gets a free agronomy seminar from Cargill.",
            ["FOMO + Competition", "Community reward"]),
        card("B)", "Local Champions (Ambassadors)",
            "Hire <b>5-10 respected farmers</b> (retired, Farm Bureau leaders) as Ambassadors. Pay $500/month. "
            "They visit neighbors in person: <b>\"I already filled it out. Here's my report. You should try it too.\"</b> "
            "<b>Key:</b> A farmer trusts a neighbor, not a corporation. Peer-to-peer works 5x better than cold outreach.",
            ["Trust transfer", "MUST HAVE"]),
        card("C)", "Coffee Mornings at the Elevator",
            "Once a month — <b>free breakfast</b> at the Cargill elevator. Coffee, donuts, market update from an analyst. "
            "At the end: <b>\"Help us help you — fill out this 3-minute survey on the tablet while you have your coffee.\"</b> "
            "Tablet with the form. Staff member nearby to help. Barrier = 0.",
            ["Face-to-face", "Free food"]),
    ]:
        for e in elems: story.append(e)

    # ===== STRATEGY 3 =====
    story.append(PageBreak())
    for e in sec_hdr("3", "INDIRECT COLLECTION — DATA WITHOUT ASKING", "The best data = data you don't have to ask for"):
        story.append(e)
    story.append(Spacer(1, 6))

    for elems in [
        card("A)", "Satellite + USDA Open Data",
            "<b>USDA CropScape</b> — free satellite data: which crop on which field, county-level yield estimates. "
            "<b>NASS Quick Stats</b> — yield by county, planted acreage. "
            "<b>No farmer consent needed.</b> Supplement with surveys for ground truth.",
            ["Public data", "Free"]),
        card("B)", "Cargill Elevator Data (Internal)",
            "Cargill ALREADY HAS data! Every delivery = <b>ticket, weight, moisture, grade, date, farmer</b>. "
            "Need: aggregate delivery data by county/season. <b>80% of needed information is already in the system.</b> "
            "Survey only needed for: acres, challenges, sell plans (what's not in delivery data).",
            ["START HERE", "Internal data"]),
        card("C)", "Grain Bid as Bait",
            "Mobile page with <b>live grain prices from nearby elevators</b>. Farmers check prices every day. "
            "To get <b>personalized bid alerts</b>, they must specify: what they grow, volume, county. "
            "<b>Farmer voluntarily gives data</b> in exchange for prices. Not a survey — a service.",
            ["Value exchange", "Daily engagement"]),
    ]:
        for e in elems: story.append(e)

    # ===== STRATEGY 4 =====
    story.append(PageBreak())
    for e in sec_hdr("4", "INCENTIVES — WHAT WORKS IN THE MIDWEST", "A farmer won't fill out a form for a \"thank you\""):
        story.append(e)
    story.append(Spacer(1, 6))

    for elems in [
        card("A)", "$25 Casey's Gift Card",
            "<b>Casey's General Store</b> — gas stations + pizza, in every Iowa small town. Better than Amazon for farmers. "
            "Fill out survey = get $25 at Casey's. <b>Conversion: 40-60%</b> (proven by analogues). "
            "Budget: 1,000 farmers x $25 = <b>$25K</b> — pocket change for Cargill.",
            ["Direct reward", "Locally relevant"]),
        card("B)", "Big Prize Drawing",
            "<b>\"Fill out the survey and enter to win a John Deere Gator (UTV, ~$15K).\"</b> "
            "Or: 1 year free seed treatment, or $5K toward input costs. "
            "Combine: $25 Casey's (guaranteed) + chance at a Gator (excitement).",
            ["Lottery effect", "High perceived value"]),
        card("C)", "Premium Pricing for Data",
            "<b>\"Program participants receive +$0.02/bu premium when selling at Cargill elevators.\"</b> "
            "On 50K bu of corn = $1,000 bonus. <b>That's real money.</b> "
            "Cargill gets loyal supplier + data. Farmer gets better price. <b>Most powerful long-term incentive.</b>",
            ["KILLER INCENTIVE", "Financial"]),
    ]:
        for e in elems: story.append(e)

    # ===== DO / DON'T =====
    story.append(PageBreak())
    for e in sec_hdr("5", "COMMUNICATION RULES", "How to talk — and how NOT to talk — to a farmer"):
        story.append(e)
    story.append(Spacer(1, 8))

    do_items = [
        '"Help us help Iowa agriculture" — common good, not Cargill',
        '"Your data is anonymous" — always emphasize anonymity',
        '"Takes 3 minutes" — always state exact time',
        'Show social proof: "47 farmers in your county already participated"',
        'Give first: report, calculator, forecast — then ask',
        'Ask little: 5-7 questions max. Each extra question = -15% conversion',
        'Ask for ranges: "100-200 ac" instead of exact numbers. Less scary.',
        'SMS-first: farmers read texts. They ignore email.',
    ]
    dont_items = [
        'DON\'T say "Cargill wants to know your yield" — sounds like surveillance',
        'DON\'T ask for SSN, exact address, or financial data',
        'DON\'T make long forms — more than 8 questions = abandonment',
        "DON'T send email-only — 70% of farmers don't check email regularly",
        'DON\'T use corporate language: "data collection," "survey," "compliance"',
        "DON'T require login/signup — instant loss of 80% of audience",
        "DON'T call during harvest season (Sept-Nov) — farmer isn't home and is angry",
        "DON'T share data by name — a leak = end of the program forever",
    ]

    do_data = [[Paragraph('<b><font color="#27ae60">DO</font></b>', sH2)]]
    for item in do_items:
        do_data.append([Paragraph(f'<font color="#27ae60">+</font>  {item}', sSmall)])
    dont_data = [[Paragraph('<b><font color="#c0392b">DON\'T</font></b>', sH2)]]
    for item in dont_items:
        dont_data.append([Paragraph(f'<font color="#c0392b">-</font>  {item}', sSmall)])

    do_t = Table(do_data, colWidths=[220])
    do_t.setStyle(TableStyle([
        ('BACKGROUND', (0,0),(-1,-1), C_LIGHT_GREEN),
        ('GRID', (0,0),(-1,-1), 0.5, HexColor('#c8e6c9')),
        ('TOPPADDING', (0,0),(-1,-1), 5), ('BOTTOMPADDING', (0,0),(-1,-1), 5),
        ('LEFTPADDING', (0,0),(-1,-1), 8), ('RIGHTPADDING', (0,0),(-1,-1), 8),
        ('VALIGN', (0,0),(-1,-1), 'TOP'),
    ]))
    dont_t = Table(dont_data, colWidths=[220])
    dont_t.setStyle(TableStyle([
        ('BACKGROUND', (0,0),(-1,-1), C_LIGHT_RED),
        ('GRID', (0,0),(-1,-1), 0.5, HexColor('#f5c6cb')),
        ('TOPPADDING', (0,0),(-1,-1), 5), ('BOTTOMPADDING', (0,0),(-1,-1), 5),
        ('LEFTPADDING', (0,0),(-1,-1), 8), ('RIGHTPADDING', (0,0),(-1,-1), 8),
        ('VALIGN', (0,0),(-1,-1), 'TOP'),
    ]))
    outer = Table([[do_t, dont_t]], colWidths=[235, 235])
    outer.setStyle(TableStyle([('VALIGN', (0,0),(-1,-1), 'TOP'), ('LEFTPADDING', (0,0),(-1,-1), 0), ('RIGHTPADDING', (0,0),(-1,-1), 0)]))
    story.append(outer)

    # ===== FUNNEL =====
    story.append(Spacer(1, 20))
    for e in sec_hdr("6", "CONVERSION FUNNEL", "Realistic numbers for Iowa"):
        story.append(e)
    story.append(Spacer(1, 8))

    fd = [
        ['Stage', 'Count', 'Conversion'],
        ['Total farms in Iowa (USDA Census)', '~85,000', ''],
        ['Farms in target 10 counties', '~25,000', 'Top corn/soy counties'],
        ['Received SMS / learned about program', '~15,000', '60% have mobile on file'],
        ['Opened the link', '~6,700', 'SMS open rate ~45%'],
        ['Completed the survey', '~2,700', 'Completion 40% (w/ $25)'],
        ['+ elevator events + ambassadors', '', '+800-1,300'],
        ['TOTAL TARGET', '~3,500-4,000', 'Realistic target'],
    ]
    ft = Table(fd, colWidths=[200, 100, 150])
    ft.setStyle(TableStyle([
        ('FONTNAME', (0,0),(-1,0),'ArialBold'), ('FONTSIZE', (0,0),(-1,-1), 9),
        ('FONTNAME', (0,1),(-1,-2),'Arial'), ('FONTNAME', (0,-1),(-1,-1),'ArialBold'),
        ('BACKGROUND', (0,0),(-1,0), C_BLUE), ('TEXTCOLOR', (0,0),(-1,0), white),
        ('BACKGROUND', (0,-1),(-1,-1), C_LIGHT_ORANGE), ('TEXTCOLOR', (0,-1),(-1,-1), C_ORANGE),
        ('ROWBACKGROUNDS', (0,1),(-1,-2), [C_LIGHT_BLUE, white]),
        ('GRID', (0,0),(-1,-1), 0.5, HexColor('#dddddd')),
        ('TOPPADDING', (0,0),(-1,-1), 6), ('BOTTOMPADDING', (0,0),(-1,-1), 6),
        ('LEFTPADDING', (0,0),(-1,-1), 8), ('ALIGN', (1,0),(1,-1),'CENTER'),
        ('VALIGN', (0,0),(-1,-1), 'MIDDLE'),
    ]))
    story.append(ft)

    # ===== SCRIPTS =====
    story.append(PageBreak())
    for e in sec_hdr("7", "READY-TO-USE SCRIPTS", "What to write and say"):
        story.append(e)
    story.append(Spacer(1, 8))

    scripts = [
        ("SMS (First Contact)",
         "\"Hey [Name], this is [Ambassador] from [County]. Iowa State + Cargill are putting together a crop report for our area. Takes 3 min, you get a free county yield comparison + $25 Casey's card. No login needed: [link]. 47 folks in [County] already did it.\""),
        ("Elevator Event (In Person)",
         "\"Morning! Grab some coffee. Hey, we're doing a quick thing - trying to get a picture of how the season went around here. Just 6 questions on this iPad. Everything's anonymous - no names attached. You get to see how [County] compares to the rest of the state. Want to give it a shot?\""),
        ("Phone (Follow-up, Ambassador)",
         "\"Hey [Name], it's [Bob] - yeah, from down the road. Listen, I did this quick crop survey thing, took me like two minutes. They show you how your county stacks up yield-wise - kinda interesting actually. You got a sec? I can walk you through it right now on your phone. Or I'll just text you the link.\""),
        ("Flyer at Co-op / Elevator",
         "\"HOW DOES YOUR FARM STACK UP?  Take the 3-min Iowa Crop Survey. Get your FREE County Yield Report + $25 Casey's Gift Card.  Anonymous | No login | Phone-friendly.  Scan QR or text FARM to 55555.  Powered by Iowa State Extension &amp; Cargill Agricultural Partners.\""),
    ]

    for label, text in scripts:
        story.append(Paragraph(f'<b>{label}</b>', sScriptLabel))
        st = Table([[Paragraph(text, sScript)]], colWidths=[440])
        st.setStyle(TableStyle([
            ('BACKGROUND', (0,0),(-1,-1), HexColor('#f0f8f0')),
            ('GRID', (0,0),(-1,-1), 0.5, HexColor('#c8e6c9')),
            ('LEFTPADDING', (0,0),(-1,-1), 12), ('RIGHTPADDING', (0,0),(-1,-1), 12),
            ('TOPPADDING', (0,0),(-1,-1), 8), ('BOTTOMPADDING', (0,0),(-1,-1), 8),
        ]))
        story.append(st)
        story.append(Spacer(1, 8))

    # ===== TIMELINE =====
    story.append(Spacer(1, 10))
    for e in sec_hdr("8", "LAUNCH TIMELINE"):
        story.append(e)
    story.append(Spacer(1, 8))

    td = [
        ['Period', 'Phase', 'Actions', 'Target'],
        ['Month 1', Paragraph('<b>Preparation</b>', sSmall),
         Paragraph('- Finalize survey form (7 questions max)<br/>- Hire 5 ambassadors in key counties<br/>- Prepare Casey\'s gift cards<br/>- Get SMS list via Farm Bureau / FSA<br/>- Build benchmark report template', sSmall), ''],
        ['Month 2-3', Paragraph('<b>Soft Launch</b>', sSmall),
         Paragraph('- Launch in 3 counties (Polk, Story, Black Hawk)<br/>- Coffee events at 2-3 elevators<br/>- SMS blast (batch 1: 3,000)<br/>- Ambassadors begin peer outreach', sSmall), '500'],
        ['Month 4-6', Paragraph('<b>Scale</b>', sSmall),
         Paragraph('- Expand to 10 counties<br/>- Launch benchmark report (viral loop)<br/>- Grain bid alerts service<br/>- County leaderboard<br/>- <b>Best timing: Jan-March</b> (post-harvest, pre-planting)', sSmall), '3,500+'],
    ]
    tt = Table(td, colWidths=[65, 80, 260, 50])
    tt.setStyle(TableStyle([
        ('FONTNAME', (0,0),(-1,0),'ArialBold'), ('FONTSIZE', (0,0),(-1,0), 9),
        ('FONTSIZE', (0,1),(-1,-1), 9), ('FONTNAME', (0,1),(0,-1),'ArialBold'),
        ('BACKGROUND', (0,0),(-1,0), C_ORANGE), ('TEXTCOLOR', (0,0),(-1,0), white),
        ('ROWBACKGROUNDS', (0,1),(-1,-1), [C_LIGHT_ORANGE, white]),
        ('GRID', (0,0),(-1,-1), 0.5, HexColor('#dddddd')),
        ('TOPPADDING', (0,0),(-1,-1), 6), ('BOTTOMPADDING', (0,0),(-1,-1), 6),
        ('LEFTPADDING', (0,0),(-1,-1), 6), ('RIGHTPADDING', (0,0),(-1,-1), 6),
        ('VALIGN', (0,0),(-1,-1), 'TOP'), ('ALIGN', (3,0),(3,-1),'CENTER'),
    ]))
    story.append(tt)

    # ===== KEY TAKEAWAYS =====
    story.append(Spacer(1, 20))
    story.append(HRFlowable(width="100%", thickness=1, color=C_ORANGE, spaceAfter=12))
    story.append(Paragraph('<b><font color="#e8792b">KEY TAKEAWAYS</font></b>', sH1))
    story.append(Spacer(1, 6))

    for tw in [
        '<b>1. Benchmark Report</b> — the most powerful technique. Curiosity &gt; Privacy.',
        '<b>2. Local Ambassadors</b> — peer-to-peer trust is 5x stronger than any corporate outreach.',
        '<b>3. +$0.02/bu premium</b> — real money, long-term loyalty.',
        '<b>4. Start with internal data</b> — 80% of the info already exists at Cargill elevators.',
        '<b>5. Timing</b> — launch Jan-March (post-harvest, pre-planting).',
        '<b>6. SMS-first</b> — no email, no logins, no long forms.',
    ]:
        story.append(Paragraph(tw, sBullet))

    story.append(Spacer(1, 30))
    story.append(HRFlowable(width="40%", thickness=1, color=C_GRAY, spaceAfter=10))
    story.append(Paragraph("Confidential  |  Cargill Agricultural Data Initiative  |  April 2026", sFooter))

    doc.build(story)
    print(f"PDF created: {out}")
    print(f"Size: {os.path.getsize(out) / 1024:.0f} KB")


if __name__ == '__main__':
    build_pdf()
