/* =====================================================================
   هوش مصنوعی مرغیار — گوی متفکر و کادر پرسش (ai-orb.js)
   همه مقدارهای متغیر (--w, --h, --oPill, ...) را خط زمانی جاوااسکریپت
   فریم‌به‌فریم می‌نویسد؛ اینجا فقط «هر لایه با کدام متغیر» تعریف شده است.
   ===================================================================== */

@property --angle {
  syntax: "<angle>";
  inherits: false;
  initial-value: 0deg;
}

@keyframes mo-spin { to { --angle: 360deg; } }
@keyframes mo-drift { from { transform: translateX(-14%); } to { transform: translateX(14%); } }
@keyframes mo-shimmer { from { background-position: 150% 0; } to { background-position: -100% 0; } }
@keyframes mo-dot { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@keyframes mo-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes mo-out { from { opacity: 1; transform: none; } to { opacity: 0; transform: translateY(-6px); } }
@keyframes mo-fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes mo-fade-out { from { opacity: 1; } to { opacity: 0; } }
@keyframes mo-shake {
  0%, 100% { transform: translate(-50%, -50%); }
  25% { transform: translate(calc(-50% - 4px), -50%); }
  75% { transform: translate(calc(-50% + 4px), -50%); }
}

/* ---------- صفحه «هوش مصنوعی مرغیار» داخل برنامه ---------- */
/* صفحه ثابت روی گوشی: بدون اسکرول، بدون کشیدن صفحه، بدون زوم با دو ضربه */
html:has(body.ai-fullscreen), body.ai-fullscreen {
  overflow: hidden;
  overscroll-behavior: none;
  height: 100%;
}
body.ai-fullscreen .ai-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 20;
  will-change: transform;
}
.ai-stage {
  touch-action: manipulation;
  overscroll-behavior: none;
  position: fixed;
  left: 0; right: 0; bottom: 0;
  top: 69px; /* با جاوااسکریپت دقیقا زیر سربرگ تنظیم می‌شود */
  z-index: 5;
}
.ai-note {
  position: absolute;
  top: 12px; left: 50%;
  transform: translateX(-50%);
  width: min(520px, calc(100% - 32px));
  z-index: 3;
  text-align: center;
  font-family: "Dana", Tahoma, sans-serif;
  font-size: 11.5px;
  line-height: 1.8;
  color: #FFFFFF;
  pointer-events: none;
}
.ai-note b { color: #34d399; font-weight: 700; }
.ai-headline {
  display: block;
  margin-bottom: 6px;
  font-size: 16px;
  font-weight: 700;
  line-height: 1.7;
  color: #FFFFFF;
  text-shadow: 0 0 10px rgba(255, 255, 255, 0.18);
}

/* ---------- صحنه ---------- */
.mo-root {
  position: absolute;
  inset: 0;
  overflow: hidden;
  --oCenter: 0;
  --cardH: 108px;
  color: #FFFFFF;
  /* همه متن‌های فارسی این صفحه با همان فونت Dana روی هاست */
  font-family: "Dana", Tahoma, sans-serif;
  -webkit-tap-highlight-color: transparent;
}
.mo-bg {
  position: absolute; inset: 0;
  background: radial-gradient(120% 80% at 50% 46%, rgba(10, 7, 22, 0) 0%, rgba(6, 5, 9, 0.35) 70%, rgba(6, 5, 9, 0.6) 100%);
  pointer-events: none;
}
.mo-halo {
  position: absolute;
  left: 50%; top: 46%;
  width: 420px; height: 420px;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(45, 226, 255, 0.22), rgba(140, 90, 255, 0.10) 55%, transparent 75%);
  opacity: var(--oCenter);
  pointer-events: none;
}

.mo-mover {
  position: absolute;
  left: 50%; top: 46%;
  width: 0; height: 0;
  will-change: transform;
}
.mo-trail {
  position: absolute;
  left: 0; top: 0;
  width: 100px; height: 100px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, 0.9), rgba(45, 226, 255, 0.55) 45%, rgba(45, 226, 255, 0) 72%);
  opacity: 0;
  pointer-events: none;
  will-change: transform, opacity;
}

