/* DWB CMS — styles for sanitised rich-text content. Wrap the output in <div class="dwb-content">.
 *
 * Only the things the content needs to work (embeds, tables, alignment, images). Fonts, colours and
 * heading sizes are inherited from the site theme. Every selector is wrapped in :where() so it has
 * the specificity of a single class at most — a theme can override any rule with a plain selector.
 */

.dwb-content { overflow-wrap: break-word; }
.dwb-content::after { content: ""; display: block; clear: both; } /* contain floated images */

/* ---- alignment */
:where(.dwb-content) .text-left { text-align: left; }
:where(.dwb-content) .text-center { text-align: center; }
:where(.dwb-content) .text-right { text-align: right; }
:where(.dwb-content) .text-justify { text-align: justify; }

/* ---- images and figures */
:where(.dwb-content) img { max-width: 100%; height: auto; }
:where(.dwb-content) figure { margin: 1.5em 0; max-width: 100%; }
:where(.dwb-content) figure > img { display: block; }
:where(.dwb-content) figcaption { margin-top: .5em; font-size: .875em; opacity: .8; }

:where(.dwb-content) .img-left { float: left; max-width: min(50%, 420px); margin: .3em 1.5em 1em 0; }
:where(.dwb-content) .img-right { float: right; max-width: min(50%, 420px); margin: .3em 0 1em 1.5em; }
:where(.dwb-content) .img-center { display: block; margin-left: auto; margin-right: auto; }
:where(.dwb-content) .img-full { display: block; width: 100%; max-width: 100%; }
:where(.dwb-content) figure:where(.img-left, .img-right, .img-center) { display: table; }
:where(.dwb-content) figure:where(.img-left, .img-right, .img-center) > figcaption { display: table-caption; caption-side: bottom; }
:where(.dwb-content) figure.img-full > img { width: 100%; }
:where(.dwb-content) :where(h2, h3, h4, hr, table, .dwb-embed, .dwb-table-wrap) { clear: both; }

@media (max-width: 560px) {
  /* no room for text beside a picture on a phone */
  :where(.dwb-content) :where(.img-left, .img-right) { float: none; display: block; max-width: 100%; margin: 1em auto; }
}

/* ---- embeds: responsive 16:9 video, taller map */
:where(.dwb-content) .dwb-embed { position: relative; width: 100%; max-width: 100%; margin: 1.5em 0; aspect-ratio: 16 / 9; background: rgba(127, 127, 127, .12); overflow: hidden; }
:where(.dwb-content) .dwb-embed > iframe { position: absolute; inset: 0; width: 100%; height: 100%; border: 0; display: block; }
:where(.dwb-content) .dwb-embed-map { aspect-ratio: 4 / 3; max-height: 480px; }
@media (min-width: 768px) {
  :where(.dwb-content) .dwb-embed-map { aspect-ratio: 16 / 9; }
}
@supports not (aspect-ratio: 1 / 1) {
  :where(.dwb-content) .dwb-embed { height: 0; padding-bottom: 56.25%; }
  :where(.dwb-content) .dwb-embed-map { padding-bottom: 75%; }
}

/* ---- tables: scroll sideways on narrow screens instead of breaking the layout */
:where(.dwb-content) .dwb-table-wrap { width: 100%; max-width: 100%; margin: 1.5em 0; overflow-x: auto; -webkit-overflow-scrolling: touch; }
:where(.dwb-content) table { width: 100%; border-collapse: collapse; border-spacing: 0; }
:where(.dwb-content) :where(th, td) { padding: .55em .75em; border: 1px solid rgba(127, 127, 127, .35); text-align: left; vertical-align: top; }
:where(.dwb-content) th { font-weight: 600; background: rgba(127, 127, 127, .1); }
:where(.dwb-content) caption { caption-side: top; padding: 0 0 .6em; font-weight: 600; text-align: left; }

/* ---- document links */
:where(.dwb-content) .dwb-file-link { font-weight: 600; }
:where(.dwb-content) .dwb-file-link::before { content: "\2913\00a0"; text-decoration: none; display: inline-block; } /* ⤓ downwards arrow to bar */

/* ---- small defaults a reset may have removed */
:where(.dwb-content) blockquote { margin: 1.5em 0; padding: .25em 0 .25em 1.1em; border-left: 3px solid currentColor; }
:where(.dwb-content) hr { border: 0; border-top: 1px solid rgba(127, 127, 127, .4); margin: 2em 0; }
:where(.dwb-content) :where(ul, ol) { padding-left: 1.5em; }
:where(.dwb-content) ul { list-style: disc; }
:where(.dwb-content) ol { list-style: decimal; }

@media print {
  :where(.dwb-content) .dwb-embed { display: none; }
  :where(.dwb-content) .dwb-table-wrap { overflow: visible; }
}
