/* Keep the mobile header in flow. The open disclosure overlays the content. */
@media (max-width: 1279px) {
    body > header:has(> .ehsami-mobile-menu) {
        position: sticky;
        top: 0;
    }

    body:has(> header > .ehsami-mobile-menu) > main {
        padding-top: 0 !important;
    }

    body:has(> header > .ehsami-mobile-menu) > main.tool-public:not(:has(> .eh-subhero, > .eh-magazine-hero)),
    body:has(> header > .ehsami-mobile-menu) > main.ops-public-content {
        padding-top: 1.25rem !important;
    }

    body.eh-flow:has(> header > .ehsami-mobile-menu) > main.eh-intake-grid {
        padding-top: clamp(1.25rem, 4vw, 3rem) !important;
    }

    header > .ehsami-mobile-menu {
        padding: 0 clamp(.75rem, 4vw, 2rem);
        border-block-start: 1px solid #dfe9ed;
    }

    header > .ehsami-mobile-menu summary {
        box-sizing: border-box;
        min-block-size: 44px;
        padding: .55rem .3rem;
        line-height: 1.7;
        font-weight: 750;
    }

    header > .ehsami-mobile-menu nav {
        position: absolute;
        z-index: 1;
        inset: 100% 0 auto;
        max-height: 65vh;
        max-height: min(65dvh, 28rem);
        padding: .45rem clamp(.75rem, 4vw, 2rem);
        overflow-y: auto;
        overscroll-behavior: contain;
        background: #fff;
        border-block-end: 1px solid #dfe9ed;
        box-shadow: 0 12px 18px #0a26351a;
    }

    header > .ehsami-mobile-menu:not([open]) nav { display: none; }

    header > .ehsami-mobile-menu nav a {
        display: flex;
        align-items: center;
        min-height: 44px;
        box-sizing: border-box;
    }

    body:has(> header > .ehsami-mobile-menu) main [id] { scroll-margin-top: 8rem; }
}

@media (max-width: 767px) {
    header:has(> .ehsami-mobile-menu) > div:first-child {
        min-width: 0;
        height: 4rem;
        gap: .45rem;
    }

    header:has(> .ehsami-mobile-menu) > div:first-child > div { min-width: 0; gap: .35rem; }

    header:has(> .ehsami-mobile-menu) a[data-path="home"] img {
        max-inline-size: clamp(5.5rem, 29vw, 7.5rem);
        max-block-size: 2.6rem;
        object-fit: contain;
    }

    header:has(> .ehsami-mobile-menu) a[data-path="start-partnership"] {
        min-block-size: 44px;
        padding-inline: .65rem;
        font-size: .82rem;
        white-space: nowrap;
    }

    header:has(> .ehsami-mobile-menu) a[aria-label="حساب کاربری"] {
        min-inline-size: 44px;
        min-block-size: 44px;
        flex: none;
        margin-inline: 0;
    }

    :is(.eh-organization-hero__copy, .eh-subhero__copy, .mag-hero, .mag-article-heading) h1 {
        font-size: clamp(1.45rem, 4.6vw + .55rem, 1.85rem) !important;
        line-height: 1.5 !important;
        overflow-wrap: anywhere;
    }

    :is(.eh-organization-hero__copy, .eh-organization-hero__summary, .eh-subhero__copy, .mag-hero) {
        min-inline-size: 0;
        max-inline-size: 100%;
        overflow-wrap: anywhere;
    }

    .eh-organization-hero__copy > :last-child > a {
        min-block-size: 44px;
        flex: 1 1 9.5rem;
        justify-content: center;
        text-align: center;
    }

    .eh-subhero--work > .eh-subhero__inner {
        min-block-size: clamp(16rem, 65vw, 19rem);
    }

    .eh-subhero-listing__body,
    .ops-public-content {
        padding-inline: clamp(.875rem, 4vw, 1.5rem);
    }

    :is(.ops-public-content, .eh-app-main, .ops-workspace, #selected-projects) .ops-grid {
        grid-template-columns: minmax(0, 1fr);
    }

    :is(.tool-wrap, .magazine-prose, .ops-public-content, .eh-app-main, .ops-workspace) {
        min-inline-size: 0;
        overflow-wrap: anywhere;
    }

    :is(.tool-wrap, .ops-public-content, .magazine-prose) :is(img, video, iframe) {
        max-inline-size: 100%;
    }

    :is(.tool-wrap, .ops-public-content, .magazine-prose) :is(img, video) { height: auto; }
    .magazine-prose pre { max-inline-size: 100%; overflow-x: auto; }

    :is(.mag-search, .tool-url-row, .eh-audit-row) {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
    }

    :is(.mag-search, .tool-url-row, .eh-audit-row) button { inline-size: 100%; }

    :is(main, .access-card) :is(input:not([type=hidden]):not([type=checkbox]):not([type=radio]), select, textarea) {
        box-sizing: border-box;
        min-inline-size: 0;
        max-inline-size: 100%;
        font-size: 16px;
    }

    :is(.tool-public, .eh-flow, .eh-app-main, .ops-workspace, .access-card, .ops-login) :is(button, .admin-button),
    :is(.eh-mobile-menu, .ops-mobile-nav) :is(summary, nav a),
    .mag-categories a {
        min-block-size: 44px;
        white-space: normal;
    }

    .mag-categories a { align-items: center; }

    :is(.eh-app-header, .eh-app-actions, .eh-section-head, .ops-actions) {
        flex-wrap: wrap;
        min-inline-size: 0;
    }

    :is(.eh-table-scroll, .admin-table-wrap, .ops-table, .monitor-table-wrap, .eh-mobile-table) {
        max-inline-size: 100%;
        min-inline-size: 0;
        overflow-x: auto;
        overscroll-behavior-inline: contain;
    }

    .eh-mobile-table > table { min-inline-size: 28rem; }
}

@media (max-width: 1279px) {
    :is(.ehsami-mobile-menu, .eh-mobile-menu, .ops-mobile-nav) :is(summary, a):focus-visible,
    .eh-mobile-table:focus-visible {
        outline: 2px solid #087d79;
        outline-offset: -2px;
    }
}
