/* ============================================================
   QR Menu — shared template styles
   Per-cafe theming via CSS variables (set from menu-data.json).
   Layout uses logical properties (inline-start/end), so the same
   rules work for LTR and RTL (dir="rtl" on <html>).
   ============================================================ */

:root {
  --accent:       #c0392b;
  --accent-ink:   #ffffff;
  --accent-soft:  color-mix(in srgb, var(--accent) 9%, #ffffff);
  --accent-deep:  color-mix(in srgb, var(--accent) 70%, #000000);
  --bg:           #f6f2ec;
  --card:         #ffffff;
  --ink:          #231b16;
  --muted:        color-mix(in srgb, var(--ink) 55%, var(--bg));
  --line:         color-mix(in srgb, var(--ink) 9%, transparent);
  --shadow-sm:    0 1px 2px rgba(35, 27, 22, .05), 0 4px 14px rgba(35, 27, 22, .06);
  --shadow-md:    0 2px 6px rgba(35, 27, 22, .06), 0 14px 34px rgba(35, 27, 22, .12);
  --font-brand:   "Italiana", "Jost", serif;
  --font-body:    "Jost", "Tajawal", system-ui, sans-serif;
  --radius:       22px;
  --radius-sm:    16px;
  --shell-w:      560px;
  --tabs-h:       68px;
  --ease:         cubic-bezier(.22, 1, .36, 1);
}

:root[dir="rtl"] {
  --font-body: "Tajawal", "Jost", system-ui, sans-serif;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--ink);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}
img { display: block; max-width: 100%; }

.shell {
  max-width: var(--shell-w);
  margin-inline: auto;
  min-height: 100dvh;
  background: var(--bg);
}
@media (min-width: 640px) {
  body { background: color-mix(in srgb, var(--bg) 88%, var(--ink)); }
  .shell { box-shadow: 0 0 80px rgba(35, 27, 22, .16); }
}

[hidden] { display: none !important; }

/* ---------- 1 · Cover (hero) ---------- */
.cover {
  position: relative;
  height: clamp(300px, 86vw, 440px);
  overflow: hidden;
  background: var(--accent-deep);
  border-end-start-radius: 32px;
  border-end-end-radius: 32px;
  isolation: isolate;
}
.cover > img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  animation: coverIn 1.6s var(--ease) both;
}
/* darken the bottom so the brand name is always legible */
.cover::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 1;
  background:
    linear-gradient(180deg,
      rgba(0,0,0,.28) 0%,
      rgba(0,0,0,0) 26%,
      rgba(0,0,0,0) 42%,
      color-mix(in srgb, var(--accent-deep) 55%, transparent) 70%,
      color-mix(in srgb, var(--accent-deep) 94%, transparent) 100%);
}
@keyframes coverIn {
  from { transform: scale(1.08); opacity: .6; }
  to   { transform: scale(1);    opacity: 1; }
}

.cover-brand {
  position: absolute;
  z-index: 2;
  inset-inline: 0;
  bottom: 0;
  padding: 0 24px 30px;
  text-align: center;
  color: #fff;
}
.cafe-name {
  font-family: var(--font-brand);
  font-weight: 400;
  font-size: clamp(54px, 16vw, 78px);
  line-height: 1;
  letter-spacing: .01em;
  text-shadow: 0 2px 24px rgba(0,0,0,.25);
  animation: riseIn .9s .15s var(--ease) both;
}
.cafe-subtitle {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  font-family: "Jost", var(--font-body);
  font-size: 12px;
  font-weight: 500;
  letter-spacing: .42em;
  text-transform: uppercase;
  color: rgba(255,255,255,.86);
  animation: riseIn .9s .25s var(--ease) both;
}
.cafe-subtitle::before,
.cafe-subtitle::after {
  content: "";
  width: 28px; height: 1px;
  background: rgba(255,255,255,.5);
}

/* Identity block when there is no cover image */
.identity {
  text-align: center;
  padding: 36px 24px 8px;
}
.identity .cafe-name { color: var(--accent); text-shadow: none; }
.identity .cafe-subtitle { color: var(--muted); }
.identity .cafe-subtitle::before,
.identity .cafe-subtitle::after { background: var(--line); }

@keyframes riseIn {
  from { opacity: 0; transform: translateY(14px); }
  to   { opacity: 1; transform: none; }
}

/* ---------- 2 · Tagline ---------- */
.extras {
  padding: 22px 16px 0;
  animation: riseIn .8s .2s var(--ease) both;
}
.cafe-tagline {
  max-width: 400px;
  margin: 0 auto;
  text-align: center;
  font-size: 15.5px;
  font-weight: 500;
  line-height: 1.8;
  color: color-mix(in srgb, var(--ink) 78%, var(--bg));
  text-wrap: balance;
}

