/**
 * Worksheet styles — for section worksheets rendered as HTML
 */

/* Lettered question lists (a, b, c, ...) */
ol.questions {
    list-style-type: lower-alpha;
    margin-left: 2em;
    margin-bottom: 1.5em;
}

ol.questions > li {
    margin-bottom: 1em;
    padding-left: 0.25em;
}

ol.questions > li > p:first-child {
    margin-bottom: 0.5em;
}

/* Blank answer space — hidden on screen, blank space when printed */
.answer-space {
    display: none;
}

/* Specification comparison table — supports class on <table> or wrapper <div> */
table.spec-table,
.spec-table table {
    border-collapse: collapse;
    margin: 1em auto;
}

table.spec-table th,
table.spec-table td,
.spec-table table th,
.spec-table table td {
    border: 1px solid #333;
    padding: 0.3em 1.2em;
    text-align: center;
    min-width: 3em;
    font-weight: bold;
}

table.spec-table thead th,
.spec-table table thead th {
    background-color: #f5f5f5;
}

table.spec-table tbody th,
.spec-table table tbody th {
    background-color: #f5f5f5;
}

table.spec-table td:empty,
.spec-table table td:empty {
    min-height: 1.5em;
}

/* Solution callouts */
.solution {
    color: #0a3d91;
    border-left: 3px solid #0a3d91;
    padding-left: 1em;
    margin: 0.5em 0;
}

/* Screen-reader-only label before each solution */
.solution::before {
    content: "Solution: ";
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.solution p {
    margin-bottom: 0.5em;
}

.solution ul {
    margin-top: 0.25em;
    margin-bottom: 0.5em;
}

/**
 * Print-specific overrides for worksheets
 */
@media print {
    /* Don't show link URLs in worksheet context */
    a[href]::after {
        content: "" !important;
    }

    /* Show answer spaces as blank space when printing */
    .answer-space {
        display: block;
        min-height: 5em;
        border: none;
    }

    /* Give code blocks a subtle background */
    pre {
        background-color: #f8f8f8 !important;
        border: 1px solid #ccc !important;
    }

    /* Each task (h2) starts on a new page */
    h2 {
        page-break-before: always;
    }

    /* ...except the first one */
    h2:first-of-type {
        page-break-before: avoid;
    }

    /* Avoid page breaks inside questions, code blocks, tables */
    ol.questions > li {
        page-break-inside: avoid;
    }

    ol.questions > li > pre,
    ol.questions > li > .answer-space {
        page-break-inside: avoid;
    }

    table.spec-table,
    .spec-table table,
    .spec-table {
        page-break-inside: avoid;
    }

    /* Explicit page-break class for manual control:
       <div class="page-break"></div>  */
    .page-break {
        page-break-before: always;
        break-before: page;
        height: 0;
        margin: 0;
        border: 0;
    }

    /* Suppress a page break on a specific element:
       <h2 class="no-break-before">...</h2>  */
    .no-break-before {
        page-break-before: avoid !important;
        break-before: avoid !important;
    }
}
