/* ألوان مختارة بتباين ≥ 4.5:1 للنصوص على خلفياتها */
:root {
  --bg: #f7f5f2;
  --surface: #ffffff;
  --text: #1c1b1a;          /* على الأبيض ≈ 17:1 */
  --muted: #5c5852;         /* على الأبيض ≈ 6.9:1، وعلى --bg ≈ 6.3:1 */
  --border: #d9d4cc;
  --primary: #0b5d3b;       /* نص أبيض عليه ≈ 7.6:1 */
  --primary-hover: #084a2f;
  --primary-soft: #e3f1ea;  /* نص --primary عليه ≈ 6.6:1 */
  --danger: #a4161a;        /* نص أبيض عليه ≈ 7.4:1 */
  --danger-soft: #fbe9e9;   /* نص --danger عليه ≈ 6.5:1 */
  --focus: #1d4ed8;
  --radius: 14px;
  --shadow: 0 1px 2px rgb(0 0 0 / 0.06), 0 4px 14px rgb(0 0 0 / 0.06);
  --font: "Tajawal", system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

img { max-inline-size: 100%; display: block; }

button, input, textarea, select { font: inherit; color: inherit; }

button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: 0.55; }

:focus-visible { outline: 3px solid var(--focus); outline-offset: 2px; }

.visually-hidden {
  position: absolute; inline-size: 1px; block-size: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

.wrap { max-inline-size: 960px; margin-inline: auto; padding-inline: 16px; }

/* ---------- تحميل ---------- */
.loading { display: grid; place-items: center; min-block-size: 60vh; }
.spinner {
  inline-size: 36px; block-size: 36px; border-radius: 50%;
  border: 4px solid var(--border); border-block-start-color: var(--primary);
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }
.noscript { padding: 24px; text-align: center; }

/* ---------- رأس المتجر ---------- */
.store-header { background: var(--surface); border-block-end: 1px solid var(--border); }
.store-header .wrap { display: flex; align-items: center; gap: 12px; padding-block: 14px; }
.logo {
  inline-size: 56px; block-size: 56px; border-radius: 12px; object-fit: cover;
  background: var(--primary-soft); flex: none;
}
.logo-fallback {
  display: grid; place-items: center; color: var(--primary); font-weight: 700; font-size: 1.4rem;
}
.store-title { flex: 1; min-inline-size: 0; }
.store-title h1 { margin: 0; font-size: 1.25rem; line-height: 1.3; overflow-wrap: anywhere; }
.pill {
  display: inline-block; margin-block-start: 4px; padding: 2px 10px; border-radius: 999px;
  font-size: 0.85rem; font-weight: 500;
}
.pill.open { background: var(--primary-soft); color: var(--primary); }
.pill.closed { background: var(--danger-soft); color: var(--danger); }

.lang-btn {
  border: 1px solid var(--border); background: var(--surface); border-radius: 10px;
  padding: 6px 12px; min-block-size: 40px; font-weight: 500;
}

.notice { margin-block: 12px 0; padding: 10px 14px; border-radius: 10px; background: var(--surface); border: 1px solid var(--border); color: var(--muted); }
.notice.closed { background: var(--danger-soft); color: var(--danger); border-color: transparent; font-weight: 500; }
.notice a { color: var(--primary); font-weight: 700; }

/* ---------- تبويبات الفئات ---------- */
.tabs {
  position: sticky; inset-block-start: 0; z-index: 5; background: var(--bg);
  border-block-end: 1px solid var(--border);
}
.tabs .wrap { display: flex; gap: 8px; overflow-x: auto; padding-block: 10px; scrollbar-width: none; }
.tabs .wrap::-webkit-scrollbar { display: none; }
.tab {
  flex: none; border: 1px solid var(--border); background: var(--surface); color: var(--text);
  border-radius: 999px; padding: 6px 16px; min-block-size: 40px; white-space: nowrap;
}
.tab[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- المنتجات ---------- */
.section { padding-block: 16px 4px; scroll-margin-block-start: 64px; }
.section h2 { margin: 0 0 10px; font-size: 1.1rem; }
.grid { display: grid; gap: 12px; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); }
@media (min-width: 640px) { .grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); } }

