#!/usr/bin/env python3
"""
Build sheet_staging.json for Nurse Charles 2026-04-20 content cycle.
Run this script to regenerate the staging file with full HTML content embedded.
"""
import json
import os

BASE = '/Users/bryce/FLSM/.tmp/briefs/nurse-charles-2026-04-20'

def read(path):
    with open(path, encoding='utf-8') as f:
        return f.read()

# Source data
data = json.loads(read(os.path.join(BASE, 'content_data_scripts.json')))
yt1, yt2, yt3, yt4 = data['yt1'], data['yt2'], data['yt3'], data['yt4']
shorts = data['shorts']

# HTML content
blog1_html = read(os.path.join(BASE, 'pieces/blog1.html'))
blog2_html = read(os.path.join(BASE, 'pieces/blog2.html'))
blog3_html = read(os.path.join(BASE, 'pieces/blog3.html'))
email1_html = read(os.path.join(BASE, 'pieces/email1.html'))
email2_html = read(os.path.join(BASE, 'pieces/email2.html'))


def yt_script(yt):
    parts = ['HOOK: ' + yt['hook_section']]
    parts.append('OPEN: ' + yt['open_section'])
    for sec in yt['sections']:
        lines = [sec['name']] + ['- ' + p for p in sec['points']]
        parts.append('\n'.join(lines))
    parts.append('PROOF: ' + yt['proof_section'])
    parts.append('CTA: ' + yt['close_cta'])
    return '\n\n'.join(parts)


def short_script(clip):
    return 'HOOK: ' + clip['hook'] + '\n\n' + clip['core_message'] + '\n\nCTA: ' + clip['cta']


