/**
 * Beauty Balance responsive production-readiness fixes.
 *
 * These rules intentionally sit after Botiga's generated custom stylesheet.
 * Keep desktop presentation in the parent theme and scope adaptations to the
 * exact breakpoints where Botiga swaps to its mobile header.
 */

@media (max-width: 1024px) {
    /* Keep the mobile header compact while preserving full touch targets. */
    .bhfb-header.bhfb-mobile {
        background: #fff;
        position: sticky !important;
        top: 0;
        width: 100%;
        z-index: 100001;
    }

    .bhfb-header.bhfb-mobile .bhfb-main_header_row,
    .bhfb-header.bhfb-mobile .bhfb-main_header_row > .container-fluid,
    .bhfb-header.bhfb-mobile .bhfb-main_header_row .bhfb-row,
    .bhfb-header.bhfb-mobile .bhfb-main_header_row .bhfb-column {
        height: 60px !important;
        min-height: 60px !important;
    }

    .bhfb-header.bhfb-mobile .bhfb-main_header_row > .container-fluid {
        padding-left: 8px;
        padding-right: 8px;
    }

    .bhfb-header.bhfb-mobile .bhfb-main_header_row .bhfb-column {
        min-width: 0;
        width: auto !important;
    }

    .bhfb-header.bhfb-mobile .bhfb-main_header_row .bhfb-column-3,
    .bhfb-header.bhfb-mobile .bhfb-component-woo_icons {
        gap: 0;
    }

    .bhfb-header.bhfb-mobile .bhfb-component-mobile_hamburger,
    .bhfb-header.bhfb-mobile .bhfb-component-search {
        height: 44px;
        margin: 0 !important;
        width: 44px;
    }

    .bhfb-header.bhfb-mobile .bhfb-component-woo_icons {
        height: 44px;
        margin: 0 !important;
        width: 88px;
    }

    .bhfb-header.bhfb-mobile .menu-toggle,
    .bhfb-header.bhfb-mobile .header-search,
    .bhfb-header.bhfb-mobile .wc-account-link,
    .bhfb-header.bhfb-mobile .cart-contents {
        align-items: center;
        box-sizing: border-box;
        display: flex;
        height: 44px;
        justify-content: center;
        margin: 0 !important;
        min-width: 44px;
        padding: 0 !important;
        position: relative;
        width: 44px;
    }

    .bhfb-header.bhfb-mobile .menu-toggle .ws-svg-icon svg {
        height: auto;
        width: 22px;
    }

    .bhfb-header.bhfb-mobile .header-search .ws-svg-icon svg,
    .bhfb-header.bhfb-mobile .wc-account-link .ws-svg-icon svg,
    .bhfb-header.bhfb-mobile .cart-contents .ws-svg-icon svg {
        height: 21px;
        width: 21px;
    }

    .bhfb-header.bhfb-mobile .site-branding,
    .bhfb-header.bhfb-mobile .custom-logo-link {
        align-items: center;
        display: flex;
        height: 44px;
        justify-content: center;
        margin: 0 !important;
        max-width: 100%;
        width: 100%;
    }

    .bhfb-header.bhfb-mobile .custom-logo {
        height: auto !important;
        max-height: 40px;
        max-width: clamp(44px, calc(100vw - 280px), 85px) !important;
        object-fit: contain;
        width: auto !important;
    }

    .bhfb-header.bhfb-mobile .site-title,
    .bhfb-header.bhfb-mobile .site-description {
        display: none !important;
    }

    /* Keep the close control fixed while the full navigation scrolls. */
    .bhfb-mobile_offcanvas {
        background: #fff;
        box-shadow: 10px 0 36px rgba(20, 16, 14, .14);
        height: calc(100vh - 60px) !important;
        height: calc(100dvh - 60px) !important;
        max-width: 360px;
        overflow: hidden !important;
        overscroll-behavior: contain;
        top: 60px !important;
        width: min(88vw, 360px) !important;
    }

    .bhfb-mobile_offcanvas .mobile-menu-close {
        appearance: none;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
        color: #1b1918;
        align-items: center;
        display: flex;
        height: 44px;
        justify-content: center;
        z-index: 2;
        width: 44px;
    }

    .bhfb-mobile_offcanvas > .bhfb-mobile-offcanvas-rows {
        max-height: calc(100vh - 155px);
        max-height: calc(100dvh - 155px);
        overflow-y: auto;
        overscroll-behavior: contain;
        padding-bottom: max(24px, env(safe-area-inset-bottom));
        scrollbar-gutter: stable;
    }

    #mobile-menu img,
    #mobile-menu picture,
    #mobile-menu source,
    #mobile-menu svg,
    #mobile-menu noscript {
        display: none !important;
    }

    #mobile-menu,
    #mobile-menu ul {
        background: #fff;
        list-style: none;
        margin: 0;
        padding: 0;
    }

    #mobile-menu .bb-mobile-menu-item {
        border-bottom: 1px solid #eeeae7;
        position: relative;
    }

    #mobile-menu .bb-mobile-submenu .bb-mobile-menu-item {
        border-bottom-color: #f2efed;
    }

    #mobile-menu .bb-mobile-menu-row {
        align-items: stretch;
        display: flex;
        min-width: 0;
        width: 100%;
    }

    #mobile-menu .bb-mobile-menu-link,
    #mobile-menu .bb-mobile-menu-toggle {
        appearance: none !important;
        align-items: center;
        background: transparent !important;
        border: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        color: #201d1b !important;
        cursor: pointer;
        display: flex;
        font-family: inherit;
        font-size: 15.5px;
        font-weight: 600;
        letter-spacing: .005em;
        line-height: 1.35;
        min-height: 48px !important;
        text-align: left;
        text-decoration: none;
        text-transform: none;
    }

    #mobile-menu .bb-mobile-menu-link {
        flex: 1 1 auto;
        min-width: 0;
        padding: 10px 16px;
        width: auto;
    }

    #mobile-menu .bb-mobile-menu-toggle {
        flex: 0 0 48px !important;
        justify-content: center;
        margin: 0 !important;
        min-width: 48px !important;
        padding: 0 !important;
        width: 48px !important;
    }

    #mobile-menu .bb-mobile-menu-parent-toggle {
        justify-content: space-between;
        padding: 10px 16px !important;
        width: 100% !important;
    }

    #mobile-menu .bb-mobile-menu-chevron {
        display: inline-block;
        border-bottom: 1.5px solid currentColor;
        border-right: 1.5px solid currentColor;
        height: 8px;
        transform: rotate(45deg) translate(-2px, -2px);
        transform-origin: center;
        transition: transform 160ms ease;
        width: 8px;
    }

    #mobile-menu .bb-mobile-menu-item.bb-is-open > .bb-mobile-menu-row .bb-mobile-menu-chevron {
        transform: rotate(225deg) translate(-2px, -2px);
    }

    #mobile-menu .bb-mobile-submenu[hidden] {
        display: none !important;
    }

    #mobile-menu .bb-mobile-submenu:not([hidden]) {
        display: block !important;
    }

    #mobile-menu .bb-mobile-submenu {
        border-top: 1px solid #eeeae7;
        margin: 0;
        padding: 3px 0 5px;
    }

    #mobile-menu .bb-mobile-submenu .bb-mobile-menu-link,
    #mobile-menu .bb-mobile-submenu .bb-mobile-menu-toggle {
        font-size: 14.5px;
        font-weight: 500;
        min-height: 44px !important;
    }

    #mobile-menu .bb-mobile-menu-depth-1 > .bb-mobile-menu-row > .bb-mobile-menu-link {
        padding-left: 28px;
    }

    #mobile-menu .bb-mobile-menu-depth-2 > .bb-mobile-menu-row > .bb-mobile-menu-link {
        padding-left: 42px;
    }

    #mobile-menu .bb-mobile-menu-depth-3 > .bb-mobile-menu-row > .bb-mobile-menu-link {
        padding-left: 56px;
    }

    #mobile-menu .bb-mobile-menu-row:hover,
    #mobile-menu .bb-mobile-menu-row:focus-within {
        background: #faf8f7;
    }

    #mobile-menu .bb-mobile-menu-link:focus-visible,
    #mobile-menu .bb-mobile-menu-toggle:focus-visible,
    .widget.bb-mobile-filter .wc-block-product-filters__open-overlay:focus-visible {
        outline: 2px solid currentColor;
        outline-offset: -2px;
    }

    /* The block exists in the sidebar; JavaScript moves it above the grid. */
    .widget.bb-mobile-filter {
        border: 0;
        margin: 0 0 18px;
        padding: 0;
        width: 100%;
    }

    .widget.bb-mobile-filter .wc-block-product-filters__open-overlay {
        align-items: center;
        display: flex !important;
        justify-content: center;
        min-height: 48px;
        width: 100%;
    }

    .wc-block-product-filters__close-overlay,
    .wc-block-product-filters__apply {
        min-height: 48px;
    }

    .woocommerce ul.products li.product .button,
    .wc-block-grid__product-add-to-cart .wp-block-button__link {
        min-height: 44px !important;
    }

    /* Cart, checkout and account forms already stack; retain that flow. */
    .woocommerce-cart input[type="radio"],
    .woocommerce-checkout input[type="radio"],
    .woocommerce-account input[type="radio"] {
        height: 20px;
        min-width: 20px;
        width: 20px;
    }

    .woocommerce-checkout .woocommerce-additional-fields textarea,
    .woocommerce-checkout #order_comments {
        box-sizing: border-box;
        max-width: 100%;
        width: 100%;
    }
}

