#!/usr/bin/env python3
"""
Corporate Video Production Guide PDF
Executive talking-head / straight-to-camera shoot guide for high-end production company.
"""

from reportlab.lib.pagesizes import letter
from reportlab.lib.colors import HexColor, Color, white, black
from reportlab.lib.styles import ParagraphStyle
from reportlab.lib.enums import TA_CENTER, TA_LEFT, TA_JUSTIFY
from reportlab.platypus import (
    SimpleDocTemplate, Paragraph, Spacer, Table, TableStyle,
    PageBreak, Flowable, KeepTogether
)
from reportlab.platypus.doctemplate import PageTemplate
from reportlab.platypus.frames import Frame
from reportlab.lib.units import inch
import io

OUTPUT = '/home/node/workspace/corporate_video_guide.pdf'

W, H = letter
LM = RM = 0.75 * inch
TM = 0.65 * inch
BM = 0.6 * inch

# ── COLORS ──────────────────────────────────────────────────────────────────
C_BG        = HexColor('#F8F7F4')     # warm off-white
C_DARK      = HexColor('#1A1A1A')     # near-black text
C_ACCENT    = HexColor('#C8A96E')     # warm gold
C_ACCENT2   = HexColor('#8B6E47')     # deeper gold/brown
C_RULE      = HexColor('#D4C4A0')     # light rule
C_SECTION   = HexColor('#2C2C2C')     # section header text
C_MID       = HexColor('#5A5A5A')     # body text
C_LIGHT     = HexColor('#9A9A9A')     # subtle text
C_BOX_BG    = HexColor('#F0EBE1')     # warm cream box
C_BOX_BRD   = HexColor('#C8A96E')     # gold border
C_COVER_BG  = HexColor('#1A1814')     # cover dark bg
C_COVER_TXT = HexColor('#F5F0E8')     # cover text

# ── PAGE BACKGROUND CALLBACKS ────────────────────────────────────────────────
def cover_bg(canvas, doc):
    canvas.saveState()
    canvas.setFillColor(C_COVER_BG)
    canvas.rect(0, 0, W, H, fill=1, stroke=0)
    # Subtle gold top bar
    canvas.setFillColor(C_ACCENT)
    canvas.rect(0, H - 6, W, 6, fill=1, stroke=0)
    # Bottom bar
    canvas.rect(0, 0, W, 4, fill=1, stroke=0)
    # Side accent lines
    canvas.setFillColor(Color(0.78, 0.66, 0.43, 0.3))
    canvas.rect(LM - 0.15*inch, BM, 1.5, H - TM - BM, fill=1, stroke=0)
    canvas.rect(W - RM + 0.1*inch, BM, 1.5, H - TM - BM, fill=1, stroke=0)
    canvas.restoreState()

def content_bg(canvas, doc):
    canvas.saveState()
    canvas.setFillColor(C_BG)
    canvas.rect(0, 0, W, H, fill=1, stroke=0)
    # Top gold rule
    canvas.setFillColor(C_ACCENT)
    canvas.rect(LM, H - TM + 10, W - LM - RM, 1.5, fill=1, stroke=0)
    # Bottom rule
    canvas.rect(LM, BM - 14, W - LM - RM, 1.5, fill=1, stroke=0)
    # Footer text
    canvas.setFont('Helvetica', 7.5)
    canvas.setFillColor(C_LIGHT)
    canvas.drawCentredString(W/2, BM - 24, 'EXECUTIVE VIDEO PRODUCTION GUIDE  //  CONFIDENTIAL')
    # Page number
    canvas.drawRightString(W - RM, BM - 24, f'{doc.page}')
    canvas.restoreState()

# ── CUSTOM FLOWABLES ─────────────────────────────────────────────────────────
class GoldRule(Flowable):
    def __init__(self, width, thickness=1.0, alpha=1.0):
        Flowable.__init__(self)
        self.width = width
        self.thickness = thickness
        self.alpha = alpha
        self.height = thickness + 2

    def draw(self):
        self.canv.setFillColor(Color(0.78, 0.66, 0.43, self.alpha))
        self.canv.rect(0, 0, self.width, self.thickness, fill=1, stroke=0)

