/* ==========================================================================
   AURORA — Digital QR Menu
   3 stages: welcome -> categories -> products (+ full-screen product detail)
   ========================================================================== */

/* Theme: RESTAURANT.theme ("dark"|"light", see data.js) sets data-theme on
   <html> — app_new.js does this before first render, so there's no flash of
   the wrong theme. Everything below in this block re-themes; --on-dark-*
   tokens (further down) deliberately do NOT, since they're for text/chrome
   sitting on top of always-dark photo scrims (welcome hero, category card
   labels, detail hero) regardless of which app theme is active. */
:root{
  --bg-0: #14110f;
  --bg-1: #1c1815;
  --bg-2: #23201b;
  --surface: #29241f;
  --border: rgba(212,175,106,0.16);
  --ink-0: #f5efe4;
  --ink-1: #cfc6b8;
  --ink-2: #948a7c;
  --gold: #d4af6a;
  --glass: rgba(255,255,255,0.045);
  --danger: #e2694b;

  /* fixed — never flip with theme, see comment above */
  --on-dark: #f5efe4;
  --on-dark-soft: #cfc6b8;
  --on-dark-mute: #948a7c;
  --on-dark-border: rgba(212,175,106,0.16);
  --on-dark-glass: rgba(255,255,255,0.045);
  --on-dark-gold: #d4af6a;
  --on-dark-gold-soft: #e7cf9c;

  --radius-s: 10px;
  --radius-m: 16px;
  --radius-l: 26px;

  --font-display: "Cormorant Garamond", Georgia, serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;

  --ease: cubic-bezier(.22,.61,.36,1);
}
:root[data-theme="light"]{
  --bg-0: #faf7f2;
  --bg-1: #f3efe7;
  --bg-2: #ece5d8;
  --surface: #ffffff;
  --border: rgba(150,110,40,0.22);
  --ink-0: #2a2420;
  --ink-1: #55493c;
  --ink-2: #766b5d;
  --gold: #8c6630;
  --glass: rgba(20,17,15,0.035);
}

*, *::before, *::after{ box-sizing: border-box; }
html, body{ height: 100%; }
body{
  margin: 0;
  background: var(--bg-0);
  color: var(--ink-0);
  font-family: var(--font-body);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
}
h1,h2,h3{ font-family: var(--font-display); font-weight: 600; margin: 0; }
p{ margin: 0; }
button{ font-family: inherit; }

img{ max-width: 100%; display: block; }

/* ---------- screens ---------- */
.screen{
  position: fixed;
  inset: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  opacity: 0;
  visibility: hidden;
  transform: scale(1.14);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility 0s linear .45s;
  background: var(--bg-0);
}
.screen--active{
  opacity: 1;
  visibility: visible;
  transform: scale(1);
  transition: opacity .45s var(--ease), transform .45s var(--ease), visibility 0s linear 0s;
  z-index: 2;
}