/* ---------- 6 · Visit us: branches + social (bottom of page) ---------- */
.visit {
  margin: 4px 16px 0;
  padding: 16px 16px 14px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
}
.visit-title {
  font-size: 16px;
  font-weight: 800;
  color: var(--ink);
  margin-bottom: 2px;
}

.locations { list-style: none; }
.location {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 10px 0;
}
.location + .location { border-top: 1px solid var(--line); }
.location-body { flex: 1; min-width: 0; }
.location-city { font-size: 14.5px; font-weight: 700; line-height: 1.3; }
.location-addr { font-size: 12.5px; color: var(--muted); line-height: 1.45; }
.location-num {
  margin-top: 1px;
  font-family: "Jost", var(--font-body);
  font-size: 12.5px;
  font-weight: 500;
  letter-spacing: .03em;
  color: var(--ink);
  direction: ltr;
  unicode-bidi: isolate;
  width: fit-content;
}
.location-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 8px;
}
.location-map,
.location-call {
  flex: 0 0 auto;
  width: 36px; height: 36px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 10px color-mix(in srgb, var(--accent) 28%, transparent);
  transition: transform .15s;
}
.location-map {
  background: var(--accent-soft);
  color: var(--accent);
  box-shadow: none;
}
.location-map svg,
.location-call svg { width: 16px; height: 16px; }
.location-map:active,
.location-call:active { transform: scale(.92); }

.social-row {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
  padding-top: 12px;
  border-top: 1px solid var(--line);
}
.visit > .social-row:first-child { border-top: 0; padding-top: 0; margin-top: 0; }
.social-link {
  width: 40px; height: 40px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  transition: background .2s, color .2s, transform .15s;
}
.social-link svg { width: 20px; height: 20px; }
.social-link:hover { background: var(--accent); color: var(--accent-ink); }
.social-link:active { transform: scale(.92); }

/* ---------- 3 · Sticky tabs bar ---------- */
.tabsbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: var(--tabs-h);
  margin-top: 10px;
  padding: 12px 14px;
  background: color-mix(in srgb, var(--bg) 86%, transparent);
  -webkit-backdrop-filter: saturate(1.4) blur(16px);
  backdrop-filter: saturate(1.4) blur(16px);
  border-bottom: 1px solid var(--line);
}

.search-btn, .search-close {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  display: grid; place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  color: var(--ink);
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: color .2s, border-color .2s, transform .15s;
}
.search-btn svg, .search-close svg { width: 18px; height: 18px; }
.search-btn:hover { color: var(--accent); border-color: var(--accent); }
.search-btn:active, .search-close:active { transform: scale(.92); }

.tabs {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  scrollbar-width: none;
  scroll-snap-type: x proximity;
  scroll-padding-inline: 8px;
  -webkit-overflow-scrolling: touch;
  padding: 4px 2px 8px;
  margin-bottom: -4px;
}
.tabs::-webkit-scrollbar { display: none; }

.tab {
  flex: 0 0 auto;
  scroll-snap-align: start;
  padding: 10px 18px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--card);
  font-family: var(--font-body);
  font-size: 14.5px;
  font-weight: 700;
  line-height: 1.2;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  transition: color .25s, background .25s, border-color .25s, box-shadow .25s, transform .15s;
}
.tab:hover { color: var(--ink); }
.tab:active { transform: scale(.95); }
.tab[aria-selected="true"] {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
  box-shadow: 0 3px 8px color-mix(in srgb, var(--accent) 30%, transparent);
}
.tab:focus-visible,
.search-btn:focus-visible,
.search-close:focus-visible,
.social-link:focus-visible,
.location-call:focus-visible,
.location-map:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.searchbox {
  position: absolute;
  inset-block: 12px;
  inset-inline: 14px;
  display: flex;
  align-items: center;
  gap: 8px;
  padding-inline: 18px 5px;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: var(--shadow-md);
  animation: searchIn .25s var(--ease);
}
@keyframes searchIn {
  from { opacity: 0; transform: translateY(-6px); }
  to   { opacity: 1; transform: none; }
}
.searchbox input {
  flex: 1; min-width: 0;
  border: 0; background: none; outline: none;
  font: inherit; font-size: 16px;
  color: var(--ink);
}
.searchbox input::placeholder { color: var(--muted); }
.searchbox input::-webkit-search-cancel-button { display: none; }
.search-close { width: 34px; height: 34px; border: 0; box-shadow: none; background: var(--accent-soft); color: var(--accent); }

/* ---------- 4 · Category hero ---------- */
.menu { padding-bottom: 28px; scroll-margin-top: calc(var(--tabs-h) + 12px); }