class SectionDivider(Flowable):
    """Gold dot — rule — dot divider"""
    def __init__(self, width):
        Flowable.__init__(self)
        self.width = width
        self.height = 12

    def draw(self):
        c = self.canv
        y = 5
        c.setFillColor(C_ACCENT)
        c.circle(6, y, 3, fill=1, stroke=0)
        c.circle(self.width - 6, y, 3, fill=1, stroke=0)
        c.setFillColor(C_RULE)
        c.rect(14, y - 0.5, self.width - 28, 1, fill=1, stroke=0)

class PromptCard(Flowable):
    """Stub — replaced by prompt_card_table below."""
    pass


# ── STYLES ───────────────────────────────────────────────────────────────────
def make_styles():
    s = {}

    s['cover_title'] = ParagraphStyle('cover_title',
        fontName='Helvetica-Bold', fontSize=32,
        textColor=C_COVER_TXT, leading=38,
        alignment=TA_CENTER, spaceAfter=6)

    s['cover_sub'] = ParagraphStyle('cover_sub',
        fontName='Helvetica', fontSize=13,
        textColor=HexColor('#C8A96E'), leading=18,
        alignment=TA_CENTER, spaceAfter=4)

    s['cover_detail'] = ParagraphStyle('cover_detail',
        fontName='Helvetica', fontSize=9,
        textColor=HexColor('#888880'), leading=14,
        alignment=TA_CENTER)

    s['section_label'] = ParagraphStyle('section_label',
        fontName='Helvetica-Bold', fontSize=8,
        textColor=C_ACCENT2, leading=12,
        spaceBefore=18, spaceAfter=2,
        leftIndent=0)

    s['section_title'] = ParagraphStyle('section_title',
        fontName='Helvetica-Bold', fontSize=17,
        textColor=C_SECTION, leading=21,
        spaceBefore=2, spaceAfter=8)

    s['body'] = ParagraphStyle('body',
        fontName='Helvetica', fontSize=10,
        textColor=C_MID, leading=15,
        spaceBefore=3, spaceAfter=6,
        alignment=TA_LEFT)

    s['bullet'] = ParagraphStyle('bullet',
        fontName='Helvetica', fontSize=10,
        textColor=C_MID, leading=15,
        spaceBefore=2, spaceAfter=2,
        leftIndent=16, firstLineIndent=0)

    s['sub_head'] = ParagraphStyle('sub_head',
        fontName='Helvetica-Bold', fontSize=11,
        textColor=C_DARK, leading=15,
        spaceBefore=10, spaceAfter=4)

    s['callout'] = ParagraphStyle('callout',
        fontName='Helvetica-BoldOblique', fontSize=10.5,
        textColor=C_ACCENT2, leading=16,
        spaceBefore=4, spaceAfter=4,
        alignment=TA_CENTER)

    s['tip_head'] = ParagraphStyle('tip_head',
        fontName='Helvetica-Bold', fontSize=9.5,
        textColor=C_DARK, leading=13,
        spaceBefore=0, spaceAfter=2)

    s['tip_body'] = ParagraphStyle('tip_body',
        fontName='Helvetica', fontSize=9,
        textColor=C_MID, leading=13,
        spaceBefore=0, spaceAfter=0)

    return s

# ── HELPERS ──────────────────────────────────────────────────────────────────
def section_header(label, title, styles):
    return [
        Spacer(1, 0.15*inch),
        Paragraph(label.upper(), styles['section_label']),
        Paragraph(title, styles['section_title']),
        GoldRule(W - LM - RM, thickness=1.5),
        Spacer(1, 0.12*inch),
    ]

