/* ============================================================
   CannabisDependence.org — Print Stylesheet
   ============================================================
   Optimized for printing recovery guides, withdrawal timelines,
   and self-assessment results that users may want to share
   with their healthcare provider or counselor.
   ============================================================ */

@media print {
    /* Hide non-essential elements */
    .site-header,
    .top-bar,
    .crisis-banner,
    .breadcrumb-wrapper,
    .cookie-consent,
    .site-footer,
    .related-pages,
    .pathway-section,
    .companion-link-box,
    .btn,
    nav,
    .navbar {
        display: none !important;
    }

    /* Reset page */
    body {
        font-family: 'Georgia', 'Times New Roman', serif;
        font-size: 11pt;
        line-height: 1.6;
        color: #000;
        background: #fff;
        margin: 0;
        padding: 0;
    }

    /* Content width */
    .container,
    .content-body {
        max-width: none !important;
        width: 100% !important;
        padding: 0 !important;
        margin: 0 !important;
    }

    main {
        padding: 0 !important;
    }

    .content-page {
        padding: 0 !important;
    }

    /* Headings */
    h1 { font-size: 18pt; margin-bottom: 8pt; }
    h2 { font-size: 14pt; margin-top: 16pt; margin-bottom: 6pt; border-bottom: 0.5pt solid #ccc; padding-bottom: 4pt; }
    h3 { font-size: 12pt; margin-top: 12pt; margin-bottom: 4pt; }

    /* Links — show URLs */
    a {
        color: #000;
        text-decoration: underline;
    }

    a[href^="http"]::after {
        content: " [" attr(href) "]";
        font-size: 8pt;
        color: #666;
        word-break: break-all;
    }

    /* Don't show URL for internal links */
    a[href^="/"]::after {
        content: none;
    }

    /* Disclaimers — keep visible and prominent */
    .disclaimer-box,
    .pharma-warning {
        border: 1pt solid #000 !important;
        background: #f5f5f5 !important;
        padding: 8pt !important;
        margin: 12pt 0 !important;
        page-break-inside: avoid;
    }

    /* Encouragement boxes */
    .encouragement-box {
        border: 1pt solid #999;
        background: #f9f9f9 !important;
        padding: 8pt !important;
        margin: 10pt 0 !important;
        page-break-inside: avoid;
    }

    /* Research citations */
    .research-citation {
        border-left: 2pt solid #999;
        padding: 6pt 12pt;
        margin: 10pt 0;
        background: #f9f9f9;
        page-break-inside: avoid;
    }

    /* Withdrawal timeline */
    .withdrawal-day {
        page-break-inside: avoid;
    }

    .withdrawal-day::before {
        background: #ccc;
    }

    .withdrawal-day-marker {
        background: #666 !important;
        box-shadow: none !important;
    }

    /* Self-assessment */
    .self-assessment {
        border: 1pt solid #999;
        page-break-inside: avoid;
    }

    .self-assessment-question {
        background: #f5f5f5 !important;
        border: 0.5pt solid #ccc !important;
    }

    /* Tables */
    table {
        border-collapse: collapse;
        width: 100%;
        page-break-inside: avoid;
    }

    th, td {
        border: 0.5pt solid #ccc;
        padding: 4pt 8pt;
        font-size: 9pt;
    }

    th {
        background: #f0f0f0;
        font-weight: bold;
    }

    /* Key takeaway boxes */
    .key-takeaway {
        border: 1pt solid #999;
        padding: 8pt;
        margin: 10pt 0;
        page-break-inside: avoid;
    }

    /* Evidence badges — simplified for print */
    .evidence-badge {
        border: 0.5pt solid #999;
        padding: 2pt 6pt;
        font-size: 8pt;
        background: #f5f5f5;
    }

    /* Page breaks */
    h2, h3 {
        page-break-after: avoid;
    }

    .page-hero {
        background: none !important;
        border-bottom: 1pt solid #ccc;
        padding: 0 0 8pt 0 !important;
        margin-bottom: 12pt;
    }

    /* Page header for printed documents */
    @page {
        margin: 2cm 2.5cm;
    }

    /* ─── Handout Print Styles ──────────────────────────── */
    .btn-print,
    .handout-actions,
    .no-print {
        display: none !important;
    }

    .print-only {
        display: block !important;
    }

    .handout {
        border: none;
        padding: 0;
        margin: 0;
        box-shadow: none;
        page-break-after: always;
    }

    .handout:last-child {
        page-break-after: auto;
    }

    .handout-title {
        font-size: 16pt;
        margin-bottom: 4pt;
        border-bottom: 1pt solid #000;
        padding-bottom: 6pt;
    }

    .handout-subtitle {
        font-size: 9pt;
        color: #666;
        margin-bottom: 8pt;
    }

    .handout-meta {
        display: flex;
        gap: 2cm;
        margin-bottom: 12pt;
        padding-bottom: 8pt;
        border-bottom: 0.5pt solid #ccc;
    }

    .handout-field label {
        font-size: 7pt;
        font-weight: bold;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: #666;
    }

    .handout-field .field-line {
        border-bottom: 0.5pt solid #999;
        min-height: 14pt;
    }

    .handout-checkbox {
        border: 0.5pt solid #ccc;
        padding: 4pt 6pt;
        margin-bottom: 3pt;
        page-break-inside: avoid;
    }

    .handout-checkbox .check-box {
        width: 10pt;
        height: 10pt;
        border: 1pt solid #000;
        border-radius: 1pt;
    }

    .handout-checkbox .check-label {
        font-size: 9pt;
    }

    .handout-textarea {
        border: 0.5pt solid #ccc;
        min-height: 3cm;
    }

    .handout-section h4 {
        font-size: 10pt;
        font-weight: bold;
        margin-top: 10pt;
        margin-bottom: 4pt;
    }

    .handout-print-header {
        text-align: right;
        font-size: 7pt;
        color: #999;
        margin-bottom: 8pt;
    }

    .handout-print-footer {
        border-top: 0.5pt solid #ccc;
        padding-top: 6pt;
        margin-top: 16pt;
        font-size: 7pt;
        color: #999;
    }

    /* ─── Isolated Handout Printing ─────────────────────── */
    /* When .print-handout-only is on body, hide everything except the targeted handout */
    .print-handout-only .page-hero,
    .print-handout-only .disclaimer-box,
    .print-handout-only .content-body > *:not(.handout),
    .print-handout-only .handout:not(.printing),
    .print-handout-only aside,
    .print-handout-only .research-citation,
    .print-handout-only .companion-link-box,
    .print-handout-only .encouragement-box {
        display: none !important;
    }

    .print-handout-only .handout.printing {
        display: block !important;
        border: none;
        padding: 0;
        margin: 0;
    }

    /* Footer note for printed pages */
    body::after {
        content: "Printed from CannabisDependence.org — Educational information only, not professional treatment advice. If you need help, call SAMHSA at 1-800-662-4357.";
        display: block;
        font-size: 8pt;
        color: #999;
        border-top: 0.5pt solid #ccc;
        padding-top: 8pt;
        margin-top: 24pt;
    }
}
