/*
 * FireRescue Mobile Width Fix
 * Main corrections only apply to smartphone / small tablet widths.
 */

@media only screen and (max-width: 782px) {

    html,
    body {
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Main WordPress/theme wrappers */
    #page,
    .site,
    #content,
    .site-content,
    .content-area,
    main,
    article,
    .post,
    .page,
    .entry,
    .entry-content,
    .post-content,
    .page-content,
    .inside-article {
        box-sizing: border-box !important;
        width: 100% !important;
        max-width: 100% !important;
        min-width: 0 !important;
    }

    /*
     * Comfortable phone spacing.
     * This helps old posts that sit hard against the left/right edge.
     */
    .entry-content,
    .post-content,
    .page-content {
        padding-left: 14px !important;
        padding-right: 14px !important;
        overflow-wrap: anywhere;
        word-wrap: break-word;
    }

    /*
     * Stop common old inline widths from escaping the post.
     * Slider/carousel internals are deliberately excluded.
     */
    .entry-content > *,
    .post-content > *,
    .page-content > * {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    .entry-content div:not(.slick-track):not(.swiper-wrapper):not(.owl-stage):not(.fr-no-mobile-fix),
    .entry-content section:not(.fr-no-mobile-fix),
    .post-content div:not(.slick-track):not(.swiper-wrapper):not(.owl-stage):not(.fr-no-mobile-fix),
    .post-content section:not(.fr-no-mobile-fix),
    .page-content div:not(.slick-track):not(.swiper-wrapper):not(.owl-stage):not(.fr-no-mobile-fix),
    .page-content section:not(.fr-no-mobile-fix) {
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Media */
    .entry-content img,
    .post-content img,
    .page-content img,
    .entry-content video,
    .post-content video,
    .page-content video,
    .entry-content svg,
    .post-content svg,
    .page-content svg,
    .entry-content canvas,
    .post-content canvas,
    .page-content canvas,
    .entry-content embed,
    .post-content embed,
    .page-content embed,
    .entry-content object,
    .post-content object,
    .page-content object {
        max-width: 100% !important;
        height: auto !important;
        box-sizing: border-box !important;
    }

    /* Embeds */
    .entry-content iframe,
    .post-content iframe,
    .page-content iframe {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Figures and captions */
    .entry-content figure,
    .post-content figure,
    .page-content figure,
    .entry-content .wp-caption,
    .post-content .wp-caption,
    .page-content .wp-caption {
        width: auto !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        box-sizing: border-box !important;
    }

    /* Tables stay readable without forcing the entire page wider */
    .entry-content table,
    .post-content table,
    .page-content table,
    .wp-block-table table {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
        box-sizing: border-box !important;
    }

    .entry-content th,
    .entry-content td,
    .post-content th,
    .post-content td,
    .page-content th,
    .page-content td {
        overflow-wrap: anywhere;
        word-break: normal;
    }

    /* Code / copied text */
    .entry-content pre,
    .post-content pre,
    .page-content pre {
        display: block !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: auto !important;
        white-space: pre-wrap;
        overflow-wrap: anywhere;
        box-sizing: border-box !important;
    }

    .entry-content code,
    .post-content code,
    .page-content code {
        overflow-wrap: anywhere;
        word-break: break-word;
    }

    /* Old WordPress wide/full alignment */
    .entry-content .alignwide,
    .entry-content .alignfull,
    .post-content .alignwide,
    .post-content .alignfull,
    .page-content .alignwide,
    .page-content .alignfull {
        width: auto !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Flex/grid children can otherwise create hidden minimum widths */
    .entry-content [style*="display:flex"],
    .entry-content [style*="display: flex"],
    .post-content [style*="display:flex"],
    .post-content [style*="display: flex"],
    .page-content [style*="display:flex"],
    .page-content [style*="display: flex"] {
        max-width: 100% !important;
        min-width: 0 !important;
        flex-wrap: wrap !important;
        box-sizing: border-box !important;
    }

    /* JavaScript rescue class for stubborn inline fixed-width elements */
    .fr-mobile-force-fit {
        max-width: 100% !important;
        min-width: 0 !important;
        box-sizing: border-box !important;
    }

    /* Allow opt-out for unusual widgets */
    .fr-no-mobile-fix,
    .fr-no-mobile-fix * {
        /* Intentionally left alone */
    }
}
