/* ============================================================
   worksheet.css — shared partner-worksheet component
   PSYC/BIOL/SOCI 224 interactive modules

   Pairs with worksheet.js. See INTERACTIVE-MODULES-PLAN.md §2.

   Two jobs:
     1. Style only the elements the component itself creates (.ws-*),
        so including this file never restyles an existing module.
     2. Own the @media print block, which fixes defect D-1 — textarea
        content being clipped out of submitted PDFs.
   ============================================================ */

/* ---------- storage-unavailable banner (component-created) ---------- */
.ws-banner {
    position: sticky;
    top: 0;
    z-index: 9999;
    background: #b71c1c;
    color: #fff;
    padding: 12px 18px;
    font-weight: bold;
    font-size: 15px;
    line-height: 1.5;
    box-shadow: 0 2px 6px rgba(0, 0, 0, .3);
}

.ws-banner code {
    background: rgba(255, 255, 255, .18);
    padding: 1px 5px;
    border-radius: 3px;
}

/* ---------- footer action bar (download/load always; save/print if the page lacks them) ---------- */
.ws-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    justify-content: center;
    margin: 30px 0 10px;
    padding: 18px;
    background: #eef2f7;
    border-radius: 8px;
}

.ws-actions button {
    background: #1976d2;
    color: #fff;
    border: none;
    padding: 12px 24px;
    border-radius: 5px;
    cursor: pointer;
    font-size: 16px;
    font-family: inherit;
}

.ws-actions button:hover { background: #1565c0; }

/* ---------- progress bar (only created if page lacks one) ---------- */
.ws-progress {
    background: #e0e0e0;
    border-radius: 10px;
    height: 20px;
    margin: 20px 0;
    overflow: hidden;
}

.ws-progress-bar {
    background: #4caf50;
    height: 100%;
    width: 0;
    transition: width .3s;
    text-align: center;
    color: #fff;
    line-height: 20px;
    font-size: 12px;
}

/* ---------- save confirmation toast ---------- */
.ws-toast {
    position: fixed;
    left: 50%;
    bottom: 28px;
    transform: translateX(-50%);
    background: #2e7d32;
    color: #fff;
    padding: 12px 22px;
    border-radius: 6px;
    font-size: 15px;
    z-index: 10000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, .25);
    opacity: 0;
    transition: opacity .25s;
    pointer-events: none;
}

.ws-toast.ws-toast-on { opacity: 1; }

/* ---------- print twin, hidden on screen ---------- */
.ws-print-answer { display: none; }


/* ============================================================
   PRINT — defect D-1 fix

   A textarea does not grow to fit its content, so a rows="3" box
   holding eight lines prints three lines and silently drops the
   rest from the submitted PDF. CSS alone cannot fix this; the JS
   renders a .ws-print-answer twin holding the full text, and here
   we swap which one is visible.
   ============================================================ */
@media print {

    /* the swap */
    textarea { display: none !important; }

    .ws-print-answer {
        display: block;
        white-space: pre-wrap;      /* keep the student's line breaks */
        overflow-wrap: break-word;  /* no overflow off the page edge  */
        border: 1px solid #999;
        border-radius: 4px;
        padding: 8px 10px;
        margin: 8px 0;
        min-height: 2.5em;
        background: #fff;
        color: #000;
        font-family: inherit;
        font-size: 12pt;
        line-height: 1.5;
        break-inside: avoid;
    }

    .ws-print-answer.ws-empty { color: #777; font-style: italic; }

    /* hide anything interactive — it is meaningless on paper */
    .btn,
    .no-print,
    .controls,
    .button-group,
    .ws-actions,
    .ws-banner,
    .ws-toast,
    button,
    input[type="range"] { display: none !important; }

    /* keep the progress bar — it shows the grader how complete the work is */
    .ws-progress, .progress { break-inside: avoid; }

    body {
        background: #fff !important;
        font-size: 11pt;
    }

    /* text and number inputs are single-line and do print, but they render as
       empty boxes in some engines — force the border so the value is legible.
       Number inputs also print their spinner arrows unless suppressed. */
    input[type="number"]::-webkit-inner-spin-button,
    input[type="number"]::-webkit-outer-spin-button {
        -webkit-appearance: none;
        appearance: none;
        margin: 0;
    }

    input[type="text"],
    input[type="number"] {
        border: none !important;
        border-bottom: 1px solid #999 !important;
        background: transparent !important;
        color: #000 !important;
    }

    /* pagination: do not strand a heading or split a box across pages */
    h1, h2, h3, h4 { break-after: avoid; }

    .alert-box,
    table,
    canvas,
    .dataset-card,
    .stat-card,
    details { break-inside: avoid; }

    /* some print engines append the href after every link; suppress it */
    a[href]:after { content: "" !important; }

    /* canvas plots keep their ink */
    canvas { max-width: 100% !important; }
}
