/* ============ المنيو العام — الألوان تأتي من config.json وتُطبَّق عبر هذه المتغيرات ============ */
:root {
  --bg: #F5F7F3;
  --surface: #FFFFFF;
  --ink: #16241D;
  --muted: #5C6B63;
  --line: #E1E7E1;
  --primary: #0E6B4E;
  --on-primary: #FFFFFF;
  --accent: #E9A23B;
  --radius: 18px;
  --maxw: 980px;
  --rail-h: 60px;
  --font: "Readex Pro", system-ui, -apple-system, "Segoe UI", Tahoma, "Noto Sans Arabic", sans-serif;
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  font-size: 1rem;
  line-height: 1.55;
  -webkit-tap-highlight-color: transparent;
}
body.locked { overflow: hidden; }
h1, h2, h3, p, ul { margin: 0; padding: 0; }
ul { list-style: none; }
button, input { font: inherit; color: inherit; }
img { display: block; max-width: 100%; }
svg { width: 22px; height: 22px; flex: none; }
.sprite { position: absolute; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
[hidden] { display: none !important; }

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

.wrap { max-width: var(--maxw); margin-inline: auto; padding-inline: 16px; }

/* ---------- الغلاف والهوية ---------- */
.hero { position: relative; }
.hero-cover {
  height: clamp(150px, 38vw, 270px);
  background: var(--primary);
  position: relative;
  overflow: hidden;
}
.hero-cover img { width: 100%; height: 100%; object-fit: cover; }
.hero-cover.has-img::after {
  content: ""; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, .3), transparent 40%);
}
.lang-btn {
  position: absolute; top: calc(12px + env(safe-area-inset-top)); inset-inline-end: 14px; z-index: 2;
  min-height: 40px; padding: 0 16px; border-radius: 999px; border: 0; cursor: pointer;
  background: rgba(255, 255, 255, .92); color: #16241D; font-weight: 500; font-size: .9rem;
  box-shadow: 0 1px 6px rgba(0, 0, 0, .18);
}
.hero-id {
  position: relative; margin-top: -26px; padding: 0 20px 16px;
  background: var(--bg); border-radius: 28px 28px 0 0; text-align: center;
}
.logo {
  width: 88px; height: 88px; margin: -44px auto 10px; border-radius: 50%;
  background: var(--surface); border: 4px solid var(--bg); overflow: hidden;
  display: grid; place-items: center; box-shadow: 0 2px 12px rgba(0, 0, 0, .14);
  color: var(--primary); font-size: 2rem; font-weight: 700;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
h1 { font-size: clamp(1.5rem, 5.2vw, 2.2rem); font-weight: 700; line-height: 1.25; }
.tagline { margin-top: 4px; color: var(--muted); max-width: 46ch; margin-inline: auto; }
.links { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; margin-top: 14px; }
.links a {
  display: inline-flex; align-items: center; gap: 8px; min-height: 44px; min-width: 44px;
  padding: 0 14px; justify-content: center; border-radius: 999px; text-decoration: none;
  background: var(--surface); border: 1px solid var(--line); color: var(--ink); font-size: .9rem;
}
.links a svg { color: var(--primary); }
.links a.addr { max-width: 100%; }
.links a.addr span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- شريط الأقسام والبحث ---------- */
.rail {
  position: sticky; top: 0; z-index: 20;
  background: var(--bg);
  background: color-mix(in srgb, var(--bg) 90%, transparent);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--line);
  padding-top: env(safe-area-inset-top);
}
.rail-in {
  max-width: var(--maxw); margin-inline: auto; height: var(--rail-h);
  display: flex; align-items: center; gap: 8px; padding-inline: 12px;
}
.icon-btn {
  flex: none; width: 44px; height: 44px; border-radius: 50%; border: 1px solid var(--line);
  background: var(--surface); display: grid; place-items: center; cursor: pointer; color: var(--ink);
}
.chips { flex: 1; min-width: 0; display: flex; gap: 8px; overflow-x: auto; scrollbar-width: none; padding-block: 2px; }
.chips::-webkit-scrollbar { display: none; }
.chip {
  flex: none; height: 40px; padding: 0 16px; border-radius: 999px; cursor: pointer;
  border: 1px solid var(--line); background: var(--surface); color: var(--ink); font-weight: 500; font-size: .92rem;
  transition: background-color .15s, color .15s, border-color .15s;
}
.chip[aria-current="true"] { background: var(--primary); border-color: var(--primary); color: var(--on-primary); }
.search {
  flex: 1; min-width: 0; height: 44px; display: flex; align-items: center; gap: 8px;
  padding-inline: 14px 4px; background: var(--surface); border: 1px solid var(--primary); border-radius: 999px;
}
.search > svg { color: var(--muted); }
.search input {
  flex: 1; min-width: 0; height: 100%; border: 0; background: transparent; outline: 0; font-size: 1rem;
  -webkit-appearance: none; appearance: none;
}
.search input::-webkit-search-cancel-button { display: none; }
.search .icon-btn { border: 0; width: 36px; height: 36px; background: transparent; }
.search:focus-within { outline: 3px solid color-mix(in srgb, var(--primary) 30%, transparent); }

