/*!
 * rb-mobile-product.css — mobile product page buy bar + size/qty sheet
 * Pairs with rb-mobile-product.js. Mobile only, product pages only.
 */

@media (max-width: 991px) {

  /* ---- retire the theme's 244px sticky block that buried the footer ---- */

  /* The site's own custom code carries
     `#product .rb-buy-module .button-group-page { display:block !important }`
     — an ID selector, so it outranks any class-only rule. These selectors
     include the same #product id to win the specificity contest. */
  /* Hidden outright, not gated on `rb-buy-active` the way this used to be.
     That class is only set once the deferred JS has built the bar, so the
     theme block stayed visible for the whole parse-to-DOMContentLoaded
     window -- the red add-to-cart that flashed back on every reload.

     The escape hatch is inverted instead: the JS adds `rb-buy-fallback` if it
     cannot build the bar, which brings the theme controls back, because a
     product page with no buy control at all is worse than the block being
     replaced. Nothing here is gated on a template flag on purpose -- the HTML
     is page-cached, so a flag in the template would not reach visitors until
     that cache is cleared, while this file is picked up by a CSS rebuild.

     `:not(.popup)`: Journal's quick-options popup (a listing's cart button on
     a product with a required size) renders this same product route inside a
     ~570px iframe, so it matched this query too. The JS never builds the bar
     there, which left the popup with no size picker and no add-to-cart --
     only the cashback badge and the MIS Pay widget. */
  html.route-product-product:not(.rb-buy-fallback):not(.popup) #product .rb-buy-module .button-group-page,
  html.route-product-product:not(.rb-buy-fallback):not(.popup) #product .button-group-page,
  html.route-product-product:not(.rb-buy-fallback):not(.popup) .button-group-page {
    position: static !important;
    display: none !important;
  }

  /* The inline options + quantity now live in the sheet. */
  html.route-product-product:not(.rb-buy-fallback):not(.popup) .product-options,
  html.route-product-product:not(.rb-buy-fallback):not(.popup) .stepper-group.cart-group {
    display: none !important;
  }

  /* Room for the slim bar so the footer is fully reachable. */
  html.route-product-product.rb-buy-active body {
    padding-bottom: 76px !important;
  }

  /* ---- bring back the site's sticky bottom menu on product pages -------
     Journal3 ships `html:not(.popup).has-bottom-menu.route-product-product
     .bottom-menu { display:none }` because its own 244px sticky block needed
     the room. That block is gone now, so the menu comes back and the buy bar
     stacks directly above it using the theme's own offset variables. */

  /* The theme collapses the menu on product pages by zeroing this variable
     (68px everywhere else, 0px here), which is why display:block alone left
     it 1px tall. Restore the height, then read it back for the offsets. */
  html.rb-buy-active:not(.popup).has-bottom-menu.route-product-product {
    --bottom-menu-height: 68px !important;
  }

  html.rb-buy-active:not(.popup).has-bottom-menu.route-product-product .bottom-menu {
    display: block !important;
  }

  html.route-product-product.rb-buy-active.has-bottom-menu .rb-buy-bar {
    bottom: var(--bottom-menu-height, 0px);
  }

  html.route-product-product.rb-buy-active.has-bottom-menu body {
    padding-bottom: calc(78px + var(--bottom-menu-height, 0px)) !important;
  }

  html.rb-buy-lock,
  html.rb-buy-lock body {
    overflow: hidden !important;
  }

  /* ------------------------------------------------------------ the bar */

  .rb-buy-bar {
    position: fixed;
    inset-inline: 0;
    bottom: 0;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0px));
    background: #fff;
    border-top: 1px solid #ececec;
    box-shadow: 0 -6px 20px rgba(0, 0, 0, .08);
    direction: rtl;
  }

  .rb-buy-bar .rb-buy-main {
    flex: 1;
    height: 50px;
    border: 0;
    border-radius: 14px;
    background: #f5a400;
    color: #1a1208;
    font-size: 16px;
    font-weight: 900;
    box-shadow: 0 6px 16px rgba(245, 164, 0, .32);
  }

  .rb-buy-bar .rb-buy-main:active { transform: translateY(1px); }

  .rb-buy-bar .rb-buy-cart {
    width: 50px;
    height: 50px;
    flex: 0 0 50px;
    border-radius: 14px;
    background: #fff;
    border: 1.5px solid #171717;
    color: #171717;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .rb-buy-bar .rb-buy-cart svg { width: 22px; height: 22px; }
  .rb-buy-bar .rb-buy-cart:active { background: #f7f7f7; }

  /* ---------------------------------------------------------- the sheet */

  .rb-buy-sheet-wrap {
    position: fixed;
    inset: 0;
    z-index: 10000;
    display: flex;
    align-items: flex-end;
    direction: rtl;
  }

  .rb-buy-bg {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, .45);
    opacity: 0;
    transition: opacity .18s ease;
  }

  .rb-buy-sheet-wrap.is-open .rb-buy-bg { opacity: 1; }

  .rb-buy-sheet {
    position: relative;
    width: 100%;
    max-height: 86vh;
    overflow-y: auto;
    background: #fff;
    border-radius: 22px 22px 0 0;
    padding: 10px 16px calc(16px + env(safe-area-inset-bottom, 0px));
    transform: translateY(16px);
    opacity: .8;
    transition: transform .2s ease, opacity .2s ease;
  }

  .rb-buy-sheet-wrap.is-open .rb-buy-sheet { transform: none; opacity: 1; }

  .rb-buy-handle {
    width: 40px;
    height: 4px;
    border-radius: 999px;
    background: #e3e3e3;
    margin: 2px auto 12px;
  }

  .rb-buy-close {
    position: absolute;
    top: 12px;
    inset-inline-end: 12px;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: #f5f5f6;
    border: 0;
    color: #777;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .rb-buy-close svg { width: 15px; height: 15px; }

  .rb-buy-head {
    display: flex;
    gap: 12px;
    align-items: center;
    padding-bottom: 14px;
    border-bottom: 1px solid #f1f1f1;
    padding-inline-end: 34px;
  }

  .rb-buy-thumb {
    width: 72px;
    height: 72px;
    flex: 0 0 72px;
    border: 1px solid #f0f0f0;
    border-radius: 12px;
    overflow: hidden;
    background: #fff;
  }

  .rb-buy-thumb img { width: 100%; height: 100%; object-fit: contain; }

  .rb-buy-headinfo { min-width: 0; }

  .rb-buy-name {
    font-size: 14px;
    font-weight: 800;
    color: #171717;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
  }

  .rb-buy-price {
    margin-top: 6px;
    font-size: 18px;
    font-weight: 900;
    color: #171717;
  }

  .rb-buy-price .price-old,
  .rb-buy-price del { font-size: 13px; color: #aaa; font-weight: 400; }

  .rb-buy-body { padding: 14px 0 4px; }

  .rb-buy-group + .rb-buy-group { margin-top: 18px; }

  .rb-buy-label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13.5px;
    font-weight: 900;
    color: #171717;
    margin-bottom: 10px;
  }

  .rb-buy-req {
    font-size: 10.5px;
    font-weight: 800;
    color: #9a6200;
    background: #fff7e7;
    border: 1px solid #f5a400;
    border-radius: 999px;
    padding: 2px 8px;
  }

  .rb-buy-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }

  .rb-buy-chip {
    min-width: 52px;
    padding: 11px 16px;
    border-radius: 12px;
    background: #f7f7f8;
    border: 1.5px solid #ececec;
    color: #333;
    font-size: 13.5px;
    font-weight: 800;
  }

  .rb-buy-chip.is-on {
    background: #fff7e7;
    border-color: #f5a400;
    color: #9a6200;
  }

  .rb-buy-qty {
    display: inline-flex;
    align-items: center;
    background: #f7f7f8;
    border: 1.5px solid #ececec;
    border-radius: 999px;
    overflow: hidden;
  }

  .rb-buy-qty button {
    width: 46px;
    height: 46px;
    border: 0;
    background: none;
    color: #2f2f2f;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
  }

  .rb-buy-qty button:active { background: #ededed; }
  .rb-buy-qty button svg { width: 17px; height: 17px; }

  .rb-buy-qtyval {
    min-width: 44px;
    text-align: center;
    font-size: 15px;
    font-weight: 900;
    color: #171717;
  }

  .rb-buy-error {
    margin-top: 14px;
    background: #fff2f2;
    border: 1px solid #ffcaca;
    color: #c0392b;
    border-radius: 10px;
    padding: 10px 12px;
    font-size: 12.5px;
    font-weight: 700;
  }

  .rb-buy-confirm {
    width: 100%;
    height: 52px;
    margin-top: 18px;
    border: 0;
    border-radius: 14px;
    background: #f5a400;
    color: #1a1208;
    font-size: 16px;
    font-weight: 900;
    box-shadow: 0 6px 16px rgba(245, 164, 0, .32);
  }

  .rb-buy-confirm:active { transform: translateY(1px); }

  /* ------------------------------------------- unreadable dark blocks ---
     The theme's dark colour scheme leaks into these product blocks: measured
     background luminance 39 with text luminance 34, i.e. dark-on-dark. They
     are the two icon cards (shipping / returns), the specification tables and
     the expand button. #content / #product are included so these outrank the
     theme's own id-based rules. */

  html.route-product-product #content .info-block,
  html.route-product-product #product .info-block {
    background: #fff !important;
    border: 1px solid #ececec !important;
    border-radius: 14px !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04) !important;
  }

  html.route-product-product #content .info-block,
  html.route-product-product #content .info-block *,
  html.route-product-product #product .info-block,
  html.route-product-product #product .info-block * {
    color: #171717 !important;
  }

  html.route-product-product #content table,
  html.route-product-product #product table {
    background: #fff !important;
    border-radius: 14px;
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    width: 100% !important;
  }

  html.route-product-product #content table td:not(.product-extra-description td),
  html.route-product-product #content table th:not(.product-extra-description th),
  html.route-product-product #product table td:not(.product-extra-description td),
  html.route-product-product #product table th:not(.product-extra-description th) {
    background: #fff !important;
    color: #444 !important;
    border-color: #f0f0f0 !important;
    font-size: 13px;
    padding: 11px 12px !important;
  }

  html.route-product-product #content table td b:not(.product-extra-description b),
  html.route-product-product #content table th:not(.product-extra-description th),
  html.route-product-product #product table td b:not(.product-extra-description b),
  html.route-product-product #product table th:not(.product-extra-description th) {
    color: #171717 !important;
    font-weight: 800 !important;
  }

  html.route-product-product #content .block-expand.btn,
  html.route-product-product #product .block-expand.btn {
    background: #fff !important;
    border: 1px solid #e2e2e2 !important;
    color: #333 !important;
    border-radius: 999px !important;
  }

  /* Product spec list ("الموديل", "رقم المنتج") sits on the light card too. */
  html.route-product-product #content .product-stats,
  html.route-product-product #content .product-stats * {
    color: #444 !important;
  }

  html.route-product-product #content .product-stats b {
    color: #171717 !important;
  }

  /* -------------------------------------------- related product strips ---
     The theme lays these out as a grid 390px wide inside a 342px module with
     282px items, so the carousel never contains them: items land at x=84,
     -215, -513 and get sliced at both edges. Turned into a proper swipeable
     row with two cards per screen. */

  html.route-product-product .side-products,
  html.route-product-product .side-products.no-scroll {
    width: 100% !important;
    max-width: 100% !important;
    overflow: visible !important;
  }

  /* Once a strip has been rebuilt by the JS, the original grid must stay
     hidden. Its inline display:none loses to the !important rule below, so
     it needs its own !important rule. */
  html.route-product-product .auto-grid-items[data-rb-strip="1"] {
    display: none !important;
  }

  /* `:not([data-rb-strip="1"])` matters: :has() carries the specificity of its
     argument, so without it this selector ties the hide rule above and, being
     later in the file, un-hides the original grid — it then paints underneath
     the rebuilt strip. */
  html.route-product-product .auto-grid-items:has(> .product-layout):not([data-rb-strip="1"]) {
    display: flex !important;
    grid-template-columns: none !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 10px !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x proximity;
    padding: 2px 0 10px !important;
    scrollbar-width: none;
  }

  html.route-product-product .auto-grid-items::-webkit-scrollbar {
    display: none;
  }

  /* Keep the card at the width the theme designed it for. Squeezing it to a
     percentage collapsed the Arabic product names to one letter per line. */
  html.route-product-product .auto-grid-items > .product-layout {
    flex: 0 0 min(264px, 78vw) !important;
    width: min(264px, 78vw) !important;
    max-width: min(264px, 78vw) !important;
    min-width: min(264px, 78vw) !important;
    margin: 0 !important;
    scroll-snap-align: start;
  }

  html.route-product-product .auto-grid-items > .product-layout .product-thumb {
    height: auto !important;
    background: #fff !important;
    border: 1px solid #ececec !important;
    border-radius: 14px !important;
    overflow: hidden;
  }

  html.route-product-product .auto-grid-items > .product-layout .caption,
  html.route-product-product .auto-grid-items > .product-layout .name a {
    color: #171717 !important;
  }

  html.route-product-product .auto-grid-items > .product-layout .name a {
    font-size: 12.5px !important;
    font-weight: 700 !important;
    line-height: 1.4 !important;
  }

  html.route-product-product .auto-grid-items > .product-layout .price {
    font-size: 14px !important;
    font-weight: 900 !important;
    color: #171717 !important;
  }

  /* ------------------------------------------ product info-blocks row ---
     The badge cards under the buy module come from an info_blocks module, so
     their children are `.module-item`, not `.product-layout`. The strip rule
     above used to match this grid too: it forced the horizontal flex scroller
     on them while the sizing rule next to it only targets `.product-layout`,
     so the badges fell back to intrinsic width. Together with the negative
     inline margins the theme puts on `.auto-grid` below 900px (they let a
     scroller bleed past the card edge) the row sat off-centre and the last
     badge was clipped by the viewport.

     There are only ever a handful of badges, so lay them out as equal columns
     that fit inside the card instead of a scroller. Scoped to `.product-blocks`
     on purpose: the same module type is used in the footer, which is fine as
     the theme renders it and must not be touched here. */

  html.route-product-product .product-blocks .module-info_blocks .auto-grid {
    margin-inline-start: 0 !important;
    margin-inline-end: 0 !important;
    --scroll-padding: 0px !important;
  }

  html.route-product-product .product-blocks .module-info_blocks .auto-grid-items {
    display: grid !important;
    grid-auto-flow: row !important;
    grid-template-columns: repeat(auto-fit, minmax(84px, 1fr)) !important;
    width: 100% !important;
    max-width: 100% !important;
    gap: 8px !important;
    margin: 0 !important;
    padding: 0 !important;
    overflow: visible !important;
  }

  /* The theme sizes these from --item-width for the scroller it no longer is;
     let the grid track decide the width instead. */
  html.route-product-product .product-blocks .module-info_blocks .auto-grid-items > .module-item {
    width: auto !important;
    min-width: 0 !important;
    max-width: none !important;
    margin: 0 !important;
  }

  /* Badges are icon-only (the glyph is an ::before on .info-block), so centre
     it and let every card share one height. */
  html.route-product-product .product-blocks .module-info_blocks .auto-grid-items > .module-item > .info-block {
    display: flex !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 62px !important;
    align-items: center !important;
    justify-content: center !important;
    margin: 0 !important;
    padding: 12px 6px !important;
  }

  /* ---- rebuilt related strip (markup from rb-mobile-product.js) -------- */

  /* The strip is inserted inside `.side-products`, which is itself a flex
     container — so without these it becomes a centred flex item and the row
     gets clipped at BOTH edges instead of starting flush at the right. */
  html.route-product-product .side-products {
    display: block !important;
    justify-content: flex-start !important;
  }

  html.route-product-product .rb-rel-strip {
    display: flex;
    flex: 1 1 100%;
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    gap: 10px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 0 12px;
    scrollbar-width: none;
    justify-content: flex-start;
    align-items: stretch;
    scroll-snap-type: x proximity;
  }

  html.route-product-product .rb-rel-strip::-webkit-scrollbar { display: none; }

  html.route-product-product .rb-rel-card {
    flex: 0 0 156px;
    width: 156px;
    scroll-snap-align: start;
    display: flex;
    flex-direction: column;
    background: #fff !important;
    border: 1px solid #ececec;
    border-radius: 14px;
    overflow: hidden;
    text-decoration: none !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, .04);
  }

  html.route-product-product .rb-rel-img {
    display: block;
    width: 100%;
    aspect-ratio: 1 / 1;
    background: #fff;
    position: relative;
    overflow: hidden;
  }

  html.route-product-product .rb-rel-img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 6px;
  }

  html.route-product-product .rb-rel-name {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    padding: 8px 10px 0;
    font-size: 12px;
    font-weight: 700;
    line-height: 1.45;
    color: #171717 !important;
    overflow: hidden;
    min-height: 2.9em;
  }

  html.route-product-product .rb-rel-price {
    display: block;
    margin-top: auto;
    padding: 6px 10px 12px;
    font-size: 14px;
    font-weight: 900;
    color: #171717 !important;
  }

  /* Tags block is another dark-on-dark leak. */
  html.route-product-product #content .product-tags,
  html.route-product-product #content .tags,
  html.route-product-product #content .product-tags *,
  html.route-product-product #content .tags * {
    background: transparent !important;
    color: #444 !important;
  }
}

/* RB-POPUP-OPTIONS: in Journal's quick-options popup the shopper came to pick
   a size and add to cart. The payment promos sat above the size picker and
   filled the whole popup, so drop them there; the product page keeps them. */
html.popup .rb-buy-module .mispay-widget-container,
html.popup .rb-buy-module #tabbyPromo {
  display: none !important;
}
