/* Phase 4A.11 visual closure — Tier 2 + Tier 3 only.
   Loaded after the core homepage bundle so presentation wins without mutating Top Banner. */

/* —— Tier 2: neutral utility surface + logical distribution —— */
.ag-dh-topbar.ag-dh-topbar--utility {
    background: #ffffff !important;
    background: var(--ag-dh-surface, #ffffff) !important;
    color: var(--ag-dh-text, #0f172a) !important;
    border-bottom: 1px solid var(--ag-dh-border, #e5e7eb) !important;
    box-shadow: none !important;
}

.ag-dh-topbar--utility .ag-dh-topbar-inner {
    display: flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: space-between !important;
    gap: var(--ag-mkt-2, 16px);
    min-height: 34px;
    width: 100%;
}

.ag-dh-topbar--utility .ag-dh-topbar-start,
.ag-dh-topbar--utility .ag-dh-topbar-end {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    white-space: nowrap;
    min-width: 0;
}

.ag-dh-topbar--utility .ag-dh-topbar-start {
    justify-content: flex-start;
    margin-inline-end: auto;
}

.ag-dh-topbar--utility .ag-dh-topbar-end {
    justify-content: flex-end;
    margin-inline-start: auto;
}

.ag-dh-topbar--utility a,
.ag-dh-topbar--utility .ag-dh-currency,
.ag-dh-topbar--utility .ag-locale-switcher__item {
    color: inherit !important;
}

@media (max-width: 575.98px) {
    .ag-dh-topbar--utility .ag-dh-topbar-start a:not([data-header-seller]) {
        display: none;
    }

    .ag-dh-topbar--utility .ag-dh-topbar-start [data-header-seller] {
        max-width: 42vw;
        overflow: hidden;
        text-overflow: ellipsis;
    }
}

/* —— Tier 3: flex row, growing search, adjacent inline actions —— */
.ag-dh-header-main {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-start !important;
    gap: var(--ag-dh-header-main-gap, 12px) !important;
    padding-block: var(--ag-dh-header-pad-y, 8px) !important;
    min-height: calc(var(--ag-dh-header-row-h, 44px) + (var(--ag-dh-header-pad-y, 8px) * 2)) !important;
    height: auto !important;
}

.ag-dh-logo {
    flex: 0 0 auto !important;
    align-self: center !important;
}

.ag-dh-search {
    flex: 1 1 auto !important;
    width: auto !important;
    min-width: min(100%, 240px) !important;
    max-width: none !important;
    align-self: center !important;
    min-height: var(--ag-dh-header-row-h, 44px) !important;
    height: var(--ag-dh-header-row-h, 44px) !important;
    max-height: var(--ag-dh-header-row-h, 44px) !important;
}

.ag-dh-header-actions {
    display: flex !important;
    flex: 0 0 auto !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: flex-end !important;
    gap: var(--ag-dh-header-action-gap, 4px) !important;
    min-height: var(--ag-dh-header-row-h, 44px) !important;
    height: var(--ag-dh-header-row-h, 44px) !important;
    max-height: var(--ag-dh-header-row-h, 44px) !important;
}

.ag-dh-header-actions > .ag-dh-account,
.ag-dh-header-actions > .ag-dh-action,
.ag-dh-header-actions a.ag-dh-action,
.ag-dh-header-actions a.ag-dh-counter-action,
.ag-dh-header-actions .ag-dh-account-toggle {
    display: inline-flex !important;
    flex-direction: row !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 6px !important;
    padding: 0 8px !important;
    min-height: var(--ag-dh-header-row-h, 44px) !important;
    height: var(--ag-dh-header-row-h, 44px) !important;
    max-height: var(--ag-dh-header-row-h, 44px) !important;
    white-space: nowrap !important;
    line-height: 1.2 !important;
}

.ag-dh-header-actions .ag-dh-account-caret {
    position: static !important;
    inset: auto !important;
    transform: none !important;
    margin-inline-start: 2px !important;
}

.ag-dh-header-actions .ag-dh-account.is-open .ag-dh-account-caret {
    transform: rotate(180deg) !important;
}

.ag-dh-header-actions .ag-dh-account-toggle > span,
.ag-dh-header-actions .ag-dh-account-toggle > .ag-dh-account-name,
.ag-dh-header-actions .ag-dh-action-label,
.ag-dh-header-actions .ag-dh-action > span {
    font-size: 0.75rem !important;
    font-weight: 700 !important;
    line-height: 1.2 !important;
}

@media (min-width: 992px) {
    .ag-dh-header.ag-dh-header--no-secondary-nav,
    .ag-dh-header:not(:has(.ag-dh-nav)) {
        min-height: 0 !important;
    }

    /* Homepage: collapse suppressed mega shell so Tier 3 has no empty bottom band. */
    .ag-sf-home .ag-dh-mega-inner {
        display: none !important;
    }

    .ag-sf-home .ag-dh-mega {
        min-height: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 0 !important;
        overflow: visible;
        background: transparent !important;
    }
}

/* CAT-5: trigger stays in DOM for shared drawer payload; hidden by default on desktop (>=992px). */
.ag-dh-mobile-cat-trigger {
    display: none !important;
}

@media (max-width: 991.98px) {
    .ag-dh-header-main {
        flex-wrap: wrap !important;
    }

    .ag-dh-search {
        flex: 1 1 100% !important;
        order: 3;
        max-width: none !important;
    }

    .ag-dh-account-name,
    .ag-dh-action-label,
    .ag-dh-account-caret {
        display: none;
    }

    .ag-dh-header--mobile-category-nav .ag-dh-mobile-cat-trigger {
        display: inline-flex !important;
        flex: 0 0 auto;
        order: 0;
        align-items: center;
        justify-content: center;
        gap: 0;
        padding: 0;
        width: var(--ag-dh-header-row-h, 44px);
        min-width: var(--ag-dh-header-row-h, 44px);
        min-height: var(--ag-dh-header-row-h, 44px);
        height: var(--ag-dh-header-row-h, 44px);
        border: 0;
        border-radius: 8px;
        background: transparent;
        color: var(--ag-dh-text, #0f172a);
        cursor: pointer;
    }

    .ag-dh-header--mobile-category-nav .ag-dh-logo {
        order: 1;
        flex: 1 1 auto;
        min-width: 0;
        max-width: none;
    }

    .ag-dh-header--mobile-category-nav .ag-dh-header-actions {
        order: 2;
        margin-inline-start: auto;
    }

    .ag-dh-header--mobile-category-nav .ag-dh-mobile-cat-trigger .bi {
        font-size: 1.5rem;
        flex-shrink: 0;
    }

    .ag-dh-header--mobile-category-nav .ag-dh-mobile-cat-trigger:focus-visible {
        outline: 2px solid var(--ag-dh-accent, #f68b1e);
        outline-offset: 2px;
    }
}

/* CAT-5 mobile marketplace drawer — scoped to mobile-nav variant only */
.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-panel {
    width: min(340px, 88vw);
    max-width: 100%;
    display: flex;
    flex-direction: column;
    padding: 0;
    overflow: hidden;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-toolbar {
    display: grid;
    grid-template-columns: 44px 1fr 44px;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    border-bottom: 1px solid var(--ag-dh-border, #e5e7eb);
    flex: 0 0 auto;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 0;
    text-decoration: none;
    color: inherit;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-logo .ag-dh-logo-img {
    max-height: 34px;
    width: auto;
    object-fit: contain;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-cart,
.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-cart-spacer {
    justify-self: end;
    width: 44px;
    height: 44px;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-cart {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: var(--ag-dh-text, #0f172a);
    text-decoration: none;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-utilities {
    border-bottom: 1px solid var(--ag-dh-border, #e5e7eb);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-utility {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    min-height: 48px;
    padding: 10px 16px;
    color: var(--ag-dh-text, #0f172a);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    border-bottom: 1px solid var(--ag-dh-border, #e5e7eb);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-utility:last-child {
    border-bottom: 0;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-section {
    padding: 12px 0 8px;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-section-title {
    margin: 0;
    padding: 8px 16px 4px;
    font-size: 0.75rem;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: var(--ag-dh-muted, #64748b);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    min-height: 48px;
    padding: 10px 16px;
    border: 0;
    background: transparent;
    color: var(--ag-dh-text, #0f172a);
    text-decoration: none;
    font-size: 0.9375rem;
    font-weight: 500;
    line-height: 1.35;
    text-align: start;
    cursor: pointer;
    box-sizing: border-box;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-row--expand {
    appearance: none;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-row--all {
    font-weight: 700;
    color: var(--ag-dh-primary, #0e7490);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-icon {
    flex: 0 0 28px;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-icon .ag-image,
.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-icon img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-icon .bi {
    font-size: 1.125rem;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-label {
    flex: 1 1 auto;
    min-width: 0;
    word-break: break-word;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-chevron {
    flex: 0 0 auto;
    font-size: 0.875rem;
    opacity: 0.65;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-footer {
    margin-top: 8px;
    padding: 8px 16px 20px;
    border-top: 1px solid var(--ag-dh-border, #e5e7eb);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-footer-link {
    display: block;
    min-height: 44px;
    padding: 10px 0;
    color: var(--ag-dh-text, #0f172a);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-subhead {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 4px;
    padding: 8px 12px 4px;
    border-bottom: 1px solid var(--ag-dh-border, #e5e7eb);
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-back {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    align-self: flex-start;
    min-height: 40px;
    padding: 4px 0;
    border: 0;
    background: transparent;
    color: var(--ag-dh-primary, #0e7490);
    font-size: 0.875rem;
    font-weight: 700;
    cursor: pointer;
}

.ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-subtitle {
    padding: 0 4px 4px;
    font-size: 1rem;
    line-height: 1.3;
}

[dir="rtl"] .ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-chevron.bi-chevron-right,
[dir="rtl"] .ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-back-icon.bi-chevron-left {
    transform: scaleX(-1);
}

[dir="rtl"] .ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-row,
[dir="rtl"] .ag-dh-mega-drawer--mobile-nav .ag-dh-mobile-drawer-utility {
    text-align: right;
}