/* ---------- generic image placeholder tile ---------- */
.img-ph{
  position: relative;
  z-index: 0; /* contains .img-ph__logo/.img-ph__photo's own z-index so it can't leak out and cover sibling UI (e.g. a card's name label) */
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(120% 140% at 30% 20%, #3a2f22 0%, #211c17 60%, #17130f 100%);
  color: rgba(245,239,228,0.85);
  overflow: hidden;
}
.img-ph::after{
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(160deg, rgba(212,175,106,0.10), transparent 55%);
}
.img-ph__logo{
  position: relative; z-index: 1;
  height: auto;
  opacity: 0.55;
}
.img-ph__photo{
  position: absolute; inset: 0;
  z-index: 2; /* must sit above .img-ph__logo (z-index:1) once loaded, or the logo shows through on top of the photo */
  width: 100%; height: 100%;
  object-fit: cover;
  opacity: 0;
  transform: scale(1.12);
  transition: opacity .6s var(--ease), transform .6s var(--ease);
}
.img-ph__photo.is-loaded{ opacity: 1; transform: scale(1); }

/* ==========================================================================
   STAGE 1 — WELCOME
   ========================================================================== */
#screen-welcome{ overflow: hidden; }

.welcome-bg{ position: absolute; inset: 0; z-index: 0; }
.welcome-bg__layer{
  position: absolute; inset: -10%;
  background-repeat: no-repeat;
  filter: blur(0px);
}
.welcome-bg__layer--1{
  background:
    radial-gradient(45% 38% at 22% 28%, rgba(212,175,106,0.16), transparent 60%),
    radial-gradient(55% 45% at 82% 74%, rgba(226,105,75,0.10), transparent 60%),
    linear-gradient(160deg, #1a1512 0%, #201b16 45%, #14110f 100%);
  animation: driftA 22s ease-in-out infinite;
  animation-play-state: paused; /* only runs while the welcome screen is active — see below */
}
.welcome-bg__layer--2{
  background: radial-gradient(30% 24% at 70% 20%, rgba(212,175,106,0.10), transparent 65%);
  animation: driftB 28s ease-in-out infinite;
  animation-play-state: paused;
  mix-blend-mode: screen;
}
/* CSS animations don't auto-pause just because an element is hidden/off-screen —
   without this, the welcome background would keep animating forever in the
   background after navigating away, burning CPU/GPU (and RAM) for a screen
   nobody sees. Only run it while #screen-welcome is actually the active screen. */
#screen-welcome.screen--active .welcome-bg__layer--1,
#screen-welcome.screen--active .welcome-bg__layer--2{
  animation-play-state: running;
}
@keyframes driftA{
  0%,100%{ transform: translate3d(0,0,0) scale(1); }
  50%{ transform: translate3d(-2%,2%,0) scale(1.04); }
}
@keyframes driftB{
  0%,100%{ transform: translate3d(0,0,0) scale(1.05); }
  50%{ transform: translate3d(3%,-2%,0) scale(1); }
}
/* optional full-bleed background image/video behind the welcome content —
   see RESTAURANT.welcomeBackground in data.js. Hidden entirely when not
   configured, leaving the original animated gradient untouched. */
.welcome-media{
  position: absolute; inset: 0; z-index: 0;
  overflow: hidden; /* fixed "window" for the parallax photo, same as .detail__hero */
  display: none;
}
.welcome-media.is-active{ display: block; }
.welcome-media__parallax{
  position: absolute;
  inset: -22px; /* overscan margin, mirrors .detail__hero-parallax */
  will-change: transform;
}
.welcome-media__photo,
.welcome-media__video{
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
}
.welcome-scrim{
  position: absolute; inset: 0; z-index: 0;
  background: linear-gradient(180deg, rgba(15,12,10,0.52) 0%, rgba(15,12,10,0.32) 45%, rgba(15,12,10,0.8) 100%);
  display: none;
}
.welcome-scrim.is-active{ display: block; }
/* the decorative animated gradient is pure waste once a real photo/video
   covers it entirely — drop it from rendering rather than paint it hidden */
#screen-welcome.has-media .welcome-bg{ display: none; }

.welcome-bg__grain{
  position: absolute; inset: 0;
  opacity: .05;
  background-image: url("data:image/svg+xml;utf8,<svg xmlns='http://www.w3.org/2000/svg' width='120' height='120'><filter id='n'><feTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2' stitchTiles='stitch'/></filter><rect width='100%25' height='100%25' filter='url(%23n)'/></svg>");
}

.welcome-content{
  position: relative; z-index: 1;
  min-height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: max(6vh, 32px) 24px max(4vh, 24px);
  text-align: center;
}
.welcome-top{ padding-top: 2vh; }
.brand-logo{ display: flex; flex-direction: column; align-items: center; gap: 6px; }
.brand-logo__img{
  width: 50vw;
  height: auto;
  margin-bottom: 4px;
  filter: drop-shadow(0 2px 12px rgba(0,0,0,0.35));
}
.brand-logo__name{
  font-family: var(--font-display);
  font-size: clamp(2.4rem, 9vw, 3.4rem);
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--on-dark);
  background: linear-gradient(180deg, var(--on-dark-gold-soft), var(--on-dark-gold) 70%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.brand-logo__tagline{
  font-size: 0.72rem;
  letter-spacing: 0.42em;
  color: var(--on-dark-mute);
  padding-inline-start: 0.42em; /* optical centering for the added tracking */
}

.welcome-mid{ display: flex; flex-direction: column; align-items: center; gap: 22px; max-width: 420px; }
.lang-prompt{ color: var(--on-dark-soft); font-size: 0.92rem; letter-spacing: 0.01em; }
.lang-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 12px;
  width: 100%;
}
.lang-btn{
  display: flex; align-items: center; justify-content: center; gap: 10px;
  padding: 14px 16px;
  border-radius: var(--radius-m);
  border: 1px solid var(--on-dark-border);
  background: var(--on-dark-glass);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  color: var(--on-dark);
  font-size: 0.98rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
  min-height: 52px;
}
.lang-btn:active{ transform: scale(0.96); }
.lang-btn:hover{ border-color: rgba(212,175,106,0.5); background: rgba(212,175,106,0.08); }
.lang-btn__flag{ font-size: 1.2rem; }

/* shown instead of .lang-grid when there's only one language configured —
   nothing to choose, so a single "Enter" action replaces the picker */
.enter-btn{
  display: flex; align-items: center; justify-content: center;
  width: 100%;
  padding: 16px 20px;
  border-radius: var(--radius-m);
  border: 1px solid var(--on-dark-border);
  background: var(--on-dark-glass);
  backdrop-filter: blur(10px) saturate(140%);
  -webkit-backdrop-filter: blur(10px) saturate(140%);
  color: var(--on-dark);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s var(--ease), background .2s var(--ease);
  min-height: 56px;
}
.enter-btn:active{ transform: scale(0.96); }
.enter-btn:hover{ border-color: rgba(212,175,106,0.5); background: rgba(212,175,106,0.08); }

.welcome-bottom{ padding-bottom: 1vh; }
.social-row{ display: flex; gap: 16px; align-items: center; justify-content: center; }
.social-btn{
  width: 42px; height: 42px;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--on-dark-border);
  background: var(--on-dark-glass);
  color: var(--on-dark-soft);
  transition: color .2s var(--ease), border-color .2s var(--ease), transform .2s var(--ease);
}
.social-btn:hover{ color: var(--on-dark-gold); border-color: var(--on-dark-gold); transform: translateY(-2px); }

