/* Slide / lesson HTML from the editor (image + text layouts) */
.wa-course-slide-layout,
.wa-exam-outlines-html.wa-course-learn__content,
.wa-exam-outlines-html.course-public-sec__html {
    line-height: 1.6;
    color: inherit;
    display: flow-root;
    text-align: left;
}

.wa-course-slide-layout p,
.wa-exam-outlines-html.wa-course-learn__content p,
.wa-exam-outlines-html.course-public-sec__html p {
    margin: 0 0 0.65em;
    margin-left: 0 !important;
    padding-left: 0 !important;
    text-indent: 0 !important;
    text-align: left;
}

/* Honor alignment set in the admin editor */
.wa-course-slide-layout [style*="text-align: center"],
.wa-course-slide-layout [style*="text-align:center"],
.wa-exam-outlines-html [style*="text-align: center"],
.wa-exam-outlines-html [style*="text-align:center"] {
    text-align: center !important;
}

.wa-course-slide-layout [style*="text-align: right"],
.wa-course-slide-layout [style*="text-align:right"],
.wa-exam-outlines-html [style*="text-align: right"],
.wa-exam-outlines-html [style*="text-align:right"] {
    text-align: right !important;
}

.wa-course-slide-layout [style*="text-align: justify"],
.wa-course-slide-layout [style*="text-align:justify"],
.wa-exam-outlines-html [style*="text-align: justify"],
.wa-exam-outlines-html [style*="text-align:justify"] {
    text-align: justify !important;
}

.wa-course-slide-layout p:last-child,
.wa-exam-outlines-html.wa-course-learn__content p:last-child,
.wa-exam-outlines-html.course-public-sec__html p:last-child {
    margin-bottom: 0;
}

/* Respect width/height from the admin editor; only cap overflow */
.wa-course-slide-layout img,
.wa-exam-outlines-html.wa-course-learn__content img,
.wa-exam-outlines-html.course-public-sec__html img {
    max-width: 100%;
    border-radius: 6px;
    float: none;
    clear: none;
}

/* Standalone / stacked images */
.wa-course-slide-layout img:not([style*="float"]):not([align="left"]):not([align="right"]),
.wa-exam-outlines-html img:not([style*="float"]):not([align="left"]):not([align="right"]) {
    display: block;
    margin: 0 auto 1rem;
}

/* Keep aspect ratio when only width is set in the editor */
.wa-course-slide-layout img[style*="width"]:not([style*="height"]),
.wa-exam-outlines-html img[style*="width"]:not([style*="height"]),
.wa-course-slide-layout img[width]:not([height]),
.wa-exam-outlines-html img[width]:not([height]) {
    height: auto;
}

.wa-course-slide-layout > p:has(> img:only-child),
.wa-exam-outlines-html > p:has(> img:only-child) {
    float: none;
    max-width: none;
    margin: 0 0 0.65em;
    padding: 0;
}

.wa-course-slide-layout > p:has(> img:only-child) img,
.wa-exam-outlines-html > p:has(> img:only-child) img {
    max-width: 100%;
}

/* Center image when it is the only block on the slide */
.wa-course-slide-layout:not(:has(> p:nth-child(2))) > p:has(> img:only-child) img,
.wa-exam-outlines-html:not(:has(> p:nth-child(2))) > p:has(> img:only-child) img {
    margin-left: auto;
    margin-right: auto;
}

/* Floated images: text wraps beside; keep top alignment */
.wa-course-slide-layout img[style*="float: left"],
.wa-course-slide-layout img[style*="float:left"],
.wa-exam-outlines-html img[style*="float: left"],
.wa-exam-outlines-html img[style*="float:left"],
.wa-exam-outlines-html img[align="left"] {
    display: inline-block;
    float: left;
    vertical-align: top;
    max-width: min(360px, 42%);
    margin: 0 1.25rem 0.5rem 0;
}

.wa-course-slide-layout img[style*="float: right"],
.wa-course-slide-layout img[style*="float:right"],
.wa-exam-outlines-html img[style*="float: right"],
.wa-exam-outlines-html img[style*="float:right"],
.wa-exam-outlines-html img[align="right"] {
    display: inline-block;
    float: right;
    vertical-align: top;
    max-width: min(360px, 42%);
    margin: 0 0 0.5rem 1.25rem;
}

