/* ════════════════════════════════════════════════════════════
   عارض الطبق — 3D + واقع معزّز WebXR (apps/menu-public/ar)
   ────────────────────────────────────────────────────────────
   .yp-ar            الجذر (شاشة كاملة فوق المنيو)
   .yp-ar.is-visible مفتوح
   .yp-ar.is-xr      جلسة WebXR جارية: الجذر نفسه هو dom-overlay فوق
                     الكاميرا — الخلفية شفافة، الرأس/الذيل مخفيان،
                     وطبقة .yp-ar-xr هي الواجهة داخل الكاميرا.
   ════════════════════════════════════════════════════════════ */

.yp-ar {
  position: fixed;
  inset: 0;
  z-index: 400;
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  overflow: hidden;
  touch-action: none;
  background:
    radial-gradient(circle at 50% 62%, rgb(var(--yp-gold-rgb, 216 164 90) / .14), transparent 60%),
    var(--yp-bg-1, #1B0D06);
  transition: opacity .22s ease, visibility .22s ease;
}
.yp-ar.is-visible { opacity: 1; visibility: visible; }
.yp-ar.is-xr { background: transparent !important; }

/* ── المسرح ── */
.yp-ar-stage {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
}
.yp-ar-canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  touch-action: none;
  outline: none;
}
/* داخل WebXR يرسم المؤلِّف طبقة الكاميرا + الموديل بنفسه؛ الـcanvas
   يبقى إطارًا قديمًا من المعاينة فيُخفى حتى لا يغطي الكاميرا. */
.yp-ar.is-xr .yp-ar-stage { visibility: hidden; }

