/* =====================================================================
   MOBILE SPECIFIC STYLES (< 900px)
   Features: Safe Areas, Touch Optimization, Focus Mode, Gestures
   ===================================================================== */

/* 1. إخفاء عناصر الكمبيوتر نهائياً */
.sidebar {
  display: none !important;
}

/* 2. تحسينات التخطيط والأداء (Layout & Performance) */
body {
  /* منع تكبير النص التلقائي عند تدوير الشاشة */
  -webkit-text-size-adjust: 100%;
  /* منع الارتداد المزعج للصفحة (Rubber-banding) */
  overscroll-behavior-y: none;
  background-attachment: fixed; /* تثبيت الخلفية للأداء */
}

.main-view {
  /* مسافة سفلية ذكية تحسب حساب البار السفلي + منطقة الآيفون الآمنة */
  padding-bottom: calc(95px + env(safe-area-inset-bottom));
  padding-left: 16px;
  padding-right: 16px;

  /* تفعيل التمرير السلس والفيزيائي */
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;

  /* تحسين أداء الرسم */
  will-change: scroll-position;
}

.deck-grid {
  display: grid;
  grid-template-columns: 1fr; /* عمود واحد لراحة العين */
  gap: 16px;
}

/* 🌟 NEW: Mobile Stats Bar (شريط الإحصائيات للجوال) */
/* تصميم مصغر ليناسب شاشة الجوال (4 أعمدة بجانب بعض) */
.stats-bar {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
  margin-bottom: 20px;
  background: var(--bg-surface);
  padding: 12px 8px;
  border-radius: 16px;
  border: 1px solid var(--glass-border);
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.stat-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.stat-val {
  font-size: 15px; /* خط أصغر ومناسب للجوال */
  font-weight: 800;
  color: var(--text-primary);
  line-height: 1.1;
  margin-bottom: 2px;
}

.stat-lbl {
  font-size: 9px;
  color: var(--text-secondary);
  font-weight: 500;
  white-space: nowrap; /* منع نزول النص لسطرين */
}

/* 3. تكبير مناطق اللمس (Touch Targets) */
.btn {
  min-height: 52px; /* ارتفاع مثالي للإبهام */
  font-size: 16px;
  margin-bottom: 12px;
  /* إزالة تأخير النقر (300ms delay) */
  touch-action: manipulation;
  /* منع تحديد النص داخل الأزرار */
  user-select: none;
  -webkit-user-select: none;
}

.card,
.word-card {
  padding: 20px;
  border-radius: 20px;
}

/* تكبير أيقونات الهيدر */
.btn-icon {
  width: 44px;
  height: 44px;
  display: grid;
  place-items: center;
}

/* 4. شريط التنقل السفلي (Premium Bottom Nav) */
.bottom-nav {
  display: flex;
  justify-content: space-around;
  align-items: center;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;

  /* خلفية زجاجية قوية */
  background: rgba(3, 4, 7, 0.9);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid rgba(255, 255, 255, 0.05);

  /* دعم المنطقة الآمنة للآيفون */
  padding: 8px 0 calc(8px + env(safe-area-inset-bottom));

  z-index: 100;
  box-shadow: 0 -10px 30px rgba(0, 0, 0, 0.5);

  /* حركة ناعمة للإخفاء عند فتح الكيبورد */
  transition: transform 0.3s cubic-bezier(0.2, 0.8, 0.2, 1);
  will-change: transform;
}

/* كلاس يتم تفعيله عند فتح الكيبورد */
.bottom-nav.nav-hidden {
  transform: translateY(100%);
}

.b-nav-item {
  background: none;
  border: none;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  cursor: pointer;
  flex: 1;
  padding: 4px;
  /* تأثير النقر */
  transition: color 0.2s, transform 0.2s;
  -webkit-tap-highlight-color: transparent;
}

.b-nav-item span {
  font-size: 22px;
  line-height: 1;
}
.b-nav-item small {
  font-size: 10px;
  font-weight: 500;
  opacity: 0.8;
}

.b-nav-item.active {
  color: var(--accent-primary);
}
.b-nav-item.active span {
  transform: translateY(-2px);
  text-shadow: 0 0 15px rgba(83, 117, 255, 0.5);
}

/* 5. وضع التركيز (Focus Mode) */
/* يخفي الهيدر والبار السفلي والإحصائيات أثناء الكويز */
body.focus-mode .hdr,
body.focus-mode .bottom-nav,
body.focus-mode .stats-bar {
  display: none !important;
}

body.focus-mode .main-view {
  padding-top: 40px;
  padding-bottom: 20px;
  height: 100vh;
  overflow-y: auto;
}

/* 6. تحسينات الكويز (Ergonomics) */
.quiz-container {
  min-height: 80vh;
  display: flex;
  flex-direction: column;
  /* وضع العناصر في الأسفل ليسهل الوصول إليها بيد واحدة */
  justify-content: flex-end;
  padding-bottom: 20px;
}

.quiz-opt {
  padding: 18px;
  font-size: 17px;
  margin-bottom: 10px;
  border-radius: 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--glass-border);
  text-align: center;
  transition: transform 0.1s, background 0.2s;
  user-select: none;
  -webkit-user-select: none;
  font-weight: 500;
}

.quiz-opt:active {
  background: var(--glass-highlight);
  transform: scale(0.97);
}

.quiz-opt.correct {
  border-color: var(--accent-success);
  background: rgba(18, 183, 106, 0.15);
  color: #a6f4c5;
}

.quiz-opt.wrong {
  border-color: var(--accent-error);
  background: rgba(240, 68, 56, 0.15);
  color: #fecdca;
}

.quiz-q {
  margin-top: auto;
  margin-bottom: 25px;
  font-size: 2.2rem; /* تكبير الخط للجوال */
}

/* 7. الوضع الأفقي (Landscape) */
@media (orientation: landscape) {
  .deck-grid {
    grid-template-columns: 1fr 1fr;
  }

  .quiz-container {
    justify-content: center;
    flex-direction: row;
    align-items: center;
    gap: 20px;
  }
  .quiz-container > * {
    flex: 1;
  }

  .bottom-nav {
    padding: 4px 0;
  }
  .b-nav-item span {
    font-size: 20px;
  }
  .b-nav-item small {
    display: none;
  } /* توفير مساحة */
}
html,
body {
  height: 100%;
  overscroll-behavior: none;
}

.app-shell {
  min-height: 100dvh;
}
