.space-bg {
  position: fixed;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(60% 55% at 68% 48%, rgba(40, 110, 255, 0.18), transparent 70%),
    radial-gradient(40% 40% at 6% 8%, rgba(34, 211, 238, 0.06), transparent 70%),
    var(--bg);
}

#scene {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: -1;
  opacity: 0;
  transition: opacity 1.4s var(--ease);
  pointer-events: none;
}

#scene.is-ready {
  opacity: 1;
}

/* وقت الافتتاحية الـ Canvas يظهر فورًا (العناصر هي اللي بتظهر تدريجيًا) */
html.is-intro #scene {
  transition: none;
}

/* ===== Hero ===== */
.hero {
  position: relative;
  min-height: 100svh;
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: calc(var(--nav-h) + 24px) var(--pad-x) 96px;
}

/* ضل خفيف ورا كلام الـ Hero: الكواكب اللي بتعدي ورا العنوان والزراير بتبهت شوية فالكلام يتقري بسهولة.
   على الكمبيوتر بس (على الموبايل الكوكب فوق والكلام تحت)، وبيتعكس في العربي */
@media (min-width: 821px) {
  .hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(90deg, rgba(4, 7, 13, 0.62) 0%, rgba(4, 7, 13, 0.4) 34%, rgba(4, 7, 13, 0) 58%);
  }

  [dir="rtl"] .hero::before {
    background: linear-gradient(270deg, rgba(4, 7, 13, 0.62) 0%, rgba(4, 7, 13, 0.4) 34%, rgba(4, 7, 13, 0) 58%);
  }
}

.hero__inner {
  max-width: 680px;
}

.hero__tag {
  margin-bottom: 26px;
  padding-inline-start: 14px;
  border-inline-start: 2px solid var(--accent);
  color: var(--text-dim);
  font-size: 0.72rem;
  letter-spacing: 0.24em;
}

.hero__title {
  font-size: clamp(2.3rem, 5.6vw, 5.2rem);
  font-weight: 800;
  line-height: 1.02;
  letter-spacing: -0.01em;
  text-shadow: 0 4px 40px rgba(0, 0, 0, 0.6);
}

.hero__sub {
  max-width: 470px;
  margin-top: 26px;
  color: var(--text);
  opacity: 0.85;
  font-size: clamp(1rem, 1.3vw, 1.15rem);
}

.hero__actions {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  margin-top: 34px;
}

/* ===== إحصائيات ===== */
.hero__stats {
  display: flex;
  margin-top: 48px;
}

.stat {
  display: grid;
  gap: 2px;
  margin-inline-end: 34px;
  padding-inline-end: 34px;
  border-inline-end: 1px solid var(--line);
}

.stat:last-child {
  margin: 0;
  padding: 0;
  border: 0;
}

.stat__icon {
  margin-bottom: 6px;
  color: var(--accent);
  font-size: 1.5rem;
}

.stat__value {
  color: var(--accent);
  font-size: 1.5rem;
  font-weight: 700;
  line-height: 1.1;
}

.stat__label {
  color: var(--text-dim);
  font-size: 0.85rem;
}

/* ===== مؤشر الـ Scroll ===== */
.hero__scroll {
  position: absolute;
  left: 50%;
  bottom: 86px;
  display: grid;
  justify-items: center;
  gap: 8px;
  color: var(--text-dim);
  font-size: 0.8rem;
  transform: translateX(-50%);
}

.hero__mouse {
  position: relative;
  width: 20px;
  height: 32px;
  border: 1.5px solid rgba(255, 255, 255, 0.55);
  border-radius: 11px;
}

.hero__mouse::after {
  content: "";
  position: absolute;
  top: 6px;
  left: 50%;
  width: 3px;
  height: 6px;
  border-radius: 2px;
  background: #fff;
  transform: translateX(-50%);
  animation: wheel 1.8s var(--ease) infinite;
}