.card {
  background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow);
  overflow: hidden; display: flex; flex-direction: column;
}
.card img, .card .img-ph { aspect-ratio: 4 / 3; inline-size: 100%; object-fit: cover; background: var(--primary-soft); }
.card .img-ph { display: grid; place-items: center; color: var(--primary); font-size: 2rem; font-weight: 700; }
.card-body { padding: 10px 12px 12px; display: flex; flex-direction: column; gap: 6px; flex: 1; }
.card-name { margin: 0; font-size: 1rem; font-weight: 500; overflow-wrap: anywhere; }
.price { font-weight: 700; color: var(--primary); }
.card-actions { margin-block-start: auto; }

.btn {
  border: 0; border-radius: 10px; padding: 8px 14px; min-block-size: 44px;
  background: var(--primary); color: #fff; font-weight: 700; inline-size: 100%;
}
.btn:hover:not(:disabled) { background: var(--primary-hover); }
.btn.secondary { background: var(--surface); color: var(--primary); border: 1px solid var(--primary); }
.btn.whatsapp { background: #0b6b3a; }

.stepper { display: flex; align-items: center; justify-content: space-between; gap: 6px; }
.stepper button {
  inline-size: 44px; block-size: 44px; border-radius: 10px; border: 1px solid var(--primary);
  background: var(--surface); color: var(--primary); font-size: 1.3rem; font-weight: 700; line-height: 1;
}
.stepper output { min-inline-size: 2ch; text-align: center; font-weight: 700; }

/* ---------- شريط السلة ---------- */
.cart-bar {
  position: fixed; inset-inline: 0; inset-block-end: 0; z-index: 10;
  padding: 10px 16px calc(10px + env(safe-area-inset-bottom));
  background: var(--surface); border-block-start: 1px solid var(--border); box-shadow: 0 -4px 14px rgb(0 0 0 / 0.08);
}
.cart-bar .btn { display: flex; justify-content: space-between; align-items: center; max-inline-size: 928px; margin-inline: auto; }
.has-cart { padding-block-end: 88px; }

/* ---------- نافذة السلة وإتمام الطلب ---------- */
.sheet-backdrop { position: fixed; inset: 0; background: rgb(0 0 0 / 0.45); z-index: 20; display: flex; align-items: flex-end; justify-content: center; }
.sheet {
  background: var(--surface); inline-size: 100%; max-inline-size: 640px; max-block-size: 92vh; overflow-y: auto;
  border-start-start-radius: 18px; border-start-end-radius: 18px; padding: 16px 16px calc(20px + env(safe-area-inset-bottom));
}
@media (min-width: 640px) { .sheet-backdrop { align-items: center; } .sheet { border-radius: 18px; } }
.sheet-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-block-end: 8px; }
.sheet-head h2 { margin: 0; font-size: 1.2rem; }
.close-btn { border: 0; background: transparent; font-size: 1.6rem; inline-size: 44px; block-size: 44px; border-radius: 10px; }

.cart-line { display: flex; align-items: center; gap: 10px; padding-block: 10px; border-block-end: 1px solid var(--border); }
.cart-line .info { flex: 1; min-inline-size: 0; }
.cart-line .info p { margin: 0; overflow-wrap: anywhere; }
.cart-line .info .muted { font-size: 0.9rem; }
.cart-line .stepper { flex: none; inline-size: 140px; }

.muted { color: var(--muted); }

