/* =========================================================
   BROWN TROUT DYNAMIC MEGA MENU
   CLEAN CSS
   ========================================================= */


/* =========================================================
   1. ROOT / FLATSOME RESET
   ========================================================= */

#bt-mega-menu-root {
    position: relative !important;
    width: 100% !important;
    height: 0 !important;
    margin: 0 !important;
    padding: 0 !important;
    pointer-events: none;
    z-index: 99990;
}

#bt-mega-menu-root .section,
#bt-mega-menu-root .section-content,
#bt-mega-menu-root .row,
#bt-mega-menu-root .col,
#bt-mega-menu-root .col-inner {
    box-sizing: border-box !important;
}

#bt-mega-menu-root .section,
#bt-mega-menu-root .section-content,
#bt-mega-menu-root .row,
#bt-mega-menu-root .col,
#bt-mega-menu-root .col-inner {
    margin-top: 0 !important;
    margin-bottom: 0 !important;
    padding-top: 0 !important;
    padding-bottom: 0 !important;
}

#bt-mega-menu-root .section-content,
#bt-mega-menu-root .col-inner {
    padding-left: 0 !important;
    padding-right: 0 !important;
}


/* =========================================================
   2. MAIN MEGA MENU PANEL
   IMPORTANT: HEIGHT IS CONTENT-BASED
   ========================================================= */

#bt-dynamic-mega-menu {
    display: none;

    position: fixed !important;

    top: 90px !important;
    left: 50% !important;

    transform: translateX(-50%) !important;

    width: calc(100% - 200px) !important;
    max-width: 1700px !important;

    /* IMPORTANT WHITE-SPACE FIX */
    height: auto !important;
    min-height: 0 !important;

    /* Never become taller than available screen */
    max-height: calc(100vh - 90px) !important;

    margin: 0 !important;
    padding: 0 !important;

    background: #fff !important;

    overflow: hidden !important;

    pointer-events: auto;

    z-index: 99999;

    box-sizing: border-box !important;

    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.18);
}


/* Open menu */

#bt-dynamic-mega-menu.bt-mega-open {
    display: block !important;
}


/* =========================================================
   3. CONTENT
   ========================================================= */

#bt-mega-content {
    display: block !important;

    width: 100% !important;

    /* IMPORTANT WHITE-SPACE FIX */
    height: auto !important;
    min-height: 0 !important;

    max-height: calc(100vh - 90px) !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    box-sizing: border-box !important;

    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;

    scrollbar-width: none;
    -ms-overflow-style: none;
}

#bt-mega-content::-webkit-scrollbar {
    display: none;
}


/* =========================================================
   4. PRODUCT GRID
   ========================================================= */

#bt-mega-content .bt-product-categories {
    display: grid !important;

    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;

    width: 100% !important;

    height: auto !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    gap: 0 !important;

    align-items: start !important;
    align-content: start !important;

    box-sizing: border-box !important;
}


/* =========================================================
   5. PRODUCT TILE
   ========================================================= */

#bt-mega-content .bt-product-category {
    position: relative !important;

    width: 100% !important;

    aspect-ratio: 4 / 3 !important;

    min-width: 0 !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    overflow: hidden !important;

    background: #222;

    box-sizing: border-box !important;
}


/* Fix any AJAX inline grid positioning */

#bt-mega-content .bt-product-category[style] {
    grid-column-start: auto !important;
}


/* =========================================================
   6. PRODUCT IMAGE
   ========================================================= */

#bt-mega-content .bt-product-category-image {
    position: absolute !important;

    inset: 0 !important;

    width: 100% !important;
    height: 100% !important;
}

#bt-mega-content .bt-product-category-image-link {
    display: block !important;

    width: 100% !important;
    height: 100% !important;
}

#bt-mega-content .bt-product-category-image img {
    display: block !important;

    width: 100% !important;
    height: 100% !important;

    margin: 0 !important;
    padding: 0 !important;

    object-fit: cover !important;
    object-position: center !important;

    transition: transform 0.35s ease;
}

