/*
 * RB CASHBACK picker.
 *
 * Brand palette, not a generic green: the store is black chrome with the gold
 * used on "اشتر الآن". The gold variables are already declared globally by
 * rb_contrast_fix.css; they are repeated here as fallbacks so the popup is
 * never unstyled if that file is reordered.
 *
 * Layout: categories in a fixed side rail, products in a card grid. Both panes
 * scroll independently and the body is capped, so a long category list can no
 * longer stretch the dialog down the page.
 *
 * Logical properties (inline-start/end) throughout, so the same rules lay out
 * correctly in this RTL storefront and in an LTR one.
 */
.rb-cb-modal {
  --cb-gold: var(--rb-fix-gold, #f5a400);
  --cb-gold-ink: var(--rb-fix-gold-ink, #1a1208);
  --cb-gold-soft: #fff6e2;
  --cb-gold-line: #f0d9a4;
  --cb-ink: var(--rb-fix-ink, #171717);
  --cb-muted: var(--rb-fix-muted, #6b7280);
  --cb-line: var(--rb-fix-border, #e4e8f0);
  --cb-black: #141414;

  position: fixed;
  inset: 0;
  z-index: 16000;
  display: none;
}
.rb-cb-modal.is-open { display: block; }
body.rb-cb-locked { overflow: hidden; }

.rb-cb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 8, .66);
}

.rb-cb-box {
  position: relative;
  margin: 5vh auto;
  width: min(880px, 94vw);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 26px 64px rgba(0, 0, 0, .4);
}

/* ── Header: black chrome, gold badge ─────────────────────────────────────── */
.rb-cb-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--cb-black);
  color: #fff;
}
.rb-cb-title {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  font-size: 15px;
  font-weight: 700;
  line-height: 1.45;
}
.rb-cb-coin {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  flex: 0 0 30px;
  border-radius: 50%;
  background: var(--cb-gold);
  color: var(--cb-gold-ink);
  font-size: 15px;
  font-weight: 800;
}
.rb-cb-x {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  opacity: .75;
}
.rb-cb-x:hover { opacity: 1; }

/* ── Meter: used vs left ──────────────────────────────────────────────────── */
.rb-cb-meter {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 16px;
  background: var(--cb-gold-soft);
  border-bottom: 1px solid var(--cb-gold-line);
  color: var(--cb-gold-ink);
  font-size: 12.5px;
  font-weight: 700;
}
.rb-cb-sep {
  flex: 1;
  height: 1px;
  background: var(--cb-gold-line);
}

/* ── Two panes ────────────────────────────────────────────────────────────── */
.rb-cb-body {
  display: flex;
  min-height: 0;
  /* Capped so a long category list cannot stretch the dialog; each pane
     scrolls on its own instead. */
  max-height: 62vh;
}

.rb-cb-cats {
  width: 190px;
  flex: 0 0 190px;
  border-inline-end: 1px solid var(--cb-line);
  background: #fafafa;
  overflow-y: auto;
}
.rb-cb-cats-title {
  padding: 11px 13px 5px;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .5px;
  color: var(--cb-muted);
  text-transform: uppercase;
}
.rb-cb-cats ul { list-style: none; margin: 0; padding: 0 0 10px; }
.rb-cb-cats li {
  padding: 8px 13px;
  font-size: 12.5px;
  line-height: 1.4;
  color: #33383f;
  cursor: pointer;
  border-inline-start: 3px solid transparent;
}
.rb-cb-cats li:hover { background: #f1f2f4; }
.rb-cb-cats li.is-active {
  background: #fff;
  border-inline-start-color: var(--cb-gold);
  color: var(--cb-ink);
  font-weight: 700;
}

.rb-cb-items {
  flex: 1;
  min-width: 0;
  overflow-y: auto;
  padding: 12px;
  display: grid;
  /* Narrower columns than before so three or four cards share a row instead of
     leaving a wide empty band under them. */
  grid-template-columns: repeat(auto-fill, minmax(168px, 1fr));
  gap: 10px;
  align-content: start;
}
.rb-cb-empty {
  grid-column: 1 / -1;
  padding: 36px 10px;
  text-align: center;
  color: var(--cb-muted);
  font-size: 13px;
}

/* ── Product card: image, name, the three numbers, action ─────────────────── */
.rb-cb-card {
  display: flex;
  flex-direction: column;
  padding: 10px;
  border: 1px solid var(--cb-line);
  border-radius: 10px;
  background: #fff;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.rb-cb-card:hover {
  border-color: var(--cb-gold);
  box-shadow: 0 6px 18px rgba(0, 0, 0, .08);
}
.rb-cb-card img {
  width: 100%;
  height: 84px;
  object-fit: contain;
  border-radius: 6px;
  background: #fff;
  margin-bottom: 8px;
}
.rb-cb-card-body { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.rb-cb-name {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  font-size: 12px;
  font-weight: 600;
  line-height: 1.4;
  color: var(--cb-ink);
  text-decoration: none;
  margin-bottom: 7px;
  min-height: 33px;
}
.rb-cb-name:hover { color: var(--cb-gold-ink); }

/* Label left, figure right, on their own baseline so the three rows line up
   down the card instead of drifting with the text length. */
.rb-cb-rows {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: baseline;
  gap: 3px 8px;
  font-size: 11px;
  color: var(--cb-muted);
  margin-bottom: 9px;
}
.rb-cb-rows b { font-weight: 700; color: #3a4048; }
.rb-cb-green { color: var(--cb-gold-ink) !important; }
.rb-cb-rows b.rb-cb-green { color: #9a6b00 !important; }

/* What they actually part with - the number that decides the sale. */
.rb-cb-pay { color: var(--cb-ink) !important; font-weight: 700 !important; }
.rb-cb-rows b.rb-cb-pay {
  font-size: 14px;
  color: var(--cb-ink) !important;
}

.rb-cb-add {
  display: block;
  margin-top: auto;
  width: 100%;
  padding: 8px 10px;
  border: 0;
  border-radius: 8px;
  background: var(--cb-gold);
  color: var(--cb-gold-ink);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.rb-cb-add:hover,
.rb-cb-add:focus {
  background: #e09600;
  color: var(--cb-gold-ink);
  text-decoration: none;
}
.rb-cb-add.is-busy { opacity: .55; pointer-events: none; }

/* Notice shown once the cashback is spent - they can still add more, at price. */
.rb-cb-note {
  grid-column: 1 / -1;
  padding: 9px 12px;
  margin-bottom: 2px;
  border: 1px solid var(--cb-gold-line);
  border-radius: 8px;
  background: var(--cb-gold-soft);
  color: var(--cb-gold-ink);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

/* Added confirmation */
.rb-cb-card.is-added { border-color: var(--cb-gold); }
.rb-cb-add.is-added {
  background: #1e9e4a;
  color: #fff;
  pointer-events: none;
}

/* ── Footer: the way onward ───────────────────────────────────────────────── */
.rb-cb-foot {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border-top: 1px solid var(--cb-line);
  background: #fafafa;
}
.rb-cb-go {
  flex: 1;
  padding: 11px 16px;
  border-radius: 9px;
  background: var(--cb-black);
  color: #fff;
  font-size: 13.5px;
  font-weight: 800;
  text-align: center;
  text-decoration: none;
}
.rb-cb-go:hover,
.rb-cb-go:focus { background: #000; color: #fff; text-decoration: none; }

/* Once the cashback is used the order is the thing to finish, so the primary
   action takes the brand gold. */
.rb-cb-modal.is-done .rb-cb-go {
  background: var(--cb-gold);
  color: var(--cb-gold-ink);
}
.rb-cb-modal.is-done .rb-cb-go:hover { background: #e09600; color: var(--cb-gold-ink); }

.rb-cb-cart {
  flex: 0 0 auto;
  padding: 11px 14px;
  border: 1px solid var(--cb-line);
  border-radius: 9px;
  background: #fff;
  color: var(--cb-ink);
  font-size: 12.5px;
  font-weight: 700;
  text-decoration: none;
}
.rb-cb-cart:hover { border-color: var(--cb-gold); color: var(--cb-ink); text-decoration: none; }

.rb-cb-later {
  flex: 0 0 auto;
  background: transparent;
  border: 0;
  color: var(--cb-muted);
  font-size: 12.5px;
  text-decoration: underline;
  cursor: pointer;
}
.rb-cb-later:hover { color: var(--cb-ink); }

@media (max-width: 480px) {
  .rb-cb-foot { flex-wrap: wrap; }
  .rb-cb-go { flex: 1 0 100%; order: 1; }
  .rb-cb-cart { order: 2; flex: 1; text-align: center; }
  .rb-cb-later { order: 3; flex: 1; text-align: center; }
}

/* ── Phones: categories become a chip strip above the products ────────────── */
@media (max-width: 767px) {
  .rb-cb-box {
    margin: 0;
    width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
  }
  .rb-cb-body {
    flex-direction: column;
    max-height: none;
    flex: 1;
  }
  .rb-cb-cats {
    width: auto;
    flex: 0 0 auto;
    border-inline-end: 0;
    border-bottom: 1px solid var(--cb-line);
    overflow-x: auto;
    overflow-y: hidden;
    white-space: nowrap;
    background: #fff;
  }
  .rb-cb-cats-title { display: none; }
  .rb-cb-cats ul { display: flex; gap: 7px; padding: 9px; }
  .rb-cb-cats li {
    border: 1px solid var(--cb-line);
    border-radius: 999px;
    padding: 6px 13px;
    background: #fff;
  }
  .rb-cb-cats li.is-active {
    border-color: var(--cb-gold);
    background: var(--cb-gold-soft);
  }
  .rb-cb-items {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .rb-cb-title { font-size: 14px; }
}

/* ------------------------------------------------------------------------
 * Listing card offer tags (rb_cashback.js -> scanCards).
 *
 * Pinned to the bottom inline-start corner of the product image, clear of
 * Journal's own corner labels and the floating wishlist button. BOGO is the
 * gold pill (the stronger offer), cashback the black pill with gold ink.
 * ---------------------------------------------------------------------- */
.rb-tag-stack {
  position: absolute;
  inset-inline-start: 8px;
  bottom: 8px;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 5px;
  max-width: calc(100% - 16px);
  pointer-events: none;
}

.rb-tag {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  max-width: 100%;
  padding: 3px 10px 3px 3px;
  padding-inline: 3px 10px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 800;
  line-height: 1.2;
  white-space: nowrap;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .18), inset 0 0 0 1px rgba(255, 255, 255, .14);
  animation: rb-tag-in .45s cubic-bezier(.2, .9, .3, 1.25) both;
}

.rb-tag-txt {
  overflow: hidden;
  text-overflow: ellipsis;
}

.rb-tag-txt i {
  font-size: .95em;
}

.rb-tag-ico {
  flex: 0 0 auto;
  display: inline-grid;
  place-items: center;
  width: 22px;
  height: 22px;
  border-radius: 50%;
}

.rb-tag-ico svg {
  width: 13px;
  height: 13px;
  display: block;
  transform-origin: 50% 80%;
  animation: rb-tag-wiggle 4.5s ease-in-out 1.2s infinite;
}

.rb-tag-bogo {
  color: #1a1208;
  background: linear-gradient(135deg, #ffd66b 0%, #f5a400 55%, #e08e00 100%);
}

.rb-tag-bogo .rb-tag-ico {
  color: #f5c542;
  background: #141414;
}

/* Cashback: green = money back. White gift disc holding a filled two-tone gift. */
.rb-tag-cb {
  color: #fff;
  background: linear-gradient(135deg, #34d058 0%, #16a34a 55%, #0f7a37 100%);
  box-shadow: 0 4px 12px rgba(22, 163, 74, .35), inset 0 0 0 1px rgba(255, 255, 255, .22);
}

.rb-tag-cb .rb-tag-ico {
  width: 24px;
  height: 24px;
  background: #fff;
  box-shadow: 0 1px 3px rgba(0, 0, 0, .18);
}

.rb-tag-cb .rb-tag-ico svg {
  width: 17px;
  height: 17px;
}

/* A slow sheen across the pill, so the offer catches the eye without shouting. */
.rb-tag {
  position: relative;
  overflow: hidden;
}

.rb-tag::after {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  width: 40%;
  left: -60%;
  background: linear-gradient(100deg, transparent, rgba(255, 255, 255, .45), transparent);
  animation: rb-tag-sheen 5s ease-in-out 1.5s infinite;
}

@keyframes rb-tag-in {
  from { opacity: 0; transform: translateY(6px) scale(.9); }
  to   { opacity: 1; transform: none; }
}

@keyframes rb-tag-wiggle {
  0%, 86%, 100% { transform: rotate(0); }
  89% { transform: rotate(-14deg); }
  92% { transform: rotate(12deg); }
  95% { transform: rotate(-8deg); }
  98% { transform: rotate(4deg); }
}

@keyframes rb-tag-sheen {
  0%, 70% { left: -60%; }
  100%    { left: 130%; }
}

@media (max-width: 575px) {
  .rb-tag-stack { inset-inline-start: 5px; bottom: 5px; gap: 4px; max-width: calc(100% - 10px); }
  .rb-tag { font-size: 10.5px; gap: 4px; padding-inline: 2px 8px; }
  .rb-tag-ico { width: 18px; height: 18px; }
  .rb-tag-ico svg { width: 11px; height: 11px; }
  .rb-tag-cb .rb-tag-ico { width: 21px; height: 21px; }
  .rb-tag-cb .rb-tag-ico svg { width: 15px; height: 15px; }
}

@media (prefers-reduced-motion: reduce) {
  .rb-tag, .rb-tag-ico svg, .rb-tag::after { animation: none; }
}

/*
 * rb_contrast_fix.css forces `color: var(--rb-text) !important` on everything
 * under #content (ID specificity), which painted dark text onto the black
 * cashback pill. The two :not(#id) clauses lift these rules to 2 IDs so the
 * pills keep their own ink wherever they appear.
 */
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo,
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo .rb-tag-txt {
  color: #1a1208 !important;
  -webkit-text-fill-color: #1a1208 !important;
}

html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo .rb-tag-ico,
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo .rb-tag-ico svg,
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo .rb-tag-ico svg * {
  color: #f5c542 !important;
}

html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-cb,
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-cb .rb-tag-txt {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .18);
}

/* The cashback amount carries the store's riyal icon (<i class="icon-saudi-riyal-symbol">),
   which the site-wide contrast rule would otherwise paint dark on the green pill. */
html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-cb .rb-tag-txt * {
  color: #fff !important;
  -webkit-text-fill-color: #fff !important;
}

html:not(#rb-tag-a):not(#rb-tag-b) .rb-tag-bogo .rb-tag-txt * {
  color: #1a1208 !important;
  -webkit-text-fill-color: #1a1208 !important;
}

.rb-tag-txt i[class*="riyal"] {
  font-size: .95em;
  margin-inline-end: 2px;
  vertical-align: -1px;
}