fieldset { border: 0; padding: 0; margin: 16px 0 0; }
legend, label.field-label { display: block; font-weight: 700; margin-block-end: 6px; }
.field { margin-block-start: 14px; }
.types { display: flex; flex-wrap: wrap; gap: 8px; }
.types label {
  flex: 1 1 100px; display: flex; align-items: center; justify-content: center; gap: 6px;
  border: 1px solid var(--border); border-radius: 10px; padding: 10px; min-block-size: 44px; cursor: pointer;
}
.types input { accent-color: var(--primary); }
.types label:has(input:checked) { border-color: var(--primary); background: var(--primary-soft); color: var(--primary); font-weight: 700; }

input[type="text"], input[type="tel"], textarea {
  inline-size: 100%; border: 1px solid var(--border); border-radius: 10px; padding: 10px 12px;
  background: var(--surface); min-block-size: 44px;
}
textarea { min-block-size: 80px; resize: vertical; }
.phone { display: flex; gap: 0; }
.phone .dial {
  display: grid; place-items: center; padding-inline: 12px; border: 1px solid var(--border);
  border-inline-end: 0; border-start-start-radius: 10px; border-end-start-radius: 10px; background: var(--bg); color: var(--muted);
}
.phone input { border-start-start-radius: 0; border-end-start-radius: 0; }
.hint { font-size: 0.85rem; color: var(--muted); margin-block-start: 4px; }

.summary { margin-block-start: 16px; padding: 12px; border-radius: 10px; background: var(--bg); }
.summary div { display: flex; justify-content: space-between; padding-block: 3px; }
.summary .total { font-weight: 700; font-size: 1.1rem; border-block-start: 1px solid var(--border); margin-block-start: 6px; padding-block-start: 8px; }

.error { margin-block-start: 12px; padding: 10px 12px; border-radius: 10px; background: var(--danger-soft); color: var(--danger); font-weight: 500; }
.turnstile { margin-block-start: 16px; min-block-size: 65px; }
.submit { margin-block-start: 12px; }

/* ---------- التتبع ---------- */
.track { padding-block: 20px 40px; }
.track-card { background: var(--surface); border-radius: var(--radius); box-shadow: var(--shadow); padding: 16px; margin-block-end: 14px; }
.track-card h2 { margin: 0 0 8px; font-size: 1.1rem; }
.order-no { font-size: 1.6rem; font-weight: 700; margin: 0; }
.status-now { font-size: 1.25rem; font-weight: 700; color: var(--primary); margin: 6px 0 0; }
.status-now.cancelled { color: var(--danger); }
.steps { list-style: none; margin: 14px 0 0; padding: 0; display: grid; gap: 8px; }
.steps li { display: flex; align-items: center; gap: 10px; color: var(--muted); }
.steps li::before {
  content: ""; inline-size: 14px; block-size: 14px; border-radius: 50%;
  border: 2px solid var(--border); background: var(--surface); flex: none;
}
.steps li.done { color: var(--text); }
.steps li.done::before { background: var(--primary); border-color: var(--primary); }
.steps li.current { color: var(--primary); font-weight: 700; }
.steps li.current::before { background: var(--surface); border-color: var(--primary); border-width: 4px; }
.item-row { display: flex; justify-content: space-between; gap: 10px; padding-block: 6px; border-block-end: 1px dashed var(--border); }
.item-row:last-child { border-block-end: 0; }
.updated { font-size: 0.85rem; color: var(--muted); margin-block-start: 10px; }
.back-link { display: inline-block; margin-block-end: 12px; color: var(--primary); font-weight: 700; }

/* ---------- 404 ---------- */
.empty { text-align: center; padding-block: 15vh; }
.empty .big { font-size: 4rem; font-weight: 700; color: var(--primary); margin: 0; line-height: 1; }
.empty h1 { font-size: 1.3rem; margin: 16px 0 8px; }
.empty p { color: var(--muted); margin: 0 auto; max-inline-size: 36ch; }
.empty .lang-btn { margin-block-start: 24px; }

a.btn { display: flex; align-items: center; justify-content: center; text-decoration: none; text-align: center; }
