/* WeasyPrint-Optimized CSS for Mac-letterhead Markdown Processing
 * This file is optimized for WeasyPrint PDF generation with consistent pt units
 * All WeasyPrint-incompatible features have been removed or replaced
 *
 * Usage: uvx mac-letterhead install letterhead.pdf --css my-brand.css --name "My Company"
 */

/* ==================== PAGE LAYOUT ==================== */
@page {
	/* Page margins are automatically calculated based on letterhead content */
	/* These will be overridden by the letterhead analysis */
	margin-top: 72pt;
	margin-right: 72pt;
	margin-bottom: 72pt;
	margin-left: 72pt;

	/* Page footer with page numbers */
	@bottom-center {
		content: counter(page);
		font-family: 'Helvetica Neue', Arial, sans-serif;
		font-size: 9pt;
		color: #660000;
	}
}

/* ==================== BODY AND BASE TYPOGRAPHY ==================== */
body {
	font-family: 'Helvetica Neue', Arial, sans-serif;
	font-size: 9pt;
	line-height: 1.3;
	color: #000000;
	max-width: 100%;
	margin: 0;
	padding: 0;
	text-align: left;
}

/* Reset margins for consistent spacing */
* {
	margin-top: 0;
}

*+* {
	margin-top: 4pt;
}

/* ==================== HEADINGS ==================== */
h1 {
	font-size: 14pt;
    font-weight: bold;
    color: #000000;
    margin-top: 12pt;
    margin-bottom: 6pt;
    line-height: 1.2;
    page-break-after: avoid;
	page-break-inside: avoid;
}

h2 {
	font-size: 12pt;
	font-weight: bold;
	color: #000000;
	margin-top: 10pt;
	margin-bottom: 8pt;
	line-height: 1.2;
	page-break-after: avoid;
	page-break-inside: avoid;
}

h3 {
	font-size: 9pt;
	font-weight: bold;
	color: #000000;
	margin-top: 8pt;
	margin-bottom: 4pt;
	line-height: 1.2;
	page-break-after: avoid;
	page-break-inside: avoid;
}

h4, h5, h6 {
	font-size: 9pt;
	font-weight: bold;
	color: #000000;
	margin-top: 6pt;
	margin-bottom: 3pt;
	line-height: 1.2;
	page-break-after: avoid;
	page-break-inside: avoid;
}

/* Adjust spacing after headings */
h1+*,
h2+*,
h3+*,
h4+*,
h5+*,
h6+* {
	margin-top: 4pt;
}

/* ==================== PARAGRAPHS ==================== */
p {
	font-weight: 200;
	margin-top: 4pt;
	margin-bottom: 4pt;
	orphans: 2;
	widows: 2;
	/* Inherits font-family, font-size, line-height, color, text-align from body */
}

/* ==================== TEXT FORMATTING ==================== */
strong,
b {
	font-weight: bold;
	color: inherit;
}

em,
i {
	font-style: italic;
	color: inherit;
}

u {
	text-decoration: underline;
}

s,
strike,
del {
	text-decoration: line-through;
}

small {
	font-size: 8pt;
}

/* ==================== LINKS ==================== */
a {
	color: #0066cc;
	text-decoration: underline;  /* Always show underline in PDF */
}

a:visited {
	color: #663399;
}

/* ==================== LISTS ==================== */
/* CSS Custom Properties for flexible indentation */
:root {
	--base-indent: 12pt;
	--indent-step: 18pt;
}

ul {
	margin-top: 6pt;
	margin-bottom: 6pt;
	padding-left: var(--base-indent);
	list-style-type: disc;
}

ol {
	margin-top: 6pt;
	margin-bottom: 6pt;
	padding-left: var(--base-indent);
	list-style-type: decimal;
}

/* Nested list indentation levels */
ul ul, ol ol, ul ol, ol ul {
	padding-left: var(--indent-step);
}

ul ul ul, ol ol ol, ul ol ul, ol ul ol {
	padding-left: 27pt; /* --indent-step * 1.5 = 18pt * 1.5 */
}

ul ul ul ul, ol ol ol ol, ul ol ul ul, ol ul ol ol {
	padding-left: 36pt; /* --indent-step * 2 = 18pt * 2 */
}

li {
	margin-bottom: 3pt;
	line-height: 1.3;
	orphans: 2;
	widows: 2;
}

/* Nested lists */
ul ul,
ol ol,
ul ol,
ol ul {
	margin-top: 3pt;
	margin-bottom: 3pt;
}

ul ul {
	list-style-type: circle;
}

ul ul ul {
	list-style-type: square;
}

