/* ============================================================
   PureLeaf Menu — main.css
   RTL-first, light theme, mobile-first
   ============================================================ */

:root {
  --bg:        #faf7f2;
  --surface:   #ffffff;
  --surface2:  #f3eee6;
  --border:    #e8e0d4;
  --accent:    #b4532a;
  --accent-soft: rgba(180, 83, 42, .10);
  --text:      #2a211b;
  --muted:     #8a7d70;
  --danger:    #b3261e;

  --font: 'Vazirmatn', system-ui, -apple-system, 'Segoe UI', Tahoma, sans-serif;

  --radius:    14px;
  --max-w:     760px;
  --header-h:  56px;
  --tabs-h:    56px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

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

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.7;
  min-height: 100vh;
  -webkit-tap-highlight-color: transparent;
}
body.has-tabs { padding-bottom: calc(var(--tabs-h) + env(safe-area-inset-bottom, 0px) + 16px); }
body.modal-open { overflow: hidden; }

img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { font: inherit; color: inherit; cursor: pointer; border: 0; background: none; }

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

/* ---------- Loading / error ---------- */
.loading, .error-box {
  text-align: center; color: var(--muted); padding: 64px 16px; font-size: .95rem;
}
.loading::before {
  content: ''; display: block; width: 28px; height: 28px; margin: 0 auto 14px;
  border: 3px solid var(--border); border-top-color: var(--accent);
  border-radius: 50%; animation: spin .8s linear infinite;
}
.error-box { color: var(--danger); }
@keyframes spin { to { transform: rotate(360deg); } }

.fade-in { animation: fadeIn .45s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }

/* ---------- Home ---------- */
.home-hero { padding: 40px 0 24px; text-align: center; }
.home-hero h1 { font-size: 1.9rem; font-weight: 800; line-height: 1.3; }
.home-hero p  { color: var(--muted); margin-top: 6px; font-size: .95rem; }

.cat-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 12px; padding-bottom: 24px;
}
.cat-card {
  position: relative; display: block; overflow: hidden;
  aspect-ratio: 1 / 1; border-radius: var(--radius);
  background: linear-gradient(135deg, #c9754a, #8e3f1d); border: 1px solid var(--border);
  transition: transform .2s ease, box-shadow .2s ease;
}
.cat-card:active { transform: scale(.98); }
.cat-card img {
  position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover;
}
.cat-card::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to top, rgba(30, 20, 12, .78) 0%, rgba(30, 20, 12, 0) 62%);
}
.cat-card-info {
  position: absolute; inset-inline: 0; bottom: 0; z-index: 1;
  padding: 14px; color: #fff;
}
.cat-card-name  { font-weight: 800; font-size: 1.1rem; line-height: 1.3; }
.cat-card-count { font-size: .8rem; opacity: .85; margin-top: 2px; }

.btn-primary {
  display: block; width: fit-content; margin: 8px auto 40px;
  padding: 12px 28px; border-radius: 999px;
  background: var(--accent); color: #fff; font-weight: 700;
}
.btn-primary:active { opacity: .85; }

.updated {
  text-align: center; color: var(--muted); font-size: .8rem; padding-bottom: 32px;
}

/* ---------- Menu top bar ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30; height: var(--header-h);
  background: rgba(250, 247, 242, .92);
  -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar .wrap { height: 100%; display: flex; align-items: center; gap: 10px; }
.topbar-back {
  width: 38px; height: 38px; border-radius: 50%;
  display: grid; place-items: center; background: var(--surface2); font-size: 1.1rem;
}
.topbar-title { font-weight: 800; font-size: 1.05rem; }

/* ---------- Category section ---------- */
.menu-section { scroll-margin-top: calc(var(--header-h) + 8px); padding-top: 20px; }
.menu-section-title {
  display: flex; align-items: center; gap: 12px;
  font-size: 1.25rem; font-weight: 800; padding-bottom: 12px;
}
.menu-section-title::after {
  content: ''; flex: 1; height: 1px; background: var(--border);
}

/* ---------- Item row: image | name+desc | price ---------- */
.item {
  display: grid;
  grid-template-columns: 76px 1fr auto;   /* RTL: image on the right, price on the left */
  align-items: center; gap: 12px;
  width: 100%; text-align: start;
  padding: 10px; margin-bottom: 10px;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius);
  transition: box-shadow .2s ease, transform .15s ease;
}
.item:active { transform: scale(.992); }

.item-img {
  width: 76px; height: 76px; border-radius: 10px; overflow: hidden;
  background: var(--surface2); display: grid; place-items: center;
  color: var(--muted); font-weight: 800; font-size: 1.4rem;
}
.item-img img { width: 100%; height: 100%; object-fit: cover; }

