/**
 * صفحه اصلی — موبایل / viewport باریک (≤991px)
 */

@media (max-width: 991.98px) {
    body.home,
    body.page-id-159241,
    .home-mega-app {
        --hm-brand: #812990;
        --hm-brand-deep: #5c1d66;
        --hm-surface: #f4f6fb;
        --hm-card: #ffffff;
        --hm-text: #0f172a;
        --hm-muted: #64748b;
        --hm-border: rgba(15, 23, 42, 0.08);
        --hm-radius: 16px;
        --hm-shadow: 0 8px 28px rgba(15, 23, 42, 0.08);
        background: var(--hm-surface);
    }

    body.home main .container {
        padding-inline: 0;
    }

    /* ─── هدر: بدون override پهنا — همان layout-enhanced سراسری ─── */
    body.hpb-has-site-header .hd-mobile-top-spacer,
    body.hpb-has-site-header .hpb-lb-mobile-spacer,
    body.home:has(#hpb-site-header) .hd-mobile-top-spacer,
    body.home:has(#hpb-site-header) .hpb-lb-mobile-spacer {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
    }

    .hpb-lb-sticky-bottom-host {
        display: none !important;
        height: 0 !important;
        min-height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        visibility: hidden !important;
    }

    body.hpb-has-site-header,
    body:has(#hpb-site-header),
    body.home:has(#hpb-site-header),
    body.hpb-has-sticky-bottom-nav {
        padding-top: calc(55px + env(safe-area-inset-top, 0)) !important;
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
    }

    body.home main.home-mega-app,
    body.home .home-mega-app {
        padding-top: 0 !important;
        margin-top: 0 !important;
    }

    /* ─── ریتم فاصله یکدست بین سکشن‌ها و آیتم‌ها ─── */
    body.home main.crafto-home,
    body.home .crafto-home.home-v2-app,
    body.home main.home-v2-app {
        --h-gap: 8px !important;
        --h-pad: 0 !important;
        gap: 8px !important;
        padding: 0 0 8px !important;
    }

    /* استایل/لینک داخل main فاصلهٔ flex نسازند */
    body.home main.crafto-home > style,
    body.home main.crafto-home > link,
    body.home main.home-v2-app > style,
    body.home main.home-v2-app > link {
        position: absolute !important;
        width: 0 !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow: hidden !important;
        border: 0 !important;
        clip: rect(0, 0, 0, 0) !important;
    }

    /* سکشن خالی هیرو تماس — فقط فاصله می‌ساخت */
    body.home main .crafto-section.contact-hero:not(:has(.contact-hero__title, .contact-hero__text, h1, h2, p, a, img, button, input)) {
        display: none !important;
    }

    body.home main.crafto-home > .hpb-sp-styled,
    body.home main.crafto-home > .crafto-section,
    body.home main.home-v2-app > .hpb-sp-styled,
    body.home main.home-v2-app > .crafto-section {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    body.home main .hamta-flash-deals {
        margin: 0 !important;
    }

    body.home main .crafto-products .hpb-carousel,
    body.home main .crafto-news-block .hpb-carousel {
        --hpb-gap: 8px !important;
    }

    body.home main .crafto-products__header,
    body.home main .crafto-products .hpb-mega-top-arrow-header {
        margin-bottom: 6px !important;
    }

    body.home main .hpb-ctaimg__grid {
        gap: 8px !important;
    }

    body.home main .request_consultant,
    body.home main .crafto-consult,
    body.home main .freebox_image {
        margin-top: 0 !important;
        margin-bottom: 0 !important;
    }

    header.elementor-location-header,
    .elementor-location-header {
        display: none !important;
    }

    /* هدر سایت: فقط layout-enhanced / LayoutCriticalCss سراسری — بدون override خانه */

    /* بلانتون — فقط ظرف و فلش؛ ابعاد مربع از grid.css می‌آید و کوچک نمی‌شود */
    body.home,
    body.home main,
    body.home .home-mega-app,
    body.home .crafto-section,
    body.home .crafto-blanton-grid,
    body.home .crafto-blanton-grid__viewport {
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    body.home {
        overflow-x: clip;
    }

    body.home .hpb-grid--blanton,
    body.home .hpb-grid--blanton-carousel {
        max-width: 100% !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }

    body.home .hpb-blanton-pager {
        display: none !important;
    }

    body.home main .slider_home_mega .hpb-slider,
    body.home main .slider_home_mega .hpb-slider__swiper,
    body.home main .slider_home_mega .swiper-slide,
    body.home main .slider_home_mega .hpb-slide__bg {
        max-width: 100% !important;
        overflow: hidden !important;
    }

    #hpb-site-header .hamta-shop-search-mobile .hamta-mobile-search-toggle {
        width: 40px;
        height: 40px;
        border-radius: 12px;
        border: 1px solid var(--hm-border);
        background: #fff;
    }

    /* ─── اسلایدر ─── */
    body.home main .slider_home_mega {
        margin-top: 0;
    }

    body.home main .slider_home_mega .hpb-slider,
    body.home main .slider_home_mega .hpb-slider__swiper {
        border-radius: var(--hm-radius);
        overflow: hidden;
        box-shadow: var(--hm-shadow);
    }

    body.home main .slider_home_mega .hpb-slider__swiper {
        min-height: 160px;
        aspect-ratio: 16 / 9;
    }

    /* ارتفاع تنظیم‌شده — فقط وقتی ارتفاع موبایل جدا ست شده؛ وگرنه تصویر ارتفاع را تعیین می‌کند */
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .hpb-slider__frame,
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .hpb-slider__swiper,
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .hpb-slider__swiper.swiper,
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .swiper-slide,
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .hpb-slide,
    body.home main .slider_home_mega .hpb-slider--has-height-mobile .hpb-slide__inner {
        aspect-ratio: unset !important;
        height: var(--hpb-slider-h-mobile) !important;
        min-height: var(--hpb-slider-h-mobile) !important;
        max-height: none !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slider__frame,
    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slider__swiper,
    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .swiper-slide,
    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slide,
    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slide__inner {
        aspect-ratio: unset !important;
        height: auto !important;
        min-height: 0 !important;
        max-height: none !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) {
        height: auto !important;
        min-height: 0 !important;
        padding-bottom: 0 !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) img.hpb-slide__bg--img {
        position: relative !important;
        inset: auto !important;
        width: 100% !important;
        height: auto !important;
        object-fit: contain !important;
        display: none !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slide--has-mobile-bg img.hpb-slide__bg--mobile {
        display: block !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slide:not(.hpb-slide--has-mobile-bg).hpb-slide--has-tablet-bg img.hpb-slide__bg--tablet {
        display: block !important;
    }

    body.home main .slider_home_mega .hpb-slider--fit-image-mobile:not(.hpb-slider--has-height-mobile) .hpb-slide:not(.hpb-slide--has-mobile-bg):not(.hpb-slide--has-tablet-bg) img.hpb-slide__bg--desktop {
        display: block !important;
    }

    body.home main .slider_home_mega .swiper-button-prev,
    body.home main .slider_home_mega .swiper-button-next {
        width: 32px !important;
        height: 32px !important;
        background: rgba(255, 255, 255, 0.92) !important;
        border-radius: 50% !important;
        color: var(--hm-brand) !important;
    }

    /* ─── دکمه‌های مصرف‌کننده / نمایندگی ─── */
    body.home .home-segment-pills {
        margin: 10px 0 8px;
    }

    body.home .home-segment-pills__row {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    body.home .home-segment-pills__btn {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 46px;
        padding: 10px 8px;
        border-radius: 14px;
        font-size: 13px;
        font-weight: 800;
        text-decoration: none;
        text-align: center;
        line-height: 1.35;
        border: 1px solid transparent;
    }

    body.home .home-segment-pills__btn--consumer {
        background: linear-gradient(135deg, var(--hm-brand) 0%, #9b3aab 100%);
        color: #fff;
        box-shadow: 0 4px 14px rgba(129, 41, 144, 0.2);
    }

    body.home .home-segment-pills__btn--branch {
        background: var(--hm-card);
        color: var(--hm-brand-deep);
        border-color: rgba(129, 41, 144, 0.22);
    }

    /* ─── گرید دسته‌بندی — ارتفاع بهینه ─── */
    body.home main .home_mega_categoies .hpb-grid__inner {
        grid-auto-rows: minmax(0, auto) !important;
        gap: 10px !important;
    }

    body.home main .home_mega_categoies .hpb-grid__item {
        min-height: 0;
    }

    body.home main .home_mega_categoies .hpb-cat-card {
        border-radius: 14px;
        box-shadow: 0 2px 10px rgba(15, 23, 42, 0.06);
        min-height: 0;
    }

    body.home main .home_mega_categoies .hpb-cat-card__media {
        aspect-ratio: 1 / 1;
        max-height: 72px;
        padding: 8px;
    }

    body.home main .home_mega_categoies .hpb-cat-card__media img {
        object-fit: contain;
        max-height: 56px;
        width: auto;
        margin: 0 auto;
    }

    body.home main .home_mega_categoies .hpb-cat-card__icon {
        font-size: 1.75rem;
        padding: 8px;
    }

    body.home main .home_mega_categoies .hpb-cat-card__body {
        padding: 8px 10px 12px;
    }

    body.home main .home_mega_categoies .hpb-cat-card__title {
        font-size: 0.78rem;
        line-height: 1.35;
        -webkit-line-clamp: 2;
    }

    /* ─── بنر دریافت نمایندگی ─── */
    body.home main .freebox_image {
        display: flex !important;
        flex-direction: column !important;
        align-items: center;
        text-align: center;
        gap: 12px;
        margin: 16px 0;
        padding: 20px 16px;
        min-height: 0;
        height: auto;
        border-radius: 20px;
        background: linear-gradient(135deg, #812990 0%, #673ab7 55%, #5ec8f0 100%);
        box-shadow: var(--hm-shadow);
        overflow: hidden;
    }

    body.home main .freebox_image .col-6 {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        padding: 0 !important;
    }

    body.home main .freebox_image .circle {
        display: none !important;
    }

    body.home main .freebox_image h2 {
        margin: 0 0 8px;
        font-size: 1.05rem;
        font-weight: 800;
        color: #fff;
        text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
    }

    body.home main .freebox_image .content,
    body.home main .freebox_image p {
        margin: 0 0 12px;
        font-size: 0.88rem;
        line-height: 1.65;
        color: rgba(255, 255, 255, 0.92);
    }

    body.home main .freebox_image a {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        background: #fff;
        color: var(--hm-brand-deep);
        font-weight: 700;
        font-size: 0.9rem;
        padding: 10px 22px;
        border-radius: 999px;
        text-decoration: none;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12);
    }

    body.home main .freebox_image .image_branch {
        display: flex;
        justify-content: center;
        max-width: 180px;
        margin: 0 auto;
        height: auto;
    }

    body.home main .freebox_image .image_branch img {
        width: 100%;
        max-width: 160px;
        height: auto;
        filter: drop-shadow(0 8px 20px rgba(255, 255, 255, 0.35));
    }

    /* ─── فرم درخواست مشاوره — موبایل‌فرندلی ─── */
    body.home main .request_consultant {
        display: flex !important;
        flex-direction: column !important;
        margin: 16px 0;
        padding: 0;
        border-radius: 18px;
        overflow: hidden;
        background: linear-gradient(145deg, #7b1fa2 0%, #512da8 100%);
        border: none;
        box-shadow: var(--hm-shadow);
        position: relative;
    }

    body.home main .request_consultant::before,
    body.home main .request_consultant::after {
        display: none;
    }

    body.home main .request_consultant .col-6,
    body.home main .request_consultant .form_boxer,
    body.home main .request_consultant .the_form_container {
        width: 100% !important;
        max-width: 100% !important;
        flex: 0 0 100% !important;
    }

    body.home main .request_consultant .form_boxer {
        padding: 18px 16px 8px;
        color: #fff;
    }

    body.home main .request_consultant .inner_title > div,
    body.home main .request_consultant .inner_title {
        font-size: 1.05rem;
        font-weight: 800;
        color: #fff;
        margin-bottom: 8px;
    }

    body.home main .request_consultant .form_boxer p {
        margin: 0;
        font-size: 0.85rem;
        line-height: 1.7;
        color: rgba(255, 255, 255, 0.9);
    }

    body.home main .request_consultant .the_form_container {
        padding: 8px 16px 18px;
        display: flex;
        flex-direction: column;
        gap: 8px;
    }

    body.home main .request_consultant .hpb-home-consultation-form {
        display: flex;
        flex-direction: column;
        gap: 8px;
        margin: 0;
    }

    body.home main .request_consultant .hpb-home-consultation-form.is-loading button[type="submit"] {
        opacity: 0.75;
        pointer-events: none;
    }

    body.home main .request_consultant .hpb-cta-newsletter__form-message {
        display: none;
        margin-top: 4px;
        padding: 10px 12px;
        border-radius: 12px;
        font-size: 0.82rem;
        line-height: 1.6;
    }

    body.home main .request_consultant .hpb-cta-newsletter__form-message.is-visible.is-success {
        display: block;
        background: rgba(255, 255, 255, 0.95);
        color: #166534;
    }

    body.home main .request_consultant .hpb-cta-newsletter__form-message.is-visible.is-error {
        display: block;
        background: rgba(255, 255, 255, 0.95);
        color: #b91c1c;
    }

    body.home main .request_consultant label {
        display: block;
        font-size: 0.82rem;
        font-weight: 600;
        color: rgba(255, 255, 255, 0.95);
        margin: 4px 0 2px;
    }

    body.home main .request_consultant input,
    body.home main .request_consultant select {
        width: 100% !important;
        min-height: 46px !important;
        padding: 10px 12px !important;
        border-radius: 12px !important;
        border: 1px solid rgba(255, 255, 255, 0.25) !important;
        background: #fff !important;
        font-size: 14px !important;
        box-sizing: border-box;
    }

    body.home main .request_consultant button {
        width: 100%;
        min-height: 48px;
        margin-top: 8px;
        padding: 12px 20px;
        border: none;
        border-radius: 12px;
        background: #fff;
        color: var(--hm-brand-deep);
        font-size: 15px;
        font-weight: 800;
        cursor: pointer;
    }

    /* ─── کاروسل‌ها — یکدست با محصولات، بدون progress bar ─── */
    .home-mega-app .home_mega_categoies,
    .home-mega-app section {
        margin-bottom: 8px;
    }

    .home-mega-app .hpb-mega-top-arrow-header,
    .home-mega-app .hpb-module-title {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
        margin-bottom: 6px !important;
    }

    .home-mega-app .hpb-mega-top-arrow-header__title,
    .home-mega-app .hpb-module-title__heading {
        font-size: 1.05rem !important;
        font-weight: 800 !important;
        color: var(--hm-brand-deep) !important;
        margin: 0 !important;
    }

    .home-mega-app .hpb-module-title__link,
    .home-mega-app .hpb-mega-top-arrow-header__tools a {
        font-size: 0.82rem !important;
        font-weight: 700 !important;
        color: var(--hm-brand) !important;
        text-decoration: none !important;
        white-space: nowrap;
    }

    /* عنوان راست + لینک «+ همه» چپ، یک ردیف */
    body.home .crafto-products__header,
    .home-mega-app .crafto-products__header {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        justify-content: space-between !important;
        flex-wrap: nowrap !important;
        gap: 8px !important;
    }

    body.home .crafto-products__title,
    .home-mega-app .crafto-products__title {
        margin: 0 !important;
        flex: 1 1 auto;
        min-width: 0;
    }

    body.home .crafto-view-all,
    .home-mega-app .crafto-view-all {
        display: inline-flex !important;
        align-items: center !important;
        margin-inline-start: auto !important;
        white-space: nowrap !important;
        text-align: start !important;
        font-size: 0.82rem !important;
        font-weight: 700 !important;
        color: var(--hm-brand) !important;
        text-decoration: none !important;
    }

    .home-mega-app .hpb-carousel__pagination,
    .home-mega-app .swiper-pagination-progressbar,
    .home-mega-app .hpb-mega-top-arrow-pagination,
    .home-mega-app .hpb-carousel--pag-progressbar .hpb-carousel__pagination {
        display: none !important;
        height: 0 !important;
        margin: 0 !important;
        padding: 0 !important;
        visibility: hidden !important;
    }

    .home-mega-app .hpb-carousel .swiper-button-prev,
    .home-mega-app .hpb-carousel .swiper-button-next {
        display: none !important;
    }

    .home-mega-app .hpb-carousel-mega-product .hpb-card,
    .home-mega-app .hpb-carousel .hpb-card {
        border-radius: 14px;
        box-shadow: 0 2px 12px rgba(15, 23, 42, 0.06);
    }

    /* ─── نوار پایین ثابت ─── */
    .hpb-sticky-bottom-nav-shell.mobile-bottom-nav-shell {
        position: fixed !important;
        left: 0 !important;
        right: 0 !important;
        bottom: 0 !important;
        z-index: 10060 !important;
    }

    body.hpb-has-sticky-bottom-nav,
    body.has-mobile-bottom-nav {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
    }

    body.hpb-has-sticky-bottom-nav:has(.hpb-sticky-bottom-nav-shell--has-search),
    body.has-mobile-bottom-nav:has(.hpb-sticky-bottom-nav-shell--has-search) {
        padding-bottom: calc(10px + env(safe-area-inset-bottom, 0)) !important;
    }

    /* ─── فوتر: همان نسخه سراسری صفحات داخلی (بدون مخفی‌کردن ردیف‌ها) ─── */
    body.home #hpb-site-footer {
        margin-bottom: 0 !important;
        padding-bottom: 0 !important;
    }

    /* offcanvas منو — خارج از جریان سند (جلوگیری از اسکرول سفید زیر فوتر) */
    .hpb-sticky-offcanvas.offcanvas,
    .offcanvas.mobile-menu-offcanvas {
        position: fixed !important;
        inset: 0 0 0 auto !important;
        width: min(100vw, 420px) !important;
        max-width: 100vw !important;
        height: 100% !important;
        visibility: hidden !important;
        pointer-events: none !important;
        z-index: 1050 !important;
    }

    .hpb-sticky-offcanvas.offcanvas.show,
    .offcanvas.mobile-menu-offcanvas.show {
        visibility: visible !important;
        pointer-events: auto !important;
    }

    body.home {
        min-height: 0 !important;
    }
}

@media (min-width: 992px) {
    .hpb-sticky-bottom-nav-shell.mobile-bottom-nav-shell {
        display: none !important;
    }
}
