/* =========================================================
   متجر السنبلة — صفحة الكاتالوج
   ========================================================= */
.catalogue { padding-top: 28px; }
.catalogue:focus { outline: none; }

.cat-intro { display: grid; gap: 8px; margin-bottom: 20px; }
.cat-title { font-size: clamp(2rem, 7vw, 3rem); }
.cat-lead { color: var(--muted); max-width: 60ch; }

/* ---------- البحث والأصناف ---------- */
.toolbar { display: grid; gap: 14px; }
.search-box { position: relative; }
.search-icon {
  position: absolute; inset-inline-start: 16px; top: 50%; translate: 0 -50%;
  width: 20px; height: 20px; fill: none; stroke: var(--muted); stroke-width: 2; stroke-linecap: round;
  pointer-events: none;
}
.search-box input {
  width: 100%; min-height: 54px; padding-inline: 48px 52px;
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff;
  font-size: 1rem; /* 16px على الأقل: يمنع iPhone من تكبير الصفحة */
  -webkit-appearance: none; appearance: none;
}
.search-box input::placeholder { color: #8c8378; }
.search-box input:focus { border-color: var(--indigo); outline: none; box-shadow: 0 0 0 3px rgba(30, 42, 74, .15); }
.search-box input::-webkit-search-cancel-button { display: none; }
.search-clear {
  position: absolute; inset-inline-end: 6px; top: 50%; translate: 0 -50%;
  width: 42px; height: 42px; border: 0; border-radius: 50%; background: transparent;
  display: grid; place-items: center;
}
.search-clear:hover { background: var(--linen); }
.search-clear svg, .dlg-close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; }

.chips {
  display: flex; gap: 8px; overflow-x: auto; padding-block: 2px 6px;
  margin-inline: calc(var(--pad) * -1); padding-inline: var(--pad);
  scrollbar-width: none; scroll-padding-inline: var(--pad);
}
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; display: inline-flex; align-items: center; gap: 6px;
  min-height: 42px; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: #fff; font-size: .95rem; white-space: nowrap;
}
.chip:hover { border-color: var(--indigo); }
.chip[aria-pressed="true"] { background: var(--indigo); border-color: var(--indigo); color: #fff; }
.chip-n { font-size: .78rem; opacity: .7; }

.count { margin: 18px 0 12px; font-size: .9rem; color: var(--muted); }

/* ---------- الشبكة ---------- */
.grid {
  list-style: none; margin: 0; padding: 0;
  display: grid; gap: 14px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
}
@media (min-width: 700px) { .grid { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 20px; } }
@media (min-width: 1100px) { .grid { grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 24px; } }

.card {
  position: relative; background: #fff; border-radius: var(--r-md);
  overflow: hidden; box-shadow: var(--shadow);
  display: flex; flex-direction: column;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease);
}
.card:hover { transform: translateY(-3px); box-shadow: 0 2px 4px rgba(34,30,26,.06), 0 14px 32px rgba(34,30,26,.1); }
.card:focus-within { outline: 3px solid var(--indigo); outline-offset: 2px; }
.card-media { aspect-ratio: 1 / 1; background: var(--linen); }
.card-media img { width: 100%; height: 100%; object-fit: cover; }
.card-body { padding: 12px 14px 14px; display: grid; gap: 2px; }
.card-title { font-family: var(--f-body); font-size: 1rem; font-weight: 600; line-height: 1.35; color: var(--ink); }
.card-hit {
  all: unset; cursor: pointer; display: inline;
}
.card-hit::after { content: ""; position: absolute; inset: 0; z-index: 1; }   /* البطاقة كلها قابلة للمس */
.card-hit:focus-visible { outline: none; }
.card-meta { font-size: .8rem; color: var(--muted); }
.card-ref { font-variant-numeric: tabular-nums; }
.card-price { margin-top: 4px; font-weight: 700; color: var(--indigo); font-size: 1.02rem; }
.card-badge {
  position: absolute; top: 10px; inset-inline-start: 10px; z-index: 2; pointer-events: none;
  background: var(--madder); color: #fff; font-size: .75rem; padding: 3px 10px; border-radius: 999px;
}
.card.is-out .card-media { opacity: .55; }