def tip_box(head, body_text, styles, aw):
    data = [[
        Paragraph(head, styles['tip_head']),
        Paragraph(body_text, styles['tip_body']),
    ]]
    t = Table(data, colWidths=[1.3*inch, aw - 1.3*inch])
    t.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), C_BOX_BG),
        ('BOX', (0,0), (-1,-1), 0.5, C_BOX_BRD),
        ('LINEAFTER', (0,0), (0,-1), 0.5, C_BOX_BRD),
        ('TOPPADDING', (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 10),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ]))
    return t

def prompt_table(prompts, styles, aw):
    """Single-column prompt cards — full width, no overflow possible."""
    q_style = ParagraphStyle('q',
        fontName='Helvetica-Bold', fontSize=10.5,
        textColor=C_DARK, leading=15, spaceAfter=4)
    sub_style = ParagraphStyle('sub',
        fontName='Helvetica', fontSize=9,
        textColor=C_MID, leading=13)
    num_style = ParagraphStyle('num',
        fontName='Helvetica-Bold', fontSize=9,
        textColor=white, alignment=TA_CENTER)

    num_col = 26
    text_col = aw - num_col - 32  # 32 = left/right padding inside card

    result = []
    for i, (q, sub) in enumerate(prompts):
        num_cell = Table(
            [[Paragraph(str(i + 1), num_style)]],
            colWidths=[num_col], rowHeights=[num_col])
        num_cell.setStyle(TableStyle([
            ('BACKGROUND', (0, 0), (-1, -1), C_ACCENT),
            ('TOPPADDING', (0, 0), (-1, -1), 4),
            ('BOTTOMPADDING', (0, 0), (-1, -1), 4),
            ('LEFTPADDING', (0, 0), (-1, -1), 0),
            ('RIGHTPADDING', (0, 0), (-1, -1), 0),
            ('ALIGN', (0, 0), (-1, -1), 'CENTER'),
            ('VALIGN', (0, 0), (-1, -1), 'MIDDLE'),
        ]))

        text_block = Table(
            [[Paragraph(q, q_style)],
             [Paragraph(sub, sub_style)]],
            colWidths=[text_col])
        text_block.setStyle(TableStyle([
            ('TOPPADDING', (0, 0), (-1, -1), 0),
            ('BOTTOMPADDING', (0, 0), (-1, -1), 0),
            ('LEFTPADDING', (0, 0), (-1, -1), 0),
            ('RIGHTPADDING', (0, 0), (-1, -1), 0),
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ]))

        card = Table(
            [[num_cell, text_block]],
            colWidths=[num_col + 10, text_col + 22])
        card.setStyle(TableStyle([
            ('BACKGROUND', (0, 0), (-1, -1), C_BOX_BG),
            ('BOX', (0, 0), (-1, -1), 0.5, C_BOX_BRD),
            ('LINEAFTER', (0, 0), (0, -1), 3, C_ACCENT),
            ('TOPPADDING', (0, 0), (-1, -1), 8),
            ('BOTTOMPADDING', (0, 0), (-1, -1), 8),
            ('LEFTPADDING', (0, 0), (0, -1), 8),
            ('RIGHTPADDING', (0, 0), (0, -1), 6),
            ('LEFTPADDING', (1, 0), (1, -1), 10),
            ('RIGHTPADDING', (1, 0), (1, -1), 10),
            ('VALIGN', (0, 0), (-1, -1), 'TOP'),
        ]))

        result.append(KeepTogether([card, Spacer(1, 6)]))

    return result


