/**
 * MDCodeLookup Engagement Suite — Print Stylesheet
 * Version: 1.0.0
 *
 * Loaded with media="print" via wp_enqueue_style.
 * Produces clean, ink-efficient printouts suitable for bringing to a doctor.
 *
 * Goals:
 * - Hide all non-essential UI (nav, ads, sidebars, engagement buttons)
 * - Show calculator content, results, and next-step recommendations
 * - Clean serif typography at 12pt for legibility
 * - "Printed from MDCodeLookup.com" footer with date
 * - Smart page-break rules to keep content together
 */


/* ==========================================================================
   1. Page Setup
   ========================================================================== */

@page {
    size: auto;
    margin: 1in;
}

@page :first {
    margin-top: 0.75in;
}


/* ==========================================================================
   2. Global Resets for Print
   ========================================================================== */

*,
*::before,
*::after {
    background: transparent !important;
    color: #000000 !important;
    box-shadow: none !important;
    text-shadow: none !important;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

body {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 12pt;
    line-height: 1.6;
    color: #000000;
    margin: 0;
    padding: 0;
    width: 100%;
}

/* Remove all animations and transitions */
*,
*::before,
*::after {
    animation: none !important;
    transition: none !important;
}


/* ==========================================================================
   3. Hidden Elements — UI That Doesn't Belong on Paper
   ========================================================================== */

/* Site navigation / header */
header,
.site-header,
#masthead,
nav,
.main-navigation,
.navbar,
.menu-toggle,
.nav-menu,
.breadcrumbs,
.breadcrumb {
    display: none !important;
}

/* Footer */
footer,
.site-footer,
#colophon {
    display: none !important;
}

/* Sidebar */
.sidebar,
.widget-area,
#secondary,
aside {
    display: none !important;
}

/* Engagement action bar & reminder bar — no interactivity on paper */
.mdce-action-bar,
.mdce-reminder-bar,
.mdce-reminder-due {
    display: none !important;
}

/* Dark mode toggle */
.mdce-dark-toggle {
    display: none !important;
}

/* Modals */
.mdce-modal {
    display: none !important;
}

/* Notifications */
.mdce-notification {
    display: none !important;
}

/* Ads and ad containers */
.ad,
.ads,
.adsbygoogle,
.ad-container,
.ad-wrapper,
.ad-unit,
[id*="google_ads"],
[class*="ad-slot"],
[class*="ad-banner"],
ins.adsbygoogle,
.ezoic-ad,
[id^="ezoic-pub-ad"],
.quads-ad,
.wp-block-advads {
    display: none !important;
}

/* Cookie banners / consent */
.cookie-banner,
.cookie-notice,
.cc-banner,
.gdpr-banner,
#cookie-law-info-bar,
.cli-modal,
[class*="cookie-consent"],
[class*="cookie-popup"],
[id*="cookie"] {
    display: none !important;
}

/* Social share buttons (theme-level) */
.social-share,
.share-buttons,
.sharing-buttons,
.sharedaddy,
.sd-sharing-enabled,
[class*="social-share"],
[class*="share-bar"] {
    display: none !important;
}

/* Comments section */
.comments-area,
#comments,
.comment-respond,
#respond {
    display: none !important;
}

/* Related posts (theme-level — not our engagement related) */
.related-posts,
.jp-related-posts {
    display: none !important;
}

/* Floating elements, popups, chat widgets */
.back-to-top,
.scroll-to-top,
.chat-widget,
[class*="popup"],
[class*="overlay"]:not(.mdce-modal) {
    display: none !important;
}

/* WordPress admin bar */
#wpadminbar {
    display: none !important;
}

/* Skip-link */
.skip-link,
.screen-reader-text {
    display: none !important;
}

/* Search forms */
.search-form,
.wp-block-search {
    display: none !important;
}


/* ==========================================================================
   4. Visible Content — Calculator & Results
   ========================================================================== */

/* Ensure main content fills the page */
.site-content,
.content-area,
.entry-content,
main,
#primary,
#main,
article {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    float: none !important;
    display: block !important;
}

