/* AFGHANZONE_PUBLIC_HOME_HEADER_UI_V1_0_0
   Additive public-home presentation layer only.
   Canonical address source remains Settings/MySQL via public-address-settings-v1.js.
*/

/* Keep the address compact so account/login and existing header actions retain space. */
body.az-home-v2 .header-actions {
    min-width: 0;
}

body.az-home-v2 .az-public-settings-address {
    position: relative;
    min-width: 0;
    width: clamp(132px, 10vw, 165px);
    max-width: 165px;
    flex: 0 1 165px;
    cursor: pointer;
    outline: none;
}

body.az-home-v2 .az-public-settings-address > span:not(.az-public-settings-address-popover) {
    min-width: 0;
    max-width: calc(100% - 25px);
    overflow: hidden;
}

body.az-home-v2 .az-public-settings-address .az-public-settings-address-value {
    display: block;
    max-width: 118px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Existing account/login and icon actions are protected from address flex pressure. */
body.az-home-v2 .header-actions > a.header-action[data-az-public-account-entry="true"],
body.az-home-v2 .header-actions > a.header-action[href="login.html"],
body.az-home-v2 .header-actions > .header-icon-action,
body.az-home-v2 .header-actions > #header-whatsapp {
    flex: 0 0 auto;
}

/* Full canonical address on hover/focus/click without changing stored data. */
body.az-home-v2 .az-public-settings-address-popover {
    position: absolute;
    inset-block-start: calc(100% + 9px);
    inset-inline-start: 0;
    z-index: 2147482000;
    width: max-content;
    min-width: 250px;
    max-width: min(420px, 72vw);
    padding: 10px 12px;
    border: 1px solid rgba(15, 23, 42, .12);
    border-radius: 12px;
    background: rgba(255, 255, 255, .99);
    color: #172033;
    box-shadow: 0 16px 38px rgba(15, 23, 42, .18);
    font-size: 11px;
    font-weight: 700;
    line-height: 1.75;
    text-align: start;
    white-space: normal;
    overflow-wrap: anywhere;
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transform: translateY(-4px);
    transition: opacity .14s ease, transform .14s ease, visibility .14s ease;
}

body.az-home-v2 .az-public-settings-address:hover .az-public-settings-address-popover,
body.az-home-v2 .az-public-settings-address:focus .az-public-settings-address-popover,
body.az-home-v2 .az-public-settings-address.is-expanded .az-public-settings-address-popover {
    opacity: 1;
    visibility: visible;
    transform: none;
}

body.az-home-v2 .az-public-settings-address:focus-visible {
    border-radius: 10px;
    box-shadow: 0 0 0 3px rgba(249, 115, 22, .16);
}

html[data-theme="dark"] body.az-home-v2 .az-public-settings-address-popover,
[data-theme="dark"] body.az-home-v2 .az-public-settings-address-popover {
    border-color: rgba(148, 163, 184, .22);
    background: #0f1b2b;
    color: #f8fafc;
}

/* The injected address changed :first-child semantics. Restore the old responsive intent. */
@media (max-width: 1180px) {
    body.az-home-v2 .header-actions > #header-whatsapp {
        display: none;
    }
}

@media (max-width: 1450px) and (min-width: 901px) {
    body.az-home-v2 .az-public-settings-address {
        width: 138px;
        max-width: 138px;
        flex-basis: 138px;
    }

    body.az-home-v2 .az-public-settings-address .az-public-settings-address-value {
        max-width: 94px;
    }
}

/* One visible language control on desktop:
   - If the existing top-strip proxy is confirmed wired, hide the floating duplicate.
   - If proxy wiring is unavailable, hide the non-working top trigger and keep the global working control.
   Mobile keeps the global control because the top strip is hidden by the existing responsive layout. */
@media (min-width: 901px) {
    body.az-home-v2.az-home-language-proxy-ready #az-global-language > .az-lang-icon {
        display: none !important;
    }

    body.az-home-v2.az-home-language-global-fallback #open-language-menu {
        display: none !important;
    }
}

@media (max-width: 900px) {
    body.az-home-v2 .az-public-settings-address-popover {
        display: none !important;
    }
}


/* AFGHANZONE_PUBLIC_MOBILE_HEADER_LANGUAGE_DOCK_V1_0_0
   Public home mobile-only refinement.
   Uses the existing working #open-language-menu proxy beside the brand and
   hides the duplicate floating language icon. Desktop layout is unchanged. */