@media (max-width: 768px) {
    /* The homepage has one desktop-sized spacer immediately below the hero. */
    .home .entry-content > .wp-block-spacer {
        height: clamp(32px, 10vw, 48px) !important;
    }

    /* Undo the legacy 1.25x crop that overflows narrow product cards. */
    .woocommerce ul.products li.product a img,
    .wc-block-grid__product-image img {
        box-sizing: border-box;
        height: clamp(140px, 42vw, 220px) !important;
        max-width: 100% !important;
        object-fit: contain !important;
        transform: none !important;
    }

    .woocommerce ul.products li.product .button,
    .wc-block-grid__product-add-to-cart .wp-block-button__link {
        align-items: center;
        display: flex !important;
        justify-content: center;
        line-height: 1.25;
        min-height: 44px !important;
        padding: 10px 8px !important;
        white-space: normal;
        width: 100% !important;
    }

    /* Keep Merchant's SALE label on the image and return the price to flow. */
    body.home .wc-block-grid .wc-block-grid__product .wc-block-grid__product-price.price {
        align-items: baseline;
        background: transparent !important;
        border: 0 !important;
        box-shadow: none !important;
        bottom: auto !important;
        color: inherit !important;
        display: flex !important;
        float: none !important;
        flex-wrap: wrap;
        gap: 4px 7px;
        inset: auto !important;
        justify-content: center;
        left: auto !important;
        margin: 8px 0 12px !important;
        max-width: 100% !important;
        min-width: 0 !important;
        padding: 0 !important;
        position: static !important;
        right: auto !important;
        text-align: center !important;
        top: auto !important;
        transform: none !important;
        width: 100% !important;
        z-index: auto !important;
    }

    body.home .wc-block-grid .wc-block-grid__product .wc-block-grid__product-price.price del,
    body.home .wc-block-grid .wc-block-grid__product .wc-block-grid__product-price.price ins {
        background: transparent !important;
        display: inline-flex;
        inset: auto !important;
        margin: 0 !important;
        padding: 0 !important;
        position: static !important;
        transform: none !important;
    }

    body.home .wc-block-grid .wc-block-grid__product .wc-block-grid__product-price.price ins {
        font-weight: 700;
        text-decoration: none;
    }

    body.home .wc-block-grid .wc-block-grid__product .wc-block-grid__product-price.price del {
        font-size: .88em;
        opacity: .55;
    }

    .woocommerce .woocommerce-sorting-wrapper {
        align-items: stretch;
        display: grid;
        gap: 10px;
        grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    }

    .woocommerce .woocommerce-ordering,
    .woocommerce .woocommerce-ordering select {
        max-width: 100%;
        min-height: 44px;
        width: 100%;
    }
}

