/*
 * Mobile responsive fixes v2
 * Scoped to article content to avoid changing the home page/grid layout.
 */
@media (max-width: 767px) {
    html,
    body {
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Keep only the article itself inside the viewport. */
    .post-content,
    .post-content .post-summary,
    .post-content .post-text,
    .post-content .post-image,
    .post-content .post-image .post-image-inner,
    .post-content .post-player,
    .post-content .post-tags,
    .post-content .post-share {
        width: 100%;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    /* IMPORTANT: do not apply responsive image rules to author avatars. */
    .post-content .post-text img,
    .post-content .post-image img {
        display: block;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        box-sizing: border-box;
        margin-left: auto;
        margin-right: auto;
    }

    /* Restore the author's avatar size. */
    .post-content .post-author-meta img,
    .post-author-meta img {
        display: block !important;
        width: 30px !important;
        min-width: 30px !important;
        max-width: 30px !important;
        height: 30px !important;
        min-height: 30px !important;
        max-height: 30px !important;
        object-fit: cover;
        border-radius: 50% !important;
        float: left !important;
        margin: 0 10px 0 0 !important;
    }

    /* Make metadata wrap naturally without breaking the layout. */
    .post-content .post-meta {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        width: 100%;
        min-height: 30px;
        gap: 8px 12px;
        margin-bottom: 15px;
    }

    .post-content .post-meta .sp-left,
    .post-content .post-meta .sp-right {
        float: none !important;
        margin: 0 !important;
    }

    .post-content .post-author-meta a {
        display: flex;
        align-items: center;
        min-height: 30px;
        white-space: nowrap;
    }

    /* Content pasted from old editors can contain fixed widths. */
    .post-content .post-text > *,
    .post-content .post-text p,
    .post-content .post-text div,
    .post-content .post-text section,
    .post-content .post-text article,
    .post-content .post-text figure,
    .post-content .post-text blockquote,
    .post-content .post-text center {
        max-width: 100% !important;
        box-sizing: border-box;
        overflow-wrap: break-word;
        word-wrap: break-word;
    }

    .post-content .post-text figure {
        width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Videos and embedded content cannot exceed the article width. */
    .post-content .post-text iframe,
    .post-content .post-text object,
    .post-content .post-text embed,
    .post-content .post-text video,
    .post-content .post-player iframe,
    .post-content .post-player video {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box;
    }

    /* Tables scroll inside the article instead of widening the whole page. */
    .post-content .post-text table {
        display: block;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box;
    }

    .post-content .post-text table img {
        max-width: 100% !important;
        height: auto !important;
    }

    .post-content .post-text pre {
        display: block;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        white-space: pre-wrap;
        overflow-wrap: break-word;
        box-sizing: border-box;
    }

    /* Bootstrap rows pasted into an article should not create horizontal overflow. */
    .post-content .post-text .row {
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Share buttons and tags may wrap, but never widen the viewport. */
    .post-content .post-share,
    .post-content .post-share .share-box,
    .post-content .post-tags,
    .post-content .post-tags .tag-list {
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .post-content .post-share .share-box {
        white-space: normal !important;
    }

    .post-content .post-tags .tag-list {
        float: none;
    }
}

@media (max-width: 480px) {
    .post-content .title,
    .post-content .post-summary,
    .post-content .post-text,
    .post-content .post-meta,
    .post-content .post-tags {
        max-width: 100% !important;
        box-sizing: border-box;
    }

    .post-content .title,
    .post-content .post-summary h2 {
        overflow-wrap: break-word;
        word-wrap: break-word;
    }
}