.cat-hero {
  position: relative;
  margin: 18px 16px 0;
  aspect-ratio: 16 / 8;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: var(--shadow-md);
  isolation: isolate;
  animation: riseIn .6s var(--ease) both;
}
.cat-hero img {
  position: absolute;
  inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: -2;
}
.cat-hero::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  background: linear-gradient(180deg,
    rgba(0,0,0,0) 20%,
    color-mix(in srgb, var(--accent-deep) 45%, transparent) 55%,
    color-mix(in srgb, var(--accent-deep) 92%, transparent) 100%);
}
.cat-hero-text {
  position: absolute;
  inset-inline: 0;
  bottom: 0;
  padding: 18px 20px;
  color: #fff;
}
.cat-hero h2 {
  font-size: 26px;
  font-weight: 800;
  line-height: 1.15;
  text-shadow: 0 2px 14px rgba(0,0,0,.25);
}
.cat-hero p {
  margin-top: 4px;
  font-size: 13.5px;
  font-weight: 500;
  color: rgba(255,255,255,.88);
}
/* banner image missing → plain accent card with the title */
.cat-hero--plain { aspect-ratio: auto; min-height: 110px; }

.results-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin: 22px 20px 0;
}
.results-head h2 { font-size: 22px; font-weight: 800; color: var(--ink); }
.results-head span {
  min-width: 28px;
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* ---------- 5 · Items grid ---------- */
.items {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  padding: 18px 16px 12px;
}

.item {
  display: flex;
  flex-direction: column;
  background: var(--card);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
  animation: riseIn .5s calc(var(--i, 0) * 45ms) var(--ease) both;
}

.thumb {
  position: relative;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: var(--accent-soft);
}
.thumb img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .6s var(--ease);
}
.item:hover .thumb img { transform: scale(1.05); }
.thumb--ph {
  display: grid;
  place-items: center;
  font-family: var(--font-brand);
  font-size: 44px;
  color: var(--accent);
  user-select: none;
}

.ibody {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 13px 13px;
}
.ibody .cat-tag {
  align-self: flex-start;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
}
.ibody h3 {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  overflow-wrap: anywhere;
}
.ibody .desc {
  font-size: 12.5px;
  line-height: 1.5;
  color: var(--muted);
}
.ibody .allerg {
  font-size: 11px;
  font-style: italic;
  color: var(--muted);
}

.prices {
  margin-top: auto;
  padding-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
}
.price {
  display: inline-flex;
  align-items: baseline;
  gap: 4px;
  white-space: nowrap;
}
.price .amount {
  font-family: "Jost", var(--font-body);
  font-size: 18px;
  font-weight: 700;
  line-height: 1;
  color: var(--accent);
}
.price .cur {
  font-size: 12px;
  font-weight: 700;
  color: var(--accent);
  opacity: .75;
}
.price .plabel {
  font-size: 11px;
  font-weight: 500;
  color: var(--muted);
}

/* items with no image at all span the full row as a compact card */
.item.no-thumb .ibody { padding: 14px 16px; }

.empty {
  grid-column: 1 / -1;
  text-align: center;
  color: var(--muted);
  font-size: 14.5px;
  padding: 48px 20px 60px;
}

/* ---------- Skeleton ---------- */
.cat-skel { padding: 18px 16px 0; }
.skel {
  border-radius: var(--radius-sm);
  background: linear-gradient(100deg,
    rgba(35,27,22,.06) 40%, rgba(35,27,22,.11) 50%, rgba(35,27,22,.06) 60%);
  background-size: 200% 100%;
  animation: shimmer 1.3s infinite linear;
}
.skel-banner { aspect-ratio: 16 / 8; border-radius: var(--radius); margin-bottom: 18px; }
.skel-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.skel-card { aspect-ratio: 4 / 5; }
@keyframes shimmer { to { background-position: -200% 0; } }

/* ---------- Error ---------- */
.error {
  text-align: center;
  padding: 90px 28px;
  color: var(--muted);
}
.error-icon { width: 44px; height: 44px; color: var(--accent); margin: 0 auto 14px; }
.error h2 { color: var(--ink); font-size: 19px; margin-bottom: 8px; }
.error p { font-size: 13.5px; line-height: 1.6; max-width: 380px; margin-inline: auto; }
.error-hint { margin-top: 14px; opacity: .8; }
.error code { background: rgba(35,27,22,.07); padding: 1px 6px; border-radius: 6px; font-size: 12px; }

/* ---------- Footer ---------- */
.foot {
  text-align: center;
  padding: 16px 24px 44px;
  color: var(--muted);
}
.foot-rule {
  display: block;
  width: 46px; height: 1px;
  background: var(--line);
  margin: 0 auto 16px;
}
.foot p {
  font-family: var(--font-brand);
  font-size: 26px;
  color: var(--accent);
}

/* ---------- Reduced motion ---------- */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: .001s !important;
    transition-duration: .001s !important;
  }
  html { scroll-behavior: auto; }
}

.visit + .foot { padding-top: 26px; }
