/* =====================================================
   MODERN HEALTH LIBRARY - MOBILE LAYER
   Loaded after the child theme stylesheet.
   Everything here is scoped to small screens except
   the two "ALL SCREENS" fixes at the top.

   Selectors start with "html body" on purpose: the
   Customizer's Additional CSS and the page-level
   <style> blocks print later in the page and use
   !important, so these rules need the extra weight.
===================================================== */


/* ALL SCREENS: copyright strip.
   The old 100vw strip was wider than the page (100vw
   includes the scrollbar), which let the whole site
   scroll sideways. Paint the full-width band with a
   shadow instead so nothing overflows. */
html body .mhl-site-footer .mhl-copyright {
    width: auto !important;
    max-width: none !important;
    left: auto !important;
    right: auto !important;
    margin-left: 0 !important;
    margin-right: 0 !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
    box-shadow: 0 0 0 100vmax #171717;
    clip-path: inset(0 -100vmax);
}

/* ALL SCREENS: back-to-top button in brand colours. */
html body #ast-scroll-top {
    background: #171717 !important;
    color: #FFFFFF !important;
    border: 1px solid #C49A42 !important;
    border-radius: 50% !important;
    outline: none !important;
}


/* ALL SCREENS: intro text on the black page banners.
   A later page-wide paragraph colour turned it dark
   grey on black; restore the intended light colour. */
html body .mhl-write-hero p,
html body .mhl-disclaimer-hero p {
    color: #E8E5DF !important;
}


