/* Mahdafzar Blog Pro 1.5.1 — coordinated with Header & Hero 1.2.0.
   This layer is enqueued only on Blog Pro pages and only while Header & Hero is enabled.
   It does not restyle the header/hero itself; it coordinates spacing, active navigation and modal layers. */

body.mmbp-blog-page.mmbp-with-header-hero {
    --mmbp-header-anchor-offset: 108px;
    --mmbp-header-sidebar-offset: 82px;
}

/* Keep the global header and its mega menu above archive/article content. */
body.mmbp-with-header-hero .mmx-header {
    isolation: isolate;
}
body.mmbp-with-header-hero .mmx-header .mmx-mega {
    z-index: 12;
}

/* Mark the magazine destination in both the WP menu and generated fallback menu. */
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li > a.active,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current-menu-item > a,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current_page_item > a,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current_page_parent > a,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current-menu-ancestor > a {
    color: #3e3e3e !important;
}
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li > a.active::before,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current-menu-item > a::before,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current_page_item > a::before,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current_page_parent > a::before,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-nav > li.current-menu-ancestor > a::before {
    content: "";
    position: absolute;
    inset-inline: 14px;
    bottom: 0;
    height: 2px;
    border-radius: 4px;
    background: #ec2323;
}
body.mmbp-blog-page.mmbp-with-header-hero .mmx-drawer a.is-current,
body.mmbp-blog-page.mmbp-with-header-hero .mmx-drawer a[aria-current="page"],
body.mmbp-blog-page.mmbp-with-header-hero .mmx-drawer a[aria-current="location"] {
    color: #3e3e3e !important;
    border-color: #e7e7e7 !important;
    background: #f3f3f3 !important;
    box-shadow: inset -3px 0 0 #ec2323;
}

/* Explicit global interaction order:
   mobile backdrop 3000 < drawer 3001 < article lightbox 3002 < Smart Search 3005. */
body.mmbp-with-header-hero .mmx-overlay {
    z-index: 2147483000 !important;
}
body.mmbp-with-header-hero .mmx-drawer {
    z-index: 2147483001 !important;
}
body.mmbp-with-header-hero .mmbpr-lightbox {
    z-index: 2147483002 !important;
}
body.mmbp-with-header-hero .mmx-search-modal {
    z-index: 2147483005 !important;
}

/* Reading helpers remain below the header and do not cover its menu or controls. */
body.mmbp-with-header-hero .mmbp .mmbp-reading-progress {
    z-index: 40 !important;
}
body.mmbp-with-header-hero .mmbp .mmbp-toast,
body.mmbp-with-header-hero .mmbpr-feedback {
    z-index: 60 !important;
}
body.mmbp-with-header-hero .mmbpr .mmbpr-up {
    z-index: 45 !important;
}

/* Sticky article tools stop below the compact desktop header. */
body.mmbp-with-header-hero .mmbpr .mmbpr-sidebar {
    top: calc(var(--mmbp-header-sidebar-offset) + var(--wp-admin--admin-bar--height, 0px)) !important;
    max-height: calc(100dvh - 104px - var(--wp-admin--admin-bar--height, 0px)) !important;
}

/* Anchor navigation from the TOC and comment links clears the sticky header. */
body.mmbp-with-header-hero .mmbpr .mmbpr-content :is(h2, h3, h4, h5, h6),
body.mmbp-with-header-hero .mmbpr .mmbpr-comments,
body.mmbp-with-header-hero .mmbp-archive #mmbp-articles {
    scroll-margin-top: calc(var(--mmbp-header-anchor-offset) + var(--wp-admin--admin-bar--height, 0px));
}
body.mmbp-with-header-hero .mmbp.mmbp-archive,
body.mmbp-with-header-hero .mmbp.mmbpr {
    scroll-margin-top: calc(86px + var(--wp-admin--admin-bar--height, 0px));
}

/* When WordPress uses its posts index as the front page, the real-estate hero
   is hidden only on this blog route. The Blog Pro magazine hero stays visible. */
body.mmbp-blog-page.mmh-frontpage .mmx-hero {
    display: none !important;
}
body.mmbp-blog-page.mmh-frontpage .mmx-header-spacer {
    display: block !important;
    height: calc(152px + var(--wp-admin--admin-bar--height, 0px)) !important;
}

@media (max-width: 950px) {
    body.mmbp-with-header-hero .mmbpr .mmbpr-sidebar {
        top: auto !important;
        max-height: none !important;
    }
    body.mmbp-with-header-hero .mmbpr .mmbpr-content :is(h2, h3, h4, h5, h6),
    body.mmbp-with-header-hero .mmbpr .mmbpr-comments,
    body.mmbp-with-header-hero .mmbp-archive #mmbp-articles {
        scroll-margin-top: calc(100px + var(--wp-admin--admin-bar--height, 0px));
    }
}

@media (max-width: 900px) {
    /* Header & Hero becomes fixed on phones; reserve its real compact height. */
    body.mmbp-blog-page.mmh-active:not(.mmh-frontpage) .mmx-header-spacer {
        display: block !important;
        height: calc(84px + var(--wp-admin--admin-bar--height, 0px)) !important;
    }
    body.mmbp-blog-page.mmh-frontpage .mmx-header-spacer {
        height: calc(84px + var(--wp-admin--admin-bar--height, 0px)) !important;
    }
    body.mmbp-with-header-hero .mmx-drawer {
        padding-bottom: calc(22px + env(safe-area-inset-bottom, 0px));
    }
    body.mmbp-with-header-hero .mmbpr-lightbox {
        padding: calc(58px + env(safe-area-inset-top, 0px)) 12px calc(16px + env(safe-area-inset-bottom, 0px));
    }
    body.mmbp-with-header-hero .mmbpr-lightbox > img {
        max-width: 100%;
        max-height: calc(100dvh - 94px - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    }
    body.mmbp-with-header-hero .mmbpr-lightbox button {
        top: calc(12px + env(safe-area-inset-top, 0px));
        left: 12px;
    }
}

@media (max-width: 620px) {
    body.mmbp-blog-page.mmh-active:not(.mmh-frontpage) .mmx-header-spacer,
    body.mmbp-blog-page.mmh-frontpage .mmx-header-spacer {
        height: calc(77px + var(--wp-admin--admin-bar--height, 0px)) !important;
    }
}

@media (prefers-reduced-motion: reduce) {
    body.mmbp-with-header-hero .mmbp :is(a, button, input, select, details, summary),
    body.mmbp-with-header-hero .mmbpr-lightbox {
        scroll-behavior: auto !important;
        transition-duration: 0.01ms !important;
        animation-duration: 0.01ms !important;
    }
}