/* ── الرأس ── */
.yp-ar-head {
  flex: none;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: calc(env(safe-area-inset-top, 0px) + 10px) 14px 10px;
}
.yp-ar-close {
  flex: none;
  width: 40px;
  height: 40px;
  display: grid;
  place-items: center;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  color: var(--yp-text-1, #E8DCCB);
  background: rgb(var(--yp-gold-rgb, 216 164 90) / .12);
  border: 1px solid var(--yp-line, rgb(255 255 255 / .16));
  border-radius: 13px;
}
.yp-ar-title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 15px;
  font-weight: 800;
  color: var(--yp-text-0, #fff);
}
.yp-ar-tag {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 4px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: .04em;
  color: #F0FDFA;
  background: linear-gradient(135deg, #0E7490, #0F766E);
  border: 1px solid rgb(45 212 191 / .6);
}
.yp-ar-tag svg { width: 13px; height: 13px; }

/* ── الذيل ── */
.yp-ar-foot {
  flex: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 12px 14px calc(env(safe-area-inset-bottom, 0px) + 16px);
}
.yp-ar-progress {
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11.5px;
  color: var(--yp-text-2, #CDB89B);
}
.yp-ar-progress[hidden] { display: none; }
.yp-ar-bar {
  height: 4px;
  border-radius: 999px;
  overflow: hidden;
  background: rgb(var(--yp-gold-rgb, 216 164 90) / .18);
}
.yp-ar-bar i {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: var(--yp-gold-500, #D89B3A);
  transition: width .2s ease;
}
.yp-ar-hint {
  margin: 0;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--yp-text-2, #CDB89B);
}
.yp-ar-hint:empty { display: none; }
.yp-ar-hint.is-warn { color: #E9A06A; }
.yp-ar-hint.is-muted { opacity: .85; }

.yp-ar-place {
  min-height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  font-size: 15px;
  font-weight: 900;
}
.yp-ar-place[hidden] { display: none !important; }
.yp-ar-place:disabled { opacity: .55; cursor: default; }
.yp-ar-badge {
  display: inline-grid;
  place-items: center;
  min-width: 28px;
  height: 22px;
  padding-inline: 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 900;
  border: 1px solid rgb(255 255 255 / .3);
  background: rgb(255 255 255 / .14);
}
.yp-ar-support {
  margin: 0;
  text-align: center;
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: .02em;
  color: rgb(var(--yp-gold-rgb, 216 164 90) / .8);
}
.yp-ar-support:empty { display: none; }
.yp-ar-support.is-warn { color: #E9A06A; }

/* ── طبقة WebXR (فوق الكاميرا) ── */
.yp-ar-xr {
  display: none;
  position: absolute;
  inset: 0;
  z-index: 5;
  flex-direction: column;
  justify-content: space-between;
  pointer-events: none;
  padding:
    calc(env(safe-area-inset-top, 0px) + 12px)
    14px
    calc(env(safe-area-inset-bottom, 0px) + 18px);
}
.yp-ar.is-xr .yp-ar-xr { display: flex; }
.yp-ar-xr button { pointer-events: auto; }

.yp-ar-xr-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.yp-ar-xr-dish {
  min-width: 0;
  display: flex;
  align-items: baseline;
  gap: 10px;
  padding: 8px 13px;
  border-radius: 14px;
  background: rgb(27 13 6 / .74);
  border: 1px solid rgb(var(--yp-gold-rgb, 216 164 90) / .42);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}
.yp-ar-xr-dish b {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 900;
  color: #fff;
}
.yp-ar-xr-dish span {
  flex: none;
  font-size: 14px;
  font-weight: 900;
  color: var(--yp-gold-300, #E9C285);
}
.yp-ar-xr-dish span:empty { display: none; }
.yp-ar-xr-close {
  flex: none;
  min-height: 40px;
  padding: 8px 14px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: rgb(27 13 6 / .78);
  border: 1px solid rgb(var(--yp-gold-rgb, 216 164 90) / .5);
  border-radius: 13px;
}

/* التوجيه في منتصف الشاشة: مسح ← انقر ← ثُبّت */
.yp-ar-xr-guide {
  align-self: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  max-width: 78vw;
  padding: 16px 18px;
  border-radius: 20px;
  text-align: center;
  color: #fff;
  background: rgb(27 13 6 / .58);
  border: 1px solid rgb(var(--yp-gold-rgb, 216 164 90) / .35);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: opacity .3s ease;
}
.yp-ar-xr-guide[hidden] { display: none; }
.yp-ar-xr-guide p {
  margin: 0;
  font-size: 13.5px;
  font-weight: 800;
  line-height: 1.45;
}
.yp-ar-scan-rings {
  position: relative;
  width: 64px;
  height: 64px;
  display: block;
}
.yp-ar-scan-rings i {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid var(--yp-gold-300, #E9C285);
  opacity: 0;
  animation: yp-ar-ring 2.1s ease-out infinite;
}
.yp-ar-scan-rings i:nth-child(2) { animation-delay: .7s; }
.yp-ar-scan-rings i:nth-child(3) { animation-delay: 1.4s; }
@keyframes yp-ar-ring {
  0%   { transform: scale(.35); opacity: .9; }
  100% { transform: scale(1.15); opacity: 0; }
}
.yp-ar-scan-phone {
  width: 34px;
  height: 34px;
  margin-top: -52px;
  color: var(--yp-gold-300, #E9C285);
  animation: yp-ar-sway 1.8s ease-in-out infinite;
}
@keyframes yp-ar-sway {
  0%, 100% { transform: rotate(-10deg); }
  50%      { transform: rotate(10deg); }
}
/* عند وجود سطح صالح: تختفي الحلقات ويبقى «انقر للوضع» */
.yp-ar-xr-guide.is-tap .yp-ar-scan-rings,
.yp-ar-xr-guide.is-tap .yp-ar-scan-phone,
.yp-ar-xr-guide.is-placed .yp-ar-scan-rings,
.yp-ar-xr-guide.is-placed .yp-ar-scan-phone { display: none; }
.yp-ar-xr-guide.is-tap {
  background: rgb(var(--yp-gold-rgb, 216 164 90) / .28);
  border-color: rgb(var(--yp-gold-rgb, 216 164 90) / .7);
}
.yp-ar-xr-guide.is-placed { animation: yp-ar-fade 2.8s ease forwards; }
@keyframes yp-ar-fade {
  0%, 70% { opacity: 1; }
  100%    { opacity: 0; }
}

/* شريط التحكم بعد الوضع: تحريك / إعادة */
.yp-ar-xr-bar {
  align-self: center;
  display: flex;
  gap: 10px;
}
.yp-ar-xr-bar[hidden] { display: none; }
.yp-ar-xr-btn {
  min-height: 46px;
  padding: 8px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 800;
  cursor: pointer;
  color: #fff;
  background: rgb(27 13 6 / .78);
  border: 1px solid rgb(var(--yp-gold-rgb, 216 164 90) / .5);
  border-radius: 999px;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
}
.yp-ar-xr-btn svg { width: 18px; height: 18px; }
.yp-ar-xr-btn.is-active {
  color: #1B0D06;
  background: var(--yp-gold-300, #E9C285);
}

@media (prefers-reduced-motion: reduce) {
  .yp-ar { transition-duration: .01ms; }
  .yp-ar-scan-rings i, .yp-ar-scan-phone { animation: none; opacity: .8; }
}