/* Page title */
h1, .entry-title, .page-title {
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 18pt;
    font-weight: bold;
    margin: 0 0 12pt;
    padding: 0;
    border-bottom: 2pt solid #000000;
    padding-bottom: 6pt;
}

h2 {
    font-size: 15pt;
    margin: 16pt 0 8pt;
}

h3 {
    font-size: 13pt;
    margin: 14pt 0 6pt;
}

h4, h5, h6 {
    font-size: 12pt;
    margin: 12pt 0 4pt;
}

p {
    margin: 0 0 8pt;
    orphans: 3;
    widows: 3;
}

/* Links: show URL after link text */
a[href]::after {
    content: " (" attr(href) ")";
    font-size: 9pt;
    color: #555555 !important;
    word-break: break-all;
}

/* Don't show URL for internal/anchor links or buttons */
a[href^="#"]::after,
a[href^="javascript:"]::after,
.mdce-btn::after,
.mdce-related-card::after,
.mdce-post-link::after,
nav a::after {
    content: "" !important;
}


/* ==========================================================================
   5. Calculator Forms — Print Friendly
   ========================================================================== */

/* Show form values but simplify presentation */
input,
select,
textarea {
    border: 1px solid #999999 !important;
    padding: 4pt !important;
    font-size: 11pt !important;
    font-family: Georgia, 'Times New Roman', Times, serif !important;
}

/* Calculator result areas */
.calc-result,
.calculator-result,
.result-box,
.result-panel,
[class*="result-container"],
[class*="calc-result"] {
    border: 2pt solid #000000 !important;
    padding: 12pt !important;
    margin: 12pt 0 !important;
    page-break-inside: avoid;
}

.calc-result h2,
.calc-result h3,
.calculator-result h2,
.calculator-result h3 {
    font-size: 14pt;
    margin: 0 0 6pt;
}


/* ==========================================================================
   6. Tables — Clean Print Layout
   ========================================================================== */

table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 8pt 0 !important;
    page-break-inside: auto;
}

thead {
    display: table-header-group; /* Repeat header on each page */
}

tr {
    page-break-inside: avoid;
    page-break-after: auto;
}

th, td {
    border: 1px solid #666666 !important;
    padding: 6pt 8pt !important;
    text-align: left;
    font-size: 10pt;
    vertical-align: top;
}

th {
    font-weight: bold;
    border-bottom-width: 2px !important;
}

caption {
    font-size: 10pt;
    font-style: italic;
    margin-bottom: 4pt;
    text-align: left;
}


/* ==========================================================================
   7. Images & Charts
   ========================================================================== */

img {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
}

/* Chart.js canvases */
canvas {
    max-width: 100% !important;
    height: auto !important;
    page-break-inside: avoid;
}

.mdce-chart-container {
    page-break-inside: avoid;
    margin: 12pt 0;
}

/* Figures */
figure {
    margin: 8pt 0;
    page-break-inside: avoid;
}

figcaption {
    font-size: 9pt;
    font-style: italic;
    margin-top: 4pt;
}


/* ==========================================================================
   8. Engagement Panel — Print-Visible Sections
   ========================================================================== */

/* Show the engagement panel itself (without action bar) */
.mdce-panel {
    border: none !important;
    padding: 0 !important;
    margin: 16pt 0 0 !important;
    max-width: 100% !important;
}

/* "What Should I Do Next?" — valuable for doctor visits */
.mdce-next-steps {
    border-top: 1pt solid #cccccc !important;
    padding-top: 12pt !important;
    page-break-inside: avoid;
}

.mdce-next-title {
    font-family: Georgia, 'Times New Roman', Times, serif !important;
    font-size: 14pt !important;
    font-weight: bold !important;
    margin: 0 0 8pt !important;
}

.mdce-next-steps-content {
    margin: 0 !important;
}

.mdce-next-step-item {
    border: 1px solid #cccccc !important;
    padding: 8pt !important;
    margin: 4pt 0 !important;
    page-break-inside: avoid;
}

