/**
 * Print Core — physical A4 document only.
 *
 * Loaded by the isolated print document (body.kl-print-document).
 * Owns page size, sheet box, page breaks, and in-flow footer.
 * Worksheet card/row geometry stays in the activity renderer and
 * bundle-print.css. Screen chrome is limited to the optional
 * screen-only print-preview bar (print-hide).
 */

@page {
    size: A4;
    margin: 0;
}

html,
body.kl-print-document {
    margin: 0;
    padding: 0;
    background: #fff;
}

body.kl-print-document main {
    margin: 0;
    padding: 0;
}

body.kl-print-document .activity-sheets {
    display: block;
    width: 210mm;
    margin: 0;
    padding: 0;
    gap: 0;
}

body.kl-print-document .a4-sheet {
    width: 210mm;
    height: 297mm;
    min-height: 297mm;
    max-height: 297mm;
    box-sizing: border-box;
    margin: 0;
    padding: 12mm;
    background: #fff;
    border: none;
    border-radius: 0;
    box-shadow: none;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    page-break-inside: avoid;
    break-inside: avoid;
    page-break-after: always;
    break-after: page;
}

body.kl-print-document .a4-sheet:last-child,
body.kl-print-document .a4-sheet.print-sheet-last {
    page-break-after: avoid;
    break-after: avoid;
}

body.kl-print-document .a4-sheet.print-sheet-hidden,
body.kl-print-document .print-hide,
body.kl-print-document .kl-print-preview-bar {
    display: none !important;
}

body.kl-print-document .a4-sheet .sheet-header,
body.kl-print-document .a4-sheet .sheet-title {
    flex-shrink: 0;
}

body.kl-print-document .a4-sheet .sheet-content {
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
}

body.kl-print-document .a4-sheet .sheet-footer {
    flex-shrink: 0;
    margin-top: auto;
    position: static;
}

/* Screen-only preview chrome — never participates in pagination */
@media screen {
    body.kl-print-document {
        background: #e8edf2;
        min-height: 100vh;
    }

    body.kl-print-document .kl-print-preview-bar {
        display: flex !important;
        align-items: center;
        justify-content: space-between;
        gap: 1rem;
        flex-wrap: wrap;
        position: sticky;
        top: 0;
        z-index: 5;
        margin: 0;
        padding: 0.7rem 1.1rem;
        background: rgba(255, 255, 255, 0.96);
        border-bottom: 1px solid #d7dee6;
        box-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
    }

    body.kl-print-document .kl-print-preview-bar__brand {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        min-width: 0;
    }

    body.kl-print-document .kl-print-preview-bar__label {
        font-family: Outfit, "Segoe UI", sans-serif;
        font-weight: 700;
        font-size: 0.95rem;
        color: #334155;
        letter-spacing: 0.01em;
    }

    body.kl-print-document .kl-print-preview-bar__print {
        appearance: none;
        border: none;
        border-radius: 10px;
        padding: 0.55rem 0.95rem;
        background: #6c5ce7;
        color: #fff;
        font-family: Outfit, "Segoe UI", sans-serif;
        font-weight: 700;
        font-size: 0.92rem;
        cursor: pointer;
        min-height: 40px;
    }

    body.kl-print-document .kl-print-preview-bar__print:hover {
        background: #5a4bd1;
    }

    body.kl-print-document main {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 18px;
        padding: 1.25rem 1rem 2.5rem;
        box-sizing: border-box;
    }

    body.kl-print-document .activity-sheets {
        width: 210mm;
        margin: 0 auto;
    }

    body.kl-print-document .a4-sheet {
        box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
        border: 1px solid #e2e8f0;
    }
}

@media print {
    html,
    body.kl-print-document {
        margin: 0 !important;
        padding: 0 !important;
        background: #fff !important;
        height: auto !important;
        min-height: 0 !important;
        overflow: visible !important;
    }

    body.kl-print-document .kl-print-preview-bar,
    body.kl-print-document .print-hide,
    body.kl-print-document .kl-teaser-paywall {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: none !important;
        box-shadow: none !important;
        overflow: hidden !important;
        page-break-before: avoid !important;
        page-break-after: avoid !important;
        break-before: avoid !important;
        break-after: avoid !important;
    }

    body.kl-print-document main {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
    }

    body.kl-print-document .activity-sheets {
        display: block !important;
        width: 210mm !important;
        margin: 0 !important;
        padding: 0 !important;
        gap: 0 !important;
        overflow: visible !important;
    }

    body.kl-print-document .a4-sheet {
        width: 210mm !important;
        height: 297mm !important;
        min-height: 297mm !important;
        max-height: 297mm !important;
        box-sizing: border-box !important;
        margin: 0 !important;
        padding: 12mm !important;
        background: #fff !important;
        border: none !important;
        box-shadow: none !important;
        display: flex !important;
        flex-direction: column !important;
        overflow: hidden !important;
        page-break-inside: avoid !important;
        break-inside: avoid !important;
        page-break-after: always;
        break-after: page;
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }

    body.kl-print-document .a4-sheet:last-child,
    body.kl-print-document .a4-sheet.print-sheet-last {
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    body.kl-print-document .a4-sheet.print-sheet-hidden {
        display: none !important;
        page-break-after: avoid !important;
        break-after: avoid !important;
    }

    body.kl-print-document .a4-sheet .sheet-content {
        flex: 1 1 auto !important;
        min-height: 0 !important;
        overflow: hidden !important;
    }

    body.kl-print-document .a4-sheet .sheet-footer {
        flex-shrink: 0 !important;
        margin-top: auto !important;
        position: static !important;
        page-break-inside: avoid;
        break-inside: avoid;
    }
}

/* Invalid print request (public endpoint only; not a worksheet page) */
body.kl-print-error {
    margin: 0;
    min-height: 100vh;
    background: linear-gradient(180deg, #f7f9fc 0%, #eef3f8 100%);
    font-family: Outfit, "Segoe UI", sans-serif;
    color: #1e293b;
}

body.kl-print-error .kl-print-error__panel {
    max-width: 34rem;
    margin: 0 auto;
    padding: 3rem 1.25rem 3.5rem;
    text-align: center;
}

body.kl-print-error .kl-print-error__logo {
    justify-content: center;
    margin: 0 auto 1.25rem;
}

body.kl-print-error .kl-print-error__art {
    width: 112px;
    height: 112px;
    margin: 0 auto 1.2rem;
    border-radius: 42% 58% 52% 48% / 46% 42% 58% 54%;
    background: #dbeafe;
    color: #6c5ce7;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2.4rem;
}

body.kl-print-error h1 {
    margin: 0 0 0.65rem;
    font-size: clamp(1.55rem, 3vw, 2rem);
    letter-spacing: -0.02em;
    color: #0f172a;
}

body.kl-print-error .kl-print-error__lead {
    margin: 0 auto 1.5rem;
    color: #64748b;
    font-size: 1.05rem;
    line-height: 1.55;
}

body.kl-print-error .kl-print-error__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.75rem;
    justify-content: center;
}