/* ---------- المربع المؤقت قبل وصول الصور ---------- */
.ph {
  width: 100%; height: 100%; display: grid; place-items: center;
  background-color: var(--c, var(--linen));
  background-image:
    repeating-linear-gradient(0deg, rgba(255,255,255,.10) 0 1px, transparent 1px 5px),
    repeating-linear-gradient(90deg, rgba(0,0,0,.07) 0 1px, transparent 1px 5px);
  color: rgba(34, 30, 26, .72);
}
.ph-dark { color: rgba(250, 247, 241, .85); }
.ph-label {
  font-size: .75rem; padding: 4px 10px; border-radius: 999px;
  border: 1px dashed currentColor;
}

/* ---------- حالة لا نتائج ---------- */
.empty {
  text-align: center; padding: 40px 20px; border: 1.5px dashed var(--line); border-radius: var(--r-lg);
  display: grid; gap: 10px; justify-items: center; color: var(--muted);
}
.empty-title { font-size: 1.4rem; }
.empty-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin-top: 8px; }
.noscript { padding: 20px; background: var(--linen); border-radius: var(--r-md); }

/* ---------- شريط قائمة الطلب ---------- */
.order-bar {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 25;
  padding: 10px var(--pad) calc(10px + env(safe-area-inset-bottom));
  display: flex; justify-content: center; pointer-events: none;
}
.order-bar[hidden] { display: none; }
.order-bar-btn {
  pointer-events: auto; display: flex; align-items: center; gap: 10px;
  min-height: 54px; padding: 10px 22px; border: 0; border-radius: 999px;
  background: var(--indigo); color: #fff; box-shadow: 0 10px 30px rgba(30, 42, 74, .35);
  font-weight: 600; width: min(100%, 440px); justify-content: space-between;
}
.order-bar-count {
  min-width: 28px; height: 28px; padding: 0 8px; border-radius: 999px;
  background: var(--wheat); color: var(--indigo); display: grid; place-items: center; font-size: .9rem;
}
.order-bar-label { margin-inline-end: auto; }
body.has-order-bar .site-footer { padding-bottom: 110px; }

/* ---------- النوافذ ---------- */
.dlg {
  padding: 0; border: 0; background: transparent; color: var(--ink);
  width: 100%; max-width: 100%; max-height: 100%; height: 100%; margin: 0;
}
.dlg:focus, .dlg-inner:focus { outline: none; }
.dlg::backdrop { background: rgba(20, 24, 38, .55); }
.dlg-inner {
  position: absolute; inset-inline: 0; bottom: 0;
  max-height: 92dvh; overflow-y: auto; overscroll-behavior: contain;
  background: var(--cotton); border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding: 18px var(--pad) calc(24px + env(safe-area-inset-bottom));
}
@media (min-width: 760px) {
  .dlg-inner {
    inset: 50% auto auto 50%; translate: -50% -50%; bottom: auto;
    width: min(92vw, 880px); max-height: 88vh; border-radius: var(--r-lg); padding: 28px;
  }
  .dlg-order .dlg-inner { width: min(92vw, 560px); }
}
.dlg[open] .dlg-inner { animation: dlg-in .28s var(--ease); }
@keyframes dlg-in { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }

.dlg-close {
  position: sticky; top: 0; z-index: 3; grid-column: 1 / -1; justify-self: end;
  margin-bottom: -44px; width: 44px; height: 44px; border-radius: 50%; border: 0;
  background: #fff; box-shadow: var(--shadow); display: grid; place-items: center;
}