@keyframes wheel {
  0% { opacity: 0; transform: translate(-50%, 0); }
  30% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, 10px); }
}

/* ===== شريط الأدوات ===== */
.hero__bar {
  position: absolute;
  inset: auto 0 0 0;
  height: 64px;
  display: flex;
  align-items: center;
  gap: clamp(20px, 5vw, 70px);
  padding: 0 var(--pad-x);
  border-top: 1px solid var(--line);
  background: linear-gradient(to bottom, rgba(4, 7, 13, 0.2), rgba(4, 7, 13, 0.75));
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.hero__bar-label {
  color: var(--text-dim);
  font-size: 0.7rem;
  letter-spacing: 0.2em;
}

.hero__bar-tool {
  color: var(--text);
  opacity: 0.85;
  font-family: var(--font-en);
  font-size: 0.95rem;
  font-weight: 600;
}

/* ===================================================== */
/* ===== الافتتاحية: توقيت ظهور النصوص والـ Navbar ===== */
/* ===================================================== */

/* العناصر مخفية لحد ما الافتتاحية تفرجها (الكلاس is-intro على html) */
.reveal {
  opacity: 0;
  transform: translateY(18px);
}

.hero__scroll.reveal {
  transform: translate(-50%, 18px);
}

html.is-intro .nav,
html.is-intro .hero__bar,
html.is-intro .dots {
  opacity: 0;
}

/* لما الافتتاحية تفرج الكلاس: النصوص تدخل بالتتابع (--k بيقصّر التوقيت في النسخة المختصرة) */
html:not(.is-intro) .reveal {
  animation: reveal 0.9s var(--ease) forwards;
  animation-delay: calc(var(--d, 0) * var(--k, 1) * 1ms);
}

html:not(.is-intro) .hero__scroll.reveal {
  animation-name: reveal-center;
}

/* الـ Navbar ثم الشريط والنقط: آخر حاجة في التتابع */
html:not(.is-intro) .nav {
  animation: fade-in 0.8s var(--ease) backwards;
  animation-delay: calc(1100 * var(--k, 1) * 1ms);
}

html:not(.is-intro) .hero__bar,
html:not(.is-intro) .dots {
  animation: fade-in 0.8s var(--ease) backwards;
  animation-delay: calc(1300 * var(--k, 1) * 1ms);
}

/* لو الزائر ضغط Skip: ظهور سريع */
html.intro-skipped .reveal,
html.intro-skipped .nav,
html.intro-skipped .hero__bar,
html.intro-skipped .dots {
  animation-duration: 0.35s;
}

@keyframes reveal {
  to {
    opacity: 1;
    transform: none;
  }
}

@keyframes reveal-center {
  from { opacity: 0; transform: translate(-50%, 18px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes fade-in {
  from { opacity: 0; }
}

/* شبكة أمان: لو JavaScript وقع لأي سبب، كل حاجة تظهر لوحدها بعد 12 ثانية */
html.is-intro .reveal {
  animation: failsafe 0.01s 12s forwards;
}

html.is-intro .hero__scroll.reveal {
  animation-name: failsafe-center;
}

html.is-intro .nav,
html.is-intro .hero__bar,
html.is-intro .dots {
  animation: failsafe-fade 0.01s 12s forwards;
}

@keyframes failsafe {
  to { opacity: 1; transform: none; }
}

@keyframes failsafe-center {
  to { opacity: 1; transform: translate(-50%, 0); }
}

@keyframes failsafe-fade {
  to { opacity: 1; }
}

/* ===================================================== */
/* ===== زر Skip: Minimal Glass ===== */
/* ===================================================== */
.intro-skip {
  position: fixed;
  left: 50%;
  bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);
  z-index: 95;
  display: inline-flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 0 22px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.04);
  -webkit-backdrop-filter: blur(10px);
  backdrop-filter: blur(10px);
  color: rgba(255, 255, 255, 0.72);
  font-size: 0.68rem;
  font-weight: 500;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  white-space: nowrap;
  opacity: 0;
  transform: translateX(-50%);
  pointer-events: none;
  -webkit-tap-highlight-color: transparent;
  transition:
    opacity 0.5s var(--ease),
    color 0.3s var(--ease),
    border-color 0.3s var(--ease),
    background 0.3s var(--ease),
    box-shadow 0.3s var(--ease);
}

/* السهم الصغير (CSS بس، فبيشتغل مع أي زر Skip) */
.intro-skip::after {
  content: "";
  flex: none;
  width: 14px;
  height: 10px;
  background: currentColor;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 5h12M9 1l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 10' fill='none' stroke='black' stroke-width='1.2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M1 5h12M9 1l4 4-4 4'/%3E%3C/svg%3E") center / contain no-repeat;
}

html[dir="rtl"] .intro-skip::after {
  transform: scaleX(-1);
}

.intro-skip.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.intro-skip:hover,
.intro-skip:focus-visible {
  border-color: rgba(34, 211, 238, 0.45);
  background: rgba(255, 255, 255, 0.07);
  color: #fff;
  box-shadow: 0 0 26px rgba(34, 211, 238, 0.16);
}

.intro-skip:focus-visible {
  outline: 2px solid rgba(34, 211, 238, 0.6);
  outline-offset: 3px;
}

/* ===== عربي ===== */
html[lang="ar"] .hero__tag,
html[lang="ar"] .hero__bar-label,
html[lang="ar"] .section__tag,
html[lang="ar"] .intro-skip {
  letter-spacing: 0;
  text-transform: none;
}

html[lang="ar"] .intro-skip {
  font-size: 0.85rem;
}

html[lang="ar"] .hero__title {
  line-height: 1.25;
  letter-spacing: 0;
}

/* ===== Responsive ===== */
@media (max-width: 820px) {
  .hero {
    justify-content: flex-end;
    padding-bottom: 96px;
  }

  /* تدرّج غامق ورا النص: الكوكب واضح فوق، والكلام مقروء تحت */
  .hero::before {
    content: "";
    position: absolute;
    inset: 0;
    z-index: -1;
    pointer-events: none;
    background: linear-gradient(
      to bottom,
      transparent 0%,
      transparent 20%,
      rgba(4, 7, 13, 0.55) 34%,
      rgba(4, 7, 13, 0.82) 52%,
      rgba(4, 7, 13, 0.9) 100%
    );
  }

  .hero__sub {
    margin-top: 18px;
    font-size: 0.98rem;
  }

  .hero__actions {
    margin-top: 24px;
    gap: 12px;
  }

  .btn {
    padding: 13px 22px;
  }

  .hero__stats {
    margin-top: 30px;
  }

  .stat {
    margin-inline-end: 18px;
    padding-inline-end: 18px;
  }

  .stat__value {
    font-size: 1.25rem;
  }

  .stat__label {
    font-size: 0.75rem;
  }

  .hero__scroll {
    display: none;
  }

  .hero__bar-label {
    display: none;
  }

  .hero__bar {
    gap: 22px;
  }
}

@media (max-height: 720px) {
  .hero__scroll {
    display: none;
  }
}

/* ===== تقليل الحركة ===== */
@media (prefers-reduced-motion: reduce) {
  #scene {
    transition-duration: 0.5s;
  }

  /* ظهور بسيط بالشفافية بس، من غير حركة */
  .reveal {
    transform: none;
  }

  .hero__scroll.reveal {
    transform: translateX(-50%);
  }

  html:not(.is-intro) .reveal {
    opacity: 1;
    animation: fade-in 0.5s var(--ease) backwards;
    animation-delay: 0s;
  }

  html:not(.is-intro) .hero__scroll.reveal {
    animation-name: fade-in;
  }

  html:not(.is-intro) .nav,
  html:not(.is-intro) .hero__bar,
  html:not(.is-intro) .dots {
    animation-delay: 0s;
  }

  .hero__mouse::after {
    animation: none;
  }
}