/*
   Storefront mobile navigation
   Keep the action row, search field and expanded navigation in separate grid
   rows.  Earlier theme layers used the same grid row for search and navigation
   at compact widths, which allowed both surfaces to overlap.
*/

@media (max-width: 1180px) {
    body.customer-surface.marketplace-surface .market-header-main {
        grid-template-columns: auto auto minmax(0, 1fr);
        grid-template-rows: auto auto auto;
        align-items: center;
        column-gap: 12px;
        row-gap: 10px;
        padding-block: 12px;
    }

    body.customer-surface.marketplace-surface .market-brand {
        grid-column: 1;
        grid-row: 1;
    }

    body.customer-surface.marketplace-surface .market-menu-toggle {
        grid-column: 2;
        grid-row: 1;
        display: grid;
    }

    body.customer-surface.marketplace-surface .market-actions {
        grid-column: 3;
        grid-row: 1;
        min-width: 0;
    }

    body.customer-surface.marketplace-surface .market-search {
        grid-column: 1 / -1;
        grid-row: 2;
        order: initial;
        width: 100%;
    }

    body.customer-surface.marketplace-surface .market-navigation {
        grid-column: 1 / -1;
        grid-row: 3;
        order: initial;
        width: 100%;
        display: none;
        border-top: 1px solid var(--cw-line);
    }

    body.customer-surface.marketplace-surface.market-nav-open .market-navigation {
        display: block;
    }

    body.customer-surface.marketplace-surface .market-navigation-inner {
        min-height: 0;
        display: block;
        padding: 10px 0 4px;
    }

    body.customer-surface.marketplace-surface .market-primary-nav {
        display: grid;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: stretch;
        justify-content: stretch;
        gap: 8px;
        max-width: none;
        overflow: visible;
    }

    body.customer-surface.marketplace-surface .market-primary-nav a {
        box-sizing: border-box;
        width: 100%;
        min-height: 44px;
        display: flex;
        align-items: center;
        justify-content: flex-start;
        gap: 8px;
        padding: 0 12px;
        border: 1px solid transparent;
        border-radius: 8px;
        white-space: nowrap;
    }

    body.customer-surface.marketplace-surface .market-primary-nav a span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    body.customer-surface.marketplace-surface .market-primary-nav a:hover,
    body.customer-surface.marketplace-surface .market-primary-nav a:focus-visible,
    body.customer-surface.marketplace-surface .market-primary-nav a.active,
    body.customer-surface.marketplace-surface .market-primary-nav a[aria-current="page"] {
        padding: 0 12px;
        border-color: var(--cw-brand-border);
        border-bottom-color: var(--cw-brand-border);
        border-left-color: var(--cw-brand-border);
        background: var(--cw-brand-soft);
        color: var(--cw-brand-hover);
    }
}

@media (max-width: 640px) {
    body.customer-surface.marketplace-surface .market-header-main {
        column-gap: 8px;
        row-gap: 9px;
    }

    body.customer-surface.marketplace-surface .market-actions {
        gap: 4px;
    }

    body.customer-surface.marketplace-surface .market-primary-nav {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
    }

    body.customer-surface.marketplace-surface .market-primary-nav a {
        min-height: 43px;
        gap: 7px;
        padding-inline: 10px;
        font-size: 12px;
    }

    body.customer-surface.marketplace-surface .market-primary-nav a:hover,
    body.customer-surface.marketplace-surface .market-primary-nav a:focus-visible,
    body.customer-surface.marketplace-surface .market-primary-nav a.active,
    body.customer-surface.marketplace-surface .market-primary-nav a[aria-current="page"] {
        padding-inline: 10px;
    }

    /*
       The account popover starts below both compact header rows.  Keeping the
       search field visible gives users a clear way to close or change context,
       while the panel itself can scroll independently on short screens.
    */
    body.customer-surface.marketplace-surface .market-account-dropdown {
        top: 144px;
        right: 12px;
        left: 12px;
        width: auto;
        max-height: calc(100dvh - 156px);
        overscroll-behavior: contain;
        scrollbar-gutter: stable;
    }

    body.customer-surface.marketplace-surface .market-account-user-card {
        grid-template-columns: 42px minmax(0, 1fr);
        gap: 10px;
        margin: 10px;
        padding: 10px;
        border-radius: 12px;
    }

    body.customer-surface.marketplace-surface .market-account-avatar-large {
        width: 42px;
        height: 42px;
        flex-basis: 42px;
        font-size: 13px;
    }

    body.customer-surface.marketplace-surface .market-account-user-copy strong {
        font-size: 13px;
    }

    body.customer-surface.marketplace-surface .market-account-user-copy small {
        font-size: 10px;
    }

    body.customer-surface.marketplace-surface .market-account-user-copy mark {
        min-height: 21px;
        margin-top: 5px;
        padding: 2px 7px;
        font-size: 9px;
    }

    body.customer-surface.marketplace-surface .market-account-preferences {
        gap: 10px;
        margin: 0 10px;
        padding: 10px 0;
    }

    body.customer-surface.marketplace-surface .market-language-row {
        grid-template-columns: 1fr;
        gap: 6px;
    }

    body.customer-surface.marketplace-surface .market-language-switch {
        display: grid;
        grid-template-columns: minmax(0, 1fr) auto;
        align-items: center;
        width: 100%;
    }

    body.customer-surface.marketplace-surface .market-language-switch select {
        min-width: 0;
        width: 100%;
        height: 34px;
    }

    body.customer-surface.marketplace-surface .market-language-switch button {
        min-width: 72px;
        height: 34px;
        padding-inline: 9px;
        white-space: nowrap;
    }

    body.customer-surface.marketplace-surface .market-theme-switch {
        gap: 6px;
    }

    body.customer-surface.marketplace-surface .market-theme-switch button {
        min-height: 36px;
        padding-inline: 6px;
        font-size: 10px;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown nav.market-account-links {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 7px;
        padding: 10px;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown nav.market-account-links a {
        min-width: 0;
        min-height: 40px;
        display: flex;
        align-items: center;
        gap: 7px;
        padding: 7px 9px;
        font-size: 11px;
        line-height: 1.2;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown nav.market-account-links a .ui-icon {
        width: 16px;
        height: 16px;
        flex: 0 0 16px;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown nav.market-account-links .market-account-admin-link {
        grid-column: 1 / -1;
        width: 100%;
        min-width: 0;
        flex: 1 1 auto;
        justify-content: center;
        padding: 7px 9px;
        white-space: nowrap;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown > form.market-account-logout {
        padding: 2px 10px 10px;
    }

    body.customer-surface.marketplace-surface .market-account-dropdown > form.market-account-logout button {
        width: 100%;
        min-height: 40px;
        justify-content: center;
        border: 1px solid color-mix(in srgb, var(--cw-danger) 28%, transparent);
        background: var(--cw-danger-soft);
        font-size: 11px;
        font-weight: 750;
    }
}