/* ==========================================================================
   SHARED — top bar / heading
   ========================================================================== */
.topbar{
  position: sticky; top: 0; z-index: 5;
  display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(180deg, var(--bg-0) 60%, var(--bg-1) 100%);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border);
}
.topbar__title{
  flex: 1;
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  color: var(--ink-0);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
/* ---------------- language switch (available on every screen) ---------------- */
.lang-switch{ position: relative; flex: none; }
.lang-toggle{
  display: flex; align-items: center; justify-content: center;
  background: none;
  border: none;
  padding: 4px;
  border-radius: 50%;
  font-size: 1.3rem;
  line-height: 1;
  cursor: pointer;
}
.lang-toggle:active{ transform: scale(0.9); }

.lang-menu{
  position: absolute;
  top: calc(100% + 8px);
  inset-inline-end: 0;
  min-width: 168px;
  background: var(--bg-1);
  border: 1px solid var(--border);
  border-radius: var(--radius-m);
  padding: 6px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  box-shadow: 0 16px 36px rgba(0,0,0,0.5);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-6px) scale(0.96);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility 0s linear .18s;
  z-index: 30;
}
.lang-menu.is-open{
  opacity: 1;
  visibility: visible;
  transform: translateY(0) scale(1);
  transition: opacity .18s var(--ease), transform .18s var(--ease), visibility 0s linear 0s;
}
.lang-menu__item{
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 9px 10px;
  border-radius: var(--radius-s);
  background: none;
  border: none;
  color: var(--ink-0);
  font-family: var(--font-body);
  font-size: 0.9rem;
  text-align: start;
  cursor: pointer;
}
.lang-menu__item:hover{ background: rgba(212,175,106,0.1); }
.lang-menu__item.is-active{ color: var(--gold); }
.lang-menu__item__flag{ font-size: 1.1rem; }

/* floating variant used over the product detail hero photo — mirrors the
   close button's circular chip style, positioned on the opposite corner */
