#!/usr/bin/env python3
"""Create Danielle's company comparison Word document."""

from docx import Document
from docx.shared import Pt, RGBColor, Inches, Cm
from docx.enum.text import WD_ALIGN_PARAGRAPH
from docx.enum.table import WD_TABLE_ALIGNMENT, WD_ALIGN_VERTICAL
from docx.oxml.ns import qn
from docx.oxml import OxmlElement
import copy

OUTPUT_PATH = '/Users/joemac/.openclaw/workspace/projects/danielle-company-comparison.docx'

def set_font(run, name='Calibri', size=11, bold=False, italic=False, color=None):
    run.font.name = name
    run.font.size = Pt(size)
    run.font.bold = bold
    run.font.italic = italic
    if color:
        run.font.color.rgb = RGBColor(*color)

def add_heading(doc, text, level=1, color=(0, 51, 102)):
    p = doc.add_paragraph()
    p.alignment = WD_ALIGN_PARAGRAPH.LEFT
    run = p.add_run(text)
    set_font(run, size=14 if level == 1 else 12, bold=True, color=color)
    # Add some space after heading
    p.paragraph_format.space_before = Pt(12)
    p.paragraph_format.space_after = Pt(4)
    return p

def add_body(doc, text, bold_prefix=None, indent=False):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after = Pt(2)
    if indent:
        p.paragraph_format.left_indent = Inches(0.25)
    if bold_prefix:
        run = p.add_run(bold_prefix)
        set_font(run, bold=True)
        run = p.add_run(text)
        set_font(run)
    else:
        run = p.add_run(text)
        set_font(run)
    return p

def add_bullet(doc, text, bold_prefix=None):
    p = doc.add_paragraph(style='List Bullet')
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after = Pt(1)
    p.paragraph_format.left_indent = Inches(0.25)
    if bold_prefix:
        run = p.add_run(bold_prefix)
        set_font(run, bold=True)
        run = p.add_run(text)
        set_font(run)
    else:
        run = p.add_run(text)
        set_font(run)
    return p

def shade_cell(cell, fill_hex):
    """Apply background color to a table cell."""
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    shd = OxmlElement('w:shd')
    shd.set(qn('w:val'), 'clear')
    shd.set(qn('w:color'), 'auto')
    shd.set(qn('w:fill'), fill_hex)
    tcPr.append(shd)

def set_cell_border(cell, **kwargs):
    """Set borders on a cell."""
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcBorders = OxmlElement('w:tcBorders')
    for edge in ('top', 'left', 'bottom', 'right', 'insideH', 'insideV'):
        tag = f'w:{edge}'
        element = OxmlElement(tag)
        element.set(qn('w:val'), kwargs.get(edge, 'single'))
        element.set(qn('w:sz'), '4')
        element.set(qn('w:space'), '0')
        element.set(qn('w:color'), kwargs.get('color', 'CCCCCC'))
        tcBorders.append(element)
    tcPr.append(tcBorders)

def add_table_cell_text(cell, text, bold=False, size=10, color=None, align=WD_ALIGN_PARAGRAPH.LEFT):
    cell.paragraphs[0].clear()
    p = cell.paragraphs[0]
    p.alignment = align
    run = p.add_run(text)
    run.font.name = 'Calibri'
    run.font.size = Pt(size)
    run.font.bold = bold
    if color:
        run.font.color.rgb = RGBColor(*color)
    cell.vertical_alignment = WD_ALIGN_VERTICAL.CENTER

def add_horizontal_rule(doc):
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(4)
    p.paragraph_format.space_after = Pt(4)
    pPr = p._p.get_or_add_pPr()
    pBdr = OxmlElement('w:pBdr')
    bottom = OxmlElement('w:bottom')
    bottom.set(qn('w:val'), 'single')
    bottom.set(qn('w:sz'), '6')
    bottom.set(qn('w:space'), '1')
    bottom.set(qn('w:color'), '003366')
    pBdr.append(bottom)
    pPr.append(pBdr)
    return p

# ============================================================
# BUILD THE DOCUMENT
# ============================================================
doc = Document()

# Page margins
for section in doc.sections:
    section.top_margin = Inches(1.0)
    section.bottom_margin = Inches(1.0)
    section.left_margin = Inches(1.0)
    section.right_margin = Inches(1.0)

# Set default font
doc.styles['Normal'].font.name = 'Calibri'
doc.styles['Normal'].font.size = Pt(11)