/* ---------- الأقسام والبطاقات ---------- */
.sec { padding-top: 24px; scroll-margin-top: calc(var(--rail-h) + 2px); }
.sec h2 { font-size: 1.3rem; font-weight: 700; margin-bottom: 12px; }
.grid { display: grid; gap: 12px; grid-template-columns: 1fr; }
@media (min-width: 760px) { .grid { grid-template-columns: 1fr 1fr; gap: 16px; } }

.card {
  display: grid; grid-template-columns: minmax(0, 1fr) 104px; gap: 14px; min-height: 128px;
  padding: 12px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  text-align: start; cursor: pointer;
}
.card:active { background: color-mix(in srgb, var(--primary) 5%, var(--surface)); }
.card .txt { display: flex; flex-direction: column; min-width: 0; padding-block: 2px; }
.card h3 { font-size: 1.02rem; font-weight: 600; line-height: 1.35; }
.card .sub { margin-top: 2px; font-size: .82rem; color: var(--muted); }
.card .desc {
  margin-top: 6px; font-size: .88rem; color: var(--muted); line-height: 1.5;
  display: -webkit-box; -webkit-line-clamp: 2; line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.price { margin-top: auto; padding-top: 8px; font-weight: 700; color: var(--primary); unicode-bidi: isolate; }
.price small { font-weight: 500; font-size: .78rem; margin-inline-start: 4px; color: var(--muted); }

.media { position: relative; width: 104px; height: 104px; align-self: center; }
.media img, .media .tile { width: 100%; height: 100%; border-radius: 12px; object-fit: cover; }
.tile { display: grid; place-items: center; color: color-mix(in srgb, var(--primary) 60%, white); background: color-mix(in srgb, var(--primary) 8%, var(--surface)); }
.tile svg { width: 34px; height: 34px; }
.badge-out {
  position: absolute; inset-inline: 6px; bottom: 6px; padding: 2px 6px; border-radius: 999px; text-align: center;
  background: rgba(22, 36, 29, .86); color: #fff; font-size: .72rem; font-weight: 500; line-height: 1.6;
}
.card.out .media img, .card.out .media .tile { filter: grayscale(1); opacity: .55; }
.card.out h3 { color: var(--muted); }
.card.out .price { color: var(--muted); text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---------- حالات خاصة ---------- */
.note { padding: 56px 16px; text-align: center; color: var(--muted); }
.note p + p, .note p + button { margin-top: 12px; }
.note strong { display: block; color: var(--ink); font-size: 1.1rem; margin-bottom: 4px; }
.btn {
  min-height: 44px; padding: 0 22px; border-radius: 999px; border: 0; cursor: pointer;
  background: var(--primary); color: var(--on-primary); font-weight: 600;
}
.count { padding-top: 16px; color: var(--muted); font-size: .9rem; }
#menu > .sk { margin-top: 12px; }
.sk { height: 128px; border-radius: var(--radius); background: color-mix(in srgb, var(--ink) 6%, var(--bg)); animation: pulse 1.2s ease-in-out infinite; }
@keyframes pulse { 50% { opacity: .5; } }
.foot { padding-block: 40px 48px; text-align: center; color: var(--muted); font-size: .85rem; }

/* ---------- نافذة تفاصيل الصنف ---------- */
.sheet { position: fixed; inset: 0; z-index: 50; display: flex; align-items: flex-end; justify-content: center; }
.scrim { position: absolute; inset: 0; background: rgba(10, 20, 15, .55); animation: fade .2s ease-out; }
.panel {
  position: relative; width: 100%; max-width: 520px; max-height: 92vh; max-height: 92dvh; overflow-y: auto;
  background: var(--surface); border-radius: 24px 24px 0 0; padding-bottom: env(safe-area-inset-bottom);
  animation: rise .28s cubic-bezier(.2, .8, .2, 1);
}
.panel .pic { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: var(--bg); }
.panel .pic.tile { border-radius: 0; aspect-ratio: 16 / 7; }
.panel .pic.tile svg { width: 48px; height: 48px; }
.panel .body { padding: 18px 20px 24px; }
.panel h2 { font-size: 1.35rem; font-weight: 700; line-height: 1.3; }
.panel .sub { color: var(--muted); font-size: .9rem; margin-top: 2px; }
.panel .desc { margin-top: 12px; color: var(--ink); white-space: pre-line; }
.panel .row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 18px; }
.panel .price { margin: 0; padding: 0; font-size: 1.4rem; }
.panel .pill { padding: 4px 12px; border-radius: 999px; background: color-mix(in srgb, var(--ink) 8%, var(--surface)); font-size: .85rem; font-weight: 500; }
.panel .x { position: absolute; top: 12px; inset-inline-end: 12px; z-index: 2; background: rgba(255, 255, 255, .94); box-shadow: 0 1px 6px rgba(0, 0, 0, .2); }
@media (min-width: 720px) { .sheet { align-items: center; } .panel { border-radius: 24px; } }
@keyframes rise { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  *, *::before, *::after { animation: none !important; transition: none !important; }
}