/* ==================== GITHUB FLAVORED MARKDOWN TASK LISTS ==================== */
/* 
 * Enhanced task list styling using CSS classes added during HTML processing.
 * We replace HTML checkboxes with Unicode symbols for better WeasyPrint rendering.
 */

/* Base styling for all task list items */
li.task-item {
	list-style-type: none;
	margin-bottom: 3pt;
	line-height: 1.3;
	position: relative;
}

/* Styling for checked tasks - highlighted in blue */
li.task-checked {
	color: #0066cc; /* Blue color for completed tasks */
	font-weight: normal;
}

/* Styling for unchecked tasks - normal black text */
li.task-unchecked {
	color: #333333; /* Dark gray for pending tasks */
	font-weight: normal;
}

/* Ensure proper font for Unicode checkbox symbols */
li.task-item {
	font-family: "SF Pro Display", "Segoe UI", "Arial Unicode MS", Arial, sans-serif;
}

/* Style the checkbox symbols specifically */
li.task-checked::first-letter,
li.task-unchecked::first-letter {
	font-size: 10pt; /* Consistent checkbox symbol size */
	line-height: 1.0;
	margin-right: 4pt;
}

/* Enhanced styling for checked items */
li.task-checked::first-letter {
	color: #28a745; /* Green checkmark */
	font-weight: bold;
}

/* Enhanced styling for unchecked items */
li.task-unchecked::first-letter {
	color: #666666; /* Gray empty checkbox */
}

/* Styling for inline checkboxes (in tables and other content) */
span.task-checked {
	color: #28a745; /* Green checkmark */
	font-weight: bold;
	font-size: 10pt; /* Back to consistent size */
	display: inline-block;
	width: 12pt;
	text-align: center;
}

span.task-unchecked {
	color: #666666; /* Gray empty checkbox */
	font-size: 10pt;
	font-weight: normal;
	display: inline-block;
	width: 12pt;
	text-align: center;
}

/* Special scaling for unchecked boxes in table cells only */
span.task-unchecked-scaled {
	transform: scale(0.75); /* Scale down the unchecked box more to match checked */
	transform-origin: center;
}

/* Legacy support for data-gfm-task attributes (fallback) */
li[data-gfm-task] {
	list-style-type: none;
	margin-bottom: 3pt;
	line-height: 1.3;
}

/* Nested task list indentation */
ul ul li.task-item {
	margin-left: var(--indent-step); /* Use existing indent variable */
}

ul ul ul li.task-item {
	margin-left: calc(var(--indent-step) * 1.5);
}

ul ul ul ul li.task-item {
	margin-left: calc(var(--indent-step) * 2);
}

/* ==================== CODE AND PREFORMATTED TEXT ==================== */
code {
	font-family: Courier, 'Courier New', monospace;
	font-size: 8pt;
	background-color: #f5f5f5;
	color: #333333;
	padding: 1pt 3pt;
	border-radius: 3pt;
	border: 0.75pt solid #e0e0e0;  /* Converted from 1px */
}

pre {
	font-family: Courier, 'Courier New', monospace;
	font-size: 8pt;
	line-height: 1.3;
	background-color: #f5f5f5;
	color: #333333;
	border: 0.75pt solid #cccccc;  /* Converted from 1px */
	border-radius: 4pt;
	padding: 8pt;
	margin: 8pt 0;
	white-space: pre-wrap;
	word-break: break-word;
	page-break-inside: avoid;
}

pre code {
	background-color: transparent;
	padding: 0;
	border: none;
	border-radius: 0;
}

/* ==================== SYNTAX HIGHLIGHTING ==================== */
/* Simplified Pygments syntax highlighting for WeasyPrint */
.codehilite {
	background-color: transparent;
	border: none;
	padding: 0;
	margin: 0;
}

.codehilite pre {
	margin: 0;
	padding: 8pt;
	background-color: #f5f5f5;
	border: 0.75pt solid #cccccc;
	white-space: pre-wrap;
	word-break: break-word;
}

