<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ plan.name }} - Reading Plan</title>
    <style>
        @page {
            size: letter;
            margin: 0.75in;
            @bottom-center {
                content: counter(page);
                font-family: "et-book", Georgia, serif;
                font-size: 10pt;
                color: #666;
            }
        }

        body {
            font-family: "et-book", Georgia, "Times New Roman", serif;
            font-size: 11pt;
            line-height: 1.55;
            color: #111;
        }

        h1 {
            font-size: 24pt;
            font-weight: normal;
            margin: 0 0 0.15in 0;
        }

        .subtitle {
            font-style: italic;
            color: #666;
            margin-bottom: 0.25in;
        }

        .overview {
            margin-bottom: 0.35in;
            padding-left: 0.25in;
            border-left: 3px solid #ddd;
        }

        .day-entry {
            margin-bottom: 0.3in;
            padding-bottom: 0.2in;
            border-bottom: 1px solid #ddd;
            page-break-inside: avoid;
        }

        .day-header {
            background: #f5f5f5;
            padding: 0.1in 0.15in;
            margin-bottom: 0.15in;
            border-radius: 3px;
        }

        .day-number {
            font-weight: 600;
            color: #333;
            font-size: 12pt;
        }

        .day-theme {
            font-style: italic;
            color: #666;
            margin-left: 0.2in;
        }

        .day-readings {
            margin: 0.05in 0;
        }

        .reading-ref {
            display: inline-block;
            margin: 0.03in 0.1in 0 0;
            padding: 0.02in 0.1in;
            background: #f5f5f5;
            border-radius: 3px;
            font-size: 10pt;
        }

        /* Scripture text styling */
        .scripture-section {
            margin-top: 0.15in;
        }

        .chapter-heading {
            font-size: 13pt;
            font-weight: 600;
            color: #444;
            margin: 0.2in 0 0.1in 0;
            padding-bottom: 0.05in;
            border-bottom: 1px solid #eee;
        }

        .verse {
            display: block;
            margin: 0.08in 0;
            text-indent: -0.25in;
            padding-left: 0.25in;
        }

        .verse-num {
            font-weight: 600;
            color: #666;
            font-size: 9pt;
            vertical-align: super;
            margin-right: 0.03in;
        }

        .verse-text {
            /* follows verse number */
        }

        .footer {
            margin-top: 0.4in;
            font-size: 9pt;
            color: #888;
            text-align: center;
        }

        /* Page breaks */
        .day-entry-with-text {
            page-break-after: always;
        }

        .day-entry-with-text:last-child {
            page-break-after: avoid;
        }

        /* Style sidenotes as inline notes for PDF */
        .margin-toggle,
        .sidenote-number,
        input[type="checkbox"] {
            display: none !important;
        }

        .sidenote,
        .marginnote {
            display: block;
            float: none;
            width: 100%;
            margin: 0.15in 0;
            padding: 0.1in 0.15in;
            font-size: 9pt;
            font-style: italic;
            color: #555;
            background: #f9f9f9;
            border-left: 2px solid #ccc;
        }

        .sidenote::before {
            content: "Note: ";
            font-weight: 600;
            font-style: normal;
        }
    </style>
</head>
<body>
    <h1>{{ plan.name }}</h1>
    <p class="subtitle">{{ plan.description }}</p>

    <div class="overview">{{ plan.overview | safe }}</div>

    {% if include_text and days_with_text %}
    {# Full text version for shorter plans #}
    {% for day in days_with_text %}
    <div class="day-entry day-entry-with-text">
        <div class="day-header">
            <span class="day-number">Day {{ day.day }}</span>
            {% if day.theme %}<span class="day-theme">{{ day.theme }}</span>{% endif %}
        </div>

        <div class="scripture-section">
            {% for section in day.text %}
            <div class="chapter-heading">{{ section.reference }}</div>
            {% for verse in section.verses %}
            <span class="verse">
                <span class="verse-num">{{ verse.verse }}</span>
                <span class="verse-text">{{ verse.text }}</span>
            </span>
            {% endfor %}
            {% endfor %}
        </div>
    </div>
    {% endfor %}

    {% else %}
    {# Reference-only version for longer plans #}
    {% set all_days = plan.days if plan.days else plan.sample_days %}
    {% for day in all_days %}
    <div class="day-entry">
        <div class="day-number">Day {{ day.day }}</div>
        <div class="day-readings">
            {% for reading in day.readings %}
            <span class="reading-ref">{{ reading }}</span>
            {% endfor %}
        </div>
        <div class="day-theme">Theme: {{ day.theme }}</div>
    </div>
    {% endfor %}
    {% endif %}

    <div class="footer">From KJV Study &bull; kjvstudy.org</div>
</body>
</html>
