The Grim Reality
${reality.text}
A Glimmer of Hope
${hope.text}
`;
briefingContent.innerHTML = generatedHtml;
outputSection.classList.add('active');
// Store for PDF
outputSection.dataset.government = government.text;
outputSection.dataset.lie = lie.text;
outputSection.dataset.reality = reality.text;
outputSection.dataset.hope = hope.text;
};
// --- PDF Generation ---
const downloadPdf = () => {
if (typeof window.jspdf === 'undefined') {
console.error('jsPDF library not loaded'); return;
}
const { jsPDF } = window.jspdf;
const doc = new jsPDF({ orientation: 'p', unit: 'mm', format: 'a4' });
const government = outputSection.dataset.government;
const lie = outputSection.dataset.lie;
const reality = outputSection.dataset.reality;
const hope = outputSection.dataset.hope;
const margin = 20, pageWidth = doc.internal.pageSize.getWidth(), usableWidth = pageWidth - margin * 2;
let y = margin;
// Header
doc.setFont('Roboto Mono', 'bold');
doc.setFontSize(18);
doc.setTextColor(30, 30, 30);
doc.text("WORLD-STATE BRIEFING", pageWidth / 2, y, { align: 'center' });
doc.setFontSize(9);
doc.setTextColor(150);
doc.text("CLASSIFICATION: NARRATIVE // EYES ONLY", pageWidth / 2, y + 5, { align: 'center' });
y += 15;
doc.setDrawColor(200);
doc.setLineWidth(0.2);
doc.line(margin, y, pageWidth - margin, y);
y += 15;
const addSection = (title, content) => {
doc.setFont('Roboto Mono', 'bold');
doc.setFontSize(10);
doc.setTextColor(100, 100, 100);
doc.text(`// ${title.toUpperCase()}`, margin, y);
y += 6;
doc.setFont('Inter', 'normal');
doc.setFontSize(11);
doc.setTextColor(20, 20, 20);
const textLines = doc.splitTextToSize(content, usableWidth);
doc.text(textLines, margin, y);
y += (textLines.length * 5) + 12;
};
addSection("Ruling Power", government);
addSection("Societal Lie", lie);
addSection("Grim Reality", reality);
addSection("Glimmer of Hope", hope);
// Footer
const pageHeight = doc.internal.pageSize.getHeight();
doc.setFont('Roboto Mono', 'normal');
doc.setFontSize(8);
doc.setTextColor(180);
doc.text(`Briefing Generated: ${new Date().toISOString()}`, pageWidth - margin, pageHeight - 10, { align: 'right' });
doc.text(`[END OF TRANSMISSION]`, margin, pageHeight - 10);
doc.save('dystopian-world-briefing.pdf');
};
// --- Event Listeners ---
generateBtn.addEventListener('click', generateWorld);
downloadPdfBtn.addEventListener('click', downloadPdf);
});