/* Essential syntax highlighting colors only */
.codehilite .c { color: #008000; font-style: italic; } /* Comment */
.codehilite .k { color: #0000ff; font-weight: bold; } /* Keyword */
.codehilite .o { color: #666666; } /* Operator */
.codehilite .s { color: #cc0000; } /* String */
.codehilite .m { color: #666666; } /* Number */
.codehilite .nc { color: #2b91af; } /* Name.Class */
.codehilite .nf { color: #0000ff; } /* Name.Function */
.codehilite .nv { color: #003366; } /* Name.Variable */

/* ==================== TABLES ==================== */
table {
	border-collapse: collapse;
	width: 100%;
	margin: 12pt 0;
	border: 0.75pt solid #000000;
	page-break-inside: auto;
}

th {
	background-color: #f0f0f0;
	font-weight: bold;
	padding: 6pt;
	text-align: left;
	vertical-align: top;
	border: 0.25pt solid #000000;
	/* Inherits font-family, font-size, color from body */
}

td {
	padding: 6pt;
	text-align: left;
	vertical-align: top;
	border: 0.25pt solid #000000;
	/* Inherits font-family, font-size, color from body */
}

tr {
	page-break-inside: avoid;
	page-break-after: auto;
}

thead {
	display: table-header-group;  /* Repeat header on each page */
}

/* Alternating row colors for better readability */
tbody tr:nth-child(even) {
	background-color: #f9f9f9;
}

/* ==================== BLOCKQUOTES ==================== */
blockquote {
	margin: 12pt 30pt 12pt 30pt;
	padding: 8pt 12pt;
	font-style: italic;
	color: #333333;
	border-left: 3pt solid #cccccc;
	background-color: #f9f9f9;
	page-break-inside: avoid;
}

blockquote p {
	margin: 0;
	font-style: italic;
}

/* Nested blockquotes */
blockquote blockquote {
	margin: 6pt 20pt;
	border-left: 2pt solid #dddddd;
	background-color: #f5f5f5;
}

/* ==================== HORIZONTAL RULES ==================== */
hr {
	border: none;
	height: 0.75pt;  /* Converted from 1pt for consistency */
	background-color: #cccccc;
	margin: 16pt 0;
	page-break-after: avoid;
}

/* ==================== DEFINITION LISTS ==================== */
/* Only include if your markdown processor supports them */
dl {
	margin: 8pt 0;
}

dt {
	font-weight: bold;
	margin-top: 6pt;
	margin-bottom: 2pt;
}

dd {
	margin-left: 20pt;
	margin-bottom: 4pt;
}

/* ==================== ABBREVIATIONS ==================== */
/* Only include if your markdown processor supports them */
abbr {
	text-decoration: none;
	border-bottom: 0.75pt dotted #666666;  /* Converted from 1pt */
}

/* ==================== FOOTNOTES ==================== */
/* Only include if your markdown processor supports them */
.footnote {
	font-size: 8pt;
	line-height: 1.2;
	margin-top: 12pt;
	border-top: 0.75pt solid #cccccc;  /* Converted from 1pt */
	padding-top: 6pt;
}

.footnote-ref {
	font-size: 7pt;
	vertical-align: super;
	color: #0066cc;
	text-decoration: none;
}

.footnote-backref {
	font-size: 7pt;
	color: #0066cc;
	text-decoration: none;
}

/* ==================== IMAGES ==================== */
img {
	max-width: 100%;
	height: auto;
	margin: 8pt 0;
	page-break-inside: avoid;
}

/* ==================== PRINT OPTIMIZATIONS ==================== */
@media print {
	/* Ensure good contrast for printing */
	body {
		color: #000000;
		background-color: #ffffff;
	}

	/* Prevent page breaks after headings */
	h1,
	h2,
	h3,
	h4,
	h5,
	h6 {
		page-break-after: avoid;
		page-break-inside: avoid;
	}

	/* Avoid breaking these elements */
	pre,
	blockquote,
	table,
	img {
		page-break-inside: avoid;
	}

	/* Better table printing */
	table {
		page-break-inside: auto;
	}

	tr {
		page-break-inside: avoid;
		page-break-after: auto;
	}

	thead {
		display: table-header-group;
	}

	/* Ensure links are distinguishable in print */
	a {
		color: #000000;
		text-decoration: underline;
	}

	/* Show URL for external links in print */
	a[href^="http"]:after {
		content: " (" attr(href) ")";
		font-size: 8pt;
		color: #666666;
	}
}

/* ==================== CUSTOM UTILITY CLASSES ==================== */
/* Only include if your markdown processor supports inline attributes */

.text-center {
	text-align: center;
}

.text-right {
	text-align: right;
}

.text-small {
	font-size: 8pt;
}

.text-large {
	font-size: 11pt;
}

.highlight {
	background-color: #ffff99;
	padding: 1pt 2pt;
}

.note {
	background-color: #e7f3ff;
	border-left: 4pt solid #2196f3;
	padding: 8pt 12pt;
	margin: 8pt 0;
}

.warning {
	background-color: #fff3cd;
	border-left: 4pt solid #ffc107;
	padding: 8pt 12pt;
	margin: 8pt 0;
}

.error {
	background-color: #f8d7da;
	border-left: 4pt solid #dc3545;
	padding: 8pt 12pt;
	margin: 8pt 0;
}

.success {
	background-color: #d4edda;
	border-left: 4pt solid #28a745;
	padding: 8pt 12pt;
	margin: 8pt 0;
}
