/*
 * أنماط جذر صفحة الويب (العقد docs/rival/web.md)، وقالبها public/index.html. ملف خارجي بدل نمط داخل الصفحة، والصفحة بلا
 * أي سكربت أو نمط مكتوب داخلها وبلا خطوط أو ملفات من عنوان ثاني: تشتغل تحت سياسة محتوى مشدّدة.
 * نفس توصية react-native-web: الصفحة بطول الشاشة، والتمرير داخل قوائم التطبيق مو بالصفحة.
 * جذر الصفحة dir="ltr" ثابت: التطبيق يبني اتجاهه بيده (dirSheet وDIR)، ولو الصفحة نفسها انقلبت ينعكس كل شي مرتين.
 * اللغة (lang) تتبدّل وقت التشغيل ويا لغة التطبيق (src/web/boot.web.js).
 *
 * «سلاسة الويب» (نفس العقد): الصفحة تتصرف مثل تطبيق هاتف. الأقسام بالترتيب:
 *   ١) الجذر: طول الشاشة الفعلي، بلا سحبة تحديث ولا مطّ، بلا ومضة لمس ولا تكبير باللمستين.
 *   ٢) التحديد والسحب: نص الواجهة ما يتحدد بالغلط، والحقول تبقى تتحدد.
 *   ٣) شريط التمرير نحيف وهادي، وحلقة التركيز للوحة المفاتيح بس.
 *   ٤) شاشة البداية (العلامة وهيكل هادي) لحد ما يركب التطبيق.
 *   ٥) حركة فتح الشاشة والظهور الناعم (يشغّلها المتصفح نفسه، فما تتأخر لمن التطبيق مشغول).
 *   ٦) «تقليل الحركة» بإعدادات الجهاز يطفّي كل الحركات.
 */

/* ───────── ١) الجذر ───────── */
html,
body {
  height: 100%;
  /* السحب العمودي ما يمطّ الصفحة ولا يحدّثها. الأفقي يبقى للمتصفح: سحبة الرجوع بلوحة اللمس ترجّع داخل التطبيق */
  overscroll-behavior-y: none;
}

html {
  touch-action: manipulation;
}

body {
  margin: 0;
  overflow: hidden;
  /* نفس خلفية التطبيق (theme.js) حتى ما تومض الصفحة بيضة قبل أول رسمة */
  background: #08101b;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
  touch-action: manipulation;
}

@media (prefers-color-scheme: light) {
  body {
    background: #f1f6f6;
  }
}

#root {
  display: flex;
  height: 100%;
  flex: 1;
}

/* طول الشاشة الفعلي: شريط عنوان المتصفح بالهاتف يطلع ويختفي، و١٠٠٪ تبقى على قياس واحد منهم */
@supports (height: 100dvh) {
  html,
  body,
  #root {
    height: 100dvh;
  }
}

/* ───────── ٢) التحديد والسحب ───────── */
body {
  -webkit-user-select: none;
  user-select: none;
}

input,
textarea,
select,
[contenteditable],
[data-selectable] {
  -webkit-user-select: text;
  user-select: text;
}

a,
img,
svg {
  -webkit-user-drag: none;
}

/* القوائم تكمل تمريرها بعد ما ترفع إصبعك: قوائم التطبيق تكتبها بنفسها (react-native-web)، وهذي لأي عنصر تمرير غيرها بمتصفحات آيفون القديمة */
body {
  -webkit-overflow-scrolling: touch;
}

/* ───────── ٣) شريط التمرير والتركيز ───────── */
* {
  scrollbar-width: thin;
  scrollbar-color: rgba(143, 163, 173, 0.34) transparent;
}

@media (prefers-color-scheme: light) {
  * {
    scrollbar-color: rgba(78, 100, 112, 0.34) transparent;
  }
}

/* الحقول إلها توهّج تركيز من التطبيق نفسه (ui.js): إطار المتصفح فوقه يصير إطارين */
input:focus,
textarea:focus,
select:focus {
  outline: none;
}

/* الضغط بالماوس أو الإصبع بلا حلقة؛ التنقّل بلوحة المفاتيح ياخذ حلقة بلون التطبيق */
:focus:not(:focus-visible) {
  outline: none;
}

:focus-visible:not(input):not(textarea):not(select) {
  outline: 2px solid #12bfae;
  outline-offset: 2px;
}

noscript {
  display: block;
  padding: 24px;
  color: #8a97a8;
  font: 16px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  direction: rtl;
}

/* ───────── ٤) شاشة البداية ─────────
 * تنرسم من أول ما توصل الصفحة (قبل حزمة التطبيق)، وsrc/web/pwa.js يشيلها لمن يركب التطبيق (يحط data-gone ثم يحذفها).
 * العلامة بنفس مكان وحجم علامة شاشة الإقلاع بالتطبيق (App.js ← Boot) حتى الانتقال ما ينحس.
 */
.splash {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  z-index: 2147483000;
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  padding: 24px;
  background: #08101b;
  color: #12bfae;
  opacity: 1;
  transition: opacity 0.22s ease-out;
}

