#!/usr/bin/env python3
"""One-pager: Wheel of Wellness proposal for HELPipedia."""

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

# ── Colors ──────────────────────────────────────────────────
TEAL       = '2E7D6F'
CORAL      = 'E8835C'
DARK       = '2D3436'
LIGHT_TEAL = 'E8F5F1'
ALT_ROW    = 'F2F2F2'
WHITE      = 'FFFFFF'

def set_cell_shading(cell, color):
    shading = OxmlElement('w:shd')
    shading.set(qn('w:fill'), color)
    shading.set(qn('w:val'), 'clear')
    cell._tc.get_or_add_tcPr().append(shading)

def set_cell_margins(cell, top=40, bottom=40, left=80, right=80):
    tc = cell._tc
    tcPr = tc.get_or_add_tcPr()
    tcMar = OxmlElement('w:tcMar')
    for side, val in [('top', top), ('bottom', bottom), ('left', left), ('right', right)]:
        el = OxmlElement(f'w:{side}')
        el.set(qn('w:w'), str(val))
        el.set(qn('w:type'), 'dxa')
        tcMar.append(el)
    tcPr.append(tcMar)

def add_run(p, text, size=9, bold=False, color=DARK, italic=False):
    r = p.add_run(text)
    r.font.size = Pt(size)
    r.font.color.rgb = RGBColor(*bytes.fromhex(color))
    r.bold = bold
    r.italic = italic
    return r

# ── Document ────────────────────────────────────────────────
doc = Document()

# Tight margins for one-pager
for section in doc.sections:
    section.top_margin = Cm(1.5)
    section.bottom_margin = Cm(1.2)
    section.left_margin = Cm(1.8)
    section.right_margin = Cm(1.8)

# ── HEADER BAR (using a single-cell table with shading) ─────
header_table = doc.add_table(rows=1, cols=1)
header_table.alignment = WD_TABLE_ALIGNMENT.CENTER
cell = header_table.rows[0].cells[0]
set_cell_shading(cell, TEAL)
set_cell_margins(cell, top=100, bottom=100, left=150, right=150)
p = cell.paragraphs[0]
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
add_run(p, 'Wheel of Wellness Resource Connector', size=18, bold=True, color=WHITE)
p2 = cell.add_paragraph()
p2.alignment = WD_ALIGN_PARAGRAPH.CENTER
add_run(p2, 'A Proposal for HELPipedia / SpecialNeeds.help  |  Kayla Newkirk, M.S.Ed., MHC-LP  |  Week of June 16, 2026', size=9, color=WHITE)

# Remove table borders
tbl = header_table._tbl
tblPr = tbl.tblPr if tbl.tblPr is not None else OxmlElement('w:tblPr')
borders = OxmlElement('w:tblBorders')
for edge in ('top', 'left', 'bottom', 'right', 'insideH', 'insideV'):
    el = OxmlElement(f'w:{edge}')
    el.set(qn('w:val'), 'none')
    el.set(qn('w:sz'), '0')
    el.set(qn('w:space'), '0')
    el.set(qn('w:color'), 'auto')
    borders.append(el)
tblPr.append(borders)

doc.add_paragraph()  # small spacer

# ── THE PROBLEM ─────────────────────────────────────────────
p = doc.add_paragraph()
add_run(p, 'THE PROBLEM  ', size=10, bold=True, color=CORAL)
add_run(p, 'Families navigating disability and caregiving often do not know what they need until someone asks the right questions. A directory is powerful when you know what to search for. An assessment tool is powerful when you do not.', size=9)

# ── THE SOLUTION ────────────────────────────────────────────
p = doc.add_paragraph()
add_run(p, 'THE SOLUTION  ', size=10, bold=True, color=CORAL)
add_run(p, 'An interactive, web-based Wheel of Wellness Assessment that asks caregivers and individuals with disabilities targeted questions across six wellness dimensions, scores each area, and automatically maps their needs to resources in the SpecialNeeds.help directory. Users arrive unsure of what they need. They leave with a personalized resource plan.', size=9)

# ── THE SIX DIMENSIONS TABLE ────────────────────────────────
p = doc.add_paragraph()
add_run(p, 'THE SIX DIMENSIONS', size=10, bold=True, color=TEAL)

dims = [
    ['Physical', 'Rest, movement, nutrition, medical care', 'Respite care, medical providers, adaptive recreation'],
    ['Emotional', 'Naming feelings, coping, support', 'Counseling referrals, caregiver support groups, crisis lines'],
    ['Social', 'Connection, understanding, community', 'Parent mentors, local support networks, peer matching'],
    ['Practical', 'Finances, advocacy, schedules, systems', 'IEP advocates, legal aid, benefits navigation'],
    ['Purpose', 'Meaning, identity, values, hope', 'Faith communities, disability-affirming organizations'],
    ['Growth', 'Learning, creativity, becoming', 'Training, conferences, podcasts, creative programs'],
]

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

# Header
for i, h in enumerate(['Dimension', 'Focus', 'Resource Connections']):
    cell = t.rows[0].cells[i]
    cell.text = ''
    p = cell.paragraphs[0]
    add_run(p, h, size=8, bold=True, color=WHITE)
    set_cell_shading(cell, TEAL)
    set_cell_margins(cell, top=30, bottom=30, left=60, right=60)

# Data
for ri, row_data in enumerate(dims):
    for ci, val in enumerate(row_data):
        cell = t.rows[ri + 1].cells[ci]
        cell.text = ''
        p = cell.paragraphs[0]
        add_run(p, val, size=8, bold=(ci == 0), color=DARK)
        set_cell_margins(cell, top=20, bottom=20, left=60, right=60)
        if ri % 2 == 1:
            set_cell_shading(cell, ALT_ROW)

# Set column widths
for row in t.rows:
    row.cells[0].width = Cm(2.5)
    row.cells[1].width = Cm(6)
    row.cells[2].width = Cm(8)

doc.add_paragraph()

# ── WHY IT MATTERS ──────────────────────────────────────────
p = doc.add_paragraph()
add_run(p, 'WHY IT MATTERS', size=10, bold=True, color=TEAL)

bullets = [
    ('Mission alignment: ', 'Bridges the gap between knowledge and opportunity'),
    ('Differentiator: ', 'No other disability directory offers a clinically grounded needs assessment'),
    ('Engagement: ', 'Personalized entry point increases return visits and directory use'),
    ('Data insight: ', 'Anonymous aggregate data reveals community needs for content and fundraising'),
    ('Scalable: ', 'Works for any new resource area added to SpecialNeeds.help'),
    ('Measurable: ', 'Completion rates, click-through, referrals all trackable'),
]
for bold_part, rest in bullets:
    p = doc.add_paragraph()
    p.paragraph_format.space_before = Pt(1)
    p.paragraph_format.space_after = Pt(1)
    add_run(p, bold_part, size=8, bold=True, color=DARK)
    add_run(p, rest, size=8)

# ── Footer ──────────────────────────────────────────────────
p = doc.add_paragraph()
p.alignment = WD_ALIGN_PARAGRAPH.CENTER
p.paragraph_format.space_before = Pt(6)
add_run(p, 'Kayla Newkirk, M.S.Ed., MHC-LP  |  Doctoral Candidate, Counselor Education & Supervision, Waynesburg University  |  kcordone30@gmail.com', size=7, color='888888')

# ── Save ────────────────────────────────────────────────────
out = '/home/newkirk/Documents/Career/WheelOfWellnessOnePager.docx'
doc.save(out)
print(f'Saved: {out}')