/* نافذة المنتج */
.dlg-inner { display: grid; align-content: start; grid-auto-rows: max-content; }
.dlg-product .dlg-inner { gap: 18px; }
@media (min-width: 760px) {
  .dlg-product .dlg-inner { grid-template-columns: 1fr 1fr; gap: 28px; align-items: start; }
}
.p-media { aspect-ratio: 1 / 1; border-radius: var(--r-md); overflow: hidden; background: var(--linen); }
.p-media img { width: 100%; height: 100%; object-fit: cover; }
.p-info { display: grid; gap: 10px; align-content: start; }
.p-cat { font-size: .85rem; color: var(--muted); }
.p-title { font-size: clamp(1.6rem, 5vw, 2.1rem); }
.p-ref { font-size: .85rem; color: var(--muted); direction: ltr; text-align: start; }
[dir="rtl"] .p-ref { text-align: right; }
.p-out {
  justify-self: start; background: var(--madder); color: #fff; font-size: .8rem;
  padding: 3px 12px; border-radius: 999px;
}
.p-specs { margin: 4px 0; display: grid; gap: 0; border-top: 1px dashed var(--line); }
.p-specs div { display: flex; justify-content: space-between; gap: 16px; padding: 9px 0; border-bottom: 1px dashed var(--line); }
.p-specs dt { color: var(--muted); }
.p-specs dd { margin: 0; font-weight: 600; text-align: end; }

.qty { display: grid; gap: 8px; margin-top: 4px; }
.qty-label { font-weight: 600; }
.qty-ctrl {
  display: inline-flex; align-items: center; justify-self: start;
  border: 1.5px solid var(--line); border-radius: 999px; background: #fff;
}
.qty-btn {
  width: 48px; height: 48px; border: 0; background: transparent; border-radius: 50%;
  font-size: 1.4rem; line-height: 1; color: var(--indigo);
}
.qty-btn:hover:not(:disabled) { background: var(--linen); }
.qty-btn:disabled { color: #b9b0a3; cursor: default; }
.qty-input {
  width: 72px; height: 48px; border: 0; text-align: center; font-size: 1.1rem; font-weight: 600;
  background: transparent; -moz-appearance: textfield; appearance: textfield;
}
.qty-input::-webkit-outer-spin-button, .qty-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
.p-total { color: var(--muted); }
.p-total strong { color: var(--indigo); font-size: 1.15rem; }

.p-actions { display: grid; gap: 10px; margin-top: 6px; }
.p-status { min-height: 1.5em; font-size: .9rem; color: var(--wa); font-weight: 600; }
.p-note { font-size: .8rem; color: var(--muted); }

/* نافذة القائمة */
.o-title { font-size: 1.6rem; margin-bottom: 14px; padding-inline-end: 56px; min-height: 44px; }
.o-empty { color: var(--muted); padding: 12px 0 8px; }
.o-list { list-style: none; margin: 0 0 12px; padding: 0; }
.o-item {
  display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center;
  padding: 12px 0; border-bottom: 1px dashed var(--line);
}
.o-swatch { width: 64px; height: 64px; border-radius: var(--r-sm); overflow: hidden; }
.o-swatch img { width: 100%; height: 100%; object-fit: cover; }
.o-swatch .ph-label { display: none; }
.o-name { font-weight: 600; line-height: 1.3; }
.o-meta { font-size: .8rem; color: var(--muted); margin-bottom: 4px; }
.qty-ctrl-sm .qty-btn { width: 38px; height: 38px; font-size: 1.15rem; }
.qty-value { min-width: 60px; text-align: center; font-weight: 600; font-size: .95rem; }
.o-side { display: grid; justify-items: end; gap: 2px; }
.o-line { font-weight: 700; color: var(--indigo); white-space: nowrap; }
.o-foot { display: grid; gap: 10px; }
.o-total { font-size: 1.05rem; }
.o-total strong { color: var(--indigo); font-size: 1.25rem; }
.o-foot .btn-text { justify-self: center; }