# ---- TITLE BLOCK ----
title_p = doc.add_paragraph()
title_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
title_p.paragraph_format.space_before = Pt(6)
title_p.paragraph_format.space_after = Pt(4)
run = title_p.add_run('Saronic Technologies vs. Northslope Technologies')
set_font(run, size=18, bold=True, color=(0, 51, 102))

title_p2 = doc.add_paragraph()
title_p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
title_p2.paragraph_format.space_before = Pt(0)
title_p2.paragraph_format.space_after = Pt(4)
run = title_p2.add_run('Career Comparison for Danielle Lynch')
set_font(run, size=16, bold=True, color=(0, 51, 102))

sub_p = doc.add_paragraph()
sub_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
sub_p.paragraph_format.space_before = Pt(0)
sub_p.paragraph_format.space_after = Pt(8)
run = sub_p.add_run('Prepared April 7, 2026')
set_font(run, size=11, italic=True, color=(100, 100, 100))

add_horizontal_rule(doc)

# ---- SECTION 1: SARONIC ----
add_heading(doc, '1. SARONIC TECHNOLOGIES — Current Employer', level=1, color=(0, 51, 102))

add_bullet(doc, 'Austin, TX', bold_prefix='Founded: ~2021 | HQ: ')
add_bullet(doc, 'Autonomous unmanned surface vessels (USVs) for maritime defense — the Corsair, Mirage, and Marauder. Autonomous ships designed for US Navy patrol, surveillance, and combat missions without human crews.', bold_prefix='What They Do: ')
add_bullet(doc, '$1.75 BILLION Series D raised March 31, 2026 — led by Kleiner Perkins. Company valued at $9.25 BILLION. One of the largest defense tech raises in history.', bold_prefix='Funding: ')
add_bullet(doc, '~$200M+ in 2025 (company valued at ~38x revenue)', bold_prefix='Revenue: ')
add_bullet(doc, 'Growing rapidly — estimated 200–500+ and climbing', bold_prefix='Employees: ')
add_bullet(doc, 'US Department of Defense, US Navy', bold_prefix='Clients: ')
add_bullet(doc, 'Building "Port Alpha" — a next-gen autonomous shipyard in Texas targeting 20+ ships/year by 2027. Aggressively hiring engineers and scaling manufacturing.', bold_prefix='Mission/Trajectory: ')
add_bullet(doc, 'Early-stage but heavily funded with sticky government defense contracts. DoD backing = strong revenue floor.', bold_prefix='Risk Level: ')
add_bullet(doc, 'Autonomous systems, navigation, vessel design, or embedded engineering on cutting-edge maritime hardware.', bold_prefix="Danielle's Likely Role: ")

add_horizontal_rule(doc)

# ---- SECTION 2: NORTHSLOPE ----
add_heading(doc, '2. NORTHSLOPE TECHNOLOGIES — Prospective Employer', level=1, color=(0, 51, 102))

add_bullet(doc, '~2022–2023 | HQ: Denver, CO (also NYC and Washington DC)', bold_prefix='Founded: ')
add_bullet(doc, 'Enterprise AI consulting/product firm specializing in Palantir\'s Foundry and AIP platforms. Think McKinsey-meets-AI — they embed engineers at client sites and build working AI solutions in weeks, not years. NOT an autonomous vehicle or maritime company.', bold_prefix='What They Do: ')
add_bullet(doc, '90%+ Palantir alumni. Brought Palantir\'s famous "Forward Deployed Engineering" model — ship MVPs in days, move fast, solve hard industrial problems on-site.', bold_prefix='Team Model: ')
add_bullet(doc, 'Private — no public funding information available. Appears to be a smaller boutique firm.', bold_prefix='Funding: ')
add_bullet(doc, 'Industrial companies, critical infrastructure operators, and government agencies.', bold_prefix='Clients: ')
add_bullet(doc, 'Growing Palantir ecosystem play. Niche, but potentially very lucrative for those who thrive in fast-moving consulting environments.', bold_prefix='Trajectory: ')
add_bullet(doc, 'Smaller and less funded than Saronic. Consulting/services model carries more client concentration risk.', bold_prefix='Risk Level: ')

# Note box
note_p = doc.add_paragraph()
note_p.paragraph_format.left_indent = Inches(0.25)
note_p.paragraph_format.right_indent = Inches(0.25)
note_p.paragraph_format.space_before = Pt(8)
note_p.paragraph_format.space_after = Pt(8)
run = note_p.add_run('⚠️  NOTE FOR JOE: ')
set_font(run, bold=True, color=(180, 50, 0))
run = note_p.add_run(
    'The company Danielle is considering may NOT be the same Northslope she\'s describing. The Northslope Technologies we found is a Palantir AI consulting firm — NOT an autonomous maritime or defense hardware company. There may be a different firm called "North Slope Technologies" in the defense/maritime space. It is critical to verify which company she is actually interviewing with before drawing conclusions.'
)
set_font(run, color=(80, 80, 80))

