/* Unspoken Systems — customer menu
   Colours come from each cafe's row in the database (set in app.js). */
:root {
  --bg: #F5EFE6;
  --text: #2B2118;
  --accent: #B5651D;
  --on-accent: #FFFFFF;
  --surface: color-mix(in srgb, var(--text) 5%, var(--bg));
  --surface-2: color-mix(in srgb, var(--text) 9%, var(--bg));
  --line: color-mix(in srgb, var(--text) 14%, var(--bg));
  --muted: color-mix(in srgb, var(--text) 62%, var(--bg));
  --accent-soft: color-mix(in srgb, var(--accent) 14%, var(--bg));
  --danger: #C0392B;
  --radius: 16px;
  --font: 'IBM Plex Sans', 'IBM Plex Sans Arabic', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}
body.locked { overflow: hidden; }
button { font: inherit; color: inherit; cursor: pointer; }
img { max-width: 100%; display: block; }
[hidden] { display: none !important; }

#app { max-width: 640px; margin: 0 auto; min-height: 100vh; padding-bottom: 40px; }

/* ---------- loading skeleton ---------- */
.loading { padding: 32px 16px; display: grid; gap: 14px; }
.sk { background: var(--surface-2); border-radius: 12px; animation: pulse 1.2s ease-in-out infinite; }
.sk-logo { width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 8px; }
.sk-line { height: 22px; width: 60%; margin: 0 auto; }
.sk-line.short { width: 35%; height: 14px; }
.sk-card { height: 96px; }
@keyframes pulse { 50% { opacity: .5; } }

/* ---------- header ---------- */
.header {
  padding: calc(20px + env(safe-area-inset-top)) 16px 12px;
  display: flex; align-items: center; gap: 12px;
}
.logo {
  width: 56px; height: 56px; border-radius: 50%; flex: none;
  background: var(--accent); color: var(--on-accent);
  display: grid; place-items: center; font-weight: 700; font-size: 22px;
  overflow: hidden;
}
.logo img { width: 100%; height: 100%; object-fit: cover; }
.title { flex: 1; min-width: 0; }
.title h1 { margin: 0; font-size: 22px; line-height: 1.2; font-weight: 700; }
.title p { margin: 2px 0 0; color: var(--muted); font-size: 13px; }
.header-actions { display: flex; gap: 8px; }
.icon-btn {
  min-width: 44px; height: 44px; padding: 0 12px; border-radius: 22px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600;
}
.icon-btn:active { transform: scale(.97); }

/* ---------- cover photo ---------- */
.cover {
  position: relative; height: 190px; overflow: hidden;
  background: var(--surface-2);
}
.cover img { width: 100%; height: 100%; object-fit: cover; }
.cover::after {
  content: ''; position: absolute; inset: 0;
  background: linear-gradient(to bottom, rgba(0,0,0,.05) 40%, var(--bg) 100%);
}
.header.has-cover { margin-top: -44px; position: relative; z-index: 1; padding-top: 0; align-items: flex-end; }
.header.has-cover .logo { width: 72px; height: 72px; border: 3px solid var(--bg); box-shadow: 0 2px 10px rgba(0,0,0,.15); }
@media (min-width: 640px) { .cover { border-radius: 0 0 var(--radius) var(--radius); } }

/* ---------- first-timer banner ---------- */
.welcome {
  margin: 4px 16px 12px; padding: 14px 16px; border-radius: var(--radius);
  background: var(--accent-soft); border: 1px solid color-mix(in srgb, var(--accent) 30%, var(--bg));
  display: flex; gap: 12px; align-items: flex-start;
}
.welcome .star { font-size: 20px; line-height: 1.3; }
.welcome strong { display: block; font-size: 14px; }
.welcome span { font-size: 14px; color: var(--text); }