@media (max-width: 900px) {
    body.az-home-v2.az-home-mobile-language-docked .header-main {
        grid-template-rows: auto auto !important;
        column-gap: 9px !important;
        row-gap: 9px !important;
        min-height: 0 !important;
        padding-top: 10px !important;
        padding-bottom: 11px !important;
        align-items: center !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked .header-main {
        grid-template-columns: 48px 42px 76px minmax(0, 1fr) !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked .header-main {
        grid-template-columns: minmax(0, 1fr) 76px 42px 48px !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked .mobile-menu-button {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked #open-language-menu.az-home-mobile-language-trigger {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked #az-home-mobile-login {
        grid-column: 3 !important;
        grid-row: 1 !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked .market-brand {
        grid-column: 4 !important;
        grid-row: 1 !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked .market-brand {
        grid-column: 1 !important;
        grid-row: 1 !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked #az-home-mobile-login {
        grid-column: 2 !important;
        grid-row: 1 !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked #open-language-menu.az-home-mobile-language-trigger {
        grid-column: 3 !important;
        grid-row: 1 !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked .mobile-menu-button {
        grid-column: 4 !important;
        grid-row: 1 !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand {
        min-width: 0 !important;
        max-width: 100% !important;
        justify-self: center !important;
        overflow: hidden !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand > span:last-child {
        min-width: 0 !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand strong,
    body.az-home-v2.az-home-mobile-language-docked .market-brand small {
        max-width: 100% !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        white-space: nowrap !important;
    }

    body.az-home-v2 #open-language-menu.az-home-mobile-language-trigger {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        justify-self: center !important;
        width: 42px !important;
        min-width: 42px !important;
        height: 42px !important;
        min-height: 42px !important;
        margin: 0 !important;
        padding: 0 !important;
        border: 1px solid #e4e7ec !important;
        border-radius: 13px !important;
        background: #fff !important;
        color: #172033 !important;
        box-shadow: 0 7px 18px rgba(15, 23, 42, .10) !important;
        font-size: 0 !important;
        line-height: 1 !important;
        overflow: hidden !important;
    }

    body.az-home-v2 #open-language-menu.az-home-mobile-language-trigger > i {
        margin: 0 !important;
        font-size: 15px !important;
        color: #172033 !important;
    }

    body.az-home-v2 #open-language-menu.az-home-mobile-language-trigger [data-az-active-language-label] {
        display: none !important;
    }

    body.az-home-v2 #az-home-mobile-login.az-home-mobile-login-trigger {
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        justify-self: center !important;
        gap: 5px !important;
        width: 76px !important;
        min-width: 76px !important;
        height: 42px !important;
        min-height: 42px !important;
        margin: 0 !important;
        padding: 0 8px !important;
        border: 1px solid #e4e7ec !important;
        border-radius: 13px !important;
        background: #fff !important;
        color: #172033 !important;
        box-shadow: 0 7px 18px rgba(15, 23, 42, .10) !important;
        text-decoration: none !important;
        line-height: 1 !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }

    body.az-home-v2 #az-home-mobile-login.az-home-mobile-login-trigger > i {
        flex: 0 0 auto !important;
        margin: 0 !important;
        font-size: 14px !important;
        color: #e85d04 !important;
    }

    body.az-home-v2 #az-home-mobile-login .az-home-mobile-login-label {
        display: inline-block !important;
        min-width: 0 !important;
        font-size: 10.5px !important;
        font-weight: 900 !important;
        color: #172033 !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
    }

    body.az-home-v2 #az-home-mobile-login[data-az-auth-state="authenticated"] {
        border-color: rgba(16, 185, 129, .28) !important;
        background: rgba(236, 253, 245, .96) !important;
    }

    body.az-home-v2 #az-home-mobile-login[data-az-auth-state="authenticated"] > i {
        color: #047857 !important;
    }

    body.az-home-v2.az-home-mobile-language-docked #az-global-language > .az-lang-icon {
        display: none !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .mobile-menu-button {
        width: 48px !important;
        height: 48px !important;
        margin: 0 !important;
        justify-self: center !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .header-search {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        margin: 0 !important;
    }
}

@media (max-width: 390px) {
    body.az-home-v2.az-home-mobile-language-docked .header-main {
        column-gap: 6px !important;
    }

    html[dir="rtl"] body.az-home-v2.az-home-mobile-language-docked .header-main {
        grid-template-columns: 46px 40px 68px minmax(0, 1fr) !important;
    }

    html[dir="ltr"] body.az-home-v2.az-home-mobile-language-docked .header-main {
        grid-template-columns: minmax(0, 1fr) 68px 40px 46px !important;
    }

    body.az-home-v2 #az-home-mobile-login.az-home-mobile-login-trigger {
        width: 68px !important;
        min-width: 68px !important;
        padding-inline: 6px !important;
    }

    body.az-home-v2 #az-home-mobile-login .az-home-mobile-login-label {
        font-size: 9.5px !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand {
        justify-self: start !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand strong {
        font-size: 17px !important;
    }

    body.az-home-v2.az-home-mobile-language-docked .market-brand small {
        font-size: 7px !important;
    }
}

/* __KZ_PUBLIC_ACCOUNT_ALWAYS_VISIBLE_V1__ */

@media (min-width: 901px) {
    body.az-home-v2 .header-actions > a.header-action[data-az-public-account-entry="true"] {
        display: flex !important;
        visibility: visible !important;
        opacity: 1 !important;
        flex: 0 0 auto !important;
        min-width: 86px;
        max-width: none;
        overflow: visible;
    }

    body.az-home-v2 .header-actions > a.header-action[data-az-public-account-entry="true"] > span {
        display: block !important;
        white-space: nowrap;
    }
}