# ── BUILD STORY ──────────────────────────────────────────────────────────────
def make_story(styles, aw):
    story = []

    # ─── COVER PAGE ──────────────────────────────────────────────────────────
    story.append(Spacer(1, 1.8*inch))

    # Gold rule above title
    story.append(GoldRule(aw, thickness=2))
    story.append(Spacer(1, 0.25*inch))

    story.append(Paragraph('Executive On-Camera', styles['cover_title']))
    story.append(Paragraph('Video Production Guide', styles['cover_title']))
    story.append(Spacer(1, 0.18*inch))
    story.append(GoldRule(aw, thickness=2))
    story.append(Spacer(1, 0.35*inch))

    story.append(Paragraph(
        'A Production Framework for Corporate Leadership',
        styles['cover_sub']))
    story.append(Spacer(1, 0.12*inch))
    story.append(Paragraph(
        'Straight-to-Camera  //  Single Camera  //  2-Hour Shoot',
        styles['cover_sub']))

    story.append(Spacer(1, 2.2*inch))
    story.append(GoldRule(aw, thickness=0.5, alpha=0.4))
    story.append(Spacer(1, 0.2*inch))
    story.append(Paragraph(
        'PREPARED FOR YOUR PRODUCTION TEAM\nCONFIDENTIAL  //  DO NOT DISTRIBUTE',
        styles['cover_detail']))

    story.append(PageBreak())

    # ─── SECTION 1: OVERVIEW ─────────────────────────────────────────────────
    story += section_header('Section 01', 'Project Overview', styles)

    story.append(Paragraph(
        'This document is a production framework for a high-end corporate '
        'straight-to-camera video shoot featuring executive leadership. '
        'The goal is to capture authentic, confident, and compelling on-camera '
        'delivery of organizational priorities, leadership vision, and annual benchmarks '
        'over a two-hour single-camera session.',
        styles['body']))

    story.append(Spacer(1, 0.1*inch))

    overview_data = [
        ['FORMAT', 'Straight-to-camera, single camera, talking head'],
        ['DURATION', '2-hour shoot session per participant'],
        ['PURPOSE', 'Leadership priorities, vision, annual benchmarks'],
        ['TONE', 'Confident, direct, warm — not scripted or stiff'],
        ['OUTPUT', 'Edited segments per topic, full-length options'],
    ]
    ot = Table(overview_data, colWidths=[1.4*inch, aw - 1.4*inch])
    ot.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (0,-1), C_BOX_BG),
        ('BACKGROUND', (1,0), (1,-1), white),
        ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'),
        ('FONTNAME', (1,0), (1,-1), 'Helvetica'),
        ('FONTSIZE', (0,0), (-1,-1), 9.5),
        ('TEXTCOLOR', (0,0), (0,-1), C_ACCENT2),
        ('TEXTCOLOR', (1,0), (1,-1), C_MID),
        ('GRID', (0,0), (-1,-1), 0.5, C_RULE),
        ('TOPPADDING', (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 10),
        ('VALIGN', (0,0), (-1,-1), 'MIDDLE'),
    ]))
    story.append(ot)

    story.append(Spacer(1, 0.25*inch))
    story.append(SectionDivider(aw))

    # ─── SECTION 2: PRODUCTION APPROACH ─────────────────────────────────────
    story += section_header('Section 02', 'High-End Production Approach', styles)

    story.append(Paragraph(
        'What separates a professional corporate video from a standard internal recording '
        'is preparation, environment, and the ability to draw out natural, confident delivery '
        'from executives who may not be accustomed to being on camera.',
        styles['body']))

    story.append(Paragraph('Camera & Technical Setup', styles['sub_head']))
    bullets_tech = [
        'Single camera, locked-off on tripod — creates a clean, authoritative frame.',
        'Eye-level placement, slight camera tilt down (2-3 degrees) — flattering and commanding.',
        'Lens: 85mm or 100mm prime — compresses background, keeps subject sharp.',
        'Shallow depth of field — subject sharp, background softly blurred. Avoid busy backgrounds.',
        'Interviewer sits directly behind or beside the lens so eyeline is near-camera.',
        'Mark the floor — subject should not shift position between setups.',
    ]
    for b in bullets_tech:
        story.append(Paragraph(f'- {b}', styles['bullet']))

    story.append(Paragraph('Lighting', styles['sub_head']))
    bullets_light = [
        'Key light at 45 degrees, slightly above eye level — eliminates harsh shadows.',
        'Soft box or beauty dish preferred for C-suite talent — flattering and professional.',
        'Fill light or reflector on the opposite side — ratio 2:1 or 3:1 max.',
        'Avoid overhead fluorescent — kills skin tone. Bring your own.',
        'Background separation light if space allows — prevents flat, 2D look.',
    ]
    for b in bullets_light:
        story.append(Paragraph(f'- {b}', styles['bullet']))

    story.append(Paragraph('Audio', styles['sub_head']))
    bullets_audio = [
        'Lavalier microphone hidden under clothing — clean, invisible.',
        'Boom mic as backup if lav placement is limited by wardrobe.',
        'Room tone recorded at top of session — critical for editing.',
        'Kill all HVAC and background noise sources before rolling.',
    ]
    for b in bullets_audio:
        story.append(Paragraph(f'- {b}', styles['bullet']))

    story.append(Spacer(1, 0.2*inch))
    story.append(SectionDivider(aw))

    # ─── SECTION 3: SESSION STRUCTURE ────────────────────────────────────────
    story += section_header('Section 03', 'Session Structure (2-Hour Shoot)', styles)

    story.append(Paragraph(
        'A structured shoot day protects the executive\'s time, ensures all topics '
        'are covered, and creates natural editorial segments in post-production. '
        'Never shoot two consecutive hours without structure — you will lose energy, '
        'focus, and usable footage.',
        styles['body']))

    timeline_data = [
        ['TIME', 'ACTIVITY', 'NOTES'],
        ['0:00 - 0:20', 'Setup & Wardrobe Check',
         'Mic placement, lighting match to wardrobe color, quick monitor review with subject'],
        ['0:20 - 0:30', 'Camera Warm-Up / Off-Camera Conversation',
         'Chat with subject naturally. Do not discuss questions yet. Get them relaxed and talking.'],
        ['0:30 - 0:50', 'Block 1 — Vision & Leadership',
         'Open-ended prompts about role, philosophy, and where the org is heading. Warm-up territory.'],
        ['0:50 - 1:00', 'Break',
         'Water, touch-up. Review any pickups from Block 1 while energy is high.'],
        ['1:00 - 1:25', 'Block 2 — Priorities & Benchmarks',
         'The core content. Specific goals, initiatives, what success looks like this year.'],
        ['1:25 - 1:35', 'Block 3 — Culture & Team',
         'Tone shift — softer, more human. Team acknowledgment, values, what they\'re proud of.'],
        ['1:35 - 1:50', 'Pickups & Repeat Answers',
         'Re-shoot any stumbles, off-axis responses, or incomplete answers from all blocks.'],
        ['1:50 - 2:00', 'Wrap & Closing Statements',
         'Direct-to-camera closing remarks. Keep short. These are gold for end-of-video use.'],
    ]
    tt = Table(timeline_data,
               colWidths=[1.15*inch, 1.65*inch, aw - 2.8*inch])
    tt.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,0), C_ACCENT2),
        ('TEXTCOLOR', (0,0), (-1,0), white),
        ('FONTNAME', (0,0), (-1,0), 'Helvetica-Bold'),
        ('FONTSIZE', (0,0), (-1,0), 8.5),
        ('FONTNAME', (0,1), (0,-1), 'Helvetica-Bold'),
        ('FONTNAME', (1,1), (1,-1), 'Helvetica-Bold'),
        ('FONTNAME', (2,1), (2,-1), 'Helvetica'),
        ('FONTSIZE', (0,1), (-1,-1), 8.5),
        ('TEXTCOLOR', (0,1), (0,-1), C_ACCENT2),
        ('TEXTCOLOR', (1,1), (1,-1), C_DARK),
        ('TEXTCOLOR', (2,1), (2,-1), C_MID),
        ('BACKGROUND', (0,1), (-1,-1), white),
        ('ROWBACKGROUNDS', (0,1), (-1,-1), [white, C_BOX_BG]),
        ('GRID', (0,0), (-1,-1), 0.5, C_RULE),
        ('TOPPADDING', (0,0), (-1,-1), 7),
        ('BOTTOMPADDING', (0,0), (-1,-1), 7),
        ('LEFTPADDING', (0,0), (-1,-1), 8),
        ('RIGHTPADDING', (0,0), (-1,-1), 8),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ]))
    story.append(tt)

    story.append(Spacer(1, 0.25*inch))
    story.append(SectionDivider(aw))

    # ─── SECTION 4: SUBJECT PREPARATION ─────────────────────────────────────
    story += section_header('Section 04', 'Preparing Your Subject', styles)

    story.append(Paragraph(
        'The most common failure point in executive video is under-preparation. '
        'Not because the subject does not know their content — they do. '
        'It is because they have never been coached on how to deliver it naturally '
        'to a lens. These preparation steps close that gap.',
        styles['body']))

    story.append(Paragraph('Two Options for Delivery Method', styles['sub_head']))

    prep_data = [
        ['OPTION A\nTalking Points\n(Recommended)',
         'Give the subject 5-7 brief bullet points per topic the morning of the shoot. '
         'No full sentences. They internalize the ideas, not the words. '
         'Result: natural, unrehearsed delivery that does not sound scripted. '
         'Producer reads one prompt at a time. Subject responds conversationally.'],
        ['OPTION B\nQ&A Format\n(Natural Fallback)',
         'Interviewer (off-camera) asks prepared questions one at a time. '
         'Subject is coached to answer without referencing the question — '
         '"Start your answer by restating the idea." '
         'This creates standalone, editable soundbites. '
         'Works well for subjects who freeze with talking points.'],
    ]
    pt = Table(prep_data, colWidths=[1.4*inch, aw - 1.4*inch])
    pt.setStyle(TableStyle([
        ('BACKGROUND', (0,0), (-1,-1), C_BOX_BG),
        ('FONTNAME', (0,0), (0,-1), 'Helvetica-Bold'),
        ('FONTNAME', (1,0), (1,-1), 'Helvetica'),
        ('FONTSIZE', (0,0), (-1,-1), 9),
        ('TEXTCOLOR', (0,0), (0,-1), C_ACCENT2),
        ('TEXTCOLOR', (1,0), (1,-1), C_MID),
        ('GRID', (0,0), (-1,-1), 0.5, C_BOX_BRD),
        ('TOPPADDING', (0,0), (-1,-1), 9),
        ('BOTTOMPADDING', (0,0), (-1,-1), 9),
        ('LEFTPADDING', (0,0), (-1,-1), 10),
        ('RIGHTPADDING', (0,0), (-1,-1), 10),
        ('VALIGN', (0,0), (-1,-1), 'TOP'),
    ]))
    story.append(pt)

    story.append(Spacer(1, 0.15*inch))
    story.append(Paragraph('Day-Of Coaching Notes for the Producer', styles['sub_head']))
    coaching = [
        'Before rolling: "We are going to do this as many times as you need. There is no pressure."',
        'After the first stumble: "Perfect — that is exactly what pickups are for. Reset and go again."',
        'If energy drops: Stop. Take 3 minutes. Get the subject moving — stand up, shake out.',
        'Watch for "reading eyes" — if subject glances up-left mid-sentence, they are reciting. Pause and reset.',
        'Best takes often happen on take 3 or 4. Do not stop at take 1 even if it seems fine.',
        'Use silences. Do not rush to the next question. Let the subject fill the air — often gold.',
    ]
    for c in coaching:
        story.append(Paragraph(f'- {c}', styles['bullet']))

    story.append(Spacer(1, 0.25*inch))
    story.append(SectionDivider(aw))
    story.append(PageBreak())

    # ─── SECTION 5: PROMPT LIBRARY ───────────────────────────────────────────
    story += section_header('Section 05', 'Executive Prompt Library', styles)

    story.append(Paragraph(
        'These prompts are designed to draw out natural, editorial-ready responses. '
        'The producer reads one prompt aloud. The subject answers directly to camera. '
        'Coach subjects to begin responses with a complete thought — not "yeah" or "so..."',
        styles['body']))
    story.append(Spacer(1, 0.12*inch))

    # BLOCK A
    story.append(Paragraph('Block 1 — Leadership Vision & Role', styles['sub_head']))
    story.append(GoldRule(aw, thickness=0.75, alpha=0.5))
    story.append(Spacer(1, 0.1*inch))

    prompts_a = [
        ('Tell us who you are and what you lead.',
         'Coach: Answer in 2-3 sentences. State your title, team, and what you are accountable for.'),
        ('What does success look like for your organization this year?',
         'Coach: Specific over general. Name one or two things that would make this year a clear win.'),
        ('What is the single most important shift happening in your space right now?',
         'Coach: This can be internal or external. Name the trend, then say what it means for you.'),
        ('What does good leadership look like on your team?',
         'Coach: Give a real example if possible. Behaviors, not values-speak.'),
        ('What do you want your team to understand about where you are taking this?',
         'Coach: Speak directly to your people. Imagine they will watch this.'),
        ('What keeps you focused when things get hard?',
         'Coach: One specific thing. Avoid generics like "my team" or "the mission."'),
    ]
    story += prompt_table(prompts_a, styles, aw)
    story.append(Spacer(1, 0.2*inch))

    # BLOCK B
    story.append(Paragraph('Block 2 — Priorities & Annual Benchmarks', styles['sub_head']))
    story.append(GoldRule(aw, thickness=0.75, alpha=0.5))
    story.append(Spacer(1, 0.1*inch))

    prompts_b = [
        ('Walk us through your top 3 priorities for the year.',
         'Coach: Number them. For each: what it is, why it matters, what action it requires.'),
        ('What benchmarks will tell you this year is working?',
         'Coach: Be specific. Numbers, milestones, outcomes — not feelings.'),
        ('What initiative are you most excited about right now, and why?',
         'Coach: Pick one. Energy and specificity matter more than comprehensiveness.'),
        ('Where is your team investing the most energy in the next 90 days?',
         'Coach: Near-term and concrete. Helps viewers understand current focus.'),
        ('What does it mean to hit the mark this year — not just check the box?',
         'Coach: Push past the obvious. What would excellence actually look like?'),
        ('What are you building toward that goes beyond this year?',
         'Coach: Paint a longer picture. One paragraph on where this is all going.'),
    ]
    story += prompt_table(prompts_b, styles, aw)
    story.append(Spacer(1, 0.2*inch))

    # BLOCK C
    story.append(Paragraph('Block 3 — Culture, Team & Closing', styles['sub_head']))
    story.append(GoldRule(aw, thickness=0.75, alpha=0.5))
    story.append(Spacer(1, 0.1*inch))

    prompts_c = [
        ('What are you most proud of about your team right now?',
         'Coach: Specific. Name what they have done or who they are. Not generic praise.'),
        ('What does the culture on your team feel like, and how did you build it?',
         'Coach: Concrete examples. What behaviors define it? What did you do to create it?'),
        ('What do you want someone new to this organization to know?',
         'Coach: Practical and human. Think: what would I tell my first-week self here?'),
        ('Is there anything you want to say directly to the people you lead?',
         'Coach: This is the most powerful prompt. Give space. Let them be human.'),
        ('What is the thing you are most looking forward to in the year ahead?',
         'Coach: Closing energy. Optimistic and forward. End on something real, not PR.'),
        ('If you had to name one thing that drives everything else — what is it?',
         'Coach: One sentence closer. This is the pull quote. Take multiple takes.'),
    ]
    story += prompt_table(prompts_c, styles, aw)
    story.append(Spacer(1, 0.25*inch))

    story.append(SectionDivider(aw))

    # ─── SECTION 6: PRODUCER DIRECTION TIPS ─────────────────────────────────
    story += section_header('Section 06', 'Producer Direction Notes', styles)

    tips = [
        ('Silence is a tool.',
         'After the subject finishes an answer, wait 3 full seconds before moving on. '
         'They will often add the best line unprompted.'),
        ('"Say that again, but start with..."',
         'The single most useful redirect. Gets a clean answer without the subject '
         'feeling like they failed. Use constantly.'),
        ('Watch the hands.',
         'Nervous energy shows in the hands. If they are gripping or fidgeting, '
         'pause and give them something to do — hold a glass of water, rest hands on knees.'),
        ('Re-ask without apologizing.',
         'Never say "that was great BUT..." Just say "Let\'s do that one more time '
         'with a little more energy" or "Start from the benchmark line."'),
        ('"Forget I\'m here."',
         'Tell the subject: "Imagine the person you most want to hear this is sitting '
         'right where that lens is. Talk to them." Kills self-consciousness immediately.'),
        ('Energy management.',
         'Schedule the most important content when the subject is freshest — '
         'typically in the first 30-40 minutes after warm-up. Do not save the best for last.'),
    ]

    tip_rows = []
    for head, body in tips:
        tip_rows.append(KeepTogether([
            tip_box(head, body, styles, aw),
            Spacer(1, 6),
        ]))
    story += tip_rows

    story.append(Spacer(1, 0.25*inch))
    story.append(SectionDivider(aw))

    # ─── SECTION 7: POST-PRODUCTION NOTES ────────────────────────────────────
    story += section_header('Section 07', 'Post-Production Notes', styles)

    story.append(Paragraph(
        'Structure the edit to support the communication goal — not to document '
        'everything that was said. Executive video lives or dies in the edit.',
        styles['body']))

    post_notes = [
        'Cut on the thought, not the sentence — edit for meaning, not for clean in/out points.',
        'L-cuts and J-cuts smooth over hesitations and re-starts without jump cuts.',
        'Color grade: warm skin tones, subtle lift in shadows — never cold or clinical.',
        'Lower thirds: name, title, organization — simple, consistent typographic treatment.',
        'Music underscore (optional): sparse, no melody — texture only. Melody fights the voice.',
        'Segment structure: each block can stand alone as a 90-second cut OR string together for a full-length piece.',
        'Export deliverables: 16:9 master, 9:16 vertical recut, 1:1 square for social.',
    ]
    for p in post_notes:
        story.append(Paragraph(f'- {p}', styles['bullet']))

    story.append(Spacer(1, 0.3*inch))

    # Final callout
    story.append(Paragraph(
        '"The best corporate video does not look like a corporate video."',
        styles['callout']))
    story.append(GoldRule(aw, thickness=1.5))

    return story