.lang-switch--floating{
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  inset-inline-start: 16px;
  z-index: 2;
}
.lang-switch--floating .lang-toggle{
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(20,17,15,0.55);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border: 1px solid var(--border);
}
.lang-switch--floating .lang-menu{
  inset-inline-start: 0;
  inset-inline-end: auto;
}

.icon-btn{
  width: 38px; height: 38px; flex: none;
  display: flex; align-items: center; justify-content: center;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--glass);
  color: var(--ink-0);
  cursor: pointer;
}
[dir="rtl"] .icon-btn svg{ transform: scaleX(-1); }

.section-heading{ padding: 20px 20px 4px; }
.section-heading h1{ font-size: clamp(1.6rem, 5vw, 2.1rem); color: var(--ink-0); }
.section-heading__note{ color: var(--ink-2); font-size: 0.86rem; margin-top: 6px; }

/* ==========================================================================
   STAGE 2 — CATEGORY GRID
   ========================================================================== */
.category-grid{
  display: grid;
  grid-template-columns: repeat(2, minmax(0,1fr));
  gap: 14px;
  padding: 16px 20px 40px;
}
.category-card{
  position: relative;
  aspect-ratio: 4 / 5;
  border-radius: var(--radius-m);
  overflow: hidden;
  cursor: pointer;
  border: 1px solid var(--border);
  transition: transform .25s var(--ease);
}
.category-card:active{ transform: scale(0.97); }
.category-card .img-ph{ position: absolute; inset: 0; }
.category-card__scrim{
  position: absolute; inset: 0;
  background: linear-gradient(180deg, transparent 40%, rgba(15,12,10,0.88) 100%);
}
.category-card__label{
  position: absolute; inset-inline: 0; bottom: 0;
  padding: 14px 12px;
  z-index: 1;
}
.category-card__label h2{
  font-size: 1.15rem;
  color: var(--on-dark);
}
.category-card__label span{
  display: block;
  width: 26px; height: 2px;
  background: var(--on-dark-gold);
  margin-top: 8px;
}

/* ==========================================================================
   STAGE 3 — PRODUCT GRID (compact list cards)
   ========================================================================== */
.product-grid{
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 16px 16px 48px;
}
.product-card{
  display: flex;
  gap: 14px;
  padding: 12px;
  border-radius: var(--radius-m);
  background: var(--bg-1);
  border: 1px solid var(--border);
  cursor: pointer;
  transition: transform .2s var(--ease), border-color .2s var(--ease);
}
.product-card:active{ transform: scale(0.98); }
.product-card:hover{ border-color: rgba(212,175,106,0.4); }

.product-card__thumb{
  position: relative;
  width: 92px; height: 92px; flex: none;
  border-radius: var(--radius-s);
  overflow: hidden;
}
.product-card__thumb .img-ph{ position: absolute; inset: 0; }