/* Image column + one text column (grid; wrapper added in CourseSectionContentHtml) */
.wa-course-slide-layout:has(.wa-course-slide-text),
.wa-course-slide-layout:has(> p:first-child > img:only-child):has(> p:nth-child(2)),
.wa-exam-outlines-html:has(.wa-course-slide-text),
.wa-exam-outlines-html:has(> p:first-child > img:only-child):has(> p:nth-child(2)) {
    display: grid;
    grid-template-columns: minmax(0, max-content) minmax(0, 1fr);
    column-gap: 1.25rem;
    row-gap: 0.35rem;
    align-items: start;
}

.wa-course-slide-layout:has(.wa-course-slide-text) > p:first-child,
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:first-child,
.wa-exam-outlines-html:has(.wa-course-slide-text) > p:first-child,
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:first-child {
    grid-column: 1;
    grid-row: 1 / -1;
    margin: 0;
    max-width: min(48%, 420px);
}

.wa-course-slide-layout:has(.wa-course-slide-text) > p:first-child img,
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:first-child img,
.wa-exam-outlines-html:has(.wa-course-slide-text) > p:first-child img,
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:first-child img {
    display: block;
    float: none !important;
    margin: 0;
}

.wa-course-slide-text,
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:not(:first-child),
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:not(:first-child) {
    grid-column: 2;
    min-width: 0;
}

.wa-course-slide-text p,
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:not(:first-child),
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:not(:first-child) {
    margin: 0 0 0.5em;
    text-align: left !important;
}

.wa-course-slide-text p:last-child,
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:not(:first-child):last-child,
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:not(:first-child):last-child {
    margin-bottom: 0;
}

/* Mixed center/right per line from PPT — one left-aligned block beside the image */
.wa-course-slide-text [style*="text-align"],
.wa-course-slide-layout:has(> p:first-child > img:only-child) > p:not(:first-child)[style*="text-align"],
.wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:not(:first-child)[style*="text-align"] {
    text-align: left !important;
}

.wa-course-slide-layout table,
.wa-exam-outlines-html table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5em 0 0.75em;
}

.wa-course-slide-layout td,
.wa-course-slide-layout th,
.wa-exam-outlines-html td,
.wa-exam-outlines-html th {
    vertical-align: top;
    padding: 0.5em 0.65em;
}

.wa-course-slide-layout td img,
.wa-exam-outlines-html td img {
    float: none;
    max-width: 100%;
    margin: 0 auto;
}

@media (max-width: 640px) {
    .wa-course-slide-layout:has(.wa-course-slide-text),
    .wa-course-slide-layout:has(> p:first-child > img:only-child):has(> p:nth-child(2)),
    .wa-exam-outlines-html:has(.wa-course-slide-text),
    .wa-exam-outlines-html:has(> p:first-child > img:only-child):has(> p:nth-child(2)) {
        display: flow-root;
    }

    .wa-course-slide-layout:has(.wa-course-slide-text) > p:first-child,
    .wa-course-slide-layout:has(> p:first-child > img:only-child) > p:first-child,
    .wa-exam-outlines-html:has(.wa-course-slide-text) > p:first-child,
    .wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:first-child {
        grid-column: auto;
        grid-row: auto;
        max-width: 100%;
        margin-bottom: 0.75rem;
    }

    .wa-course-slide-text,
    .wa-course-slide-layout:has(> p:first-child > img:only-child) > p:not(:first-child),
    .wa-exam-outlines-html:has(> p:first-child > img:only-child) > p:not(:first-child) {
        grid-column: auto;
    }

    .wa-course-slide-layout img[style*="float"],
    .wa-exam-outlines-html img[style*="float"],
    .wa-exam-outlines-html img[align="left"],
    .wa-exam-outlines-html img[align="right"] {
        float: none;
        display: block;
        max-width: 100%;
        margin: 0 auto 1rem;
    }
}