@media (max-width: 768px) {
    /* Hide only the line-art service icons; category photography is separate. */
    .home .entry-content .wp-block-media-text.is-stacked-on-mobile {
        grid-template-columns: minmax(0, 1fr) !important;
    }

    .home .entry-content .wp-block-media-text.is-stacked-on-mobile > .wp-block-media-text__media {
        display: none;
    }

    .home .entry-content .wp-block-media-text.is-stacked-on-mobile > .wp-block-media-text__content {
        grid-area: 1 / 1;
    }
}

@media (max-width: 440px) {
    /*
     * CookieYes stacks three full-width buttons at this breakpoint. Keep every
     * consent choice while reducing how much of a phone screen it obscures.
     */
    body .cky-consent-container {
        bottom: 12px;
        left: 12px;
        max-width: calc(100% - 24px);
        right: 12px;
        width: calc(100% - 24px);
    }

    body .cky-consent-container .cky-consent-bar {
        max-height: calc(100vh - 24px);
        max-height: calc(100dvh - 24px);
        overflow-y: auto;
        padding: 16px;
    }

    body .cky-consent-container .cky-notice .cky-title,
    body .cky-consent-container .cky-notice-des,
    body .cky-consent-container .cky-notice-btn-wrapper {
        padding-left: 0;
        padding-right: 0;
    }

    body .cky-consent-container .cky-notice-des {
        line-height: 1.45;
        max-height: min(24vh, 144px);
        overflow-y: auto;
    }

    body .cky-consent-container .cky-notice-btn-wrapper {
        display: grid;
        gap: 8px;
        grid-template-columns: repeat(3, minmax(0, 1fr));
        margin-top: 12px;
    }

    body .cky-consent-container .cky-notice-btn-wrapper .cky-btn {
        font-size: 13px;
        line-height: 1.2;
        margin: 0;
        min-height: 44px;
        min-width: 0;
        padding: 8px 4px;
        width: auto;
    }
}

@media (max-width: 374px) {
    body .cky-consent-container .cky-notice-btn-wrapper {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    body .cky-consent-container .cky-notice-btn-wrapper .cky-btn-accept {
        grid-column: 1 / -1;
    }

    .woocommerce .woocommerce-sorting-wrapper {
        grid-template-columns: 1fr;
    }

    .woocommerce .woocommerce-result-count,
    .woocommerce .woocommerce-ordering {
        float: none;
        margin: 0;
        width: 100%;
    }
}