.product-card__body{ flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 4px; }
.product-card__top{ display: flex; justify-content: space-between; align-items: baseline; gap: 8px; }
.product-card__name{ font-size: 1.05rem; color: var(--ink-0); line-height: 1.2; }
.product-card__price{ color: var(--gold); font-weight: 600; font-size: 0.95rem; white-space: nowrap; font-family: var(--font-body); }
.product-card__desc{
  color: var(--ink-2);
  font-size: 0.82rem;
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.product-card__meta{ display: flex; gap: 10px; margin-top: 2px; flex-wrap: wrap; }
.meta-pill{
  display: inline-flex; align-items: center; gap: 4px;
  font-size: 0.72rem;
  color: var(--ink-1);
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 3px 8px;
  border-radius: 100px;
}
.meta-pill--spicy{ color: var(--danger); border-color: rgba(226,105,75,0.35); }
.allergen-dot{
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ==========================================================================
   PRODUCT DETAIL — full screen overlay
   ========================================================================== */
.detail{
  position: fixed; inset: 0;
  z-index: 20;
  visibility: hidden;
  opacity: 0;
  transform: scale(1.1);
  transition: opacity .4s var(--ease), transform .4s var(--ease), visibility 0s linear .4s;
  background: var(--bg-0);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.detail.is-open{
  visibility: visible;
  opacity: 1;
  transform: scale(1);
  transition: opacity .4s var(--ease), transform .4s var(--ease), visibility 0s linear 0s;
}
.detail__hero{
  position: relative;
  height: 46vh;
  min-height: 260px;
  overflow: hidden; /* fixed "window" the photo pans behind for the parallax effect */
}
/* oversized on all sides so the parallax translate (±14px, see app_new.js) never
   reveals an edge against .detail__hero's fixed viewport */
.detail__hero-parallax{
  position: absolute;
  inset: -22px;
  will-change: transform;
}
.detail__hero .img-ph{ position: absolute; inset: 0; }
.detail__hero::after{
  content: "";
  position: absolute; inset: 0;
  background: linear-gradient(180deg, rgba(20,17,15,0.15) 0%, rgba(20,17,15,0) 30%, var(--bg-0) 96%);
}
.icon-btn--floating{
  position: absolute;
  top: max(16px, env(safe-area-inset-top));
  inset-inline-end: 16px;
  z-index: 2;
  background: rgba(20,17,15,0.55);
  backdrop-filter: blur(8px);
  color: var(--on-dark);
  border-color: var(--on-dark-border);
}

.detail__sheet{
  position: relative;
  margin-top: -28px;
  background: var(--bg-0);
  border-radius: 26px 26px 0 0;
  padding: 8px 22px max(40px, env(safe-area-inset-bottom));
  z-index: 1;
}
.detail__handle{
  width: 40px; height: 4px;
  background: var(--border);
  border-radius: 100px;
  margin: 8px auto 18px;
}
.detail__header{
  display: flex; justify-content: space-between; align-items: flex-start; gap: 16px;
  margin-bottom: 10px;
}
.detail__header h2{ font-size: 1.7rem; color: var(--ink-0); line-height: 1.15; }
.detail__price{
  font-family: var(--font-body);
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--gold);
  white-space: nowrap;
  padding-top: 4px;
}
.detail__desc{ color: var(--ink-1); font-size: 0.95rem; line-height: 1.55; }

.detail__chips{ display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.chip{
  display: flex; flex-direction: column; align-items: center; gap: 4px;
  min-width: 82px;
  padding: 12px 10px;
  border-radius: var(--radius-s);
  background: var(--surface);
  border: 1px solid var(--border);
  text-align: center;
}
.chip__icon{ font-size: 1.2rem; }
.chip__value{ font-size: 0.85rem; font-weight: 600; color: var(--ink-0); }
.chip__label{ font-size: 0.66rem; color: var(--ink-2); text-transform: uppercase; letter-spacing: 0.04em; }
.chip--spicy .chip__value{ color: var(--danger); }

.detail__allergens{ margin-top: 24px; }
.detail__allergens h3{
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-2);
  font-family: var(--font-body);
  font-weight: 600;
  margin-bottom: 10px;
}
.detail__allergen-list{ display: flex; gap: 8px; flex-wrap: wrap; }
.allergen-chip{
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 0.82rem;
  color: var(--ink-1);
  background: var(--glass);
  border: 1px solid var(--border);
  padding: 6px 10px;
  border-radius: 100px;
}
.detail__allergens.is-empty{ display: none; }

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */
@media (min-width: 640px){
  .lang-grid{ max-width: 360px; }
  .category-grid{ grid-template-columns: repeat(3, minmax(0,1fr)); padding-inline: 32px; }
  .product-grid{ padding-inline: 32px; max-width: 720px; margin-inline: auto; width: 100%; }
  .section-heading{ padding-inline: 32px; }
  .topbar{ padding-inline: 24px; }
  .detail__sheet{ padding-inline: 40px; }
}
@media (min-width: 960px){
  .category-grid{ grid-template-columns: repeat(4, minmax(0,1fr)); max-width: 1080px; margin-inline: auto; }
  .detail__hero{ height: 42vh; }
}

@media (prefers-reduced-motion: reduce){
  .screen, .welcome-bg__layer, .lang-btn, .category-card, .product-card, .detail, .img-ph__photo{ transition: none !important; animation: none !important; }
}