.splash[data-gone] {
  opacity: 0;
  pointer-events: none;
}

.splash-mark {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.splash-logo {
  display: block;
  width: 64px;
  height: 64px;
}

/* خط تحميل قصير بمكان دوّار شاشة الإقلاع */
.splash-line {
  display: block;
  width: 44px;
  height: 3px;
  margin-top: 40px;
  margin-bottom: 9px;
  border-radius: 3px;
  background: currentColor;
  opacity: 0.3;
  animation: splash-breathe 1.2s ease-in-out infinite alternate;
}

/* هيكل الشاشة الجاية: شريط علوي، كم صف، وشريط التبويبات. باهت ويتنفّس بهدوء */
.splash-frame {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  left: 0;
  box-sizing: border-box;
  width: 100%;
  max-width: 720px;
  margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px 0;
  opacity: 0.5;
  animation: splash-breathe 1.8s ease-in-out infinite alternate;
}

.sk {
  display: block;
  border-radius: 14px;
  background: #121b26;
}

.sk-top {
  width: 44%;
  height: 40px;
  margin-bottom: 18px;
}

.sk-row {
  height: 56px;
  margin-bottom: 10px;
}

.sk-row + .sk-row {
  opacity: 0.66;
}

.sk-row + .sk-row + .sk-row {
  opacity: 0.33;
}

.sk-dock {
  position: absolute;
  right: 0;
  bottom: calc(14px + env(safe-area-inset-bottom));
  left: 0;
  width: 84%;
  max-width: 420px;
  height: 60px;
  margin: 0 auto;
  border-radius: 30px;
}

/* شاشة قصيرة (هاتف بالعرض): الهيكل يزاحم العلامة، فالعلامة وحدها */
@media (max-height: 620px) {
  .splash-frame {
    display: none;
  }
}

/* التحميل طوّل (شبكة ضعيفة أو ملف ما وصل): رابط عادي يعيد المحاولة، بلا سكربت */
.splash-retry {
  position: absolute;
  right: 0;
  bottom: calc(96px + env(safe-area-inset-bottom));
  left: 0;
  color: #8fa3ad;
  font: 14px/1.6 system-ui, -apple-system, "Segoe UI", sans-serif;
  text-align: center;
  text-decoration: underline;
  opacity: 0;
  pointer-events: none;
  animation: splash-late 0.4s ease-out 20s forwards;
}

@media (prefers-color-scheme: light) {
  .splash {
    background: #f1f6f6;
    color: #0e9c8e;
  }

  .sk {
    background: #e7eff0;
  }

  .splash-retry {
    color: #4e6470;
  }
}

@keyframes splash-breathe {
  from {
    opacity: 0.3;
  }

  to {
    opacity: 0.62;
  }
}

@keyframes splash-late {
  to {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ───────── ٥) حركة الشاشات ─────────
 * مكدّس التنقّل على الويب يبدّل الشاشات بلا حركة (يخفي ويظهر). src/web/screenMotion.js يلف محتوى كل شاشة بعنصر عليه
 * data-screen، والحركة تشتغل وحدها كل ما تنعرض الشاشة: «push» فتح شاشة، «up» شاشة تطلع من تحت (الشارت)،
 * «back» رجعة لشاشة جنت بيها، «root» أول شاشة. بلا قيمة باقية بعد الحركة (ما يبقى transform على الشاشة).
 */
[data-screen] {
  animation-duration: 0.22s;
  animation-timing-function: cubic-bezier(0.22, 0.61, 0.36, 1);
}

[data-screen="push"] {
  animation-name: screen-push;
}

[data-screen="up"] {
  animation-name: screen-up;
  animation-duration: 0.26s;
}

[data-screen="back"] {
  animation-name: screen-back;
  animation-duration: 0.16s;
}

[data-screen="root"] {
  animation-name: screen-root;
}

@keyframes screen-push {
  from {
    opacity: 0;
    transform: translate3d(22px, 0, 0);
  }
}

@keyframes screen-up {
  from {
    opacity: 0;
    transform: translate3d(0, 28px, 0);
  }
}

@keyframes screen-back {
  from {
    opacity: 0.55;
  }
}

@keyframes screen-root {
  from {
    opacity: 0;
  }
}

/* ظهور ناعم لعنصر واحد (FadeIn بـsrc/components/ui.js على الويب): نفس حركة التطبيق، ٢٢٠ مللي ثانية و٨ نقاط لفوق */
[data-fade] {
  animation: fade-in 0.22s cubic-bezier(0.25, 0.46, 0.45, 0.94) backwards;
}

@keyframes fade-in {
  from {
    opacity: 0;
    transform: translate3d(0, 8px, 0);
  }
}

/* ───────── ٦) تقليل الحركة ───────── */
@media (prefers-reduced-motion: reduce) {
  [data-screen],
  [data-fade],
  .splash-frame,
  .splash-line {
    animation: none;
  }

  .splash {
    transition: none;
  }
}