#bt-mega-content .bt-product-category-no-image {
    width: 100%;
    height: 100%;

    background: #777;
}


/* =========================================================
   7. PRODUCT OVERLAY
   ========================================================= */

#bt-mega-content .bt-product-category-overlay {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    padding: 12px 16px;

    background: rgba(0, 0, 0, 0.50);

    z-index: 2;

    box-sizing: border-box;

    transition:
        background 0.25s ease,
        padding 0.25s ease;
}


/* Product title */

#bt-mega-content .bt-product-category-link {
    display: block;

    color: #fff !important;

    font-size: 14px;
    line-height: 1.25;

    font-weight: 600;

    text-transform: uppercase;

    text-decoration: none !important;
}


/* =========================================================
   8. PRODUCT SUBCATEGORIES
   ========================================================= */

#bt-mega-content .bt-product-subcategories {
    display: none;

    margin-top: 8px;
}

#bt-mega-content .bt-product-subcategory-link {
    display: block;

    color: #fff !important;

    font-size: 12px;
    line-height: 1.4;

    padding: 2px 0;

    text-decoration: none !important;
}


/* Product hover */

#bt-mega-content
.bt-product-category:hover
.bt-product-subcategories {
    display: block;
}

#bt-mega-content
.bt-product-category:hover
.bt-product-category-overlay {
    background: rgba(0, 0, 0, 0.75);
}

#bt-mega-content
.bt-product-category:hover img {
    transform: scale(1.03);
}


/* =========================================================
   9. CLOSE BUTTON
   ========================================================= */

#bt-dynamic-mega-menu .bt-mega-close {
    position: absolute;

    top: 12px;
    right: 15px;

    z-index: 100;

    width: 40px !important;
    height: 40px !important;

    min-width: 40px !important;
    min-height: 40px !important;

    margin: 0 !important;
    padding: 0 !important;

    border: 0 !important;

    background: rgba(255, 255, 255, 0.90);

    color: #000;

    font-size: 30px;
    line-height: 40px;

    font-weight: 300;

    text-align: center;

    cursor: pointer;

    border-radius: 50%;

    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);

    box-sizing: border-box;
}


/* =========================================================
   10. FORMAT GRID
   ========================================================= */

#bt-dynamic-mega-menu .bt-format-categories {
    display: grid !important;

    grid-template-columns: repeat(5, minmax(0, 1fr)) !important;

    width: 100% !important;

    height: auto !important;
    min-height: 0 !important;

    margin: 0 !important;
    padding: 0 !important;

    gap: 0 !important;

    align-items: start !important;
    align-content: start !important;

    box-sizing: border-box !important;
}


/* Format tile */

#bt-dynamic-mega-menu .bt-format-category {
    position: relative;

    width: 100%;

    aspect-ratio: 4 / 3 !important;

    min-width: 0;
    min-height: 0;

    margin: 0;
    padding: 0;

    overflow: hidden;

    background: #eee;

    box-sizing: border-box;
}


/* =========================================================
   11. FORMAT IMAGE
   ========================================================= */

#bt-dynamic-mega-menu .bt-format-category-image {
    position: absolute;

    inset: 0;

    width: 100%;
    height: 100%;
}

#bt-dynamic-mega-menu .bt-format-category-image-link {
    display: block;

    width: 100%;
    height: 100%;
}

#bt-dynamic-mega-menu .bt-format-category-image img {
    display: block;

    width: 100%;
    height: 100%;

    object-fit: cover;
    object-position: center;

    transition: transform 0.35s ease;
}


/* =========================================================
   12. FORMAT OVERLAY
   ========================================================= */

#bt-dynamic-mega-menu .bt-format-category-overlay {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    min-height: 60px;

    padding: 12px 14px;

    background:
        linear-gradient(
            to top,
            rgba(0, 0, 0, 0.75),
            rgba(0, 0, 0, 0)
        );

    z-index: 2;

    box-sizing: border-box;
}

