html {
  scroll-behavior: smooth;
}

body {
  font-family: 'Tajawal', sans-serif;
}

.nav-link {
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #4b5563;
  border-radius: 0.5rem;
  transition: color 0.15s, background-color 0.15s;
}
.nav-link:hover {
  color: #0f8a67;
  background-color: #eefcf6;
}

.nav-link-mobile {
  display: block;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  font-weight: 700;
  color: #374151;
  border-radius: 0.5rem;
  transition: color 0.15s, background-color 0.15s;
}
.nav-link-mobile:hover {
  color: #0f8a67;
  background-color: #eefcf6;
}

/* ============================================================
   محرك الدرس التفاعلي — العرض التقديمي بالصور والحركات
   ============================================================ */
.presentation-wrap {
  display: flex;
  flex-direction: column;
}

.pres-body {
  min-height: 380px;
}

.pres-image-pane {
  width: 100%;
  height: 200px;
}
@media (min-width: 768px) {
  .pres-image-pane {
    width: 38%;
    height: auto;
  }
}

.pres-image-kenburns {
  animation: kenburns 18s ease-in-out infinite alternate;
  transition: opacity 0.5s ease;
}
@keyframes kenburns {
  0% { transform: scale(1) translate(0, 0); }
  100% { transform: scale(1.14) translate(-2%, -2%); }
}

.pres-image-fade-swap {
  animation: presImageFade 0.6s ease;
}
@keyframes presImageFade {
  from { opacity: 0.15; filter: blur(6px); }
  to { opacity: 1; filter: blur(0); }
}

.pres-image-overlay {
  background: linear-gradient(to top, rgba(0, 0, 0, 0.65) 0%, rgba(0, 0, 0, 0.05) 55%, transparent 100%);
}
@media (min-width: 768px) {
  .pres-image-overlay {
    background: linear-gradient(to top, rgba(0, 0, 0, 0.6) 0%, rgba(0, 0, 0, 0.05) 60%, transparent 100%);
  }
}

.pres-content-pane {
  background: #fff;
}

.pres-viewport {
  min-height: 320px;
}

/* وضع ملء الشاشة — يمدّد العرض التقديمي بالكامل ويجعل المحتوى يتوسّط رأسيًا */
.presentation-wrap:fullscreen,
.presentation-wrap:-webkit-full-screen {
  width: 100vw;
  height: 100vh;
  background: #fff;
}
.presentation-wrap:fullscreen .pres-body,
.presentation-wrap:-webkit-full-screen .pres-body {
  flex: 1;
  min-height: 0;
}
.presentation-wrap:fullscreen .pres-image-pane,
.presentation-wrap:-webkit-full-screen .pres-image-pane {
  height: 100%;
}
.presentation-wrap:fullscreen .pres-content-pane,
.presentation-wrap:-webkit-full-screen .pres-content-pane {
  overflow-y: auto;
}
.presentation-wrap:fullscreen .pres-viewport,
.presentation-wrap:-webkit-full-screen .pres-viewport {
  min-height: 100%;
  display: flex;
  align-items: center;
}
.presentation-wrap:fullscreen .pres-slide,
.presentation-wrap:-webkit-full-screen .pres-slide {
  width: 100%;
}

.pres-slide-hidden {
  display: none;
}

.pres-slide-active {
  display: block;
}

.pres-anim {
  animation: presFadeUp 0.5s ease both;
}
@keyframes presFadeUp {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: translateY(0); }
}

.pres-slide-active.pres-dir-next {
  animation: presSlideInNext 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
.pres-slide-active.pres-dir-prev {
  animation: presSlideInPrev 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}
@keyframes presSlideInNext {
  from { opacity: 0; transform: translateX(24px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}
@keyframes presSlideInPrev {
  from { opacity: 0; transform: translateX(-24px) scale(0.98); }
  to { opacity: 1; transform: translateX(0) scale(1); }
}

/* بطاقة صورة سياقية داخل شريحة القسم (أسلوب إنفوجرافيك) */
.pres-inline-image {
  overflow: hidden;
  box-shadow: 0 10px 24px rgba(15, 138, 103, 0.12);
}
.pres-inline-image img {
  transition: transform 0.6s ease;
}
.pres-inline-image:hover img {
  transform: scale(1.06);
}

/* شريحة الإنفوجرافيك — بطاقات إحصائيات متحركة */
.pres-stat-card {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
}
.pres-stat-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.08);
}
.pres-stat-number {
  font-variant-numeric: tabular-nums;
}

/* نقاط شرائح مع نبض للنشِطة */
.slide-dot-active-pulse {
  box-shadow: 0 0 0 0 rgba(15, 138, 103, 0.5);
  animation: dotPulse 1.6s ease-out infinite;
}
@keyframes dotPulse {
  0% { box-shadow: 0 0 0 0 rgba(15, 138, 103, 0.45); }
  70% { box-shadow: 0 0 0 6px rgba(15, 138, 103, 0); }
  100% { box-shadow: 0 0 0 0 rgba(15, 138, 103, 0); }
}

/* ============================================================
   محرك السحب والإفلات العام — ألعاب ومحاكاة
   ============================================================ */
.dnd-chip, .dnd-item {
  transition: opacity 0.2s, transform 0.15s;
}
.dnd-chip:active {
  cursor: grabbing;
}
.dnd-disabled {
  cursor: default !important;
  pointer-events: none;
}
.dnd-dragging-source {
  opacity: 0.35;
}
.dnd-ghost {
  transform: scale(1.04) rotate(-1deg);
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.18);
  opacity: 0.95;
}
.dnd-zone {
  transition: background-color 0.2s, border-color 0.2s, transform 0.15s;
}
.dnd-zone-hover {
  border-color: #0f8a67 !important;
  background-color: #eefcf6 !important;
  transform: scale(1.01);
}
.dnd-zone-correct {
  animation: zonePulseGreen 0.5s ease;
}
.dnd-zone-wrong {
  animation: shake 0.4s;
}
@keyframes zonePulseGreen {
  0% { box-shadow: 0 0 0 0 rgba(16, 185, 129, 0.5); }
  100% { box-shadow: 0 0 0 12px rgba(16, 185, 129, 0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-6px); }
  75% { transform: translateX(6px); }
}

