/* ==========================================================================
   Onboarding Tour — منصة الدحيح
   جولة تعليمية ذكية: سبوت لايت + بطاقات شرح + انتقال بين الصفحات
   ========================================================================== */

:root {
  --tour-gold: #eab308;
  --tour-gold-soft: #facc15;
  --tour-bg: #0d1322;
  --tour-surface: #111a2e;
  --tour-text: #f1f5f9;
  --tour-muted: #9aa7bd;
  --tour-line: rgba(234, 179, 8, .28);
}

/* حاوية الجولة بالكامل */
#tourRoot {
  position: fixed;
  inset: 0;
  z-index: 2147483000;
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  pointer-events: none;
  opacity: 0;
  transition: opacity .35s ease;
}
#tourRoot.tour-visible { opacity: 1; }
#tourRoot.tour-active { pointer-events: auto; }

/* الطبقة المعتمة (خلفية) — تلتقط الضغطات */
.tour-backdrop {
  position: fixed;
  inset: 0;
  background: transparent;
}

/* السبوت لايت: مربع شفاف حوله ظل ضخم يعتّم باقي الصفحة */
.tour-spotlight {
  position: fixed;
  top: 0;
  left: 0;
  width: 0;
  height: 0;
  border-radius: 16px;
  box-shadow: 0 0 0 9999px rgba(4, 7, 14, .82);
  border: 2px solid var(--tour-gold);
  transition:
    top .45s cubic-bezier(.16, 1, .3, 1),
    left .45s cubic-bezier(.16, 1, .3, 1),
    width .45s cubic-bezier(.16, 1, .3, 1),
    height .45s cubic-bezier(.16, 1, .3, 1),
    border-radius .45s ease,
    opacity .3s ease;
  pointer-events: none;
}
.tour-spotlight::after {
  content: "";
  position: absolute;
  inset: -2px;
  border-radius: inherit;
  box-shadow: 0 0 0 3px rgba(234, 179, 8, .18), 0 0 26px 4px rgba(234, 179, 8, .30);
  animation: tourPulse 2s ease-in-out infinite;
  pointer-events: none;
}
@keyframes tourPulse {
  0%, 100% { box-shadow: 0 0 0 3px rgba(234, 179, 8, .16), 0 0 22px 3px rgba(234, 179, 8, .22); }
  50%      { box-shadow: 0 0 0 5px rgba(234, 179, 8, .26), 0 0 34px 8px rgba(234, 179, 8, .40); }
}

/* عند خطوة بلا هدف (وسط الشاشة) نخفي الحد ونعتّم كامل */
.tour-spotlight.tour-center {
  border-color: transparent;
  box-shadow: 0 0 0 9999px rgba(4, 7, 14, .90);
}
.tour-spotlight.tour-center::after { display: none; }

/* بطاقة الشرح */
.tour-card {
  position: fixed;
  width: min(340px, calc(100vw - 32px));
  background: linear-gradient(180deg, var(--tour-surface), var(--tour-bg));
  border: 1px solid var(--tour-line);
  border-radius: 18px;
  padding: 22px 20px 18px;
  color: var(--tour-text);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), 0 0 0 1px rgba(255, 255, 255, .03) inset;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(10px) scale(.98);
  transition: opacity .3s ease, transform .35s cubic-bezier(.16, 1, .3, 1),
    top .4s cubic-bezier(.16, 1, .3, 1), left .4s cubic-bezier(.16, 1, .3, 1);
}
.tour-card.tour-card-in { opacity: 1; transform: translateY(0) scale(1); }

/* سهم صغير يشير للعنصر */
.tour-arrow {
  position: absolute;
  width: 14px;
  height: 14px;
  background: var(--tour-surface);
  border: 1px solid var(--tour-line);
  transform: rotate(45deg);
  z-index: -1;
}

/* رأس البطاقة */
.tour-card-head {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.tour-badge {
  width: 34px;
  height: 34px;
  flex: none;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--tour-gold), var(--tour-gold-soft));
  color: #1a1205;
  box-shadow: 0 6px 18px rgba(234, 179, 8, .35);
}
.tour-badge svg { width: 18px; height: 18px; }
.tour-title {
  font-size: 1.06rem;
  font-weight: 700;
  letter-spacing: -.2px;
  line-height: 1.3;
}
.tour-body {
  font-size: .92rem;
  line-height: 1.7;
  color: var(--tour-muted);
  margin-bottom: 16px;
  text-wrap: pretty;
}
.tour-body b { color: var(--tour-text); font-weight: 600; }

/* شريط التقدم النقطي */
.tour-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 14px;
}
.tour-progress .tp-dot {
  height: 6px;
  border-radius: 999px;
  background: rgba(255, 255, 255, .14);
  transition: all .35s ease;
  flex: 1;
}
.tour-progress .tp-dot.done { background: rgba(234, 179, 8, .55); }
.tour-progress .tp-dot.current { background: var(--tour-gold); box-shadow: 0 0 10px rgba(234, 179, 8, .6); }

/* أزرار التحكم */
.tour-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}
.tour-btn {
  font-family: inherit;
  font-size: .92rem;
  font-weight: 600;
  border-radius: 11px;
  padding: 11px 16px;
  cursor: pointer;
  border: none;
  transition: transform .18s ease, background .25s ease, border-color .25s ease, color .25s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}