.mdce-next-step-icon {
    width: 24pt !important;
    height: 24pt !important;
    border: 1px solid #999999 !important;
    border-radius: 50% !important;
    text-align: center;
    line-height: 24pt !important;
    font-size: 10pt !important;
}

/* Related calculators — show as simple list on paper */
.mdce-related {
    page-break-inside: avoid;
    border-top: 1pt solid #cccccc !important;
    padding-top: 12pt !important;
    margin-top: 12pt !important;
}

.mdce-related-title {
    font-size: 13pt !important;
    font-weight: bold !important;
    margin-bottom: 6pt !important;
}

.mdce-related-grid {
    display: block !important;
}

.mdce-related-card {
    display: block !important;
    border: none !important;
    padding: 2pt 0 !important;
    margin: 0 !important;
    font-size: 10pt;
}

.mdce-related-card::before {
    content: "\2022  "; /* bullet */
}

.mdce-related-icon {
    display: none !important; /* Hide emoji icons on print */
}

.mdce-related-desc {
    display: none !important; /* Save space */
}

/* Blog posts — simple list */
.mdce-blog-posts {
    page-break-inside: avoid;
    border-top: 1pt solid #cccccc !important;
    padding-top: 12pt !important;
}

.mdce-post-link {
    display: block !important;
    padding: 2pt 0 !important;
    font-size: 10pt !important;
}

.mdce-post-arrow {
    display: none !important;
}


/* ==========================================================================
   9. Page Break Rules
   ========================================================================== */

/* Avoid breaking inside these blocks */
h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    page-break-inside: avoid;
}

ul, ol, dl {
    page-break-inside: avoid;
}

blockquote,
pre,
figure,
.calc-result,
.calculator-result,
.result-box,
.mdce-next-step-item,
.mdce-related {
    page-break-inside: avoid;
}

/* Force a page break before the engagement recommendations */
.mdce-next-steps {
    page-break-before: auto;
}


/* ==========================================================================
   10. Printed Footer — Site Attribution & Date
   ========================================================================== */

/*
 * Using a generated content footer at the bottom of the printed page.
 * Note: @page footer margin content is limited in browser support, so
 * we use a body::after pseudo-element as a reliable alternative.
 */

body::after {
    content: "Printed from MDCodeLookup.com  |  Date: " attr(data-print-date);
    display: block;
    text-align: center;
    font-family: Georgia, 'Times New Roman', Times, serif;
    font-size: 9pt;
    color: #999999 !important;
    border-top: 1pt solid #cccccc;
    padding-top: 8pt;
    margin-top: 24pt;
    position: relative;
    width: 100%;
}

/*
 * Fallback: if data-print-date attribute is not set by JS, show static text.
 * JS should set: document.body.setAttribute('data-print-date', new Date().toLocaleDateString());
 * before window.print() is called.
 */


/* ==========================================================================
   11. Links & URLs — Print Optimization
   ========================================================================== */

/* Abbreviate very long URLs */
a[href] {
    word-break: break-all;
}

/* External links: show full URL */
a[href^="http"]:not([href*="mdcodelookup.com"])::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #777777 !important;
}

/* Internal links: just show the path */
a[href*="mdcodelookup.com"]::after {
    content: " (" attr(href) ")";
    font-size: 8pt;
    color: #777777 !important;
}


/* ==========================================================================
   12. Lists & Definition Lists
   ========================================================================== */

ul, ol {
    padding-left: 20pt;
    margin: 4pt 0 8pt;
}

li {
    margin-bottom: 2pt;
    font-size: 11pt;
    line-height: 1.5;
}

dt {
    font-weight: bold;
    margin-top: 6pt;
}

dd {
    margin-left: 16pt;
    margin-bottom: 4pt;
}


/* ==========================================================================
   13. Utility: Force Show / Force Hide on Print
   ========================================================================== */

.mdce-print-show {
    display: block !important;
}

.mdce-print-hide,
.no-print {
    display: none !important;
}

/* Visible only on screen */
.mdce-screen-only {
    display: none !important;
}