.layer-bar {
  animation: layerDrop 0.35s ease;
}
@keyframes layerDrop {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* أقراص لعبة تشفير السيمافور */
.dial-base {
  touch-action: none;
}
.dial-handle {
  width: 50%;
  height: 6px;
  cursor: grab;
}
.dial-flag {
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #dc2626 0%, #dc2626 50%, #f59e0b 50%, #f59e0b 100%);
  border-radius: 3px;
}
.dial-center {
  z-index: 2;
}

/* ============================================================
   محاكاة "أنظمة البكرات" — سحب مقبض حقيقي لرفع حمل
   ============================================================ */
.pulley-handle {
  transition: box-shadow 0.15s;
  touch-action: none;
}
.pulley-handle:active {
  cursor: grabbing;
  box-shadow: 0 0 0 4px rgba(245, 158, 11, 0.35);
}
.load-box {
  transition: bottom 0.35s ease;
}

/* ============================================================
   محاكاة "الدارة الإلكترونية" — LED حقيقي متغيّر الشدة
   ============================================================ */
.circuit-led {
  transition: box-shadow 0.15s ease, opacity 0.15s ease;
}

/* ============================================================
   محاكاة "البرمجة المرئية بالكتل" — كتاب البرمجة
   ============================================================ */
.bp-node, .bp-node-container {
  transition: box-shadow 0.2s, transform 0.15s;
}
.bp-node-active {
  box-shadow: 0 0 0 3px rgba(15, 138, 103, 0.55);
  transform: scale(1.02);
}
.bp-cell {
  transition: background-color 0.2s;
}
.bp-char {
  transition: left 0.38s ease, top 0.38s ease, transform 0.3s ease;
  background: linear-gradient(135deg, #0f8a67, #059669);
  z-index: 5;
}
.bp-inner-zone {
  min-height: 40px;
}

/* ألعاب/محاكاة قديمة (احتياط) */
.match-chip.selected-chip {
  border-color: #6366f1 !important;
  background-color: #eef2ff !important;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}
.match-chip.matched-chip {
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
  color: #065f46 !important;
  opacity: 0.75;
  cursor: default;
}
.match-chip.wrong-chip {
  border-color: #f43f5e !important;
  background-color: #fff1f2 !important;
  animation: shake 0.4s;
}

.quiz-opt.correct-opt {
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
  color: #065f46 !important;
}
.quiz-opt.wrong-opt {
  border-color: #f43f5e !important;
  background-color: #fff1f2 !important;
  color: #9f1239 !important;
}

.activity-card.activity-done {
  border-color: #10b981 !important;
  background-color: #ecfdf5 !important;
}

.activity-checkbox {
  width: 22px;
  height: 22px;
  accent-color: #0f8a67;
  cursor: pointer;
}

/* ============================================================
   تحسينات الألعاب التعليمية — نقاط/تلميحات/شارات إنجاز
   ============================================================ */
.game-score-badge {
  transition: transform 0.2s ease;
}
.game-score-pop {
  animation: scorePop 0.4s ease;
}
@keyframes scorePop {
  0% { transform: scale(1); }
  40% { transform: scale(1.25); }
  100% { transform: scale(1); }
}
.game-hint-box {
  animation: presFadeUp 0.35s ease both;
}
.game-streak-flame {
  animation: flamePulse 1s ease-in-out infinite;
}
@keyframes flamePulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.15); }
}
.game-goal-banner {
  background: linear-gradient(90deg, #f5f3ff, #ede9fe);
}
.game-star {
  transition: transform 0.25s ease, color 0.25s ease;
}
.game-star-earned {
  color: #f59e0b !important;
  transform: scale(1.15);
}
@keyframes confettiFall {
  0% { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  100% { transform: translateY(140px) rotate(360deg); opacity: 0; }
}
.confetti-piece {
  position: absolute;
  top: 0;
  width: 8px;
  height: 8px;
  animation: confettiFall 1.1s ease-in forwards;
}

/* زر إظهار/إخفاء الإجابة في قسم الاختبارات */
.test-answer-toggle {
  transition: background-color 0.15s, color 0.15s;
}

/* طباعة ورقة العمل فقط */
@media print {
  body * {
    visibility: hidden;
  }
  #worksheet-print-area, #worksheet-print-area * {
    visibility: visible;
  }
  #worksheet-print-area {
    position: absolute;
    inset: 0;
    padding: 20px;
  }
}