add_horizontal_rule(doc)

# ---- SECTION 3: COMPARISON TABLE ----
add_heading(doc, '3. SIDE-BY-SIDE COMPARISON', level=1, color=(0, 51, 102))

# Table data
headers = ['Factor', 'Saronic Technologies', 'Northslope Technologies']
rows = [
    ['Company Type', 'Hardware / Autonomous Maritime Vehicles', 'AI Consulting / Software Services (Palantir)'],
    ['Industry', 'Defense Maritime', 'Enterprise AI'],
    ['Stage', 'Series D — $9.25B valuation', 'Small private boutique — valuation unknown'],
    ['Funding', '$1.75B raised (March 2026)', 'No public funding — appears bootstrapped/small'],
    ['Career Path', 'Engineer on autonomous naval systems', 'Palantir implementation / Forward Deployed Engineer'],
    ['Job Security', 'Government/DoD contracts (sticky revenue)', 'Commercial & government clients (variable)'],
    ['Equity Upside', 'Options in a $9.25B company — significant if IPO', 'Boutique equity — smaller ceiling, unknown terms'],
    ['Work Style', 'Product company — build the thing', 'Consulting/deployed model — client to client'],
    ['Location', 'Austin, TX', 'Denver CO / NYC / Washington DC (hybrid)'],
    ['Growth Trajectory', '🚀 Massive — building shipyards, DoD backing', 'Niche Palantir ecosystem — solid but limited scale'],
]

table = doc.add_table(rows=1 + len(rows), cols=3)
table.style = 'Table Grid'
table.alignment = WD_TABLE_ALIGNMENT.CENTER

# Set column widths
col_widths = [Inches(1.8), Inches(2.5), Inches(2.5)]
for i, width in enumerate(col_widths):
    for cell in table.columns[i].cells:
        cell.width = width

# Header row
header_row = table.rows[0]
for j, hdr in enumerate(headers):
    cell = header_row.cells[j]
    shade_cell(cell, '003366')
    add_table_cell_text(cell, hdr, bold=True, size=10, color=(255, 255, 255), align=WD_ALIGN_PARAGRAPH.CENTER)

# Data rows
for i, row_data in enumerate(rows):
    row = table.rows[i + 1]
    fill = 'EBF0FA' if i % 2 == 0 else 'FFFFFF'
    for j, cell_text in enumerate(row_data):
        cell = row.cells[j]
        shade_cell(cell, fill)
        bold = (j == 0)
        color = (0, 51, 102) if j == 0 else (40, 40, 40)
        add_table_cell_text(cell, cell_text, bold=bold, size=10, color=color)

doc.add_paragraph()  # spacer

add_horizontal_rule(doc)

# ---- SECTION 4: ROB'S ASSESSMENT ----
add_heading(doc, "4. ROB'S HONEST ASSESSMENT FOR DANIELLE", level=1, color=(0, 51, 102))

p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(4)
p.paragraph_format.space_after = Pt(8)
run = p.add_run(
    'Danielle — your dad asked me to put this together because he wants you to have the full picture before making any moves. Here it is, straight.'
)
set_font(run, size=11, italic=True)

add_heading(doc, 'The Core Question', level=2, color=(0, 80, 140))
p = doc.add_paragraph()
p.paragraph_format.space_before = Pt(2)
p.paragraph_format.space_after = Pt(6)
run = p.add_run(
    'Is Northslope actually in the same space as Saronic — or is this a completely different kind of company and career?'
)
set_font(run, size=11)

add_heading(doc, 'The Saronic Reality Check', level=2, color=(0, 80, 140))

facts = [
    'Saronic just raised $1.75 BILLION in March 2026. That\'s not hype — that\'s Kleiner Perkins writing a massive check because they believe in the trajectory.',
    'The company is valued at $9.25 BILLION — with $200M+ in revenue and DoD backing. This is not a moonshot startup. This is a company the US military is betting on.',
    'They are building Port Alpha — a physical shipyard in Texas to produce 20+ autonomous ships per year by 2027. That\'s not vaporware. That\'s steel in the ground.',
    'As an engineer at Saronic RIGHT NOW, Danielle is at a critical inflection point. Early enough to hold meaningful equity. Late enough to know the company is real.',
    'If Saronic continues its trajectory and goes public or gets acquired, her equity could be worth something significant.',
]
for fact in facts:
    add_bullet(doc, fact)