#bt-dynamic-mega-menu .bt-format-category-link {
    display: block;

    position: relative;

    color: #fff !important;

    font-size: 14px;
    line-height: 1.2;

    font-weight: 600;

    text-decoration: none !important;

    z-index: 3;
}


/* =========================================================
   13. FORMAT SUBCATEGORIES
   ========================================================= */

#bt-dynamic-mega-menu .bt-format-subcategories {
    position: absolute;

    left: 0;
    right: 0;
    bottom: 0;

    padding: 14px;

    background: rgba(0, 0, 0, 0.85);

    opacity: 0;
    visibility: hidden;

    transform: translateY(10px);

    transition:
        opacity 0.25s ease,
        visibility 0.25s ease,
        transform 0.25s ease;

    z-index: 4;

    box-sizing: border-box;
}

#bt-dynamic-mega-menu
.bt-format-category:hover
.bt-format-subcategories {
    opacity: 1;
    visibility: visible;

    transform: translateY(0);
}

#bt-dynamic-mega-menu
.bt-format-subcategory-link {
    display: block;

    color: #fff !important;

    font-size: 13px;
    line-height: 1.5;

    margin: 4px 0;

    text-decoration: none !important;
}

#bt-dynamic-mega-menu
.bt-format-subcategory-link:hover {
    text-decoration: underline !important;
}

#bt-dynamic-mega-menu
.bt-format-category:hover img {
    transform: scale(1.05);
}


/* =========================================================
   14. FORMAT MODE POSITION
   Keep your existing 60px positioning
   ========================================================= */

#bt-dynamic-mega-menu[data-mega-mode="formats"] {
    margin-top: 60px !important;
}


/* =========================================================
   15. TABLET
   ========================================================= */

@media (max-width: 1100px) {

    #bt-dynamic-mega-menu {
        width: calc(100% - 30px) !important;
    }

    #bt-mega-content .bt-product-categories,
    #bt-dynamic-mega-menu .bt-format-categories {
        grid-template-columns:
            repeat(4, minmax(0, 1fr)) !important;
    }
}


/* =========================================================
   16. MOBILE
   ========================================================= */

@media (max-width: 767px) {

    #bt-dynamic-mega-menu {
        top: 90px !important;

        width: calc(100% - 20px) !important;

        /* Do NOT force viewport height */
        height: auto !important;
        min-height: 0 !important;

        max-height: calc(100vh - 90px) !important;
    }

    #bt-mega-content {
        height: auto !important;
        min-height: 0 !important;

        max-height: calc(100vh - 90px) !important;

        overflow-y: auto !important;
    }

    #bt-mega-content .bt-product-categories,
    #bt-dynamic-mega-menu .bt-format-categories {
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;
    }

    #bt-mega-content .bt-product-category,
    #bt-dynamic-mega-menu .bt-format-category {
        aspect-ratio: 1.35 / 1 !important;
    }

    #bt-mega-content .bt-product-category-link,
    #bt-dynamic-mega-menu .bt-format-category-link {
        font-size: 12px;
    }

    #bt-mega-content .bt-product-category-overlay {
        padding: 9px 10px;
    }

    #bt-dynamic-mega-menu .bt-mega-close {
        top: 10px;
        right: 10px;

        width: 36px !important;
        height: 36px !important;

        min-width: 36px !important;
        min-height: 36px !important;

        font-size: 26px;
        line-height: 30px;
    }
}


/* =========================================================
   17. SMALL MOBILE
   ========================================================= */

@media (max-width: 480px) {

    #bt-dynamic-mega-menu {
        width: 100% !important;
    }

    #bt-mega-content .bt-product-categories,
    #bt-dynamic-mega-menu .bt-format-categories {
        grid-template-columns:
            repeat(2, minmax(0, 1fr)) !important;
    }
}