/* ==========================================================================
   منوی برند سربرگ

   Kept in its own file instead of the generated style.min.css so the feature
   works right away, without waiting for the "بازسازی فایل‌ها" rebuild.
   ========================================================================== */

/* --------------------------------------------------------------------------
   دسکتاپ — بازشونده برند

   Desktop only: on mobile the theme turns every sub-menu into an accordion
   that is hidden until the item gets .open-sub-menu, and a display rule here
   would out-specify that and leave the panel permanently open.
   -------------------------------------------------------------------------- */

@media (min-width: 1025px) {
    /* The grid is a single <li> filling the dropdown, so the sub-menu's own
       column rules (mega-cols-N, the simple dropdown width) must not apply. */
    .navbar-nav > li.menu-type-brand > ul.brand-sub-menu {
        display: block;
        width: 100%;
        right: 0;
    }

    .navbar-nav > li.menu-type-brand > ul > li.header-brands-item {
        width: 100%;
        list-style: none;
    }
}

/* "نمایش تمام برندها" — a plain row above the grid, without the underline the
   theme gives first-level sub-menu links. */
.navbar-nav .header-brands-all {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin: 0 0 12px;
    padding: 0;
    font-size: 13px;
    font-weight: 700;
    color: var(--c-1);
}

.navbar-nav .header-brands-all::after,
.navbar-nav .header-brands-all::before {
    display: none;
}

.navbar-nav .header-brands-all .icon {
    width: 14px;
    height: 14px;
}

/* --------------------------------------------------------------------------
   شبکه برندها
   -------------------------------------------------------------------------- */

/* The scrolling panel. Its max-height is written inline from the header
   settings, because the sticky header would otherwise be covered by a long
   list; the viewport cap here keeps it on screen on short screens too. */
.header-brands-grid {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    align-content: flex-start;
    gap: 4px;
    max-height: calc(100vh - 160px);
    overflow-y: auto;
    overscroll-behavior: contain;
}

.header-brands-grid::-webkit-scrollbar {
    width: 6px;
}

.header-brands-grid::-webkit-scrollbar-thumb {
    background: var(--c-3);
    border-radius: 6px;
}

.navbar-nav .header-brand-item {
    flex: 0 0 130px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 8px;
    margin: 0;
    border-radius: var(--br-1, 8px);
    color: var(--c-4);
    text-align: center;
    transition: background-color .2s ease-in-out, color .2s ease-in-out;
}

.navbar-nav .header-brand-item:hover {
    background: var(--c-5, #f5f5f5);
    color: var(--c-1);
}

.navbar-nav .header-brand-item::after,
.navbar-nav .header-brand-item::before {
    display: none !important;
}

.navbar-nav .header-brand-item img {
    max-height: 52px;
    width: auto;
    margin: 0 auto;
    object-fit: contain;
    display: block;
}

.navbar-nav .header-brand-name {
    font-size: 12px;
    line-height: 1.6;
    font-weight: 500;
}

/* A brand with no logo is only its name, so it takes the height the logo
   would have to keep the row even. */
.navbar-nav .header-brand-noimg {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 52px;
    font-weight: 700;
}

/* --------------------------------------------------------------------------
   موبایل

   The slide-in menu scrolls as a whole, so the panel drops its own height cap
   and the tiles go three, then two, to a row.
   -------------------------------------------------------------------------- */

@media (max-width: 1024px) {
    .header-menu.active .header-brands-grid {
        max-height: none !important;
        overflow-y: visible;
        gap: 4px 0;
        padding: 0 10px 10px;
    }

    .header-menu.active .navbar-nav .header-brand-item {
        flex: 0 0 33.3333%;
        padding: 8px 4px;
    }

    .header-menu.active .navbar-nav .header-brand-item img {
        max-height: 40px;
    }

    .header-menu.active .navbar-nav .header-brands-all {
        margin: 0 0 6px;
        padding: 0 10px;
    }

    .header-menu.active .navbar-nav .header-brand-noimg {
        min-height: 40px;
    }
}

@media (max-width: 480px) {
    .header-menu.active .navbar-nav .header-brand-item {
        flex: 0 0 50%;
    }
}