.tour-btn:active { transform: scale(.97); }
.tour-btn-next {
  flex: 1;
  background: linear-gradient(135deg, var(--tour-gold), var(--tour-gold-soft));
  color: #1a1205;
  box-shadow: 0 8px 22px rgba(234, 179, 8, .3);
}
.tour-btn-next:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(234, 179, 8, .42); }
.tour-btn-next svg { width: 16px; height: 16px; }
.tour-btn-prev {
  background: rgba(255, 255, 255, .05);
  color: var(--tour-muted);
  border: 1px solid rgba(255, 255, 255, .1);
}
.tour-btn-prev:hover { color: var(--tour-text); border-color: var(--tour-line); }

/* زر التخطّي (أعلى البطاقة) */
.tour-skip {
  position: absolute;
  top: 12px;
  left: 14px;
  background: none;
  border: none;
  color: var(--tour-muted);
  font-family: inherit;
  font-size: .78rem;
  font-weight: 500;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  transition: color .2s, background .2s;
}
.tour-skip:hover { color: var(--tour-text); background: rgba(255, 255, 255, .06); }

/* عدّاد الخطوة */
.tour-counter {
  font-size: .74rem;
  color: var(--tour-muted);
  font-weight: 500;
  white-space: nowrap;
}

/* ======================= شاشة الترحيب (نمط نتفلكس) ======================= */
.tour-welcome {
  position: fixed;
  inset: 0;
  z-index: 2147483001;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 28px;
  background:
    radial-gradient(900px 500px at 50% -5%, rgba(234, 179, 8, .12), transparent 60%),
    rgba(4, 7, 14, .96);
  backdrop-filter: blur(6px);
  opacity: 0;
  transition: opacity .4s ease;
}
.tour-welcome.tw-in { opacity: 1; }
.tw-mark {
  width: 76px;
  height: 76px;
  border-radius: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--tour-gold), var(--tour-gold-soft));
  box-shadow: 0 14px 40px rgba(234, 179, 8, .4);
  margin-bottom: 26px;
  transform: translateY(14px) scale(.9);
  opacity: 0;
  animation: twPop .6s cubic-bezier(.16, 1, .3, 1) .15s forwards;
}
.tw-mark svg { width: 40px; height: 40px; }
.tw-title {
  font-size: clamp(1.7rem, 6vw, 2.4rem);
  font-weight: 700;
  line-height: 1.25;
  letter-spacing: -.5px;
  margin-bottom: 14px;
  color: var(--tour-text);
  max-width: 560px;
  text-wrap: balance;
  opacity: 0;
  animation: twUp .6s cubic-bezier(.16, 1, .3, 1) .28s forwards;
}
.tw-title .accent { color: var(--tour-gold); }
.tw-sub {
  font-size: clamp(1rem, 3.6vw, 1.15rem);
  color: var(--tour-muted);
  max-width: 440px;
  line-height: 1.7;
  margin-bottom: 34px;
  text-wrap: pretty;
  opacity: 0;
  animation: twUp .6s cubic-bezier(.16, 1, .3, 1) .4s forwards;
}
.tw-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  opacity: 0;
  animation: twUp .6s cubic-bezier(.16, 1, .3, 1) .52s forwards;
}
.tw-btn {
  font-family: inherit;
  font-size: 1.02rem;
  font-weight: 700;
  border-radius: 14px;
  padding: 15px 24px;
  cursor: pointer;
  border: none;
  transition: transform .18s ease, box-shadow .25s ease, background .25s, color .25s, border-color .25s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}
.tw-btn svg { width: 19px; height: 19px; }
.tw-btn-start {
  background: linear-gradient(135deg, var(--tour-gold), var(--tour-gold-soft));
  color: #1a1205;
  box-shadow: 0 12px 32px rgba(234, 179, 8, .38);
}
.tw-btn-start:hover { transform: translateY(-2px); box-shadow: 0 18px 44px rgba(234, 179, 8, .5); }
.tw-btn-skip {
  background: transparent;
  color: var(--tour-muted);
  border: 1px solid rgba(255, 255, 255, .12);
}
.tw-btn-skip:hover { color: var(--tour-text); border-color: var(--tour-line); background: rgba(255, 255, 255, .04); }

@keyframes twPop { to { opacity: 1; transform: translateY(0) scale(1); } }
@keyframes twUp  { to { opacity: 1; transform: translateY(0); } }

/* ======================= زر إعادة الشرح العائم ======================= */
#tourReplayBtn {
  position: fixed;
  bottom: 18px;
  left: 18px;
  z-index: 2147482000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: 'IBM Plex Sans Arabic', system-ui, sans-serif;
  font-size: .85rem;
  font-weight: 600;
  color: var(--tour-gold-soft);
  background: rgba(17, 26, 46, .92);
  border: 1px solid var(--tour-line);
  box-shadow: 0 8px 24px rgba(0, 0, 0, .4);
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: transform .2s ease, background .25s, color .25s, border-color .25s;
}
#tourReplayBtn:hover {
  transform: translateY(-2px);
  color: #1a1205;
  background: linear-gradient(135deg, var(--tour-gold), var(--tour-gold-soft));
  border-color: transparent;
}
#tourReplayBtn svg { width: 16px; height: 16px; }
@media (max-width: 520px) {
  #tourReplayBtn span { display: none; }
  #tourReplayBtn { padding: 11px; }
}

@media (prefers-reduced-motion: reduce) {
  .tour-spotlight, .tour-card { transition: opacity .2s ease; }
  .tour-spotlight::after, .tw-mark, .tw-title, .tw-sub, .tw-actions { animation: none; opacity: 1; transform: none; }
}