.item-text { min-width: 0; }
.item-name { font-size: 1.05rem; font-weight: 800; line-height: 1.4; }
.item-desc {
  font-size: .82rem; color: var(--muted); line-height: 1.6; margin-top: 2px;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}

.item-price { text-align: end; white-space: nowrap; }
.price-line { font-weight: 800; color: var(--accent); font-size: 1rem; }
.price-line small { font-weight: 500; color: var(--muted); font-size: .72rem; margin-inline-start: 4px; }
.price-line + .price-line { margin-top: 2px; }
.price-line.is-off { color: var(--muted); text-decoration: line-through; opacity: .65; }
.price-currency { display: block; font-size: .7rem; color: var(--muted); font-weight: 500; }

/* Unavailable: faded */
.item.is-off { opacity: .5; }
.item.is-off .item-img img { filter: grayscale(1); }
.item.is-off .price-line { color: var(--muted); text-decoration: line-through; }
.badge-off {
  display: inline-block; margin-inline-start: 6px; padding: 0 8px;
  font-size: .68rem; font-weight: 700; border-radius: 999px;
  background: var(--surface2); color: var(--muted); vertical-align: middle;
}

/* ---------- Bottom tabs ---------- */
.tabs {
  position: fixed; inset-inline: 0; bottom: 0; z-index: 40;
  background: rgba(255, 255, 255, .94);
  -webkit-backdrop-filter: blur(12px); backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  padding-bottom: env(safe-area-inset-bottom, 0px);
}
.tabs-scroll {
  display: flex; gap: 6px; align-items: center;
  height: var(--tabs-h); padding-inline: 12px;
  overflow-x: auto; scrollbar-width: none;
  max-width: var(--max-w); margin-inline: auto;
}
.tabs-scroll::-webkit-scrollbar { display: none; }
.tab {
  flex: 0 0 auto; padding: 8px 16px; border-radius: 999px;
  font-size: .9rem; font-weight: 600; color: var(--muted);
  transition: background .2s ease, color .2s ease;
}
.tab.active { background: var(--accent); color: #fff; }

/* ---------- Modal ---------- */
.modal {
  position: fixed; inset: 0; z-index: 100;
  display: none; align-items: flex-end; justify-content: center;
  background: rgba(20, 14, 8, .55);
}
.modal.open { display: flex; animation: fadeOnly .2s ease both; }
@keyframes fadeOnly { from { opacity: 0; } to { opacity: 1; } }

.modal-card {
  position: relative; width: 100%; max-width: 520px; max-height: 92vh; overflow-y: auto;
  background: var(--surface); border-radius: 22px 22px 0 0;
  animation: sheetUp .28s ease both;
}
@keyframes sheetUp { from { transform: translateY(40px); opacity: .6; } to { transform: none; opacity: 1; } }

.modal-img {
  width: 100%; aspect-ratio: 4 / 3; background: var(--surface2);
  display: grid; place-items: center; font-size: 3rem; color: var(--muted); font-weight: 800;
}
.modal-img img { width: 100%; height: 100%; object-fit: cover; }
.modal-close {
  position: absolute; top: 12px; inset-inline-start: 12px; z-index: 2;
  width: 38px; height: 38px; border-radius: 50%;
  background: rgba(255, 255, 255, .92); box-shadow: 0 2px 8px rgba(0,0,0,.18);
  font-size: 1.2rem; line-height: 1;
}
.modal-body { padding: 18px 20px 28px; }
.modal-name { font-size: 1.35rem; font-weight: 800; line-height: 1.4; }
.modal-cat  { color: var(--accent); font-size: .82rem; font-weight: 700; margin-bottom: 2px; }
.modal-desc { margin-top: 10px; color: #4a3f36; font-size: .95rem; line-height: 1.9; white-space: pre-line; }

.modal-prices { margin-top: 16px; border-top: 1px solid var(--border); }
.modal-price-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.modal-price-row .v-name { font-weight: 600; }
.modal-price-row .v-price { font-weight: 800; color: var(--accent); }
.modal-price-row.is-off { opacity: .5; }
.modal-price-row.is-off .v-price { text-decoration: line-through; color: var(--muted); }
.modal-unavailable {
  margin-top: 14px; padding: 8px 14px; border-radius: 10px;
  background: var(--surface2); color: var(--muted); font-weight: 700; text-align: center;
}

@media (min-width: 640px) {
  .modal { align-items: center; }
  .modal-card { border-radius: 22px; }
  .cat-grid { grid-template-columns: repeat(3, 1fr); }
  .item { grid-template-columns: 96px 1fr auto; }
  .item-img { width: 96px; height: 96px; }
}

footer.site-footer {
  text-align: center; color: var(--muted); font-size: .78rem; padding: 12px 0 28px;
}
