/* Mobile header corners layout.
 * Applies below lg, and also when JS adds .header-force-mobile (narrow desktop overflow). */

@media (max-width: 991.98px) {
    .mobile-header-stack {
        display: flex;
        flex-direction: column;
        align-items: stretch;
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    #kalles-section-header_top .mobile-header-stack,
    #kalles-section-header_top .hmst-mobile-nav,
    #kalles-section-header_top .navbar-wrapper > .d-lg-none {
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .mobile-header-languages-row {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.35rem;
        width: 100%;
        padding: 0.25rem 0 0.75rem;
        margin-bottom: 0.15rem;
        box-sizing: border-box;
    }

    .mobile-header-languages-row .site-language-switcher {
        display: inline-flex;
        flex-wrap: wrap;
        align-items: center;
        justify-content: flex-end;
        gap: 0.35rem;
    }

    .mobile-header-languages-row .site-language-switcher__item,
    .mobile-header-languages-row .site-language-switcher__link,
    .mobile-header-languages-row .site-language-switcher__current {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .mobile-header-languages-row .site-language-switcher__sep {
        display: none;
    }

    .mobile-header-corners-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0.25rem;
        width: 100%;
        padding: 4px 0 0 !important;
        box-sizing: border-box;
        flex: 0 0 auto;
        overflow: visible !important;
    }

    .mobile-header-corners-row .mobile-header-menu-btn {
        order: 0 !important;
    }

    .mobile-header-corners-row .mobile-header-right-cluster {
        order: 1 !important;
    }

    .mobile-header-right-cluster {
        display: flex;
        align-items: center;
        justify-content: flex-end;
        gap: 0.25rem;
        min-width: 0;
        flex: 1 1 auto;
        flex-wrap: nowrap !important;
        overflow: visible !important;
    }

    .mobile-header-search-row {
        flex: 0 0 auto;
        width: 100%;
        box-sizing: border-box;
    }

    .hmst-mobile-nav {
        display: flex !important;
        flex-direction: column !important;
        align-items: stretch !important;
        flex-wrap: nowrap !important;
    }

    /*
     * Search breathing inset: prefer parent .container-fluid (12px), same as scrolled compact bar.
     * Fallback when a search row is still a direct child of .navbar-wrapper / hmst-mobile-nav.
     */
    #kalles-section-header_top .navbar-wrapper > .mobile-header-search-row,
    .header-menu-search-toolbar-block .hmst-mobile-nav .mobile-header-search-row {
        padding-left: 12px;
        padding-right: 12px;
    }

    /* When search lives inside .mobile-header-stack (MenuCenteredIcon), inset comes from .container-fluid only */
    #kalles-section-header_top .mobile-header-stack > .mobile-header-search-row {
        padding-left: 0;
        padding-right: 0;
    }

    .mobile-header-corners-row .mobile-header-logo-col {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        overflow: hidden;
    }

    .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-link {
        margin: 0;
        display: flex;
        align-items: center;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-wrap {
        display: block;
        max-width: 100%;
        min-width: 0;
    }

    .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-link img,
    .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-img {
        max-height: 2.85rem;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }

    .mobile-header-corners-row .mobile-header-icons-col,
    .mobile-header-corners-row .mobile-header-icons-col.topbar-toolbar,
    .mobile-header-stack .topbar-toolbar.mobile-header-icons-col {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        gap: 0.2rem !important;
        min-width: 0;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
        overflow: visible !important;
    }

    .mobile-header-corners-row .mobile-header-menu-btn {
        flex: 0 0 auto;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 0.125rem 0 0.125rem 0 !important;
        min-width: 1.75rem;
        min-height: 1.75rem;
        margin: 0;
        line-height: 1;
    }

    .mobile-header-corners-row .mobile-header-menu-btn svg,
    .mobile-header-corners-row .mobile-header-menu-btn svg rect {
        fill: var(--header-main-text, currentColor) !important;
    }

    .mobile-header-corners-row .mobile-header-icons-col > a,
    .mobile-header-corners-row .mobile-header-icons-col .btn-link,
    .mobile-header-corners-row .mobile-header-icons-col .toolbar-item,
    .mobile-header-corners-row .mobile-header-right-cluster > a {
        width: 1.75rem !important;
        min-width: 1.75rem !important;
        height: 1.75rem !important;
        min-height: 1.75rem !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0 !important;
        position: relative !important;
        overflow: visible !important;
    }

    .mobile-header-corners-row .mobile-header-icons-col i {
        font-size: 1.05rem !important;
    }

    .mobile-header-corners-row .cart-count,
    .mobile-header-corners-row .wishlist-count,
    .mobile-header-corners-row .toolbar-icon-badge,
    .mobile-header-corners-row .notification-badge {
        position: absolute !important;
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        max-width: 16px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        line-height: 1 !important;
        font-size: 9px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        aspect-ratio: 1 / 1;
        box-sizing: border-box !important;
        top: -2px !important;
        right: -2px !important;
        z-index: 3 !important;
        overflow: visible !important;
        pointer-events: none;
    }

    .mobile-header-stack,
    .mobile-header-stack .hmst-mobile-nav,
    .mobile-header-stack .navbar-wrapper,
    .mobile-header-stack .header-container {
        overflow: visible !important;
    }

    /* Hide duplicate mobile-menu toolbar icon when dedicated hamburger is present */
    .mobile-header-corners-row ~ .mobile-header-stack .mobile-header-icons-col a[href="#offcanvasExample"],
    .mobile-header-stack .mobile-header-icons-col a[href="#offcanvasExample"],
    .mobile-header-stack .mobile-header-right-cluster a[href="#offcanvasExample"] {
        display: none !important;
    }
}

/* Same layout when overflow JS forces hamburger above the lg breakpoint */
@media (min-width: 992px) {
    .header-force-mobile .mobile-header-stack {
        display: flex !important;
        flex-direction: column;
        align-items: stretch;
        width: 100% !important;
        max-width: 100% !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        overflow: visible !important;
    }

    .header-force-mobile .mobile-header-languages-row {
        display: flex;
        justify-content: flex-end;
        align-items: center;
        flex-wrap: wrap;
        gap: 0.35rem;
        width: 100%;
        padding: 0.25rem 0 0.75rem;
        margin-bottom: 0.15rem;
        box-sizing: border-box;
    }

    .header-force-mobile .mobile-header-corners-row {
        display: flex !important;
        flex-direction: row !important;
        flex-wrap: nowrap !important;
        align-items: center !important;
        justify-content: flex-start !important;
        gap: 0.25rem;
        width: 100%;
        padding: 4px 0 0 !important;
        box-sizing: border-box;
        flex: 0 0 auto;
        overflow: visible !important;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-menu-btn {
        order: 0 !important;
        flex: 0 0 auto;
        flex-shrink: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 0.125rem 0 !important;
        min-width: 1.75rem;
        min-height: 1.75rem;
        margin: 0;
        line-height: 1;
    }

    .header-force-mobile .mobile-header-right-cluster {
        order: 1 !important;
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        gap: 0.25rem;
        min-width: 0;
        flex: 1 1 auto;
        flex-wrap: nowrap !important;
        overflow: visible !important;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-logo-col {
        flex: 1 1 0;
        min-width: 0;
        max-width: none;
        overflow: hidden;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-link {
        margin: 0;
        display: flex;
        align-items: center;
        width: 100%;
        max-width: 100%;
        min-width: 0;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-link img,
    .header-force-mobile .mobile-header-corners-row .mobile-header-logo-col .header-block-logo-img {
        max-height: 2.85rem;
        width: auto !important;
        max-width: 100% !important;
        height: auto !important;
        object-fit: contain;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col,
    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col.topbar-toolbar,
    .header-force-mobile .mobile-header-stack .topbar-toolbar.mobile-header-icons-col {
        display: flex !important;
        align-items: center;
        justify-content: flex-end;
        gap: 0.2rem !important;
        min-width: 0;
        flex: 0 0 auto !important;
        flex-shrink: 0 !important;
        flex-wrap: nowrap !important;
        overflow: visible !important;
        margin-left: auto;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col > a,
    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col .btn-link,
    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col .toolbar-item,
    .header-force-mobile .mobile-header-corners-row .mobile-header-right-cluster > a {
        width: 1.75rem !important;
        min-width: 1.75rem !important;
        height: 1.75rem !important;
        min-height: 1.75rem !important;
        padding: 0 !important;
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        flex-shrink: 0 !important;
        position: relative !important;
        overflow: visible !important;
    }

    .header-force-mobile .mobile-header-corners-row .mobile-header-icons-col i {
        font-size: 1.05rem !important;
    }

    .header-force-mobile .mobile-header-corners-row .cart-count,
    .header-force-mobile .mobile-header-corners-row .wishlist-count,
    .header-force-mobile .mobile-header-corners-row .toolbar-icon-badge,
    .header-force-mobile .mobile-header-corners-row .notification-badge {
        position: absolute !important;
        width: 16px !important;
        height: 16px !important;
        min-width: 16px !important;
        max-width: 16px !important;
        padding: 0 !important;
        border-radius: 50% !important;
        line-height: 1 !important;
        font-size: 9px !important;
        display: inline-flex !important;
        align-items: center !important;
        justify-content: center !important;
        aspect-ratio: 1 / 1;
        box-sizing: border-box !important;
        top: -2px !important;
        right: -2px !important;
        z-index: 3 !important;
        overflow: visible !important;
        pointer-events: none;
    }

    .header-force-mobile .mobile-header-stack .mobile-header-icons-col a[href="#offcanvasExample"],
    .header-force-mobile .mobile-header-stack .mobile-header-right-cluster a[href="#offcanvasExample"] {
        display: none !important;
    }
}
