/* ===========================================================================
   Images and captions inside editor content
   ===========================================================================
   The editor writes captions as TinyMCE does — <figure class="image"> wrapping
   an <img> and a <figcaption>. Nothing in the site styled either, so a
   captioned image rendered as a raw <figure> at the browser's default 40px
   indent with the caption running full-bleed underneath, and any image wider
   than its column pushed the article sideways.

   This gives the caption a place under the picture and keeps both inside the
   column they belong to.

   Palette follows the site: #ef8821 for actions and #3c59a7 for structure.
   ========================================================================= */

/* Every image in body copy, captioned or not. An article written years ago
   with a fixed width= attribute must not be the thing that scrolls the page. */
.content img,
.tour-content img,
.entry-content img {
    max-width: 100%;
    height: auto;
}

.content figure,
.tour-content figure,
.entry-content figure {
    /* The browser default is 1em 40px, which reads as an accidental indent. */
    margin: 22px 0;
    max-width: 100%;
    /* A figure is a block of its own; nothing should sit alongside it unless
       the editor explicitly floated it. */
    display: table;
}

.content figure img,
.tour-content figure img,
.entry-content figure img {
    display: block;
    margin: 0;
    border-radius: 3px;
}

.content figcaption,
.tour-content figcaption,
.entry-content figcaption {
    /* display:table on the figure makes this shrink to the image's width, so
       the caption never runs wider than the picture it describes. */
    display: table-caption;
    caption-side: bottom;
    padding: 9px 2px 0;
    font-size: 13px;
    line-height: 1.55;
    color: #5a6472;
    text-align: left;
    border-top: 2px solid #ef8821;
    margin-top: 8px;
    /* A caption pasted from elsewhere can carry a very long unbroken string. */
    overflow-wrap: anywhere;
}

/* TinyMCE writes alignment onto the figure. Keep the caption tied to the image
   width in each case, and stop a floated figure from swallowing the column. */
.content figure.align-left,
.tour-content figure.align-left,
.entry-content figure.align-left {
    float: left;
    margin: 6px 22px 14px 0;
    max-width: 50%;
}
.content figure.align-right,
.tour-content figure.align-right,
.entry-content figure.align-right {
    float: right;
    margin: 6px 0 14px 22px;
    max-width: 50%;
}
.content figure.align-center,
.tour-content figure.align-center,
.entry-content figure.align-center {
    margin-left: auto;
    margin-right: auto;
}
.content figure.align-center figcaption,
.tour-content figure.align-center figcaption,
.entry-content figure.align-center figcaption { text-align: center; }

/* A float that is never cleared drags the next heading up beside the picture. */
.content h2, .content h3,
.tour-content h2, .tour-content h3,
.entry-content h2, .entry-content h3 { clear: both; }

@media (max-width: 600px) {
    /* Half-width floats leave a column too narrow to read on a phone. */
    .content figure.align-left,  .content figure.align-right,
    .tour-content figure.align-left, .tour-content figure.align-right,
    .entry-content figure.align-left, .entry-content figure.align-right {
        float: none;
        max-width: 100%;
        margin: 18px 0;
    }
}