@media (max-width: 767px) {

    /* -------------------------------------------------
       1. BASE
    ------------------------------------------------- */

    /* Astra shrinks all text to 91% on phones. */
    html {
        font-size: 100% !important;
        -webkit-text-size-adjust: 100%;
    }

    html,
    body {
        overflow-x: clip;
    }

    html body #content img,
    html body #content video,
    html body #content iframe {
        max-width: 100%;
    }

    html body #content {
        overflow-wrap: break-word;
    }


    /* -------------------------------------------------
       2. HEADER
       Logo + Search on the black bar; Menu + Subscribe
       on one white row; links open underneath.
    ------------------------------------------------- */

    html body .mhl-site-header {
        position: sticky !important;
        top: 0;
    }

    html body.admin-bar .mhl-site-header {
        top: 46px;
    }

    html body .mhl-site-header .mhl-top-header {
        padding: 0 !important;
    }

    html body .mhl-site-header .mhl-top-inner {
        width: auto !important;
        min-height: 56px !important;
        margin: 0 !important;
        padding: 0 16px !important;
        gap: 12px !important;
    }

    html body .mhl-site-header .mhl-top-inner .mhl-logo {
        gap: 10px !important;
        min-width: 0 !important;
    }

    html body .mhl-site-header .mhl-top-inner .mhl-logo img {
        width: 38px !important;
        height: 38px !important;
        max-width: 38px !important;
        max-height: 38px !important;
        flex: 0 0 38px !important;
    }

    html body .mhl-site-header .mhl-top-inner .mhl-logo span {
        font-size: 17px !important;
        letter-spacing: -0.2px;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    html body .mhl-site-header .mhl-top-inner .mhl-search {
        flex: 0 0 auto;
        padding: 12px 0 12px 8px;
        font-size: 14px !important;
    }

    html body .mhl-site-header .mhl-nav-inner {
        width: auto !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 8px 16px !important;
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 0 12px !important;
    }

    html body .mhl-site-header .mhl-menu-toggle {
        order: 1;
        display: inline-flex !important;
        align-items: center !important;
        min-height: 40px;
        margin: 0 !important;
        padding: 0 16px !important;
        font-size: 14px !important;
        line-height: 1 !important;
    }

    html body .mhl-site-header .mhl-subscribe-button,
    html body .mhl-site-header .mhl-nav-inner.is-open .mhl-subscribe-button {
        order: 2;
        display: inline-flex !important;
        min-height: 40px;
        margin: 0 !important;
        padding: 0 18px !important;
    }

    html body .mhl-site-header .mhl-navigation {
        order: 3;
        display: none !important;
        flex: 0 0 100% !important;
        width: 100% !important;
        padding: 0 !important;
        margin-top: 8px;
        border-top: 1px solid #EAE5DA;
        max-height: calc(100vh - 130px);
        overflow-y: auto;
    }

    html body .mhl-site-header .mhl-navigation.is-open {
        display: block !important;
    }

    html body .mhl-site-header .mhl-navigation .mhl-menu {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0 !important;
        padding: 0 !important;
    }

    html body .mhl-site-header .mhl-navigation .mhl-menu li {
        display: block !important;
        width: 100% !important;
        border-bottom: 1px solid #EAE5DA;
    }

    html body .mhl-site-header .mhl-navigation .mhl-menu li:last-child {
        border-bottom: 0;
    }

    html body .mhl-site-header .mhl-navigation .mhl-menu li > a {
        display: flex !important;
        justify-content: flex-start !important;
        min-height: 48px;
        padding: 0 2px !important;
        font-size: 16px !important;
    }


    /* -------------------------------------------------
       3. PAGE GUTTERS
       The theme, Elementor and each section all added
       their own side padding, leaving a narrow column
       of text. Use one gutter per section instead.
    ------------------------------------------------- */

    html body.page.elementor-page #content > .ast-container {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    html body.elementor-page #content .elementor > .e-con,
    html body.elementor-page #content .elementor > .e-con > .e-con-inner {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    /* Plain pages (calculators, policies): breathing room
       between the header and the page title. */
    html body.page:not(.elementor-page) #primary {
        padding-top: 28px !important;
        padding-bottom: 36px !important;
    }

    /* Articles keep one plain reading gutter. */
    html body.single-post.elementor-page #content > .ast-container {
        padding-left: 18px !important;
        padding-right: 18px !important;
    }

    html body #content .mhl-container {
        width: auto !important;
        max-width: none !important;
        padding-left: 20px !important;
        padding-right: 20px !important;
    }


    /* -------------------------------------------------
       4. HOMEPAGE
    ------------------------------------------------- */

    html body .mhl-hero-section .mhl-hero {
        padding: 28px 0 32px !important;
    }

    html body .mhl-hero-section h1 {
        font-size: 34px !important;
        letter-spacing: -1px !important;
        margin-bottom: 14px !important;
    }

    html body .mhl-hero-section .mhl-hero-card,
    html body .mhl-category-card {
        min-height: 0 !important;
        padding: 18px !important;
        border-radius: 16px !important;
    }

    html body .mhl-hero-section .mhl-hero-card h3,
    html body .mhl-category-content h3 {
        font-size: 18px !important;
        margin-bottom: 14px !important;
    }

    html body .mhl-hero-section .mhl-button,
    html body .mhl-category-button {
        padding: 11px 18px !important;
        font-size: 14px !important;
        white-space: nowrap !important;
    }

    html body .mhl-hero-section .mhl-hero-card img,
    html body .mhl-category-image {
        width: 88px !important;
        height: 88px !important;
        min-width: 88px !important;
    }

    /* Health toolkit */
    html body .mhl-calculator-section {
        padding: 32px 0 !important;
    }

    html body .mhl-calculator-container {
        width: auto !important;
        padding: 0 20px !important;
    }

    html body .mhl-calculator-heading {
        align-items: center !important;
    }

    /* Latest article + trending */
    html body .mhl-featured {
        background: #FFFFFF;
        padding: 28px 0 12px !important;
    }

    html body .mhl-featured .mhl-trending-heading {
        font-size: 24px !important;
        color: #171717 !important;
        margin: 0 0 16px !important;
    }

    html body .mhl-featured .mhl-feature-image {
        display: block;
        width: 100% !important;
        height: auto !important;
        aspect-ratio: 3 / 2;
        object-fit: cover;
        border-radius: 12px;
        margin-bottom: 12px;
    }

    html body .mhl-featured .mhl-label {
        display: inline-block;
        color: #98712D;
        font-size: 13px;
        font-weight: 600;
    }

    html body .mhl-featured .mhl-featured-main > h2:not(.mhl-trending-heading) {
        font-size: 22px !important;
        line-height: 1.3 !important;
        margin: 4px 0 8px !important;
    }

    html body .mhl-featured .mhl-featured-main .mhl-view-all {
        display: inline-flex;
        align-items: center;
        min-height: 44px;
        font-weight: 700;
    }

    html body .mhl-trending-item:last-child {
        border-bottom: 0;
        margin-bottom: 0;
    }

    /* Health topics */
    html body .mhl-category-widget {
        padding: 32px 20px !important;
    }

    html body .mhl-category-heading {
        margin-bottom: 24px !important;
    }

    html body .mhl-category-heading h2 {
        font-size: 28px !important;
    }

    html body .mhl-category-grid {
        grid-template-columns: 1fr !important;
        gap: 14px !important;
    }


    /* -------------------------------------------------
       5. FOOTER
    ------------------------------------------------- */

    html body .mhl-site-footer {
        padding-top: 36px !important;
    }

    html body .mhl-site-footer .mhl-container {
        width: auto !important;
        margin: 0 !important;
        padding: 0 20px !important;
    }

    html body .mhl-site-footer .mhl-footer-grid {
        grid-template-columns: 1fr 1fr !important;
        gap: 28px 24px !important;
        padding-bottom: 28px !important;
    }

    html body .mhl-site-footer .mhl-footer-brand {
        grid-column: 1 / -1;
    }

    html body .mhl-footer-brand-lockup img {
        width: 48px !important;
        height: 48px !important;
    }

    html body .mhl-footer-brand-lockup span {
        font-size: 20px !important;
    }

    html body .mhl-social-icons a {
        width: 44px !important;
        height: 44px !important;
    }

    html body .mhl-site-footer .mhl-footer-links h4 {
        margin-bottom: 8px !important;
        padding-bottom: 8px !important;
        border-bottom-width: 2px !important;
    }

    html body .mhl-site-footer .mhl-footer-links ul {
        list-style: none !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    html body .mhl-site-footer .mhl-footer-links li a {
        display: flex;
        align-items: center;
        min-height: 44px;
    }

    html body .mhl-site-footer .mhl-copyright {
        margin-top: 0 !important;
        padding: 18px 0 !important;
    }

    html body .mhl-site-footer .mhl-copyright p {
        font-size: 14px;
        padding-right: 56px;
    }

    html body #ast-scroll-top {
        right: 16px !important;
        bottom: 16px !important;
        width: 44px !important;
        height: 44px !important;
        line-height: 44px !important;
    }
}
