/* Only images explicitly resized with the article toolbar use these classes. */
.ht-image-width-25, img.ht-image-width-25, .wp-block-image[class].ht-image-width-25 { width: 25%; }
.ht-image-width-50, img.ht-image-width-50, .wp-block-image[class].ht-image-width-50 { width: 50%; }
.ht-image-width-75, img.ht-image-width-75, .wp-block-image[class].ht-image-width-75 { width: 75%; }
.ht-image-width-100, img.ht-image-width-100, .wp-block-image[class].ht-image-width-100 { width: 100%; }

img[class*="ht-image-width-"],
.wp-block-image[class*="ht-image-width-"] {
    max-width: 100%;
    height: auto;
    box-sizing: border-box;
}
.wp-block-image[class*="ht-image-width-"] img,
.wp-block-image[class*="ht-image-width-"] > a {
    width: 100%;
    max-width: 100%;
    height: auto;
}

/* Classic captions have their own fixed width; resize that outer box too. */
.wp-caption:has(img.ht-image-width-25) { width: 25% !important; }
.wp-caption:has(img.ht-image-width-50) { width: 50% !important; }
.wp-caption:has(img.ht-image-width-75) { width: 75% !important; }
.wp-caption:has(img.ht-image-width-100) { width: 100% !important; }
.wp-caption:has(img[class*="ht-image-width-"]) {
    max-width: 100%;
    box-sizing: border-box;
}
.wp-caption img[class*="ht-image-width-"] { width: 100%; }

/* WordPress may move aligncenter to a figure inside the sized wrapper.
   Centre the wrapper as well, so the image centres within the article. */
.wp-block-image[class*="ht-image-width-"].aligncenter,
.wp-block-image[class*="ht-image-width-"]:has(> figure.aligncenter),
.wp-caption.aligncenter:has(img[class*="ht-image-width-"]),
img.aligncenter[class*="ht-image-width-"] {
    display: block;
    float: none;
    margin-left: auto;
    margin-right: auto;
}
