/* Named copies on the public printables (content/print-names.js). Loaded
   after worksheet-print.css and worksheet-night.css on the module worksheet
   print views, crosswords and word searches only — the teacher tools that
   share worksheet-print.css never load this file.

   Three parts: the bar and panel the script injects (screen, the night
   look), the named copies (print), and the half-sheet layout for "Two per
   sheet" (both: the script measures a copy on screen with the same mm/pt
   sizes it prints with). */

/* ── Hidden until printed ───────────────────────────────────────────── */
.ws-named,
.ws-source-url { display: none; }

/* ── Bar additions (screen) ─────────────────────────────────────────── */
@media screen {
.ws-night .ws-controls-right { flex-wrap: wrap; justify-content: flex-end; row-gap: 8px; }
.ws-night .ws-back-btn { white-space: nowrap; }
/* A list adds two or three controls: give the bar room before it wraps. */
.ws-night .ws-controls.has-class-list .ws-controls-inner { max-width: 1100px; }
.ws-night .ws-print-btn--quiet {
    background: rgba(255,255,255,0.08);
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: none;
}
.ws-night .ws-print-btn--quiet:hover { background: rgba(255,255,255,0.18); }
.ws-night .ws-print-btn:disabled { background: rgba(255,255,255,0.08); color: #9B8AC4; cursor: default; transform: none; }
.ws-night .ws-names-link {
    background: none;
    border: 0;
    padding: 0;
    font: inherit;
    color: #C4B5FD;
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 2px;
    cursor: pointer;
}
.ws-night .ws-names-link:hover { color: #fff; }
.ws-night .ws-names-link:focus-visible { outline: 3px solid #FBBF24; outline-offset: 2px; }

/* ── The panel under the bar: .rail-card ────────────────────────────── */
.ws-night .ws-names-panel {
    max-width: 900px;
    margin: 16px auto 0;
    padding: 18px 22px 20px;
    background: var(--cp-card);
    border: 1px solid rgba(255,255,255,0.12);
    border-radius: 20px;
    box-shadow: 0 20px 44px rgba(11,16,32,.35);
    font-family: var(--font-body);
    color: #E4D9FF;
}
.ws-night .ws-names-panel[hidden] { display: none; }
.ws-night .wsn-head,
.ws-night .wsn-foot,
.ws-night .wsn-actions {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 8px 12px;
}
.ws-night .wsn-head { margin-bottom: 12px; }
.ws-night .wsn-title {
    font-family: var(--font-display);
    font-size: 1.2rem;
    font-weight: 800;
    color: #fff;
    margin-right: 4px;
}
.ws-night .wsn-dot { color: #9B8AC4; }
.ws-night .wsn-spacer { flex: 1; }
.ws-night .wsn-link,
.ws-night .wsn-close {
    background: none;
    border: 0;
    padding: 2px 0;
    font: inherit;
    font-weight: 800;
    color: #C4B5FD;
    cursor: pointer;
}
.ws-night .wsn-link:hover,
.ws-night .wsn-close:hover { color: #fff; }
.ws-night .wsn-link:focus-visible,
.ws-night .wsn-close:focus-visible { outline: 3px solid #FBBF24; outline-offset: 2px; }
.ws-night .wsn-close { font-size: 1rem; padding: 2px 4px; }

.ws-night .wsn-names {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 6px;
    margin-bottom: 16px;
}
.ws-night .wsn-name {
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
    padding: 6px 10px;
    border-radius: 10px;
    background: rgba(16,8,34,0.45);
    border: 1px solid rgba(255,255,255,0.08);
    font-weight: 700;
    color: #fff;
    cursor: pointer;
}
.ws-night .wsn-name span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ws-night .wsn-name:has(input:not(:checked)) { color: #9B8AC4; background: transparent; }
.ws-night .wsn-name input,
.ws-night .wsn-foot input { accent-color: #FBBF24; width: 15px; height: 15px; flex-shrink: 0; }
.ws-night .wsn-foot .ws-check-label { font-size: 0.88rem; }

/* The editor */
.ws-night .wsn-label {
    display: block;
    margin: 0 0 6px;
    font-size: 0.75rem;
    font-weight: 900;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: #9B8AC4;
}
.ws-night .wsn-input,
.ws-night .wsn-textarea {
    display: block;
    width: 100%;
    padding: 10px 12px;
    border-radius: 12px;
    border: 1px solid rgba(255,255,255,0.16);
    background: rgba(16,8,34,0.45);
    color: #fff;
    font-family: var(--font-body);
    font-size: 1rem;
    font-weight: 600;
}
.ws-night .wsn-input { max-width: 180px; margin-bottom: 14px; }
.ws-night .wsn-textarea { min-height: 170px; resize: vertical; line-height: 1.45; }
.ws-night .wsn-input:focus,
.ws-night .wsn-textarea:focus { outline: 3px solid #FBBF24; outline-offset: 1px; }
.ws-night .wsn-input::placeholder,
.ws-night .wsn-textarea::placeholder { color: #8A7BB0; }
.ws-night .wsn-preview { min-height: 1.4em; margin: 8px 0 12px; font-size: 0.9rem; font-weight: 700; color: #E4D9FF; }
.ws-night .wsn-msg { font-size: 0.88rem; font-weight: 700; color: #FBBF24; }
.ws-night .wsn-note { margin-top: 12px; font-size: 0.8rem; font-weight: 600; color: #9B8AC4; }

@media (max-width: 640px) {
    .ws-night .ws-controls-right { justify-content: flex-start; }
    .ws-night .ws-names-panel { margin: 12px 12px 0; padding: 16px; }
    .ws-night .wsn-names { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
}
}

/* ── Filled Name / Class ────────────────────────────────────────────── */
.ws-field-line--filled {
    width: 46mm;
    padding: 0 2px 1px;
    overflow: hidden;
    white-space: nowrap;
    text-align: left;
    font-weight: 700;
    line-height: 1.2;
    color: var(--ws-text);
}
.ws-field-line--short.ws-field-line--filled { width: 24mm; }

/* ── Two per sheet: one half of an A4 landscape sheet ───────────────────
   Page box 277 × 188 mm (margins 10/10/12, set by the script's @page);
   halves 131.5 mm wide with the cut line between. Laid out at this size,
   not shrunk: body text stays at 10 pt. The overrides also beat the
   ≤640px screen rules so a phone measures what paper gets. */
.ws-half {
    flex: none;
    width: 131.5mm;
    height: 186mm;
    overflow: hidden;
    box-sizing: border-box;
    font-family: var(--ws-font);
    font-size: 10pt;
    line-height: 1.5;
    color: var(--ws-text);
    background: #fff;
    text-align: left;
}
.ws-probe-host {
    position: absolute;
    left: -10000px;
    top: 0;
    visibility: hidden;
}
/* Logo and title on one row, Name · Date · Class on the next: a half is too
   narrow for the A4 header's third column, where long titles wrapped. */
.ws-half .ws-header { grid-template-columns: auto 1fr; gap: 4px 10px; margin-bottom: 2px; }
.ws-half .ws-header-fields { grid-column: 1 / -1; flex-direction: row; justify-content: space-between; gap: 10px; text-align: left; }
.ws-half .ws-field { justify-content: flex-start; }
.ws-half .ws-field-line { width: 150px; }
.ws-half .ws-field-line--short { width: 70px; }
.ws-half .ws-field-line--filled { width: 55mm; }
.ws-half .ws-field-line--short.ws-field-line--filled { width: 24mm; }
.ws-half .ws-logo { height: 22px; }
.ws-half .ws-title { font-size: 12pt; }
.ws-half .ws-header-rule { margin: 4px 0 10px; height: 2px; }
.ws-half .ws-section { margin-bottom: 10px; }
.ws-half .ws-section-header { gap: 8px; margin-bottom: 4px; }
.ws-half .ws-section-label { width: 22px; height: 22px; }
.ws-half .ws-section-title { font-size: 11pt; }
.ws-half .ws-section-desc { font-size: 10pt; line-height: 1.3; }
.ws-half .cw-grid-wrap,
.ws-half .wsr-grid-wrap { overflow: visible; margin: 2px 0 8px; }
.ws-half .cw-grid { --cw-cell: min(6.5mm, calc(128mm / var(--cw-cols))); }
.ws-half .cw-clues { grid-template-columns: 1fr 1fr; gap: 10px; }
.ws-half .cw-clue-heading { font-size: 9pt; margin-bottom: 4px; }
.ws-half .cw-clue-list { gap: 3px; }
.ws-half .cw-clue { font-size: 10pt; line-height: 1.3; }
.ws-half .wsr-grid { --wsr-cell: min(6.2mm, calc(126mm / var(--wsr-cols))); }
.ws-half .wsr-list { gap: 5px 6px; }
.ws-half .wsr-group { font-size: 10pt; padding: 3px 8px 3px 5px; }
.ws-half .ws-answer-key { padding-top: 0; break-before: auto !important; page-break-before: auto !important; }
.ws-half .ws-answer-header { margin-bottom: 8px; padding-bottom: 6px; }
.ws-half .ws-answer-sections { gap: 8px; }
.ws-half .ws-answer-item { font-size: 10pt; line-height: 1.35; }
/* Shown in the half on screen too, so the probe measures the printed line. */
.ws-half .ws-source-url { display: block; margin-top: 1px; font-size: 7pt; color: #6b7280; overflow-wrap: anywhere; }

/* ── An A4 page: the print's page area (A4 less the 16/16/22 mm margins of
   worksheet-print.css's @page, 1 mm spare), with the sizes worksheet-
   print.css gives in print restated so the screen measures the same page —
   and the ≤640px screen rules undone, so a phone measures it too. ──── */
.ws-page {
    position: relative;
    width: 178mm;
    height: 258mm;
    overflow: hidden;
    box-sizing: border-box;
    font-family: var(--ws-font);
    font-size: 10pt;
    line-height: 1.5;
    color: var(--ws-text);
    background: #fff;
    text-align: left;
}
.ws-page .ws-header { grid-template-columns: auto 1fr auto; gap: 20px; margin-bottom: 2px; }
.ws-page .ws-header-fields { text-align: right; }
.ws-page .ws-field { justify-content: flex-end; }
.ws-page .ws-logo { height: 30px; }
.ws-page .ws-title { font-size: 14pt; }
.ws-page .ws-header-rule { margin: 6px 0 16px; height: 3px; }
.ws-page .ws-duo-options { grid-template-columns: 1fr 1fr; }
.ws-page .cw-grid-wrap,
.ws-page .wsr-grid-wrap { overflow: visible; }
.ws-page .cw-grid { --cw-cell: 8mm; }
.ws-page .cw-clues { grid-template-columns: 1fr 1fr; }
.ws-page .wsr-grid { --wsr-cell: min(8mm, calc(160mm / var(--wsr-cols))); }
.ws-page .ws-answer-key { padding-top: 0; break-before: auto !important; page-break-before: auto !important; }
.ws-page .ws-source-url { display: block; margin-top: 2px; font-size: 7.5pt; font-weight: 400; color: #6b7280; overflow-wrap: anywhere; }

/* The last block on a page ends the page: the browser drops a margin at a
   page break, so a box doesn't count it either. */
.ws-page .ws-copy > :last-child,
.ws-half .ws-copy > :last-child,
.ws-page .ws-answer-key > :last-child,
.ws-half .ws-answer-key > :last-child { margin-bottom: 0; }

/* ── Print ──────────────────────────────────────────────────────────── */
@media print {
    .ws-source-url {
        display: block;
        margin-top: 2px;
        font-size: 7.5pt;
        font-weight: 400;
        color: #6b7280;
        overflow-wrap: anywhere;
    }

    body.ws-print-named #wsDoc { display: none !important; }
    body.ws-print-named .ws-named { display: block; }

    /* One page box or sheet per printed page. */
    .ws-named > * + * {
        break-before: page;
        page-break-before: always;
    }
    .ws-page {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .ws-sheet {
        position: relative;
        display: flex;
        justify-content: space-between;
        width: 277mm;
        height: 186mm;
        overflow: hidden;
        break-inside: avoid;
        page-break-inside: avoid;
    }
    /* The cut line, only where two students share the sheet. */
    .ws-sheet--pair::after {
        content: '';
        position: absolute;
        top: 0;
        bottom: 0;
        left: 50%;
        border-left: 1px dashed #9ca3af;
    }
}
