/*
 * Worksheet image layout chosen by students in the online worksheet editor.
 *
 * Size and position are stored as classes (ws-w-NN, ws-img-left/right) because
 * the HTML sanitizer drops inline styles. This file is loaded on every page and
 * inside the TinyMCE iframe, so a worksheet image looks the same while editing,
 * after submission, and on the grading page.
 *
 * !important is deliberate: these are explicit student choices and must win over
 * the generic responsive image caps in main.css and the editor's content_style.
 * .mce-clonedresizable is TinyMCE's drag-resize preview, sized by inline style;
 * it must stay free of these rules or the preview won't follow the mouse.
 */

/* ── Size: percentage of the surrounding column / table cell ── */
img.ws-w-10:not(.mce-clonedresizable),
img.ws-w-15:not(.mce-clonedresizable),
img.ws-w-20:not(.mce-clonedresizable),
img.ws-w-25:not(.mce-clonedresizable),
img.ws-w-30:not(.mce-clonedresizable),
img.ws-w-35:not(.mce-clonedresizable),
img.ws-w-40:not(.mce-clonedresizable),
img.ws-w-45:not(.mce-clonedresizable),
img.ws-w-50:not(.mce-clonedresizable),
img.ws-w-55:not(.mce-clonedresizable),
img.ws-w-60:not(.mce-clonedresizable),
img.ws-w-65:not(.mce-clonedresizable),
img.ws-w-70:not(.mce-clonedresizable),
img.ws-w-75:not(.mce-clonedresizable),
img.ws-w-80:not(.mce-clonedresizable),
img.ws-w-85:not(.mce-clonedresizable),
img.ws-w-90:not(.mce-clonedresizable),
img.ws-w-95:not(.mce-clonedresizable),
img.ws-w-100:not(.mce-clonedresizable) {
    height: auto !important;
    max-width: 100% !important;
    max-height: none !important;
    object-fit: contain !important;
}

img.ws-w-10:not(.mce-clonedresizable) { width: 10% !important; }
img.ws-w-15:not(.mce-clonedresizable) { width: 15% !important; }
img.ws-w-20:not(.mce-clonedresizable) { width: 20% !important; }
img.ws-w-25:not(.mce-clonedresizable) { width: 25% !important; }
img.ws-w-30:not(.mce-clonedresizable) { width: 30% !important; }
img.ws-w-35:not(.mce-clonedresizable) { width: 35% !important; }
img.ws-w-40:not(.mce-clonedresizable) { width: 40% !important; }
img.ws-w-45:not(.mce-clonedresizable) { width: 45% !important; }
img.ws-w-50:not(.mce-clonedresizable) { width: 50% !important; }
img.ws-w-55:not(.mce-clonedresizable) { width: 55% !important; }
img.ws-w-60:not(.mce-clonedresizable) { width: 60% !important; }
img.ws-w-65:not(.mce-clonedresizable) { width: 65% !important; }
img.ws-w-70:not(.mce-clonedresizable) { width: 70% !important; }
img.ws-w-75:not(.mce-clonedresizable) { width: 75% !important; }
img.ws-w-80:not(.mce-clonedresizable) { width: 80% !important; }
img.ws-w-85:not(.mce-clonedresizable) { width: 85% !important; }
img.ws-w-90:not(.mce-clonedresizable) { width: 90% !important; }
img.ws-w-95:not(.mce-clonedresizable) { width: 95% !important; }
img.ws-w-100:not(.mce-clonedresizable) { width: 100% !important; }

/* ── Position: float with text wrapping (no class = centered block) ── */
img.ws-img-left:not(.mce-clonedresizable) {
    float: left !important;
    margin: 0.25rem 1.25rem 0.75rem 0 !important;
}

img.ws-img-right:not(.mce-clonedresizable) {
    float: right !important;
    margin: 0.25rem 0 0.75rem 1.25rem !important;
}

/* Keep floated images inside the worksheet box instead of spilling past its end */
.rich-worksheet-content::after,
.rich-worksheet-sheet::after,
.mce-content-body::after {
    content: "";
    display: table;
    clear: both;
}

/* Phones: text wrapping beside an image is too cramped, stack instead */
@media (max-width: 575.98px) {
    img.ws-img-left:not(.mce-clonedresizable),
    img.ws-img-right:not(.mce-clonedresizable) {
        float: none !important;
        margin: 0.75rem auto !important;
    }
}
