:root {
  color-scheme: light;
  --bg: #efe9df;
  --card: #fffdfa;
  --ink: #1d1b17;
  --muted: #746f66;
  --line: #e5ded3;
  --accent: #173f31;
  --accent-dark: #0d2e23;
  --soft: #f6f2eb;
  font-family: Tahoma, Arial, "Segoe UI", sans-serif;
}
* { box-sizing: border-box; }
html, body { min-height: 100%; }
body { margin: 0; background: var(--bg); color: var(--ink); }
body.model-fullscreen { overflow: hidden; overscroll-behavior: none; touch-action: none; }
button { font: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.viewer-shell { position: relative; width: min(760px, 100%); min-height: 100svh; margin: 0 auto; background: var(--card); box-shadow: 0 0 70px rgba(70,57,37,.08); overflow: hidden; }
.topbar { min-height: 72px; padding: 15px 20px; display: flex; align-items: center; justify-content: space-between; gap: 16px; border-bottom: 1px solid var(--line); background: #fffdfa; }
.topbar strong, .top-label { display: block; }
.topbar strong { margin-top: 3px; font-size: 14px; }
.top-label { color: var(--muted); font-size: 11px; font-weight: 800; }
.ready-pill { direction: rtl; display: inline-flex; align-items: center; gap: 7px; padding: 8px 10px; border-radius: 999px; background: #f0f6f2; color: #315b49; font-size: 10px; font-weight: 800; white-space: nowrap; }
.status-dot { width: 8px; height: 8px; border-radius: 50%; background: #3c8d68; box-shadow: 0 0 0 4px rgba(60,141,104,.1); }
.loading-state { position: absolute; z-index: 20; top: 72px; right: 0; bottom: 0; left: 0; min-height: calc(100svh - 72px); background: var(--card); }
.loading-state, .error-state { display: grid; place-items: center; align-content: center; text-align: center; padding: 32px; }
.error-state { min-height: calc(100svh - 72px); }
.loading-state p, .error-state p { color: var(--muted); }
.spinner { width: 34px; height: 34px; border: 3px solid #ddd7cf; border-top-color: var(--accent); border-radius: 50%; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.error-icon { width: 52px; height: 52px; display: grid; place-items: center; margin-bottom: 16px; border-radius: 50%; background: #f6e6e3; color: #9d3f34; font-size: 25px; font-weight: 900; }
.error-state h1 { margin: 0 0 8px; font-size: 27px; }

.product-view { padding-bottom: max(26px, env(safe-area-inset-bottom)); }
.model-stage { position: relative; height: min(62svh, 620px); min-height: 410px; background: radial-gradient(circle at 50% 42%, #ffffff 0, #f4f0e9 56%, #e8e1d6 100%); overflow: hidden; }
model-viewer { width: 100%; height: 100%; --poster-color: transparent; touch-action: none; }
.viewer-control { position: absolute; z-index: 6; top: max(14px, env(safe-area-inset-top)); left: max(14px, env(safe-area-inset-left)); min-height: 42px; border: 1px solid rgba(255,255,255,.82); border-radius: 999px; padding: 9px 13px; background: rgba(255,255,255,.94); color: #34312c; display: inline-flex; align-items: center; justify-content: center; gap: 7px; font-size: 12px; font-weight: 800; line-height: 1; box-shadow: 0 4px 14px rgba(44,38,28,.09); cursor: pointer; }
.viewer-control:active { transform: scale(.98); }
.fullscreen-close { background: rgba(28,27,24,.92); color: #fff; border-color: rgba(255,255,255,.2); }
.fullscreen-close span:first-child { font-size: 21px; line-height: .8; font-weight: 500; }
.gesture-hint { position: absolute; z-index: 5; bottom: 18px; left: 50%; transform: translateX(-50%); white-space: nowrap; border: 1px solid rgba(255,255,255,.8); border-radius: 999px; padding: 8px 12px; background: rgba(255,255,255,.94); color: #625e56; font-size: 10px; font-weight: 700; box-shadow: 0 4px 14px rgba(44,38,28,.06); pointer-events: none; }

.lite-3d-canvas {
  position: absolute;
  z-index: 1;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
model-viewer.lite-viewer-hidden { visibility: hidden !important; pointer-events: none !important; }
.lite-viewer-active { background: #f4f0e9 !important; }
.lite-viewer-active .viewer-control,
.lite-viewer-active .gesture-hint { z-index: 6; }
.lite-context-lost::after {
  content: "الـ3D محتاج إعادة تحميل على الجهاز ده";
  position: absolute;
  z-index: 7;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #f4f0e9;
  color: #5f584f;
  text-align: center;
  font-size: 13px;
  font-weight: 700;
}

.model-stage.is-fullscreen,
.model-stage:fullscreen,
.model-stage:-webkit-full-screen {
  position: fixed;
  inset: 0;
  z-index: 1000;
  width: 100vw;
  height: 100dvh;
  min-height: 100dvh;
  max-height: none;
  background: radial-gradient(circle at 50% 45%, #ffffff 0, #f4f0e9 58%, #e7e0d5 100%);
  touch-action: none;
}
.model-stage.is-fullscreen model-viewer,
.model-stage:fullscreen model-viewer,
.model-stage:-webkit-full-screen model-viewer { touch-action: none; }
.model-stage.is-fullscreen .gesture-hint,
.model-stage:fullscreen .gesture-hint,
.model-stage:-webkit-full-screen .gesture-hint { bottom: max(20px, calc(env(safe-area-inset-bottom) + 12px)); font-size: 11px; padding: 9px 13px; }

.dish-card { position: relative; z-index: 2; margin-top: -18px; border-radius: 26px 26px 0 0; background: var(--card); padding: 26px 22px 12px; box-shadow: 0 -12px 35px rgba(50,42,31,.06); }
.dish-title-row { display: flex; align-items: flex-start; justify-content: space-between; gap: 18px; }
.restaurant-small { margin: 0 0 6px; color: var(--muted); font-size: 12px; font-weight: 750; }
.dish-card h1 { margin: 0; font-size: clamp(29px, 7vw, 43px); line-height: 1.1; letter-spacing: -.02em; }
.price { flex: 0 0 auto; margin-top: 3px; border-radius: 12px; background: #f0eee8; padding: 8px 10px; font-size: 13px; white-space: nowrap; }
.description { margin: 14px 0 0; color: var(--muted); font-size: 14px; line-height: 1.8; }
.action-stack { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 9px; margin-top: 22px; }
.ar-button, .share-dish-button { min-height: 56px; border-radius: 15px; display: flex; align-items: center; justify-content: center; gap: 10px; font-weight: 850; cursor: pointer; }
.ar-button { border: 0; background: var(--accent); color: white; font-size: 15px; box-shadow: 0 12px 28px rgba(22,62,48,.2); }
.ar-button:active { transform: scale(.99); background: var(--accent-dark); }
.ar-icon { font-size: 21px; }
.share-dish-button { min-width: 116px; border: 1px solid var(--line); background: var(--soft); color: var(--ink); font-size: 13px; }
.share-dish-button:active { transform: scale(.99); }
.support-message { margin-top: 16px; border: 1px solid #e1ddd4; border-radius: 15px; background: #f7f5f0; padding: 14px 15px; }
.support-message strong, .support-message span { display: block; }
.support-message strong { font-size: 13px; }
.support-message span { margin-top: 5px; color: var(--muted); font-size: 12px; line-height: 1.7; }
.ar-help { margin: 11px 4px 0; color: var(--muted); text-align: center; font-size: 11px; line-height: 1.6; }

html[data-viewer-perf="lite"] .viewer-shell,
html[data-viewer-perf="lite"] .viewer-control,
html[data-viewer-perf="lite"] .gesture-hint,
html[data-viewer-perf="lite"] .dish-card { box-shadow: none; }
html[data-viewer-perf="lite"] .model-stage,
html[data-viewer-perf="lite"] .model-stage.is-fullscreen,
html[data-viewer-perf="lite"] .model-stage:fullscreen,
html[data-viewer-perf="lite"] .model-stage:-webkit-full-screen { background: #f4f0e9; }

/* In 3D-only fallback, no full-screen wash, branded blur, or backdrop-filter is
   allowed to sit above the WebGL canvas. Older mobile compositors can glitch or
   drop WebGL frames when these layers are present during touch interaction. */
html.ar-route-3d .ar-entry-design,
html.ar-route-3d .ar-entry-wash { display: none !important; }
html.ar-route-3d .ar-entry-3d-caption {
  background: #fffdfa !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  box-shadow: none !important;
}

@media (max-width: 480px) {
  .model-stage { min-height: 390px; height: 56svh; }
  .dish-card { padding-inline: 18px; }
  .viewer-control { min-height: 40px; padding: 8px 11px; font-size: 11px; }
  .gesture-hint { max-width: calc(100% - 32px); overflow: hidden; text-overflow: ellipsis; }
  .action-stack { grid-template-columns: 1fr; }
  .share-dish-button { min-width: 0; min-height: 48px; }
}