# ── MAIN ─────────────────────────────────────────────────────────────────────
def build():
    styles = make_styles()
    aw = W - LM - RM

    # Two-pass: measure then render
    buf = io.BytesIO()
    dummy_doc = SimpleDocTemplate(buf, pagesize=letter,
        leftMargin=LM, rightMargin=RM, topMargin=TM, bottomMargin=BM)

    cover_frame = Frame(LM, BM, aw, H - TM - BM, id='cover')
    content_frame = Frame(LM, BM, aw, H - TM - BM, id='content')
    cover_tmpl = PageTemplate(id='cover', frames=[cover_frame], onPage=cover_bg)
    content_tmpl = PageTemplate(id='content', frames=[content_frame], onPage=content_bg)
    dummy_doc.pageTemplates = [cover_tmpl, content_tmpl]

    story = make_story(styles, aw)
    dummy_doc.build(story)

    # Real render
    doc = SimpleDocTemplate(OUTPUT, pagesize=letter,
        leftMargin=LM, rightMargin=RM, topMargin=TM, bottomMargin=BM)

    cover_frame2 = Frame(LM, BM, aw, H - TM - BM, id='cover')
    content_frame2 = Frame(LM, BM, aw, H - TM - BM, id='content')
    cover_tmpl2 = PageTemplate(id='cover', frames=[cover_frame2], onPage=cover_bg)
    content_tmpl2 = PageTemplate(id='content', frames=[content_frame2], onPage=content_bg)
    doc.pageTemplates = [cover_tmpl2, content_tmpl2]

    from reportlab.platypus import NextPageTemplate
    story2 = [NextPageTemplate('content')] + make_story(styles, aw)
    doc.build(story2)
    print(f'Done: {OUTPUT}')


if __name__ == '__main__':
    build()