pieces = [
    # yt1
    {
        'piece_id': 'yt1',
        'title': 'What 2,000mg Gas-Station Gummies Actually Do to a Teenager',
        'type': 'YouTube Long-Form',
        'platforms': 'YouTube',
        'week': 1, 'day': 'Monday', 'date': '2026-04-20',
        'script': yt_script(yt1),
        'caption': yt1['description_lines'],
        'status': 'Draft',
        'notes': 'mode: TEACH | proof: proof_dose_confusion_600mg',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short1-li-a
    {
        'piece_id': 'short1-li-a',
        'title': shorts['short1']['clips']['linkedin_a']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 1, 'day': 'Tuesday', 'date': '2026-04-21',
        'script': short_script(shorts['short1']['clips']['linkedin_a']),
        'caption': shorts['short1']['clips']['linkedin_a']['caption'],
        'status': 'Draft', 'notes': 'parent: yt1',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short1-li-b
    {
        'piece_id': 'short1-li-b',
        'title': shorts['short1']['clips']['linkedin_b']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 1, 'day': 'Tuesday', 'date': '2026-04-21',
        'script': short_script(shorts['short1']['clips']['linkedin_b']),
        'caption': shorts['short1']['clips']['linkedin_b']['caption'],
        'status': 'Draft', 'notes': 'parent: yt1',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short1-reels
    {
        'piece_id': 'short1-reels',
        'title': shorts['short1']['clips']['reels']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'Instagram Reels',
        'week': 1, 'day': 'Tuesday', 'date': '2026-04-21',
        'script': short_script(shorts['short1']['clips']['reels']),
        'caption': shorts['short1']['clips']['reels']['caption'],
        'status': 'Draft', 'notes': 'parent: yt1',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short1-tiktok
    {
        'piece_id': 'short1-tiktok',
        'title': shorts['short1']['clips']['tiktok']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'TikTok',
        'week': 1, 'day': 'Tuesday', 'date': '2026-04-21',
        'script': short_script(shorts['short1']['clips']['tiktok']),
        'caption': shorts['short1']['clips']['tiktok']['caption'],
        'status': 'Draft', 'notes': 'parent: yt1',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short1-yt
    {
        'piece_id': 'short1-yt',
        'title': shorts['short1']['clips']['youtube_shorts']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'YouTube Shorts',
        'week': 1, 'day': 'Tuesday', 'date': '2026-04-21',
        'script': short_script(shorts['short1']['clips']['youtube_shorts']),
        'caption': shorts['short1']['clips']['youtube_shorts']['caption'],
        'status': 'Draft', 'notes': 'parent: yt1',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # li1
    {
        'piece_id': 'li1',
        'title': 'LinkedIn Carousel #1',
        'type': 'LinkedIn Carousel', 'platforms': 'LinkedIn',
        'week': 1, 'day': 'Wednesday', 'date': '2026-04-22',
        'script': '[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/li1.html]',
        'caption': '[See li1.html for caption]',
        'status': 'Draft', 'notes': 'proof: proof_2000mg_math_confusion',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # blog1
    {
        'piece_id': 'blog1',
        'title': "Delta-8 THC Dangers for Teenagers: What Parents Don't Know",
        'type': 'Blog Post', 'platforms': 'Blog',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': blog1_html,
        'caption': '[Blog — no caption]',
        'status': 'Draft', 'notes': '',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # blog2
    {
        'piece_id': 'blog2',
        'title': 'How to Talk to Your Teenager About Drugs: A 4-Step Framework',
        'type': 'Blog Post', 'platforms': 'Blog',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': blog2_html,
        'caption': '[Blog — no caption]',
        'status': 'Draft', 'notes': '',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # yt3
    {
        'piece_id': 'yt3',
        'title': "She Called 911 for a 'Bad Trip.' Here's What the ER Team Actually Found.",
        'type': 'YouTube Long-Form', 'platforms': 'YouTube',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': yt_script(yt3),
        'caption': yt3['description_lines'],
        'status': 'Draft', 'notes': 'mode: TEACH | proof: proof_loss_son_nov18',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short3-li-a
    {
        'piece_id': 'short3-li-a',
        'title': shorts['short3']['clips']['linkedin_a']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': short_script(shorts['short3']['clips']['linkedin_a']),
        'caption': shorts['short3']['clips']['linkedin_a']['caption'],
        'status': 'Draft', 'notes': 'parent: yt3',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short3-li-b
    {
        'piece_id': 'short3-li-b',
        'title': shorts['short3']['clips']['linkedin_b']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': short_script(shorts['short3']['clips']['linkedin_b']),
        'caption': shorts['short3']['clips']['linkedin_b']['caption'],
        'status': 'Draft', 'notes': 'parent: yt3',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short3-reels
    {
        'piece_id': 'short3-reels',
        'title': shorts['short3']['clips']['reels']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'Instagram Reels',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': short_script(shorts['short3']['clips']['reels']),
        'caption': shorts['short3']['clips']['reels']['caption'],
        'status': 'Draft', 'notes': 'parent: yt3',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short3-tiktok
    {
        'piece_id': 'short3-tiktok',
        'title': shorts['short3']['clips']['tiktok']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'TikTok',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': short_script(shorts['short3']['clips']['tiktok']),
        'caption': shorts['short3']['clips']['tiktok']['caption'],
        'status': 'Draft', 'notes': 'parent: yt3',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short3-yt
    {
        'piece_id': 'short3-yt',
        'title': shorts['short3']['clips']['youtube_shorts']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'YouTube Shorts',
        'week': 1, 'day': 'Thursday', 'date': '2026-04-23',
        'script': short_script(shorts['short3']['clips']['youtube_shorts']),
        'caption': shorts['short3']['clips']['youtube_shorts']['caption'],
        'status': 'Draft', 'notes': 'parent: yt3',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # igtt1
    {
        'piece_id': 'igtt1',
        'title': 'IG/TikTok Carousel #1',
        'type': 'IG/TikTok Carousel', 'platforms': 'Instagram, TikTok',
        'week': 1, 'day': 'Friday', 'date': '2026-04-24',
        'script': '[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/igtt1.html]',
        'caption': '[See igtt1.html for caption]',
        'status': 'Draft', 'notes': 'paired mode',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # email1
    {
        'piece_id': 'email1',
        'title': 'The text I got at 2am',
        'type': 'Nurture Email', 'platforms': 'Email',
        'week': 1, 'day': 'Saturday', 'date': '2026-04-25',
        'script': email1_html,
        'caption': '[Email — no social caption]',
        'status': 'Draft', 'notes': '',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # yt2
    {
        'piece_id': 'yt2',
        'title': 'The Shift That Changed How I Think About My Job as an ER Nurse',
        'type': 'YouTube Long-Form', 'platforms': 'YouTube',
        'week': 2, 'day': 'Monday', 'date': '2026-04-27',
        'script': yt_script(yt2),
        'caption': yt2['description_lines'],
        'status': 'Draft', 'notes': 'mode: DOCUMENT | proof: proof_emory_30yrs',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short2-li-a
    {
        'piece_id': 'short2-li-a',
        'title': shorts['short2']['clips']['linkedin_a']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 2, 'day': 'Tuesday', 'date': '2026-04-28',
        'script': short_script(shorts['short2']['clips']['linkedin_a']),
        'caption': shorts['short2']['clips']['linkedin_a']['caption'],
        'status': 'Draft', 'notes': 'parent: yt2',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short2-li-b
    {
        'piece_id': 'short2-li-b',
        'title': shorts['short2']['clips']['linkedin_b']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 2, 'day': 'Tuesday', 'date': '2026-04-28',
        'script': short_script(shorts['short2']['clips']['linkedin_b']),
        'caption': shorts['short2']['clips']['linkedin_b']['caption'],
        'status': 'Draft', 'notes': 'parent: yt2',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short2-reels
    {
        'piece_id': 'short2-reels',
        'title': shorts['short2']['clips']['reels']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'Instagram Reels',
        'week': 2, 'day': 'Tuesday', 'date': '2026-04-28',
        'script': short_script(shorts['short2']['clips']['reels']),
        'caption': shorts['short2']['clips']['reels']['caption'],
        'status': 'Draft', 'notes': 'parent: yt2',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short2-tiktok
    {
        'piece_id': 'short2-tiktok',
        'title': shorts['short2']['clips']['tiktok']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'TikTok',
        'week': 2, 'day': 'Tuesday', 'date': '2026-04-28',
        'script': short_script(shorts['short2']['clips']['tiktok']),
        'caption': shorts['short2']['clips']['tiktok']['caption'],
        'status': 'Draft', 'notes': 'parent: yt2',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short2-yt
    {
        'piece_id': 'short2-yt',
        'title': shorts['short2']['clips']['youtube_shorts']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'YouTube Shorts',
        'week': 2, 'day': 'Tuesday', 'date': '2026-04-28',
        'script': short_script(shorts['short2']['clips']['youtube_shorts']),
        'caption': shorts['short2']['clips']['youtube_shorts']['caption'],
        'status': 'Draft', 'notes': 'parent: yt2',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # li2
    {
        'piece_id': 'li2',
        'title': 'LinkedIn Carousel #2',
        'type': 'LinkedIn Carousel', 'platforms': 'LinkedIn',
        'week': 2, 'day': 'Wednesday', 'date': '2026-04-29',
        'script': '[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/li2.html]',
        'caption': '[See li2.html for caption]',
        'status': 'Draft', 'notes': 'CONTRARIAN | proof: proof_federal_rescheduling',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # blog3
    {
        'piece_id': 'blog3',
        'title': 'Cannabis Overdose: What an ER Nurse Sees That the Safety Debate Misses',
        'type': 'Blog Post', 'platforms': 'Blog',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': blog3_html,
        'caption': '[Blog — no caption]',
        'status': 'Draft', 'notes': '',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # yt4
    {
        'piece_id': 'yt4',
        'title': 'The 4-Step Clinical Framework for Talking to Your Teenager About Substances',
        'type': 'YouTube Long-Form', 'platforms': 'YouTube',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': yt_script(yt4),
        'caption': yt4['description_lines'],
        'status': 'Draft', 'notes': 'mode: TEACH | proof: proof_parents_talk_11yrs',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short4-li-a
    {
        'piece_id': 'short4-li-a',
        'title': shorts['short4']['clips']['linkedin_a']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': short_script(shorts['short4']['clips']['linkedin_a']),
        'caption': shorts['short4']['clips']['linkedin_a']['caption'],
        'status': 'Draft', 'notes': 'parent: yt4',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short4-li-b
    {
        'piece_id': 'short4-li-b',
        'title': shorts['short4']['clips']['linkedin_b']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'LinkedIn',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': short_script(shorts['short4']['clips']['linkedin_b']),
        'caption': shorts['short4']['clips']['linkedin_b']['caption'],
        'status': 'Draft', 'notes': 'parent: yt4',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short4-reels
    {
        'piece_id': 'short4-reels',
        'title': shorts['short4']['clips']['reels']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'Instagram Reels',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': short_script(shorts['short4']['clips']['reels']),
        'caption': shorts['short4']['clips']['reels']['caption'],
        'status': 'Draft', 'notes': 'parent: yt4',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short4-tiktok
    {
        'piece_id': 'short4-tiktok',
        'title': shorts['short4']['clips']['tiktok']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'TikTok',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': short_script(shorts['short4']['clips']['tiktok']),
        'caption': shorts['short4']['clips']['tiktok']['caption'],
        'status': 'Draft', 'notes': 'parent: yt4',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # short4-yt
    {
        'piece_id': 'short4-yt',
        'title': shorts['short4']['clips']['youtube_shorts']['screen_headline'],
        'type': 'Short-Form', 'platforms': 'YouTube Shorts',
        'week': 2, 'day': 'Thursday', 'date': '2026-04-30',
        'script': short_script(shorts['short4']['clips']['youtube_shorts']),
        'caption': shorts['short4']['clips']['youtube_shorts']['caption'],
        'status': 'Draft', 'notes': 'parent: yt4',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # igtt2
    {
        'piece_id': 'igtt2',
        'title': 'IG/TikTok Carousel #2',
        'type': 'IG/TikTok Carousel', 'platforms': 'Instagram, TikTok',
        'week': 2, 'day': 'Friday', 'date': '2026-05-01',
        'script': '[See: .tmp/briefs/nurse-charles-2026-04-20/pieces/igtt2.html]',
        'caption': '[See igtt2.html for caption]',
        'status': 'Draft', 'notes': 'independent mode',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
    # email2
    {
        'piece_id': 'email2',
        'title': 'The 11 comments that convinced me to make something free',
        'type': 'Nurture Email', 'platforms': 'Email',
        'week': 2, 'day': 'Saturday', 'date': '2026-05-02',
        'script': email2_html,
        'caption': '[Email — no social caption]',
        'status': 'Draft', 'notes': 'value CTA only',
        'images': '', 'platform_schedule': '', 'post_link': ''
    },
]

output = {
    'cycle_id': 'nurse-charles-2026-04-20',
    'generated_at': '2026-04-24',
    'pieces': pieces
}

out_path = os.path.join(BASE, 'sheet_staging.json')
with open(out_path, 'w', encoding='utf-8') as f:
    json.dump(output, f, indent=2, ensure_ascii=False)

print('Written:', out_path)
print('Pieces:', len(pieces))
ids = [p['piece_id'] for p in pieces]
print('IDs:', ids)
