/**
 * Print Stylesheet
 * Optimized for printing tutorials and articles
 */

/* Hide elements that shouldn't be printed */
.no-print,
.breadcrumbs,
.post-navigation,
.post-author-bio,
.email-subscription-section,
.comments,
.sidebar,
nav,
footer,
.read-next,
.ad-unit,
.inline-ad-unit,
.header-ad-widget,
.sidebar-ad-widget,
button,
.social-share {
    display: none !important;
}

/* Optimize for printing */
html,
body {
    font-size: 12pt;
    line-height: 1.6;
    color: #000;
    background-color: #fff;
}

/* Article/Post Styles */
.post-header,
article {
    max-width: 100%;
    page-break-inside: avoid;
}

.post-title {
    font-size: 24pt;
    font-weight: bold;
    margin-bottom: 0.5in;
    page-break-after: avoid;
}

.post-meta {
    font-size: 10pt;
    color: #666;
    margin-bottom: 0.5in;
    page-break-after: avoid;
}

/* Featured Image */
.featured-image {
    max-height: 4in;
    page-break-inside: avoid;
    margin-bottom: 0.5in;
}

.featured-image img {
    max-width: 100%;
    height: auto;
}

/* Content Typography */
.post-content {
    font-size: 12pt;
    line-height: 1.8;
}

.post-content p {
    margin-bottom: 0.5em;
    orphans: 3;
    widows: 3;
}

/* Headings */
h1,
h2,
h3,
h4,
h5,
h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
    font-weight: bold;
    margin-top: 0.5in;
    margin-bottom: 0.25in;
}

h1 { font-size: 22pt; }
h2 { font-size: 18pt; }
h3 { font-size: 14pt; }
h4 { font-size: 12pt; }
h5 { font-size: 11pt; }
h6 { font-size: 10pt; }

/* Code Blocks */
.code-snippet-wrap,
.code-snippet,
pre,
code {
    page-break-inside: avoid;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 10pt;
    overflow: hidden;
    padding: 10pt;
    margin: 0.5in 0;
    color: #000;
}

code {
    padding: 2pt 4pt;
    font-size: 10pt;
}

/* Tables */
table {
    page-break-inside: avoid;
    width: 100%;
    border-collapse: collapse;
    margin: 0.5in 0;
}

table,
th,
td {
    border: 1px solid #999;
}

th {
    background-color: #f5f5f5;
    font-weight: bold;
    padding: 8pt;
}

td {
    padding: 8pt;
}

/* Lists */
ul,
ol {
    margin: 0.5in 0;
    padding-left: 2cm;
}

li {
    page-break-inside: avoid;
    margin-bottom: 0.25in;
}

/* Images */
img {
    max-width: 100%;
    height: auto;
    page-break-inside: avoid;
}

/* Links */
a {
    color: #000;
    text-decoration: underline;
}

a[href]:after {
    content: "";
    /* Comment out to hide URLs after links */
    /* content: " (" attr(href) ") "; */
}

/* Blockquotes */
blockquote {
    border-left: 4pt solid #ccc;
    color: #666;
    font-style: italic;
    margin: 0.5in 0;
    page-break-inside: avoid;
    padding-left: 1cm;
}

/* Tags and Categories */
.post-tags,
.post-categories {
    page-break-after: avoid;
    margin-bottom: 0.5in;
    font-size: 10pt;
}

.tag,
.category {
    display: inline-block;
    background-color: #f5f5f5;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 4pt 8pt;
    margin-right: 4pt;
    margin-bottom: 4pt;
}

/* Page Breaks */
@page {
    margin: 2cm;
    size: A4;
}

@media print {
    /* Prevent color loss */
    * {
        background-color: transparent !important;
        box-shadow: none !important;
    }

    /* Improve text readability */
    body {
        font-family: Georgia, serif;
        font-size: 12pt;
        line-height: 1.6;
    }

    /* Print-specific rules */
    article {
        margin: 0;
        padding: 0;
    }

    /* Keep tables on page */
    table,
    figure {
        page-break-inside: avoid;
    }

    /* Avoid page breaks after important elements */
    h1,
    h2,
    h3 {
        page-break-after: avoid;
    }

    /* Remove unnecessary spacing for print */
    .post-content > * + * {
        margin-top: 0.5em;
    }
}
