/**
 * 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;
    }
}


/* Terminal-styled blocks (used in HW handouts to embed example terminal sessions). */
.terminal {
    margin: 1.25em 0;
    background: #1e1e1e;
    color: #e0e0e0;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    font-family: "SF Mono", "Menlo", "Consolas", monospace;
}

.terminal-titlebar {
    background: #2c2c2c;
    padding: 0.5em 0.75em;
    display: flex;
    gap: 0.4em;
}

.terminal-dot {
    width: 0.7em;
    height: 0.7em;
    border-radius: 50%;
    display: inline-block;
}

.terminal-dot-red    { background: #ff5f56; }
.terminal-dot-yellow { background: #ffbd2e; }
.terminal-dot-green  { background: #27c93f; }

.terminal-body {
    margin: 0;
    padding: 1em 1.25em;
    font-size: 0.9em;
    line-height: 1.4;
    overflow-x: auto;
    white-space: pre;
    background: transparent;
    color: inherit;
}

.terminal figcaption {
    background: #2c2c2c;
    color: #aaa;
    font-size: 0.85em;
    font-family: -apple-system, system-ui, sans-serif;
    text-align: center;
    padding: 0.5em 1em;
}

@media print {
    .terminal {
        background: white;
        color: black;
        box-shadow: none;
        border: 1px solid #ccc;
    }
    .terminal-titlebar { display: none; }
    .terminal figcaption { background: white; color: #333; }
}