.mo-actor {
  position: absolute;
  left: 0; top: 0;
  width: var(--w, 320px);
  height: var(--h, 60px);
  border-radius: var(--r, 999px);
  transform: translate(-50%, -50%) scale(var(--cs, 1));
  --oGlow: 1; --oHalo: 0; --oPill: 1; --oBall: 0; --oGreen: 0; --oCard: 0; --oRing: 1;
  --oInput: 1; --inScale: 1; --oAur: 1; --gs: .55; --hOp: 0; --dotS: 0; --bloom: 1;
}
.mo-actor[data-shake] { animation: mo-shake .26s ease; }
.mo-actor > * { border-radius: inherit; }

.mo-underglow {
  position: absolute; inset: 4px -4px -8px;
  background: linear-gradient(90deg, rgba(45, 226, 255, .55), rgba(255, 80, 220, .45), rgba(57, 255, 106, .45));
  filter: blur(22px);
  opacity: calc(var(--oGlow) * .55);
  transition: opacity .25s ease;
  pointer-events: none;
}
.mo-actor[data-typing] .mo-underglow { opacity: calc(var(--oGlow) * .85); }

.mo-halo-green {
  position: absolute; inset: -34px;
  border-radius: 50% !important;
  background: radial-gradient(closest-side, rgba(52, 211, 153, .55), rgba(52, 211, 153, 0));
  opacity: var(--oHalo);
  pointer-events: none;
}

.mo-surface {
  position: absolute; inset: 0;
  overflow: hidden;
  background: rgba(13, 18, 44, 0.86);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .14), 0 18px 40px -18px rgba(0, 0, 0, .7);
  -webkit-backdrop-filter: blur(14px);
  backdrop-filter: blur(14px);
  opacity: var(--oPill);
  transition: border-color .2s ease;
}
.mo-actor[data-flash] .mo-surface { border-color: rgba(255, 95, 95, .8); }
.mo-aurora {
  position: absolute; inset: 0;
  opacity: calc(var(--oAur) * .5);
  border-radius: inherit;
  overflow: hidden;
}
.mo-aurora i {
  position: absolute;
  top: -60%;
  width: 55%; height: 220%;
  border-radius: 50%;
  filter: blur(22px);
  animation: mo-drift 6s ease-in-out infinite alternate;
}
.mo-aurora i:nth-child(1) { left: -10%; background: rgba(45, 226, 255, .35); animation-duration: 7s; }
.mo-aurora i:nth-child(2) { left: 25%; background: rgba(140, 90, 255, .30); animation-duration: 9s; animation-delay: -2s; }
.mo-aurora i:nth-child(3) { left: 55%; background: rgba(255, 80, 220, .22); animation-duration: 8s; animation-delay: -4s; }
.mo-aurora i:nth-child(4) { left: 75%; background: rgba(57, 255, 106, .18); animation-duration: 10s; animation-delay: -1s; }

