<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>{{ page_title }}</title>
    <style>
        @page {
            size: letter;
            margin: 0.85in;
            @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.6;
            color: #111;
        }

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

        h2 {
            font-size: 16pt;
            font-weight: normal;
            margin-top: 0.35in;
        }

        h3 {
            font-size: 13pt;
            font-weight: normal;
            margin-bottom: 0.05in;
        }

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

        .entry-description {
            margin-bottom: 0.1in;
        }

        .verses {
            margin: 0.15in 0;
        }

        .verse-item {
            margin-bottom: 0.1in;
            padding-left: 0.25in;
            border-left: 2px solid #ddd;
        }

        .verse-ref {
            font-weight: 600;
            color: #444;
        }

        .verse-text {
            font-style: italic;
            color: #555;
        }

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

        /* 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>{{ page_title }}</h1>
    <p class="subtitle">{{ page_subtitle }}</p>
    <p>{{ page_description }}</p>

    {% for category, entries in resource_data.items() %}
    <section>
        <h2>{{ category }}</h2>
        {% for name, entry in entries.items() %}
        <article>
            <h3>{{ name }}{% if entry.title %} — {{ entry.title }}{% endif %}</h3>
            {% if entry.description %}
            <div class="entry-description">{{ entry.description | safe }}</div>
            {% endif %}

            {% if entry.verses %}
            <div class="verses">
                {% for verse in entry.verses %}
                <div class="verse-item">
                    <div class="verse-ref">{{ verse.reference if verse.reference else verse }}</div>
                    {% if verse.text %}
                    <div class="verse-text">{{ verse.text | safe }}</div>
                    {% endif %}
                </div>
                {% endfor %}
            </div>
            {% endif %}
        </article>
        {% endfor %}
    </section>
    {% endfor %}

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