add_heading(doc, 'The Northslope Reality Check', level=2, color=(0, 80, 140))

facts2 = [
    'Northslope Technologies (the company we found) is a Palantir AI consulting firm. They\'re talented, they move fast, and the Palantir ecosystem is growing.',
    'But this would be a fundamental career pivot — from building autonomous ships (hardware engineering) to consulting clients on AI software implementations (software/services).',
    'It\'s not a bad career. It\'s just a very different one. And the financial upside ceiling is lower when you\'re at a boutique services firm vs. a $9.25B product company at the edge of explosive growth.',
    '⚠️  CRITICAL: We cannot confirm this is the same company Danielle is actually interviewing with. There may be a different company called "North Slope Technologies" in the defense/maritime space. Verify this before drawing any conclusions.',
]
for fact in facts2:
    add_bullet(doc, fact)

add_heading(doc, 'Questions Danielle Should Ask — Before Saying Yes to Anyone', level=2, color=(0, 80, 140))

questions = [
    ('1. ', 'What specific role is Northslope offering? Engineer or consultant? Product or services?'),
    ('2. ', 'What equity or stock options would she receive at Northslope, and at what valuation?'),
    ('3. ', 'How does her Saronic equity vesting schedule look? How much is still unvested — and when does it vest?'),
    ('4. ', 'Is this actually "Northslope Technologies" (the Palantir firm) or a different company called "North Slope Technologies" in the defense/maritime space? This matters enormously.'),
    ('5. ', 'Is Northslope raising capital? What\'s their growth plan? How many engineers do they have?'),
]
for num, q in questions:
    p = doc.add_paragraph()
    p.paragraph_format.left_indent = Inches(0.25)
    p.paragraph_format.space_before = Pt(2)
    p.paragraph_format.space_after = Pt(2)
    run = p.add_run(num)
    set_font(run, bold=True)
    run = p.add_run(q)
    set_font(run)

# Verdict box
doc.add_paragraph()
verdict_p = doc.add_paragraph()
verdict_p.paragraph_format.left_indent = Inches(0.25)
verdict_p.paragraph_format.right_indent = Inches(0.25)
verdict_p.paragraph_format.space_before = Pt(8)
verdict_p.paragraph_format.space_after = Pt(8)
run = verdict_p.add_run('VERDICT: ')
set_font(run, bold=True, size=12, color=(0, 51, 102))
run = verdict_p.add_run(
    'If the Northslope role is in the same autonomous/maritime/defense space as Saronic, it could absolutely be worth exploring — compare the equity, the role, and the team carefully. '
    'But if it\'s the Palantir AI consulting firm, this is a significant career pivot away from hardware engineering into software consulting. '
    'That\'s not wrong — but Danielle should make that decision with eyes wide open, especially given that Saronic just lit the fuse on a $1.75 billion rocket ship. '
    'Leaving now means leaving a lot of potential upside on the table.'
)
set_font(run, size=11, color=(40, 40, 40))

add_horizontal_rule(doc)

# ---- SECTION 5: QUESTIONS TO RESEARCH ----
add_heading(doc, '5. OPEN QUESTIONS TO RESEARCH', level=1, color=(0, 51, 102))

research = [
    ('Verify the company: ', 'Is this the Northslope Technologies Palantir firm (Denver/NYC/DC), or a different company with a similar name operating in maritime/defense? Do not assume.'),
    ('Check equity before moving: ', "Review Danielle's Saronic equity grant and vesting schedule. Know exactly how much is unvested and when it vests. This is often the most financially important factor in any job change."),
    ('Ask Northslope for specifics: ', 'Role details, team size, current revenue, growth trajectory, and equity compensation terms.'),
    ('Expand the search: ', 'If Danielle is open to exploring, are there other autonomous maritime/defense companies she should evaluate? (e.g., Shield AI, Anduril, Joby, Skydio — depending on her engineering focus)'),
]
for bold_part, detail in research:
    add_bullet(doc, detail, bold_prefix=bold_part)

add_horizontal_rule(doc)

# ---- FOOTER ----
footer_p = doc.add_paragraph()
footer_p.alignment = WD_ALIGN_PARAGRAPH.CENTER
footer_p.paragraph_format.space_before = Pt(12)
run = footer_p.add_run('Research compiled by Rob Lobster 🦞 for Joe Lynch  |  April 7, 2026  |  Forward to Danielle for review')
set_font(run, size=9, italic=True, color=(120, 120, 120))

# Save
doc.save(OUTPUT_PATH)
print(f"Document saved to: {OUTPUT_PATH}")