.mo-ball {
  position: absolute; inset: 0;
  background: radial-gradient(circle at 38% 32%, #ffffff, #bdf6ff 30%, #2DE2FF 62%, #1b5bff 100%);
  box-shadow: 0 0 28px rgba(45, 226, 255, .55);
  opacity: var(--oBall);
  pointer-events: none;
}

.mo-green {
  position: absolute; inset: 0;
  border-radius: 50% !important;
  background: radial-gradient(circle at 40% 35%, #8ff5c9, #34d399 55%, #0f9f6e);
  box-shadow: 0 0 40px rgba(52, 211, 153, .55);
  transform: scale(var(--gs));
  opacity: var(--oGreen);
  pointer-events: none;
}

.mo-card {
  position: absolute; inset: 0;
  background: rgba(14, 20, 48, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .12),
    0 24px 60px -24px rgba(52, 211, 153, calc((var(--bloom) - .5) * 1.2)),
    0 0 calc(var(--bloom) * 36px) rgba(52, 211, 153, calc((var(--bloom) - .6) * .9));
  opacity: var(--oCard);
  pointer-events: none;
}

.mo-ring {
  position: absolute; inset: -1px;
  padding: 1.5px;
  background: conic-gradient(from var(--angle), rgba(45, 226, 255, 0) 0deg, rgba(45, 226, 255, .9) 70deg, rgba(255, 80, 220, .85) 140deg, rgba(57, 255, 106, 0) 220deg, rgba(57, 255, 106, 0) 360deg);
  -webkit-mask: linear-gradient(#000 0 0) content-box, linear-gradient(#000 0 0);
  -webkit-mask-composite: xor;
  mask: linear-gradient(#000 0 0) content-box exclude, linear-gradient(#000 0 0);
  animation: mo-spin 4s linear infinite;
  opacity: var(--oRing);
  pointer-events: none;
}

/* ---------- کادر پرسش ---------- */
.mo-input {
  position: absolute; inset: 0;
  display: flex; align-items: center; gap: 8px;
  padding: 0 18px 0 8px; /* راست‌به‌چپ: ستاره سمت راست، دکمه ارسال سمت چپ */
  opacity: var(--oInput);
  transform: scale(var(--inScale));
  margin: 0;
}
.mo-root:not([data-phase="idle"]) .mo-input { pointer-events: none; }
.mo-spark { width: 20px; height: 20px; flex: none; color: #2DE2FF; }
.mo-root button, .mo-root input, .mo-root textarea { font-family: "Dana", Tahoma, sans-serif; }
.mo-field {
  flex: 1; min-width: 0;
  height: 100%;
  border: 0; outline: 0;
  background: transparent;
  color: #FFFFFF;
  font: inherit;
  font-size: 16px; /* کمتر از ۱۶ پیکسل → iOS موقع تایپ صفحه را زوم می‌کند */
  padding: 0;
}
.mo-field::placeholder { color: #FFFFFF; opacity: .75; }
.mo-send {
  width: 42px; height: 42px; flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .08);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s ease, color .2s ease, transform .15s ease;
}
.mo-send svg { width: 20px; height: 20px; }
.mo-send[data-ready] {
  background: linear-gradient(135deg, #2DE2FF, #39FF6A);
  color: #07101f;
  border-color: transparent;
}
.mo-send:active { transform: scale(.94); }

/* ---------- گوی ---------- */
.mo-orb {
  position: absolute;
  left: 50%; top: 50%;
  width: 220px; height: 220px;
  transform: translate(-50%, -50%);
  border-radius: 0 !important;
  pointer-events: none;
}
.mo-pulse {
  position: absolute;
  left: 50%; top: 50%;
  width: 132px; height: 132px;
  border-radius: 50% !important;
  border: 2px solid #34d399;
  opacity: 0;
  transform: translate(-50%, -50%);
  pointer-events: none;
}

/* ---------- کارت پاسخ ---------- */
.mo-answer {
  position: absolute; inset: 0;
  padding: 14px 18px 16px;
  opacity: var(--oCard);
  overflow: hidden;
  pointer-events: none;
  outline: none;
  text-align: right;
}
.mo-root[data-phase="answered"] .mo-answer {
  pointer-events: auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
}
.mo-a-head {
  display: flex; align-items: center; gap: 8px;
  font-size: 12.5px; font-weight: 700;
  color: #34d399;
  opacity: var(--hOp, 1);
  margin-bottom: 8px;
}
.mo-a-dot {
  width: 8px; height: 8px; flex: none;
  border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, .8);
  transform: scale(var(--dotS, 1));
}
.mo-a-body {
  margin: 0;
  font-size: 14.5px;
  line-height: 2;
  color: #FFFFFF;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}
.mo-w { display: inline-block; opacity: 0; will-change: opacity, transform; }
.mo-measure {
  position: absolute !important;
  inset: auto !important;
  left: -10000px !important; top: 0 !important;
  height: auto !important;
  visibility: hidden;
  opacity: 1 !important;
  pointer-events: none !important;
}
.mo-measure .mo-w { opacity: 1; }

/* ---------- وضعیت «در حال فکر کردن» ---------- */
.mo-status {
  position: absolute;
  left: 0; right: 0;
  top: calc(46% + 86px);
  height: 26px;
  opacity: var(--sOp, 0);
  transform: translateY(calc(var(--sTy, 6) * 1px));
  pointer-events: none;
}
.mo-lab {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  font-size: 13.5px;
  color: #FFFFFF;
}
.mo-lab.mo-in { animation: mo-in .35s ease both; }
.mo-lab.mo-out { animation: mo-out .3s ease both; }
.mo-lab-t {
  /* درخشش روی متن سفید (به‌جای خاکستری) */
  background: linear-gradient(90deg, rgba(255,255,255,.78) 0%, rgba(255,255,255,.78) 35%, #ffffff 50%, rgba(255,255,255,.78) 65%, rgba(255,255,255,.78) 100%);
  background-size: 250% 100%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation: mo-shimmer 2.2s linear infinite;
}
.mo-lab-done { color: #34d399; font-weight: 700; }
.mo-dots { display: inline-flex; gap: 3px; }
.mo-dots i {
  width: 4px; height: 4px; border-radius: 50%;
  background: currentColor;
  animation: mo-dot 1.2s ease-in-out infinite;
}
.mo-dots i:nth-child(2) { animation-delay: .15s; }
.mo-dots i:nth-child(3) { animation-delay: .3s; }

/* ---------- دکمه «سوال جدید دارم» ---------- */
.mo-reset {
  position: absolute;
  left: 50%;
  top: calc(46% + var(--cardH) / 2 + 16px);
  transform: translate(-50%, 6px);
  padding: 10px 20px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, .16);
  background: rgba(13, 18, 44, .8);
  color: #FFFFFF;
  font: inherit; font-size: 13.5px; font-weight: 700;
  cursor: pointer;
  opacity: 0;
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease, background .2s ease;
}
.mo-root[data-phase="answered"] .mo-reset { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.mo-reset:hover { background: rgba(255, 255, 255, .1); }

.mo-live {
  position: absolute;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  clip-path: inset(50%);
  white-space: nowrap;
}

@media (prefers-reduced-motion: reduce) {
  .mo-aurora i, .mo-ring, .mo-lab-t, .mo-dots i { animation: none; }
}

/* ---------- فرستادن عکس ---------- */
.mo-file { display: none; }
.mo-attach {
  width: 38px; height: 38px; flex: none;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, .14);
  background: rgba(255, 255, 255, .06);
  color: #FFFFFF;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background .2s ease, transform .15s ease;
}
.mo-attach svg { width: 19px; height: 19px; }
.mo-attach:hover { background: rgba(255, 255, 255, .14); }
.mo-attach:active { transform: scale(.94); }
.mo-root[data-has-file] .mo-attach { background: rgba(52, 211, 153, .25); border-color: rgba(52, 211, 153, .6); }
.mo-chip {
  position: absolute;
  left: 50%; bottom: 138px;
  transform: translate(-50%, 6px);
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px 6px 12px;
  border-radius: 14px;
  background: rgba(13, 18, 44, .9);
  border: 1px solid rgba(52, 211, 153, .45);
  color: #FFFFFF;
  font-size: 12.5px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
  z-index: 2;
}
.mo-root[data-has-file][data-phase="idle"] .mo-chip { opacity: 1; pointer-events: auto; transform: translate(-50%, 0); }
.mo-chip-img { width: 40px; height: 40px; border-radius: 9px; object-fit: cover; background: rgba(255,255,255,.06); }
.mo-chip-x {
  width: 26px; height: 26px; border-radius: 50%;
  border: 0; background: rgba(255, 255, 255, .1); color: #FFFFFF;
  font-size: 16px; line-height: 1; cursor: pointer;
}
