/**
 * Tofaa RWD — presentation layer, desktop > 1100px intentionally untouched.
 * Keep the outer guard even though WordPress also supplies the media attribute.
 * !important overrides accumulated legacy desktop rules, not brand tokens.
 */
@media screen and (max-width: 1100px) {
    /* 01. Shared geometry, keyboard/touch targets and form zoom on iOS. */
    html { scroll-padding-top: 110px; }
    :where(main, section, article, form, .woocommerce) { min-width: 0; }
    :where(h1, h2, h3, p, label, td, th) { overflow-wrap: break-word; }
    .entry-content { overflow-wrap: anywhere; }
    .entry-content :where(ol, ul) { padding-inline-start: 24px; margin-inline: 0; }
    :where(button, a.button, input[type="submit"], [role="button"]) {
        min-width: 44px;
        min-height: 44px;
        touch-action: manipulation;
    }
    :where(input[type="text"], input[type="email"], input[type="password"], input[type="tel"], input[type="search"], input[type="number"], select, textarea) {
        max-width: 100%;
        font-size: 16px !important;
        min-height: 44px;
    }
    :where(textarea) { resize: vertical; }
    :where(button, a, input, select, textarea):focus-visible {
        outline: 2px solid currentColor;
        outline-offset: 3px;
    }
    :where([id]) { scroll-margin-top: 110px; }
    .tofaa-rwd-swipe-hint {
        display: block;
        margin: 8px 0;
        font-size: 12px;
        line-height: 1.5;
        text-align: center;
    }
    .tofaa-hero > .tofaa-rwd-swipe-hint { order: 2; margin-top: -18px; }

    /* 02. Navigation: one scrollable, tappable menu, also on narrow tablets. */
    .tofaa-nav {
        width: calc(100% - 24px) !important;
        min-height: 76px !important;
        top: 10px !important;
        padding: 8px 14px !important;
        grid-template-columns: minmax(100px, 140px) minmax(44px, 1fr) auto !important;
        gap: 10px !important;
    }
    body.admin-bar .tofaa-nav { top: 42px !important; }
    .tofaa-nav__brand { width: 130px !important; max-width: 100%; height: 52px !important; }
    .tofaa-nav__toggle { display: block !important; justify-self: end; min-width: 44px; min-height: 44px; }
    .tofaa-nav__actions { display: flex !important; gap: 6px !important; }
    .tofaa-nav__actions .tofaa-nav__action { width: 44px !important; min-width: 44px !important; min-height: 44px; justify-content: center; }
    .tofaa-nav__notification-trigger { min-width: 44px !important; min-height: 44px !important; }
    .tofaa-nav__actions .tofaa-nav__action span:not(.screen-reader-text),
    .tofaa-nav__account-dropdown > .tofaa-nav__compact-trigger { display: none; }
    .tofaa-nav__menu {
        position: absolute !important;
        top: calc(100% + 10px) !important;
        left: 0 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 14px !important;
        display: none !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 4px !important;
        max-height: calc(100vh - 112px);
        max-height: calc(100dvh - 112px);
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        border-radius: 20px;
        background: var(--tofaa-white, #fff5ec);
    }
    .tofaa-nav__menu.is-open { display: flex !important; }
    .tofaa-nav__menu .tofaa-nav__item { display: block; width: 100%; }
    .tofaa-nav__menu .tofaa-nav__link,
    .tofaa-nav__menu .tofaa-nav__trigger { width: 100%; min-height: 48px; padding: 12px 14px; justify-content: space-between; }
    .tofaa-nav__menu .tofaa-nav__submenu {
        position: static !important;
        width: 100% !important;
        min-width: 0 !important;
        max-height: none !important;
        padding: 0 !important;
        transform: none !important;
        display: none !important;
        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;
    }
    .tofaa-nav__menu .is-open > .tofaa-nav__submenu { display: block !important; }
    .tofaa-nav__submenu::before { display: none !important; }
    .tofaa-nav__submenu a { min-height: 44px; }
    .tofaa-nav__category-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .tofaa-nav__submenu-panel { width: 100%; max-width: 100%; margin: 8px 0; }
    .tofaa-nav__notifications-dropdown .tofaa-nav__submenu--notifications {
        position: fixed !important; top: calc(100% + 8px) !important; left: 12px !important; right: 12px !important;
        width: auto !important; min-width: 0 !important; transform: none !important;
        display: none !important;
    }
    .tofaa-nav__notifications-dropdown.is-open > .tofaa-nav__submenu--notifications {
        display: block !important; opacity: 1 !important; visibility: visible !important; pointer-events: auto !important;
        max-height: calc(100vh - 150px) !important; max-height: calc(100dvh - 150px) !important;
        overflow-y: auto !important; overscroll-behavior: contain;
    }
    .tofaa-nav__submenu--notifications button,
    .tofaa-nav__submenu--notifications a { display: inline-flex; align-items: center; min-height: 44px !important; }

    /* 03. Home: remove desktop offsets, compact benefits, native moment rail. */
    .tofaa-home { padding: 100px 18px 0 !important; }
    .tofaa-home .tofaa-hero {
        top: 0 !important; left: 0 !important; margin: 0 !important;
        min-height: 0 !important; padding: 12px 0 24px !important;
        display: grid; grid-template-columns: minmax(0, 1fr); gap: 20px;
    }
    .tofaa-home .tofaa-hero__copy { order: 1; padding: 0 !important; width: 100%; text-align: center; }
    .tofaa-hero__copy-main { display: flex; flex-direction: column; align-items: center; }
    .tofaa-home .tofaa-hero h1 { max-width: 760px; margin: 0 auto !important; font-size: clamp(38px, 6.7vw, 64px) !important; line-height: 1.04 !important; }
    .tofaa-home .tofaa-hero__lead { margin: 16px 0 0 !important; font-size: clamp(17px, 2.6vw, 24px) !important; }
    .tofaa-home .tofaa-hero__buttons { order: 1; width: 100%; margin: 20px 0 !important; justify-content: center; }
    .tofaa-home .tofaa-hero__buttons .tofaa-btn { min-height: 54px; max-width: 100%; }
    .tofaa-home .tofaa-benefits { order: 2; width: 100%; max-width: 650px; margin: 8px auto 0 !important; display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)) !important; gap: 8px !important; }
    .tofaa-benefit { min-width: 0; }
    .tofaa-benefits__note { order: 3; margin: 12px 0 0 !important; }
    .tofaa-home .tofaa-hero__moments {
        order: 2; display: grid !important; grid-template-columns: none !important; grid-template-rows: none !important;
        grid-auto-flow: column; grid-auto-columns: minmax(150px, 26%);
        gap: 12px; width: 100%; padding: 4px 4px 14px !important;
        overflow-x: auto; scroll-snap-type: x proximity; scroll-padding-inline: 4px;
        -webkit-overflow-scrolling: touch;
    }
    .tofaa-home .tofaa-moment-card { width: 100%; min-height: 92px !important; padding: 12px !important; scroll-snap-align: start; }
    .tofaa-home .tofaa-moment-card__number { font-size: 45px !important; }
    .tofaa-home .tofaa-moment-card__text { font-size: 14px !important; max-width: 140px; }
    .tofaa-home .tofaa-hero__visual { order: 3; width: 100%; min-height: 0 !important; height: clamp(340px, 65vw, 520px) !important; margin: 0 !important; }
    .tofaa-home .tofaa-visual__product-stage { width: 100%; height: 100%; top: 0; }
    .tofaa-community-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .tofaa-community-card--reviews { grid-column: 1 / -1; }
    .tofaa-community-card:not(.tofaa-community-card--reviews),
    .tofaa-community-card:not(.tofaa-community-card--reviews) .tofaa-community-card__content { min-height: 0 !important; height: auto !important; }
    .tofaa-community-card:not(.tofaa-community-card--reviews) .tofaa-community-card__cta { margin-top: 24px !important; }
    .tofaa-reviews-card__arrow { min-width: 44px !important; min-height: 44px !important; }

    /* 04. Store grids: no 100vw bleed and no fixed desktop purchase row. */
    .woocommerce .tofaa-shop-filters,
    .woocommerce .tofaa-product-wall,
    .woocommerce ul.products { width: 100% !important; margin-left: 0 !important; margin-right: 0 !important; left: auto !important; }
    .woocommerce ul.products { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; }
    .woocommerce ul.products li.product { width: 100% !important; min-width: 0; }
    .tofaa-product-card__footer.has-quantity { grid-template-columns: minmax(0, 1fr) auto !important; gap: 12px !important; }
    .tofaa-product-card__footer.has-quantity .tofaa-product-card__quantity { width: 132px; grid-template-columns: 44px 44px 44px; }
    .tofaa-product-card__quantity button { min-width: 44px; min-height: 44px; }
    .tofaa-product-card__footer.has-quantity .tofaa-product-card__action { grid-column: 1 / -1; width: 100% !important; }
    .tofaa-product-card__footer.has-quantity .tofaa-product-card__action .button { width: 100% !important; min-width: 0 !important; max-width: none !important; flex-basis: 100% !important; }
    .tofaa-shop-filters__tabs { overflow-x: auto; scroll-snap-type: x proximity; }
    .tofaa-shop-filters__tabs a { flex-shrink: 0; min-height: 44px; scroll-snap-align: start; }

    /* 05. Product, account, checkout and post-buy: fluid purchase surfaces. */
    .tofaa-product-pilot__hero { grid-template-columns: minmax(0, 1fr) !important; }
    .tofaa-product-pilot__gallery { min-height: 0 !important; height: clamp(310px, 60vw, 480px) !important; }
    .tofaa-product-pilot__gallery-stage { max-width: 100%; }
    .tofaa-product-pilot__title { overflow-wrap: anywhere; }
    .tofaa-product-pilot__review-modal,
    .tofaa-review-lightbox__dialog { max-width: calc(100% - 24px) !important; max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px); overflow-y: auto; overscroll-behavior: contain; }
    .tofaa-review-lightbox__media.has-image-error::after {
        content: "Nie udało się wczytać zdjęcia. Wybierz inne zdjęcie lub spróbuj ponownie później.";
        position: relative; grid-area: 1 / 1; z-index: 3; width: 100%; min-height: 160px;
        display: grid; place-items: center; box-sizing: border-box;
        padding: 16px; background: var(--tofaa-white, #fff5ec); color: var(--tofaa-purple, #7C4FA0);
        font-size: 16px; line-height: 1.5; text-align: center;
    }
    .tofaa-product-pilot__recommended .products { grid-template-columns: none !important; }
    .tofaa-checkout-grid,
    .tofaa-checkout-preflight-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .tofaa-checkout-main, .tofaa-checkout-sidebar { min-width: 0; width: 100%; }
    .tofaa-checkout-sidebar { position: static !important; }
    .tofaa-checkout-preflight-grid__spacer { display: none; }
    .tofaa-checkout-shell { width: 100%; max-width: 100%; }
    .tofaa-checkout-form .form-row { min-width: 0; }
    body.woocommerce-checkout .tofaa-checkout-shell .form-row label.screen-reader-text,
    body.woocommerce-checkout .tofaa-checkout-shell .form-row select.tofaa-country-v2-native {
        width: 1px !important; min-width: 0 !important; height: 1px !important; min-height: 1px !important;
        padding: 0 !important; margin: -1px !important; overflow: hidden !important;
        clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); white-space: nowrap;
    }
    .tofaa-checkout-form .select2-container { max-width: 100%; }
    .tofaa-checkout-form #place_order { width: 100% !important; min-height: 54px; white-space: normal; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-summary__mobile-toggle,
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-summary__mobile-toggle * { color: var(--tofaa-purple, #7C4FA0) !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-summary__mobile-toggle bdi { font-size: 16px !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-qty__stepper,
    .xoo-wsc-container .tofaa-side-cart-qty,
    .xoo-wsc-container .tofaa-side-cart-rec-qty { width: 134px !important; min-width: 134px !important; max-width: 134px !important; height: 46px !important; grid-template-columns: 44px 44px 44px !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-qty__button,
    .xoo-wsc-container .tofaa-side-cart-qty__button,
    .xoo-wsc-container .tofaa-side-cart-rec-qty__button { min-width: 44px !important; max-width: 44px !important; width: 44px !important; height: 44px !important; min-height: 44px !important; flex-basis: 44px !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-qty__value,
    .xoo-wsc-container .tofaa-side-cart-qty__value,
    .xoo-wsc-container .tofaa-side-cart-rec-qty__value { width: 44px !important; min-width: 44px !important; max-width: 44px !important; height: 44px !important; line-height: 44px !important; }
    .xoo-wsc-container .tofaa-side-cart-actions .tofaa-side-cart-qty { flex-basis: 134px !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-qty__stepper::before { left: 44px !important; }
    body.woocommerce-checkout .tofaa-checkout-shell .tofaa-checkout-qty__stepper::after { right: 44px !important; }
    .xoo-wsc-container .tofaa-side-cart-qty::before { left: 44px !important; }
    .xoo-wsc-container .tofaa-side-cart-qty::after { right: 44px !important; }
    .xoo-wsc-container .tofaa-side-cart-remove,
    .xoo-wsc-container .tofaa-side-cart-recommendations__arrow,
    .xoo-wsc-container span.xoo-wsch-close { width: 44px !important; min-width: 44px !important; height: 44px !important; min-height: 44px !important; }
    body .xoo-wsc-container .xoo-wsch-new .xoo-wsch-close {
        flex: 0 0 44px !important; width: 44px !important; min-width: 44px !important; max-width: 44px !important;
        height: 44px !important; min-height: 44px !important; max-height: 44px !important;
    }
    body .xoo-wsc-container .xoo-wsch-new .xoo-wsch-close:focus-visible { outline: 2px solid currentColor !important; outline-offset: 3px; }
    .xoo-wsc-container { max-width: 100% !important; height: 100vh !important; height: 100dvh !important; }
    /* Off-canvas position alone leaves the closed cart in keyboard/AT navigation. */
    body:not(.xoo-wsc-cart-active) .xoo-wsc-container { visibility: hidden !important; }
    body.xoo-wsc-cart-active .xoo-wsc-container { visibility: visible !important; }
    .xoo-wsc-footer { padding-bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important; }
    .woocommerce .show-password-input { width: 44px !important; height: 44px !important; min-width: 44px; min-height: 44px; }
    .woocommerce .password-input input { padding-right: 52px !important; }
    .woocommerce-account .woocommerce-MyAccount-navigation { width: 100% !important; float: none; }
    .woocommerce-account .woocommerce-MyAccount-content { width: 100% !important; float: none; min-width: 0; }
    .woocommerce-account .woocommerce-MyAccount-navigation a { min-height: 44px; }
    body.tofaa-account-ui .woocommerce-MyAccount-content button,
    body.tofaa-account-ui .woocommerce-MyAccount-content input[type="submit"] { min-height: 44px !important; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .tofaa-admin-two-factor .tofaa-two-factor-settings .button,
    body.tofaa-account-ui .woocommerce-MyAccount-content .tofaa-admin-two-factor .tofaa-two-factor-settings input[type="submit"] { min-height: 44px !important; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .tofaa-account-identity-grid { grid-template-columns: minmax(0, 1fr) !important; }
    body.tofaa-account-ui .tofaa-address-modal .screen-reader-text,
    body.tofaa-account-ui .tofaa-address-modal .select2-hidden-accessible {
        width: 1px !important; min-width: 0 !important; height: 1px !important; min-height: 1px !important;
        padding: 0 !important; margin: -1px !important; overflow: hidden !important;
        clip: rect(1px, 1px, 1px, 1px); clip-path: inset(50%); white-space: nowrap;
    }
    body.tofaa-account-ui .tofaa-account-data-nav {
        justify-content: flex-start !important; max-width: 100%; overflow-x: auto;
        scroll-padding-inline: 12px; -webkit-overflow-scrolling: touch;
    }
    body.tofaa-account-ui .tofaa-account-data-nav a,
    body.tofaa-account-ui .tofaa-orders-filter,
    body.tofaa-account-ui .tofaa-reward__button { min-height: 44px !important; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .rbs-account-history__filters {
        grid-template-columns: minmax(0, 1.35fr) repeat(2, minmax(0, 1fr)) !important;
    }
    body.tofaa-account-ui .woocommerce-MyAccount-content .rbs-account-history__filters :where(input, .rbs-history-type-picker, .rbs-history-type-control) {
        min-width: 0 !important; max-width: 100% !important; width: 100% !important;
    }
    body.tofaa-account-ui .woocommerce-MyAccount-content .rbs-account-history__filters input[type="date"] { font-size: 16px !important; }
    .woocommerce-account table { max-width: 100%; overflow-wrap: anywhere; }
    .tofaa-rwd-table-scroll { width: 100%; max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tofaa-rwd-table-scroll:focus-visible { outline: 2px solid currentColor; outline-offset: 3px; }

    /* 06. Club and FAQ: keep existing state machines, drop scaled desktop panels. */
    .tofaa-club-rotator { --club-panel-scale: 1 !important; }
    .tofaa-club-rotator .tofaa-club-drum__panel > .tofaa-club-section { width: 100% !important; zoom: 1 !important; transform: none !important; }
    .tofaa-club-jump,
    .tofaa-faq__tabs { max-width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .tofaa-faq__tabs > [role="tablist"] { justify-content: flex-start !important; }
    [data-club-drum-viewport], [data-tofaa-faq-viewport],
    [data-tofaa-product-gallery], [data-tofaa-sidecart-recommendations] { touch-action: pan-y pinch-zoom; }
    [data-club-tab], [data-tofaa-faq-tab] { min-height: 44px !important; flex-shrink: 0; }
    .tofaa-club-rotator .tofaa-club-faq-layout__intro { grid-template-columns: minmax(0, 1fr) !important; gap: 18px; }
    .tofaa-club-rotator .tofaa-club-referral { grid-template-columns: minmax(0, 1fr) !important; }
    .tofaa-club-heading h2, .tofaa-club-final h2,
    .tofaa-club-rotator .tofaa-club-faq-layout__intro h2,
    .tofaa-club-rotator .tofaa-club-referral__content h2 { font-size: clamp(28px, 4.8vw, 44px) !important; }
    .tofaa-faq :where(button), .tofaa-club-faq :where(button) { min-height: 44px; }
    .wpcf7 input.wpcf7-submit { min-height: 48px !important; }
    .rbs-review-helpful button { min-width: 44px !important; min-height: 44px !important; }

    /* 07. Cookies, floating controls and footer remain reachable above safe areas. */
    #cookie-modal .modal-content, #cookie-banner .cookie-box { max-height: calc(100vh - 24px); max-height: calc(100dvh - 24px); overflow-y: auto; }
    #cookie-manage { bottom: max(12px, env(safe-area-inset-bottom, 0px)); }
    .tofaa-floating-actions { bottom: max(12px, env(safe-area-inset-bottom, 0px)) !important; }
    footer.tofaa-footer :where(nav a, .foot_side li a) { display: inline-flex; align-items: center; min-height: 44px; max-width: 100%; }
    footer.tofaa-footer img { max-width: 100%; }
    .tofaa-home-newsletter form { min-width: 0; }
}

@media screen and (max-width: 700px) {
    .tofaa-home { padding-inline: 16px !important; }
    .tofaa-home .tofaa-hero__buttons .tofaa-btn { width: 100%; }
    .tofaa-home .tofaa-benefit__icon { width: 44px !important; height: 44px !important; }
    .tofaa-home .tofaa-benefit { font-size: 11px !important; line-height: 1.3 !important; }
    .tofaa-home .tofaa-benefits { grid-template-columns: repeat(6, minmax(0, 1fr)) !important; row-gap: 14px !important; }
    .tofaa-home .tofaa-benefit { grid-column: span 2; }
    .tofaa-home .tofaa-benefit:nth-child(4) { grid-column: 2 / span 2; }
    .tofaa-home .tofaa-benefit:nth-child(5) { grid-column: 4 / span 2; }
    .tofaa-community-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .tofaa-community-card--reviews { grid-column: auto; }
    .tofaa-home .tofaa-community-section { margin-top: 24px; }
    .tofaa-product-pilot__title { font-size: clamp(34px, 9vw, 52px) !important; line-height: 1.05 !important; }
    .tofaa-product-pilot__faq h2,
    .tofaa-product-pilot__recommended h2 { font-size: clamp(28px, 7vw, 38px) !important; }
    .tofaa-checkout-section { padding: 20px 16px !important; }
    .tofaa-checkout-form .form-row-first,
    .tofaa-checkout-form .form-row-last { width: 100% !important; float: none !important; }
    .tofaa-club-hero h1 { font-size: clamp(36px, 9vw, 52px) !important; }
    .tofaa-club-jump { justify-content: flex-start !important; flex-wrap: nowrap !important; padding-bottom: 12px; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .rbs-account-history__filters { grid-template-columns: minmax(0, 1fr) !important; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .rbs-account-history__filters > * { grid-column: 1 !important; }
    body.tofaa-account-ui .woocommerce-MyAccount-content .tofaa-account-referrals__empty > div { flex-wrap: wrap !important; }
    .tofaa-club-rotator .tofaa-club-steps,
    .tofaa-club-rotator .tofaa-club-earn-grid,
    .tofaa-club-rotator .tofaa-club-rewards-grid { grid-template-columns: minmax(0, 1fr) !important; }
    .tofaa-nav__brand { width: 110px !important; height: 48px !important; }
    .tofaa-nav { grid-template-columns: minmax(90px, 110px) minmax(44px, 1fr) auto !important; }
    .woocommerce ul.products { grid-template-columns: minmax(0, 1fr) !important; }
}

@media screen and (max-width: 1100px) and (prefers-reduced-motion: reduce) {
    .tofaa-home .tofaa-visual__product,
    .tofaa-home .tofaa-visual__fruit,
    .tofaa-home__ambient-shape { animation: none !important; }
    .tofaa-hero__moments, .tofaa-club-jump { scroll-behavior: auto; }
}