/* ---------- category tabs ---------- */
.tabs-wrap {
  position: sticky; top: 0; z-index: 5;
  background: var(--bg);
  border-bottom: 1px solid var(--line);
}
.tabs {
  display: flex; gap: 8px; overflow-x: auto; padding: 10px 16px;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab {
  flex: none; padding: 8px 16px; border-radius: 999px;
  border: 1px solid var(--line); background: var(--surface);
  font-size: 14px; font-weight: 600; white-space: nowrap;
}
.tab[aria-current="true"] { background: var(--text); color: var(--bg); border-color: var(--text); }

.filters {
  display: flex; gap: 8px; overflow-x: auto; padding: 0 16px 10px;
  scrollbar-width: none;
}
.filters::-webkit-scrollbar { display: none; }
.chip {
  flex: none; padding: 6px 12px; border-radius: 999px; font-size: 13px;
  border: 1px dashed var(--line); background: transparent; color: var(--muted);
}
.chip[aria-pressed="true"] {
  border-style: solid; border-color: var(--accent);
  background: var(--accent-soft); color: var(--text); font-weight: 600;
}

/* ---------- sections & items ---------- */
.section { padding: 20px 16px 4px; scroll-margin-top: 110px; }
.section h2 { margin: 0 0 12px; font-size: 18px; font-weight: 700; }
.empty-note { color: var(--muted); font-size: 14px; padding: 8px 0 12px; }

.item {
  width: 100%; text-align: start;
  display: flex; gap: 12px; align-items: stretch;
  padding: 14px; margin-bottom: 10px;
  border-radius: var(--radius); border: 1px solid var(--line);
  background: var(--surface);
}
.item:active { transform: scale(.99); }
.item-main { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.item-name { font-weight: 700; font-size: 16px; line-height: 1.3; }
.item-desc {
  color: var(--muted); font-size: 13px; line-height: 1.45;
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-top: auto; padding-top: 4px; }
.price { font-weight: 700; font-size: 15px; }
.kcal { color: var(--muted); font-size: 12px; }
.item-img {
  width: 92px; height: 92px; border-radius: 12px; object-fit: cover; flex: none;
  background: var(--surface-2);
}
.badges { display: flex; flex-wrap: wrap; gap: 6px; }
.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px; border-radius: 999px;
  background: var(--accent-soft); color: var(--text);
}
.badge.signature { background: var(--accent); color: var(--on-accent); }
.badge.soldout { background: var(--danger); color: #fff; }
.tags { display: flex; gap: 4px; font-size: 13px; }
.tag-icon { opacity: .9; }

.item.unavailable { opacity: .55; }
.item.unavailable .item-name { text-decoration: line-through; text-decoration-thickness: 1px; }

/* ---------- info ---------- */
.info-card {
  margin: 20px 16px 0; padding: 16px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
}
.info-card h3 { margin: 0 0 10px; font-size: 16px; }
.info-row { display: flex; gap: 10px; padding: 8px 0; border-top: 1px solid var(--line); font-size: 14px; }
.info-row:first-of-type { border-top: 0; }
.info-row .ic { width: 22px; flex: none; text-align: center; }
.extras { list-style: none; margin: 0; padding: 0; }
.extras li { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; }

.footer { text-align: center; color: var(--muted); font-size: 12px; padding: 24px 16px 8px; }
.footer .kcal-note { display: block; margin-bottom: 10px; }
.footer a { color: inherit; }

/* ---------- bottom sheet ---------- */
.sheet-backdrop {
  position: fixed; inset: 0; z-index: 20; background: rgba(0,0,0,.45);
  animation: fade .2s ease-out;
}
.sheet {
  position: fixed; z-index: 21; inset-inline: 0; bottom: 0;
  max-width: 640px; margin: 0 auto; max-height: 88vh; overflow-y: auto;
  background: var(--bg); color: var(--text);
  border-radius: 22px 22px 0 0;
  padding: 20px 16px calc(24px + env(safe-area-inset-bottom));
  animation: up .25s ease-out;
  overscroll-behavior: contain;
}
.sheet::before {
  content: ''; display: block; width: 40px; height: 4px; border-radius: 2px;
  background: var(--line); margin: -8px auto 12px;
}
.sheet-close {
  position: absolute; top: 12px; inset-inline-end: 12px;
  width: 36px; height: 36px; border-radius: 50%;
  border: 0; background: var(--surface-2); font-size: 14px;
}
@keyframes up { from { transform: translateY(40px); opacity: 0; } }
@keyframes fade { from { opacity: 0; } }

.detail-img { width: 100%; aspect-ratio: 4/3; object-fit: cover; border-radius: var(--radius); margin-bottom: 14px; background: var(--surface-2); }
.detail h2 { margin: 0 44px 6px 0; font-size: 22px; line-height: 1.25; }
[dir="rtl"] .detail h2 { margin: 0 0 6px 44px; }
.detail .desc { color: var(--muted); margin: 0 0 14px; }
.detail h3 { font-size: 14px; margin: 18px 0 8px; color: var(--muted); font-weight: 600; }

.sizes { display: grid; grid-template-columns: repeat(auto-fit, minmax(90px, 1fr)); gap: 8px; }
.size {
  padding: 10px 8px; border-radius: 12px; border: 1px solid var(--line);
  background: var(--surface); text-align: center;
}
.size b { display: block; font-size: 14px; }
.size span { display: block; font-size: 13px; }
.size small { color: var(--muted); font-size: 12px; }

.facts { display: flex; flex-wrap: wrap; gap: 8px; }
.fact {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: 10px; background: var(--surface); border: 1px solid var(--line);
  font-size: 13px;
}
.allergens .fact { border-color: color-mix(in srgb, var(--danger) 45%, var(--bg)); }
.warn { font-size: 12px; color: var(--muted); margin-top: 8px; }

.pairs { display: grid; gap: 8px; }
.pair {
  display: flex; justify-content: space-between; align-items: center; gap: 12px;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: var(--surface);
  text-align: start; width: 100%;
}
.pair .price { font-size: 14px; }

.detail-price { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.detail-price .price { font-size: 20px; }

.filter-list { display: grid; gap: 8px; }
.filter-list label {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  border: 1px solid var(--line); border-radius: 12px; background: var(--surface); font-size: 15px;
}
.filter-list input { width: 20px; height: 20px; accent-color: var(--accent); }
.btn {
  display: block; width: 100%; margin-top: 16px; padding: 14px; border-radius: 14px; border: 0;
  background: var(--accent); color: var(--on-accent); font-weight: 700; font-size: 16px;
}
.btn.ghost { background: var(--surface-2); color: var(--text); margin-top: 8px; }

/* ---------- error ---------- */
.error { text-align: center; padding: 80px 24px; }
.error h1 { font-size: 22px; margin: 0 0 8px; }
.error p { color: var(--muted); margin: 0 0 20px; }
.error .btn { display: inline-block; width: auto; padding: 12px 24px; }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; scroll-behavior: auto !important; }
}

/* ---------- AI assistant (Step 3) ---------- */
#app { padding-bottom: 96px; }
.ask-fab {
  position: fixed; z-index: 10; bottom: calc(18px + env(safe-area-inset-bottom));
  left: 50%; transform: translateX(-50%);
  display: inline-flex; align-items: center; gap: 8px;
  padding: 14px 22px; border: 0; border-radius: 999px;
  background: var(--accent); color: var(--on-accent);
  font-weight: 700; font-size: 16px; white-space: nowrap;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
}
.ask-fab:active { transform: translateX(-50%) scale(.97); }

.chat-backdrop { position: fixed; inset: 0; z-index: 14; background: rgba(0,0,0,.45); animation: fade .2s ease-out; }
.chat {
  position: fixed; z-index: 15; inset-inline: 0; bottom: 0;
  max-width: 640px; margin: 0 auto; height: 88vh; height: 88dvh;
  background: var(--bg); color: var(--text); border-radius: 22px 22px 0 0;
  animation: up .25s ease-out;
}
#chat-panel { display: flex; flex-direction: column; height: 100%; }
.chat-head {
  display: flex; justify-content: space-between; align-items: center; gap: 10px;
  padding: 16px 16px 12px; border-bottom: 1px solid var(--line);
}
.chat-head strong { display: block; font-size: 17px; }
.chat-head span { display: block; font-size: 12px; color: var(--muted); }
.chat-head-actions { display: flex; align-items: center; gap: 8px; }
.icon-btn.small { height: 34px; min-width: 0; font-size: 12px; padding: 0 12px; }
.sheet-close.static { position: static; flex: none; }

.chat-log { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 10px; overscroll-behavior: contain; }
.msg { display: flex; flex-direction: column; max-width: 88%; }
.msg.user { align-self: flex-end; }
.msg.bot { align-self: flex-start; }
.bubble { padding: 10px 14px; border-radius: 18px; font-size: 15px; line-height: 1.55; overflow-wrap: anywhere; }
.msg.user .bubble { background: var(--accent); color: var(--on-accent); border-end-end-radius: 6px; }
.msg.bot .bubble { background: var(--surface-2); border-end-start-radius: 6px; }
.msg.error .bubble { background: var(--accent-soft); }
.typing { display: inline-flex; align-items: center; gap: 4px; }
.typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--muted); animation: blink 1.2s infinite; }
.typing span:nth-child(2) { animation-delay: .2s; }
.typing span:nth-child(3) { animation-delay: .4s; }
.typing em { font-style: normal; font-size: 12px; color: var(--muted); margin-inline-start: 6px; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.mini-items { display: flex; gap: 8px; overflow-x: auto; padding: 8px 0 2px; max-width: 100%; scrollbar-width: none; }
.mini-items::-webkit-scrollbar { display: none; }
.mini-item {
  flex: none; width: 132px; text-align: start; padding: 0; overflow: hidden;
  border: 1px solid var(--line); border-radius: 14px; background: var(--surface);
  display: flex; flex-direction: column;
}
.mini-item img { width: 100%; height: 84px; object-fit: cover; }
.mini-item .mi-name { font-size: 13px; font-weight: 700; padding: 8px 10px 0; line-height: 1.3; }
.mini-item .mi-price { font-size: 12px; color: var(--muted); padding: 2px 10px 10px; }
.mini-item.unavailable { opacity: .55; }

.suggest { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.suggest .chip { border-style: solid; color: var(--text); background: var(--surface); font-size: 14px; padding: 8px 14px; }

.chat-form { display: flex; gap: 8px; padding: 10px 16px 4px; border-top: 1px solid var(--line); }
.chat-form input {
  flex: 1; min-width: 0; height: 46px; padding: 0 16px; border-radius: 23px;
  border: 1px solid var(--line); background: var(--surface); color: var(--text);
  font: inherit; font-size: 16px; /* 16px stops iPhone zooming in */
}
.chat-form input:focus { outline: 2px solid var(--accent); outline-offset: 0; }
.chat-form .send {
  flex: none; width: 46px; height: 46px; border-radius: 50%; border: 0;
  background: var(--accent); color: var(--on-accent); font-size: 20px; font-weight: 700;
}
.chat-form .send:disabled, .chat-form input:disabled { opacity: .5; }
.chat-note { margin: 0; padding: 4px 16px calc(10px + env(safe-area-inset-bottom)); font-size: 11px; color: var(--muted); text-align: center; }
