/* TFD Mobile Header v3.0
 * Desktop-safe by default. All site-changing rules are restricted to phones.
 */
.tfd-mobile-header {
    display: none !important;
}

@media screen and (max-width: 767px) {
    /* Phone-only header */
    .site-header,
    .storefront-primary-navigation,
    .header-widget-region,
    .secondary-navigation,
    .site-header-cart {
        display: none !important;
    }
    
    .tfd-mobile-header {
        display: block !important;
        position: relative;
        z-index: 9998;
        width: 100%;
        background: #fff;
        border-bottom: 1px solid #e3e3e3;
        box-shadow: 0 3px 14px rgba(0,0,0,.08);
    }
    
    .tfd-mobile-topbar {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 8px;
        min-height: 34px;
        padding: 6px 14px;
        background: #202020;
        color: #fff;
        font-size: 11px;
        font-weight: 600;
    }
    
    .tfd-mobile-topbar a,
    .tfd-mobile-topbar span {
        color: #fff !important;
        text-decoration: none !important;
        white-space: nowrap;
    }
    
    .tfd-mobile-main {
        display: flex;
        align-items: center;
        justify-content: space-between;
        gap: 12px;
        min-height: 70px;
        padding: 9px 14px 7px;
        background: #fff;
    }
    
    .tfd-mobile-brand {
        display: block;
        max-width: 190px;
        line-height: 1;
    }
    
    .tfd-mobile-brand .custom-logo-link {
        display: block;
    }
    
    .tfd-mobile-brand img,
    .tfd-mobile-brand .custom-logo {
        display: block;
        width: auto;
        max-width: 180px;
        max-height: 54px;
        margin: 0;
        object-fit: contain;
    }
    
    .tfd-mobile-actions {
        display: flex;
        align-items: center;
        gap: 8px;
    }
    
    .tfd-mobile-call,
    .tfd-mobile-menu-button {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        min-height: 42px;
        border: 1px solid #b72b22;
        border-radius: 5px;
        text-decoration: none !important;
    }
    
    .tfd-mobile-call {
        width: 42px;
        background: #fff;
        color: #b72b22 !important;
        font-size: 18px;
    }
    
    .tfd-mobile-menu-button {
        gap: 8px;
        padding: 8px 12px;
        background: #b72b22;
        color: #fff;
        font-size: 14px;
        font-weight: 700;
    }
    
    .tfd-bars {
        display: flex;
        flex-direction: column;
        gap: 4px;
        width: 18px;
    }
    
    .tfd-bars span {
        display: block;
        width: 18px;
        height: 2px;
        background: currentColor;
    }
    
    .tfd-mobile-search-row {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 94px;
        gap: 8px;
        padding: 0 14px 12px;
        background: #fff;
    }
    
    .tfd-mobile-search {
        display: grid;
        grid-template-columns: minmax(0, 1fr) 42px;
        margin: 0;
        padding: 0;
        min-width: 0;
    }
    
    .tfd-mobile-search input[type="search"] {
        width: 100%;
        height: 46px;
        margin: 0;
        padding: 0 14px;
        border: 1px solid #cfcfcf;
        border-right: 0;
        border-radius: 5px 0 0 5px;
        background: #fff;
        color: #222;
        font-size: 15px;
        box-shadow: none;
    }
    
    .tfd-mobile-search button {
        width: 42px;
        height: 46px;
        margin: 0;
        padding: 0;
        border: 1px solid #b72b22;
        border-radius: 0 5px 5px 0;
        background: #b72b22;
        color: #fff;
        font-size: 24px;
    }
    
    .tfd-mobile-navigation {
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        max-height: calc(100vh - 130px);
        overflow-y: auto;
        background: #fff;
        border-top: 1px solid #e2e2e2;
        box-shadow: 0 10px 22px rgba(0,0,0,.14);
    }
    
    .tfd-mobile-navigation[hidden] {
        display: none !important;
    }
    
    .tfd-mobile-menu,
    .tfd-mobile-menu ul {
        margin: 0;
        padding: 0;
        list-style: none;
    }
    
    .tfd-mobile-menu > li {
        border-bottom: 1px solid #ececec;
    }
    
    .tfd-mobile-menu a {
        display: block;
        padding: 14px 18px;
        color: #222 !important;
        font-size: 16px;
        font-weight: 600;
        text-decoration: none !important;
    }
    
    .tfd-mobile-menu .sub-menu {
        background: #f8f8f8;
    }
    
    .tfd-mobile-menu .sub-menu a {
        padding-left: 34px;
        font-size: 14px;
        font-weight: 500;
    }
    
    .tfd-mobile-nav-footer {
        display: grid;
        gap: 8px;
        padding: 16px 18px;
        background: #202020;
        color: #fff;
        font-size: 13px;
    }
    
    .tfd-mobile-nav-footer a {
        color: #fff !important;
        font-weight: 700;
        text-decoration: none !important;
    }
    
    @media (max-width: 390px) {
        .tfd-mobile-brand img,
        .tfd-mobile-brand .custom-logo {
            max-width: 150px;
            max-height: 46px;
        }
    
        .tfd-mobile-topbar {
            font-size: 10px;
        }
    }
    
    
    .tfd-mobile-visit {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 5px;
        min-width: 0;
        height: 46px;
        padding: 0 9px;
        border: 1px solid #b72b22;
        border-radius: 5px;
        background: #fff;
        color: #b72b22 !important;
        font-size: 13px;
        font-weight: 700;
        line-height: 1;
        text-decoration: none !important;
        white-space: nowrap;
    }
    
    .tfd-mobile-visit span:first-child {
        font-size: 18px;
    }
    
    /* Hide Storefront's old mobile footer/search bar. The new header already
       provides working product search, phone and directions actions. */
    .storefront-handheld-footer-bar,
    .handheld-navigation + .storefront-handheld-footer-bar,
    #site-navigation .handheld-navigation,
    .mobile-bottom-bar,
    .sticky-mobile-bar,
    .mobile-search-overlay,
    .site-search.active,
    .widget_product_search[style*="position: fixed"] {
        display: none !important;
    }
    
    /* Prevent old fixed mobile bars from reserving excessive red space. */
    body {
        padding-bottom: 0 !important;
    }
    
    @media (max-width: 390px) {
        .tfd-mobile-search-row {
            grid-template-columns: minmax(0, 1fr) 84px;
            gap: 6px;
            padding-left: 10px;
            padding-right: 10px;
        }
    
        .tfd-mobile-visit {
            padding-left: 7px;
            padding-right: 7px;
            font-size: 12px;
        }
    }
    
    /* v2.1: reliable menu layer */
    .tfd-mobile-header.is-menu-open {
        z-index: 2147483000;
    }
    
    .tfd-mobile-navigation {
        position: fixed !important;
        top: var(--tfd-mobile-header-bottom, 150px) !important;
        right: 0;
        bottom: 0;
        left: 0;
        width: auto !important;
        max-height: none !important;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        visibility: hidden;
        opacity: 0;
        transform: translateY(-8px);
        pointer-events: none;
        transition: opacity .18s ease, transform .18s ease, visibility .18s ease;
        z-index: 2147483001;
    }
    
    .tfd-mobile-navigation.is-open,
    .tfd-mobile-navigation:not([hidden]) {
        display: block !important;
        visibility: visible;
        opacity: 1;
        transform: translateY(0);
        pointer-events: auto;
    }
    
    body.tfd-mobile-menu-open {
        overflow: hidden !important;
    }
    
    .tfd-mobile-menu-button[aria-expanded="true"] .tfd-bars span:nth-child(1) {
        transform: translateY(6px) rotate(45deg);
    }
    .tfd-mobile-menu-button[aria-expanded="true"] .tfd-bars span:nth-child(2) {
        opacity: 0;
    }
    .tfd-mobile-menu-button[aria-expanded="true"] .tfd-bars span:nth-child(3) {
        transform: translateY(-6px) rotate(-45deg);
    }
    .tfd-bars span {
        transition: transform .18s ease, opacity .18s ease;
    }
    
    /* v2.1: two WooCommerce products per row on phones */
    body.woocommerce-page:not(.single-product) ul.products,
    body.post-type-archive-product ul.products,
    body.tax-product_cat ul.products,
    body.tax-product_tag ul.products {
        display: grid !important;
        grid-template-columns: repeat(2, minmax(0, 1fr)) !important;
        gap: 18px 12px !important;
        margin: 0 !important;
    }
    
    body.woocommerce-page:not(.single-product) ul.products::before,
    body.woocommerce-page:not(.single-product) ul.products::after,
    body.post-type-archive-product ul.products::before,
    body.post-type-archive-product ul.products::after,
    body.tax-product_cat ul.products::before,
    body.tax-product_cat ul.products::after,
    body.tax-product_tag ul.products::before,
    body.tax-product_tag ul.products::after {
        display: none !important;
    }
    
    body.woocommerce-page:not(.single-product) ul.products li.product,
    body.post-type-archive-product ul.products li.product,
    body.tax-product_cat ul.products li.product,
    body.tax-product_tag ul.products li.product {
        float: none !important;
        clear: none !important;
        width: auto !important;
        max-width: none !important;
        margin: 0 !important;
        min-width: 0 !important;
    }
    
    body.woocommerce-page:not(.single-product) ul.products li.product img,
    body.post-type-archive-product ul.products li.product img,
    body.tax-product_cat ul.products li.product img,
    body.tax-product_tag ul.products li.product img {
        width: 100% !important;
        height: auto !important;
        margin-bottom: 9px !important;
    }
    
    body.woocommerce-page:not(.single-product) ul.products li.product .woocommerce-loop-product__title,
    body.post-type-archive-product ul.products li.product .woocommerce-loop-product__title,
    body.tax-product_cat ul.products li.product .woocommerce-loop-product__title,
    body.tax-product_tag ul.products li.product .woocommerce-loop-product__title {
        font-size: 15px !important;
        line-height: 1.3 !important;
        margin: 0 0 6px !important;
    }
    
    body.woocommerce-page:not(.single-product) ul.products li.product .button,
    body.post-type-archive-product ul.products li.product .button,
    body.tax-product_cat ul.products li.product .button,
    body.tax-product_tag ul.products li.product .button {
        width: 100% !important;
        min-height: 40px;
        padding: 9px 7px !important;
        font-size: 12px !important;
        line-height: 1.2 !important;
        white-space: normal !important;
    }
}

@media screen and (min-width: 768px) {
    html body .tfd-mobile-header {
        display: none !important;
        visibility: hidden !important;
        height: 0 !important;
        min-height: 0 !important;
        overflow: hidden !important;
        pointer-events: none !important;
    }
}
