 html {
  scroll-behavior: smooth;
}
 
 /* First Section */
  /* ===== VARIABLES & RESET ===== */
    :root {
      --bg1: #020617;
      --bg2: #0f172a;
      --accent: #3b82f6;
      --purple: #8b5cf6;
      --text: #e2e8f0;
      --muted: #94a3b8;
    }

    * {
      margin: 0;
      padding: 0;
      box-sizing: border-box;
    }

    body {
      font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
      overflow-x: hidden;
      background: linear-gradient(270deg, var(--bg1), var(--bg2), var(--bg1));
      background-size: 400% 400%;
      animation: gradientShift 12s ease infinite;
      color: var(--text);
    }

    @keyframes gradientShift {
      0% { background-position: 0% }
      50% { background-position: 100% }
      100% { background-position: 0% }
    }

    /* ===== PARTICLES BACKGROUND ===== */
    #particles {
      position: fixed;
      top: 0;
      left: 0;
      width: 100vw;
      height: 100vh;
      z-index: -1;
      pointer-events: none;
    }

    /* ===== HERO SECTION ===== */
    .hero {
      width: 100vw;
      height: 100vh; /* أخذ الشاشة بالكامل لتوسيط المحتوى */
      display: flex;
      justify-content: center;
      align-items: center;
      text-align: center;
      position: relative;
      z-index: 1;
      padding: 1rem;
    }

    .content {
      max-width: 800px;
      display: flex;
      flex-direction: column;
      align-items: center;
      gap: 16px; /* مسافة متناسقة بين العناصر */
    }

    /* ===== TYPOGRAPHY ===== */
    .content h1 {
      font-size: clamp(3rem, 6vw, 5rem);
      font-weight: 700;
      line-height: 1.1;
      letter-spacing: -1px;
      opacity: 0;
      transform: translateY(40px);
    }

    .content h2 {
      font-size: clamp(1.2rem, 2.5vw, 1.8rem);
      color: var(--muted);
      margin-top: 0;
      opacity: 0;
      transform: translateY(40px);
    }

    /* ===== CTA BUTTON ===== */
    .cta {
      margin-top: 25px; 
      padding: 16px 36px;
      font-size: 16px;  
      font-family: inherit;
      border-radius: 30px;
      border: none;
      cursor: pointer;
      background: linear-gradient(90deg, var(--accent), var(--purple));
      color: white;
      font-weight: 600;
      box-shadow: 0 0 25px rgba(59, 130, 246, 0.4);
      opacity: 0;
      transform: translateY(40px);
      transition: transform 0.3s ease, box-shadow 0.3s ease;
    }

    .cta:hover {
      transform: translateY(-3px) !important; 
      box-shadow: 0 0 35px rgba(59, 130, 246, 0.7);
    }

    /* ===== ANIMATIONS ===== */
    .animate {
      animation: fadeSlideUp 0.9s ease forwards;
    }

    .delay-1 {
      animation-delay: 0.4s;
    }

    .delay-2 {
      animation-delay: 0.8s;
    }

    @keyframes fadeSlideUp {
      to {
        opacity: 1;
        transform: translateY(0);
      }
    }






/* Problem Section */
/* ===== SECOND SECTION ===== */

.video-section {
  max-width: 1100px;
  margin: auto;
  padding: 40px 20px;
}

/* ================= TEXT ================= */
.problem-text {
  max-width: 750px;
  margin-bottom: 25px; /* كبرنا المسافة شوية */
}

.problem-text h2 {
  font-size: 28px;
  margin-bottom: 20px; /* نفس مسافة السوليوشن */
  color: #f8fafc;
}

.problem-text ul {
  list-style: none;
}

.problem-text li {
  font-size: 18px; /* نفس حجم السوليوشن */
  line-height: 1.7; /* نفس تباعد السطور المريح */
  margin-bottom: 15px; /* مسافة أوسع بين النقط */
  padding-left: 22px;
  position: relative;
  color: #cbd5e1; /* نفس لون الخط الهادي بتاع السوليوشن */
}

.problem-text li::before {
  content: "•";
  position: absolute;
  left: 0;
  color: #3b82f6; /* خليت لون النقطة أزرق يتماشى مع الثيم بدل الأخضر */
  font-size: 20px;
}

/* ================= HIGHLIGHT ================= */

.highlight {
  display: flex;
  align-items: center;
  gap: 12px;
  max-width: 900px;
  margin-top: 20px;
  padding: 16px 18px;
  background: rgba(239, 68, 68, 0.08);
  border-left: 5px solid #ef4444;
  border-radius: 10px;
}

.highlight .icon {
  font-size: 22px;
  color: #facc15;
}

.highlight p {
  font-size: 18px; /* نفس الحجم */
  line-height: 1.7; /* نفس التباعد */
  color: #cbd5e1; /* نفس لون السوليوشن */
  margin: 0; /* منعنا أي مسافات عشوائية */
  font-weight: 500;
}


/* ================= PRE-SCHEDULER SIMULATION ================= */
.pre-scheduler-section {
  max-width: 1000px;
  margin: 60px auto;
  padding: 20px;
}

.sim-wrapper {
  position: relative;
  width: 100%;
  height: 450px;
  background: #020617; /* نفس خلفية الموقع */
  border: 1px solid #1e293b;
  border-radius: 20px;
  margin-bottom: 25px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

/* --- Nodes --- */
.sim-node {
  position: absolute;
  background: #0f172a;
  border: 1px solid #38bdf8;
  border-radius: 12px;
  display: flex;
  justify-content: center;
  align-items: center;
  color: #e2e8f0;
  font-weight: 600;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.15);
  z-index: 10;
}

.sim-node.glow-purple {
  border-color: #8b5cf6;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.3);
}

.node-label-bottom {
  position: absolute;
  bottom: -28px;
  left: 50%; 
  transform: translateX(-50%);
  font-size: 13px;
  color: #94a3b8;
  white-space: nowrap;
}

#sim-jq { left: 40px; top: 80px; width: 220px; height: 65px; justify-content: flex-start; padding-left: 10px;}
#sim-cpu { left: 380px; top: 80px; width: 140px; height: 65px; font-size: 20px;}
#sim-wait { left: 320px; top: 300px; width: 200px; height: 65px; }
#sim-io { left: 620px; top: 300px; width: 140px; height: 65px; font-size: 18px;}
.sim-exit { position: absolute; left: 850px; top: 102px; color: #ef4444; font-weight: 700; font-size: 18px;}

/* --- Arrows --- */
.sim-arrow {
  position: absolute;
  background: #38bdf8;
  z-index: 5;
}
/* Arrow Heads */
.sim-arrow::after {
  content: ''; position: absolute;
  border: 6px solid transparent;
}
.sim-arrow.right::after { border-left-color: #38bdf8; right: -12px; top: -5px; }
.sim-arrow.down::after { border-top-color: #38bdf8; bottom: -12px; left: -5px; }
.sim-arrow.left::after { border-right-color: #38bdf8; left: -12px; top: -5px; }
.sim-arrow.up::after { border-bottom-color: #38bdf8; top: -12px; left: -5px; }

/* Lines Positioning */
#arr-jq-cpu { left: 260px; top: 111px; width: 110px; height: 2px; }
#arr-cpu-wait { left: 450px; top: 145px; width: 2px; height: 145px; }
#arr-wait-io { left: 520px; top: 331px; width: 90px; height: 2px; }
#arr-io-up { left: 690px; top: 160px; width: 2px; height: 140px; } /* no arrow head visually needed here, just routing */
#arr-io-up::after { display: none; } 
#arr-io-cpu { left: 530px; top: 160px; width: 162px; height: 2px; }
#arr-cpu-exit { left: 520px; top: 111px; width: 315px; height: 2px; }

/* for Solution */
/* ================= POST-SCHEDULER (SOLUTION) SPECIFIC COORDINATES ================= */

/* نقل اسم الـ Ready Queue لفوق الكونتينر */
#post-jq .node-label-bottom {
  bottom: auto; /* بنلغي المسافة اللي من تحت */
  top: -28px;   /* بنرفعه لفوق بنفس المقدار */
}

#post-jq { left: 40px; top: 80px; width: 220px; height: 65px; justify-content: flex-start; padding-left: 10px;}
#post-cpu { left: 380px; top: 80px; width: 140px; height: 65px; font-size: 20px;}
#post-wait { left: 350px; top: 300px; width: 200px; height: 65px; }
#post-io { left: 80px; top: 300px; width: 140px; height: 65px; font-size: 18px;}
#post-exit-label { position: absolute; left: 650px; top: 102px; color: #ef4444; font-weight: 700; font-size: 18px;}

/* Post-Scheduler Arrows Positioning */
#arr-post-jq-cpu { left: 260px; top: 111px; width: 110px; height: 2px; }
#arr-post-cpu-wait { left: 450px; top: 145px; width: 2px; height: 145px; }
#arr-post-wait-io { left: 230px; top: 331px; width: 110px; height: 2px; }
#arr-post-io-jq { left: 150px; top: 155px; width: 2px; height: 135px; }
#arr-post-cpu-exit { left: 530px; top: 111px; width: 110px; height: 2px; }
/*End here sol */


/* --- Tokens --- */
.sim-token {
  position: absolute;
  width: 36px; height: 36px;
  border-radius: 50%;
  color: white; font-weight: bold; font-size: 14px;
  display: flex; justify-content: center; align-items: center;
  z-index: 20;
  box-shadow: 0 4px 10px rgba(0,0,0,0.5);
  transition: all 0.8s ease; /* سرعة الحركة */
}
.sim-token.p1 { background: #3b82f6; }
.sim-token.p2 { background: #22c55e; }
.sim-token.p3 { background: #f97316; }
.sim-token.p4 { background: #eab308; }

/* --- Controls --- */
.sim-controls {
  display: flex;
  align-items: center;
  gap: 15px;
  background: #0f172a;
  padding: 15px 25px;
  border-radius: 15px;
  border: 1px solid #1e293b;
}

.sim-controls .play-btn { margin: 0; width: 50px; height: 50px; }
.sim-controls .reset-btn { background: #334155; }
.sim-controls .reset-btn:hover { background: #475569; }

.sim-explainer {
  flex: 1;
  color: #cbd5e1;
  font-size: 16px;
  font-weight: 500;
  padding-left: 15px;
  border-left: 3px solid #38bdf8;
}

@media (max-width: 900px) {
  .sim-wrapper { transform: scale(0.6); transform-origin: top left; height: 270px; margin-bottom: 0; }
  .sim-controls { flex-direction: column; text-align: center; }
  .sim-explainer { border-left: none; border-top: 3px solid #38bdf8; padding-top: 10px; }
}

/* BUTTON */
.play-btn {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 110px; /* نفس الأبعاد الثابتة */
  height: 48px;
  margin: 30px auto 0;
  background: #3b82f6;
  border: none;
  border-radius: 30px; /* خليناها بيضاوية أكتر عشان تناسب الشكل الجديد */
  color: white;
  cursor: pointer;
  transition: background-color 0.3s, transform 0.2s, box-shadow 0.3s ease;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
}

.play-btn:hover {
  background: #2563eb;
  transform: scale(1.05);
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}

/* ستايل الأيقونة الجديدة */
.play-btn .icon {
  display: flex;
  justify-content: center;
  align-items: center;
  /* حجم الأيقونة تم تحديده في الجافا سكريبت مباشرةً */
  color: white; /*fill="currentColor" بيخلي الـ SVG ياخد اللون ده */
  line-height: 1; /* عشان ميبقاش في أي مسافات عشوائية */
}

.play-btn .icon {
  font-size: 16px;
}

/* RESPONSIVE */
@media (max-width: 768px) {
  .highlight {
    flex-direction: column;
  }
}





/* ================= SOLUTION SECTION ================= */

.solution-section {
  padding: 80px 20px;
}

.container {
  max-width: 1000px;
  margin: auto;
}

/* TITLE (same style as problem) */
.section-title {
  font-size: 28px;
  margin-bottom: 20px;
  color: #f8fafc;
}

/* TEXT */
.solution-section p {
  font-size: 18px;
  line-height: 1.7;
  color: #cbd5e1;
  margin-bottom: 20px;
}

/* INTERACTIVE WORDS */
.interactive {
  color: #38bdf8;
  cursor: pointer;
  font-weight: 500;
  transition: 0.2s;
}

.interactive:hover {
  color: #0ea5e9;
}

/* ACCORDION BOX */
.info-box {
  max-width: 900px;
  margin: 15px 0 0;

  background: #0f172a;
  border-left: 4px solid #38bdf8;
  border-radius: 10px;

  padding: 0 24px;
  overflow: hidden;

  max-height: 0;
  opacity: 0;

  transition: all 0.35s ease;
}

/* ACTIVE STATE */
.info-box.active {
  padding: 18px 24px;
  max-height: 150px; /* خليها قريبة من المحتوى */
  opacity: 1;
}

/* TEXT */
.info-box p {
  font-size: 16.5px;
  line-height: 1.7;
  color: #e2e8f0;

  margin: 0; /* مهم جدًا */
}
/* REVEAL ANIMATION */
.reveal {
  opacity: 0;
  transform: translateY(10px);
  transition: 0.6s ease;
}

.reveal.active {
  opacity: 1;
  transform: translateY(0);
}


/* Section Scheduling Algorithms */

    /* ===== DIAGRAM SECTION ===== */
.diagram-section {
  padding: 80px 20px;
  max-width: 1200px;
  margin: auto;
}

.section-title {
  font-size: 32px;
  margin-bottom: 40px;
  color: #f8fafc;
  text-align: left;
}

/* ===== TREE DIAGRAM CSS MAGIC ===== */
.tree-diagram {
  display: flex;
  justify-content: center;
  width: 100%;
  padding-bottom: 20px;
}

.tree-diagram ul {
  padding-top: 30px; 
  position: relative;
  transition: all 0.5s;
  display: flex;
  justify-content: center;
  padding-left: 0;
}

.tree-diagram li {
  float: left; text-align: center;
  list-style-type: none;
  position: relative;
  padding: 30px 10px 0 10px;
  transition: all 0.5s;
}

/* خطوط التوصيل (الخطوط الأفقية) */
.tree-diagram li::before, .tree-diagram li::after {
  content: '';
  position: absolute; top: 0; right: 50%;
  border-top: 2px solid #3b82f6; /* لون الخطوط */
  width: 50%; height: 30px;
}

.tree-diagram li::after {
  right: auto; left: 50%;
  border-left: 2px solid #3b82f6; /* لون الخطوط */
}

/* تظبيط الخطوط للأول والأخير */
.tree-diagram li:only-child::after, .tree-diagram li:only-child::before {
  display: none;
}
.tree-diagram li:only-child { padding-top: 0; }
.tree-diagram li:first-child::before, .tree-diagram li:last-child::after {
  border: 0 none;
}
.tree-diagram li:last-child::before {
  border-right: 2px solid #3b82f6;
  border-radius: 0 5px 0 0;
}
.tree-diagram li:first-child::after {
  border-radius: 5px 0 0 0;
}

/* خط التوصيل النازل من الأب (الخطوط العمودية) */
.tree-diagram ul ul::before {
  content: '';
  position: absolute; top: 0; left: 50%;
  border-left: 2px solid #3b82f6;
  width: 0; height: 30px;
  transform: translateX(-50%);
}

/* NODE STYLES */
.tree-diagram .node {
  padding: 14px 26px;
  border-radius: 12px;
  background: #0f172a; 
  border: 1px solid #38bdf8;
  color: #e2e8f0;
  font-weight: 500;
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.2);
  transition: 0.3s ease;
  position: relative;
  z-index: 2;

  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  box-sizing: border-box;
}

/* تحديد مقاس ثابت للعناصر اللي في النص فقط */
.tree-diagram .node:not(.main):not(.small) {
  width: 220px; 
  height: 60px; 
}

.tree-diagram .node:hover {
  transform: translateY(-5px);
  box-shadow: 0 8px 25px rgba(56, 189, 248, 0.4);
  background: #1e293b;
}

.tree-diagram .node.main {
  font-size: 20px;
  font-weight: 700;
  border-color: #8b5cf6;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.tree-diagram .node.small {
  font-size: 13px;
  width: 150px;  /* عرض ثابت للكل */
  height: 85px;  /* ارتفاع ثابت يريّح الـ 3 سطور */
  padding: 10px;
  white-space: normal;
}

/* ===== CARDS & VIDEO ===== */
.cards {
  margin-top: 80px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

.card {
  display: flex;
  gap: 40px;
  background: rgba(15, 23, 42, 0.6); /* شفافية بسيطة لتندمج مع الخلفية */
  border: 1px solid #1e293b;
  border-radius: 20px;
  padding: 40px;
  align-items: center;
  backdrop-filter: blur(10px);
}

.card-text {
  flex: 1;
}

.card-text h3 {
  color: #f8fafc;
  margin-bottom: 15px;
  font-size: 24px;
}

.card-text p {
  line-height: 1.7;
  color: #cbd5e1;
  font-size: 17px;
}

.card-video {
  flex: 1;
  display: flex;
  justify-content: center;
  width: 100%;
}



.play-btn-circle {
  width: 65px;
  height: 65px;
  border-radius: 50%;
  background: #3b82f6;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 15px rgba(59,130,246,0.5);
  transition: 0.3s;
}

.play-overlay:hover .play-btn-circle {
  transform: scale(1.1);
  background: #2563eb;
}

#miniPlayIcon, #prePlayIcon {
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
}

@media (max-width: 900px) {
  .card { flex-direction: column; text-align: center; padding: 25px; }
  .section-title { text-align: center; }
  .tree-diagram ul { transform: scale(0.6); transform-origin: top center; }
}


/* Non-Preemptive Demo */

/* ================= MINI-SIM (NON-PREEMPTIVE CARD) ================= */
.mini-sim-container {
  position: relative;
  width: 100%;
  max-width: 450px;
  height: 240px; /* ارتفاع صغير يناسب الكارت */
  border-radius: 15px;
  overflow: hidden;
  background: #020617;
  border: 1px solid #334155;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
}

/* سحر الـ CSS لتصغير المحاكاة وتسنترها بالمللي في النص */
.mini-sim-scale-wrapper {
  position: absolute; /* ده اللي هيمنع المساحة الأصلية إنها تبوظ العرض */
  width: 900px; 
  height: 400px;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.45); 
}

/* إحداثيات العناصر (زي الـ Solution بالظبط بس بـ IDs جديدة) */
#mini-jq { left: 40px; top: 80px; width: 220px; height: 65px; justify-content: flex-start; padding-left: 10px;}
#mini-jq .node-label-bottom { bottom: auto; top: -28px; font-size: 18px; }
#mini-cpu { left: 380px; top: 80px; width: 140px; height: 65px; font-size: 26px;}
#mini-wait { left: 350px; top: 300px; width: 200px; height: 65px; font-size: 22px;}
#mini-io { left: 80px; top: 300px; width: 140px; height: 65px; font-size: 24px;}
#mini-exit-label { position: absolute; left: 650px; top: 102px; color: #ef4444; font-weight: 700; font-size: 24px;}

#arr-mini-jq-cpu { left: 260px; top: 111px; width: 110px; height: 2px; }
#arr-mini-cpu-wait { left: 450px; top: 145px; width: 2px; height: 145px; }
#arr-mini-wait-io { left: 230px; top: 331px; width: 110px; height: 2px; }
#arr-mini-cpu-exit { left: 530px; top: 111px; width: 110px; height: 2px; }
#arr-mini-io-jq { left: 150px; top: 155px; width: 2px; height: 135px; }

/* Overlay بتاع الزرار */
.mini-play-overlay {
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  transition: 0.3s ease;
  cursor: pointer;
  z-index: 50;
}
.mini-play-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* تصليح زرار الميني سيم */
#miniPlayIcon::after {
  display: none; /* بيلغي المثلث القديم اللي كان مرسوم بالـ CSS */
}
#miniPlayIcon {
  color: white; /* علشان الأيقونات الجديدة تظهر باللون الأبيض */
}


/* Preemptive Demo */

/* ================= PREEMPTIVE MINI-SIM (PRIORITY SCHEDULING) ================= */
#pre-jq { left: 40px; top: 80px; width: 220px; height: 65px; justify-content: flex-start; padding-left: 10px;}
#pre-jq .node-label-bottom { bottom: auto; top: -28px; font-size: 18px; }
#pre-cpu { left: 380px; top: 80px; width: 140px; height: 65px; font-size: 26px;}
#pre-wait { left: 350px; top: 300px; width: 200px; height: 65px; font-size: 22px;}
#pre-io { left: 80px; top: 300px; width: 140px; height: 65px; font-size: 24px;}
#pre-exit-label { position: absolute; left: 650px; top: 102px; color: #ef4444; font-weight: 700; font-size: 24px;}

/* الأسهم */
#arr-pre-jq-cpu { left: 260px; top: 111px; width: 110px; height: 2px; }
#arr-pre-cpu-wait { left: 450px; top: 145px; width: 2px; height: 145px; }
#arr-pre-wait-io { left: 230px; top: 331px; width: 110px; height: 2px; }
#arr-pre-cpu-exit { left: 530px; top: 111px; width: 110px; height: 2px; }
#arr-pre-io-jq { left: 150px; top: 155px; width: 2px; height: 135px; }

/* تاج الأولوية فوق كل Process */
.sim-token[data-priority]::before {
  content: "Pri: " attr(data-priority);
  position: absolute;
  top: -26px; /* رفعناه فوق راسها */
  left: 50%;
  transform: translateX(-50%);
  font-size: 11px;
  font-weight: 800;
  color: #f8fafc;
  background: rgba(15, 23, 42, 0.85);
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid #38bdf8;
  white-space: nowrap;
  box-shadow: 0 2px 5px rgba(0,0,0,0.5);
}


/* ================= TRANSITION TO FCFS ================= */
.transition-container {
  text-align: center;
  margin-top: 80px; /* مسافة كويسة بين الكروت والجملة */
  padding-bottom: 30px;
}

.transition-text {
  font-size: 22px;
  color: #cbd5e1;
  font-weight: 500;
  margin-bottom: 20px;
}

.highlight-fcfs {
  color: #38bdf8;
  font-weight: 700;
  font-size: 26px;
}


/* ================= FCFS DETAILS SECTION & QUEUE DIAGRAM ================= */

/* مسحنا الإيد وخلينا الكلمة شكلها لينك */
.interactive-trigger {
  cursor: pointer;
  display: inline-block;
  transition: transform 0.2s ease, text-shadow 0.3s ease;
}
.interactive-trigger:hover {
  transform: scale(1.1);
  text-shadow: 0 0 15px rgba(56, 189, 248, 0.8);
}

/* السكشن الجديد المخفي */
.fcfs-details-section {
  display: none; 
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease;
  padding: 40px 20px;
  max-width: 1000px;
  margin: auto;
}
.fcfs-details-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* تظبيط الشرح ليتطابق مع ستايل الموقع */
.fcfs-list {
  list-style: none;
  margin-bottom: 50px;
  max-width: 750px; /* نفس عرض الـ problem-text */
}
.fcfs-list li {
  font-size: 18px; /* نفس حجم الخط اللي فوق */
  line-height: 1.7;
  color: #cbd5e1;
  margin-bottom: 15px;
  padding-left: 22px;
  position: relative;
}
.fcfs-list li::before {
  content: "•";
  color: #3b82f6;
  position: absolute;
  left: 0;
  font-size: 20px;
}
.text-blue {
  color: #3b82f6;
  font-weight: 700;
}

/* حل مشكلة اختفاء الزرار */
.problem-btn {
  opacity: 1 !important; 
  transform: translateY(0) !important; 
  animation: none !important; 
}


/* ================= QUEUE ANIMATED DEMO ================= */
.q-sim-wrapper {
  max-width: 750px;
  margin: 40px auto;
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.4);
  background: #020617;
  border: 1px solid #1e293b;
}

.q-sim-container {
  position: relative;
  height: 240px;
  width: 100%;
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  background: #0f172a;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

.q-sim-scale {
  position: relative;
  width: 600px;
  height: 220px;
}

/* إطار الطابور اللي في النص */
.q-sim-box {
  width: 320px;
  height: 70px;
  border: 2px solid #38bdf8;
  border-left: none; /* مفتوح من ورا */
  border-right: none; /* مفتوح من قدام */
  position: absolute;
  top: 75px;
  left: 140px; 
}

.q-label {
  position: absolute;
  color: #94a3b8;
  font-weight: 800;
  font-size: 16px;
  top: 45px;
  letter-spacing: 1px;
}
.back-label { left: 100px; }
.front-label { right: 100px; }

/* النص اللي بيظهر فوق الطابور (Enqueue/Dequeue) */
.q-sim-explainer {
  position: absolute;
  top: 170px;
  width: 100%;
  text-align: center;
  font-size: 22px;
  font-weight: 800;
  color: #f8fafc;
  transition: color 0.3s ease;
  letter-spacing: 1px;
}

/* الدوائر السادة وتكبير حجمها شوية */
.q-blank-tok {
  width: 44px !important;
  height: 44px !important;
  border-radius: 50%;
  transition: all 0.7s ease !important;
}



/* ================= SCENARIO 1 SECTION ================= */

.scenario-section {
  display: none;
  opacity: 0;
  transform: translateY(20px);
  transition: all 0.6s ease;
  padding: 60px 20px;
}
.scenario-section.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Data Grid (بدون الـ wrapper علشان يـ Fill المكان) */
.process-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr 1fr;
  gap: 15px;
  align-items: center;
  width: 100%;
}

.pg-cell {
  text-align: center;
}
.pg-header {
  font-weight: bold;
  font-size: 18px;
  color: #f8fafc;
  margin-bottom: 10px;
}
.pg-label {
  text-align: left;
  font-weight: 600;
  color: #cbd5e1;
  font-size: 16px;
}

/* ألوان أسماء الـ Processes */
.token-p1 { color: #3b82f6; font-weight: 800; }
.token-p2 { color: #22c55e; font-weight: 800; }
.token-p3 { color: #f97316; font-weight: 800; }
.token-p4 { color: #eab308; font-weight: 800; }

/* تظبيط شكل الـ Inputs علشان تليق مع الخلفية المفتوحة */
.pg-input {
  width: 100%;
  padding: 12px;
  background: #0f172a; 
  border: 1px solid #1e293b;
  border-radius: 8px;
  color: #f8fafc;
  text-align: center;
  font-size: 16px;
  font-weight: bold;
  outline: none;
  transition: all 0.3s ease;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
.pg-input:focus {
  border-color: #38bdf8;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2), inset 0 2px 4px rgba(0,0,0,0.2);
}
.pg-input.readonly {
  background: rgba(15, 23, 42, 0.4);
  color: #64748b;
  cursor: not-allowed;
  border-color: transparent;
  box-shadow: none;
}

/* إخفاء أسهم الزيادة والنقصان من حقول الأرقام */
.pg-input[type="number"]::-webkit-inner-spin-button,
.pg-input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.pg-input[type="number"] {
  -moz-appearance: textfield; /* علشان فايرفوكس */
  appearance: textfield;
}

/* Run Button */
.run-btn {
  background: #3b82f6; /* الأزرق بتاع الـ Play */
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  padding: 16px 40px;
  font-size: 18px;
  
  /* السطور دي اللي هتظهر الزرار وتلغي الإخفاء بتاع الهيرو سكشن */
  opacity: 1 !important; 
  transform: translateY(0) !important; 
  animation: none !important; 
}
.run-btn:hover {
  background: #2563eb; /* درجة أغمق سيكا في الهوفر */
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
  transform: scale(1.05) !important; 
}

/* Gantt Chart */
.gantt-section {
  margin-top: 50px;
  background: #0f172a;
  border-radius: 20px;
  padding: 40px;
  border: 1px solid #1e293b;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.gantt-title {
  color: #f8fafc;
  text-align: left; /* العنوان على الشمال */
  margin-bottom: 25px;
  font-size: 24px;
}
.gantt-container {
  display: flex;
  height: 60px;
  border-radius: 8px;
  border: 2px solid #334155;
  position: relative;
}
.gantt-block {
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  font-weight: bold;
  color: white;
  border-right: 2px solid #334155;
  position: relative;
  transition: width 0.5s ease;
  flex-grow: 1; /* السطر ده هيجبر البلوكات تملا أي فراغ ناتج عن حسابات المتصفح */
}
.gantt-block:last-child {
  border-right: none; /* شيلنا الخط اللي في الآخر */
}
.gantt-time {
  position: absolute;
  bottom: -30px;
  right: -10px; 
  color: #94a3b8;
  font-size: 14px;
  font-weight: 600;
}
.gantt-time.start-time {
  left: -5px;
  right: auto;
}

/* ستايل الـ Idle في الـ Gantt Chart */
.gantt-block.idle {
  background: repeating-linear-gradient(45deg, #334155, #334155 10px, #1e293b 10px, #1e293b 20px);
  color: #94a3b8;
  font-style: italic;
  font-weight: 500;
}

/* تدوير حواف أول وآخر بلوك علشان ميخرجوش بره الجانت شارت */
.gantt-block:first-child {
  border-top-left-radius: 6px;
  border-bottom-left-radius: 6px;
}

.gantt-block:last-child {
  border-top-right-radius: 6px;
  border-bottom-right-radius: 6px;
}

/* ================= METRICS & CALCULATIONS ================= */
.metrics-definitions {
  display: flex;
  gap: 20px;
  margin-top: 40px;
}
.metric-card {
  flex: 1;
  background: #1e293b;
  padding: 25px;
  border-radius: 15px;
  border-left: 4px solid #3b82f6;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.metric-card h4 {
  color: #f8fafc;
  font-size: 20px;
  margin-bottom: 10px;
}
.metric-card p {
  color: #cbd5e1;
  font-size: 15px;
  margin-bottom: 15px;
}
.metric-card .formula {
  background: #0f172a;
  padding: 12px;
  border-radius: 8px;
  font-family: monospace;
  color: #38bdf8;
  font-weight: bold;
  text-align: center;
  border: 1px dashed #334155;
}

/* Calculations Table */
.calculations-table-wrapper {
  background: #0f172a;
  border-radius: 20px;
  padding: 30px;
  border: 1px solid #1e293b;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
}
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1.5fr 2fr 2fr;
  gap: 10px;
  align-items: center;
}
.cg-header {
  font-weight: bold;
  font-size: 16px;
  color: #94a3b8;
  padding-bottom: 15px;
  border-bottom: 2px solid #1e293b;
  text-align: center;
}
.cg-cell {
  text-align: center;
  padding: 15px 0;
  color: #f8fafc;
  font-size: 18px;
  font-weight: 500;
  border-bottom: 1px solid #1e293b;
}
.calc-grid .cg-cell:nth-last-child(-n+4) {
  border-bottom: none; /* إزالة الخط من آخر صف */
}

/* Summary Cards */
.summary-cards {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}
.summary-card {
  background: #0f172a;
  padding: 25px;
  border-radius: 15px;
  border: 1px solid #1e293b;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}
.summary-card h4 {
  color: #f8fafc;
  font-size: 18px;
  margin-bottom: 10px;
}
.summary-card p {
  color: #94a3b8;
  font-size: 14px;
  margin-bottom: 15px;
  line-height: 1.6;
}
.summary-card .highlight-text {
  color: #10b981; /* الأخضر علشان تبرز */
  font-weight: 600;
}
.summary-card .formula {
  background: #1e293b;
  padding: 15px;
  border-radius: 8px;
  color: #e2e8f0;
  font-weight: bold;
  font-size: 16px;
  text-align: center;
  line-height: 1.8;
}
.summary-card .formula span {
  color: #38bdf8; /* لون النتيجة النهائية */
}

/* Responsive */
@media (max-width: 768px) {
  .metrics-definitions, .summary-cards {
    grid-template-columns: 1fr;
    flex-direction: column;
  }
}


/* ================= SCENARIO 3: CPU SPLIT STYLES ================= */

.cpu-split-container {
  width: 100%;
  position: relative;
}

.split-inputs {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  width: 100%;
  animation: fadeIn 0.3s ease; /* حركة ناعمة لما يظهر */
}

@keyframes fadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* تظبيط مقاسات الخانات المقسومة علشان تكفي جوه الجدول */
.half-cpu {
  padding: 12px 2px !important; 
  font-size: 15px !important;
  background: rgba(30, 41, 59, 0.6) !important; /* لون مميز يعبر عن إنها محسوبة */
  border: 1px dashed #475569 !important;
  color: #cbd5e1 !important;
  box-shadow: none !important;
  width: 100%;
}

/* الخط الفاصل بين النصين */
.split-divider {
  flex-shrink: 0;
  width: 3px;
  height: 24px;
  background-color: #38bdf8;
  border-radius: 2px;
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.5);
}

/* ================= QUIZ SECTION STYLES ================= */

.quiz-wrapper {
  max-width: 700px;
  margin: 0 auto;
  animation: fadeIn 0.5s ease;
}

/* Carousel */
.carousel-container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 30px;
}

.nav-btn {
  background: #1e293b;
  border: 1px solid #334155;
  color: #94a3b8;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  justify-content: center;
  align-items: center;
}
.nav-btn:hover {
  background: #38bdf8;
  color: #0f172a;
  border-color: #38bdf8;
  transform: scale(1.1);
}
.nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

/* Flashcard */
.flashcard {
  flex: 1;
  background: #0f172a;
  border: 1px solid #38bdf8;
  border-radius: 20px;
  padding: 40px 30px;
  text-align: center;
  position: relative;
  box-shadow: 0 10px 30px rgba(0,0,0,0.3);
  min-height: 200px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  transition: transform 0.3s ease, opacity 0.3s ease;
}

.card-counter {
  position: absolute;
  top: 15px;
  left: 50%;
  transform: translateX(-50%);
  background: #1e293b;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 13px;
  color: #94a3b8;
  font-weight: bold;
  letter-spacing: 1px;
}

.card-statement {
  font-size: 20px;
  color: #f8fafc;
  line-height: 1.6;
  font-weight: 500;
  margin: 0;
}

/* Choice Buttons */
.choice-controls {
  display: flex;
  justify-content: center;
  gap: 20px;
}

.choice-btn {
  flex: 1;
  max-width: 250px;
  padding: 16px 20px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  border: 2px solid transparent;
}

.choice-btn .icon {
  font-size: 22px;
}

.adv-btn {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border-color: rgba(34, 197, 94, 0.3);
}
.adv-btn:hover, .adv-btn.selected {
  background: #22c55e;
  color: #fff;
  box-shadow: 0 4px 15px rgba(34, 197, 94, 0.4);
}

.dis-btn {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border-color: rgba(239, 68, 68, 0.3);
}
.dis-btn:hover, .dis-btn.selected {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 4px 15px rgba(239, 68, 68, 0.4);
}

/* Submit Button - Blue Theme */
.submit-btn {
  background: #3b82f6; 
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.3);
  padding: 16px 50px;
  font-size: 18px;
  opacity: 1 !important; 
  transform: translateY(0) !important; 
  animation: none !important; 
  color: white;
  border: none;
  border-radius: 30px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.submit-btn:hover:not(:disabled) {
  background: #2563eb;
  transform: scale(1.05) !important;
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.5);
}
.submit-btn:disabled {
  background: #334155;
  color: #94a3b8;
  box-shadow: none;
  cursor: not-allowed;
  opacity: 0.7 !important;
}

.results-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 20px;
  max-width: 900px;
  margin: 0 auto;
  grid-auto-flow: dense; /* السطر السحري اللي بيمنع لخبطة الترتيب */
}

.result-item {
  background: #0f172a;
  padding: 25px 20px 20px;
  border-radius: 12px;
  border-left: 6px solid transparent;
  display: flex;
  flex-direction: column; /* علشان نوزع العناصر بالطول */
  justify-content: space-between; /* يخلي النتيجة تنزل لآخر الكارت */
  position: relative;
  min-height: 200px; /* بيوحد الطول المبدئي لكل الكروت */
}

/* لون الحافة الشمال حسب النوع الأصلي */
.result-item.type-adv { border-left-color: #22c55e; }
.result-item.type-dis { border-left-color: #ef4444; }

/* الـ Label اللي على اليمين فوق */
.actual-type-label {
  position: absolute;
  top: 15px;
  right: 15px;
  font-size: 11px;
  font-weight: 800;
  padding: 5px 12px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: 1px;
}
.result-item.type-adv .actual-type-label {
  background: rgba(34, 197, 94, 0.1);
  color: #22c55e;
  border: 1px solid rgba(34, 197, 94, 0.3);
}
.result-item.type-dis .actual-type-label {
  background: rgba(239, 68, 68, 0.1);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.3);
}

/* جملة السؤال */
.result-item p {
  margin: 25px 0 20px 0;
  font-size: 16px;
  line-height: 1.6;
  color: #cbd5e1;
}

/* نتيجة المستخدم تحت خالص */
.user-result-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  padding-top: 15px;
  border-top: 1px dashed #334155; /* خط متقطع يفصل النتيجة */
  margin-top: auto; /* بيزق النتيجة لآخر الكارت دائماً */
}

.user-result-status.correct { color: #22c55e; }
.user-result-status.wrong { color: #ef4444; }

/* للموبايل: نخليهم عمود واحد */
@media (max-width: 768px) {
  .choice-controls { flex-direction: column; }
  .choice-btn { max-width: 100%; }
  .results-grid { grid-template-columns: 1fr; }
}


/* ================= QUIZ ACCORDION & CONVOY DEMO ================= */

#quizInfoBox {
  grid-column: 1 / -1; 
  margin: 0 !important;
  padding: 0 24px !important;
  max-height: 0;
  opacity: 0;
  overflow: hidden;
  transition: all 0.4s ease-in-out; /* ده سر الانسيابية في الفتح والقفل */
  background: #0f172a;
  border-left: 4px solid #38bdf8;
  border-radius: 12px;
}

#quizInfoBox.active {
  max-height: 800px; /* مساحة كبيرة تكفي الشرح والديمو */
  opacity: 1;
  padding: 25px 24px !important;
  margin: 5px 0 15px 0 !important;
}

#quizInfoBox h4 {
  color: #38bdf8;
  font-size: 16px;
  margin-bottom: 6px;
  font-weight: 700;
}

#quizInfoBox p {
  font-size: 14.5px;
  color: #cbd5e1;
  line-height: 1.6;
  margin: 0;
}

/* --- Convoy Effect Animation --- */
.convoy-road {
  width: 100%;
  height: 80px;
  background: #1e293b;
  border-radius: 8px;
  position: relative;
  overflow: hidden;
  margin-top: 25px;
  border: 2px solid #334155;
}

/* خطوط الشارع المتقطعة */
.convoy-road::after {
  content: '';
  position: absolute;
  top: 50%; left: 0; right: 0; height: 4px;
  background: repeating-linear-gradient(90deg, #94a3b8 0, #94a3b8 20px, transparent 20px, transparent 40px);
  transform: translateY(-50%);
}

.convoy-group {
  position: absolute;
  top: 0; left: -100px; bottom: 0;
  width: 500px;
  animation: driveGroup 8s linear infinite; /* المجموعة كلها ماشية ببطء الشاحنة */
}

.convoy-vehicle {
  position: absolute;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  color: white;
  font-size: 14px;
  z-index: 2;
  box-shadow: 2px 2px 10px rgba(0,0,0,0.5);
}

.truck {
  left: 250px; top: 15px; width: 140px; height: 50px;
  background: #ef4444;
}

/* العربيات بتبدأ من ورا بعيد وتجري تلحق الشاحنة وتقف وراها */
.car { width: 50px; height: 30px; top: 25px; }
.car.c1 { background: #3b82f6; left: -100px; animation: catchUp1 8s ease-out infinite; }
.car.c2 { background: #22c55e; left: -200px; animation: catchUp2 8s ease-out infinite; }
.car.c3 { background: #eab308; left: -300px; animation: catchUp3 8s ease-out infinite; }

@keyframes driveGroup {
  0% { left: -300px; }
  100% { left: 100%; }
}
@keyframes catchUp1 { 0% { left: -100px; } 20%, 100% { left: 190px; } }
@keyframes catchUp2 { 0% { left: -200px; } 25%, 100% { left: 130px; } }
@keyframes catchUp3 { 0% { left: -300px; } 30%, 100% { left: 70px; } }



/* ================= UNIFYING LAYOUT & MARGINS ================= */

/* توحيد عرض الحاويات الأساسية في الموقع كله لـ 1000 بيكسل */
.video-section,
.solution-section .container,
.diagram-section,
.fcfs-details-section .container,
.scenario-section .container {
  max-width: 1000px !important;
  margin-left: auto !important;
  margin-right: auto !important;
}

/* فك القيود من على النصوص علشان تبدأ وتنتهي مع نفس الخط */
.problem-text,
.highlight,
.fcfs-list {
  max-width: 100% !important;
}

/* ================= FIXING TREE DIAGRAM ================= */

/* تقليل المسافات الأفقية بين الفروع علشان تكفي الشاشة */
.tree-diagram li {
  padding: 30px 4px 0 4px !important;
}

/* توحيد مقاسات كل المربعات (الأساسية، الفرعية، والصغيرة) لتكون قد بعض بالمللي */
.tree-diagram .node,
.tree-diagram .node.main,
.tree-diagram .node.small,
.tree-diagram .node:not(.main):not(.small) {
  width: 115px !important;       /* عرض موحد للكل */
  height: 75px !important;       /* طول موحد للكل */
  white-space: normal !important; /* السماح للكلام بالنزول لسطر جديد */
  font-size: 12.5px !important;    /* تصغير الخط ليناسب البوكس */
  line-height: 1.4 !important;
  padding: 5px !important;
  display: inline-flex !important;
  justify-content: center !important;
  align-items: center !important;
  text-align: center !important;
}

/* تمييز خط العنوان الرئيسي (Root) شوية بس بنفس مقاس البوكس */
.tree-diagram .node.main {
  font-size: 15px !important;
  font-weight: 800 !important;
  border-color: #8b5cf6 !important;
}

/* ================= UNIFYING ALL PLAY & RESET BUTTONS ================= */

/* توحيد الشكل الدائري لكل زراير التشغيل سواء الكبيرة أو الميني سيم */
.play-btn,
.play-btn-circle {
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
  width: 55px !important;    /* حجم دائري موحد ومثالي */
  height: 55px !important;
  margin: 0 !important;
  background: #3b82f6 !important;
  border: none !important;
  border-radius: 50% !important; /* شكل دائري تماماً */
  color: white !important;
  cursor: pointer !important;
  transition: all 0.3s ease !important;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4) !important;
}

/* توحيد الأنيميشن (التكبير والظل) لما نقف عليهم بالماوس */
.play-btn:hover,
.mini-play-overlay:hover .play-btn-circle,
.play-btn-circle:hover {
  background: #2563eb !important;
  transform: scale(1.1) !important; /* أنيميشن التكبير الموحد */
  box-shadow: 0 6px 20px rgba(59, 130, 246, 0.7) !important;
}

/* ================= RESET BUTTON SPECIFIC STYLES ================= */
/* زرار الـ Reset هياخد نفس الشكل والأنيميشن بس بلونه الرمادي الشيك */
.play-btn.reset-btn {
  background: #334155 !important;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4) !important;
}

.play-btn.reset-btn:hover {
  background: #475569 !important;
  transform: scale(1.1) !important;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.7) !important;
}

/* تظبيط حجم الأيقونات (علامة التشغيل والسهم) علشان تتسنتر جوه الدائرة */
.play-btn .icon svg,
.play-btn .icon {
  width: 24px !important;
  height: 24px !important;
  font-size: 24px !important;
  line-height: 1 !important;
  display: flex;
  justify-content: center;
  align-items: center;
}

/* ================= FIXING OPTICAL ALIGNMENT ================= */

/* تصفير أي مسافات عشوائية جوه الـ Wrapper بتاع الأيقونة */
.play-btn .icon,
#miniPlayIcon,
#prePlayIcon {
  margin: 0 !important;
  padding: 0 !important;
  display: flex !important;
  justify-content: center !important;
  align-items: center !important;
}

/* الخدعة السحرية للديزاينرز (Optical Centering):
   هتتطبق بس على الزراير الأساسية ومش هتقرب من زراير الميني سيم */
.play-btn:not(.reset-btn) .icon svg {
  transform: translateX(2px) !important;
}

/* ================= UNIFYING INFO BOXES WIDTH ================= */
.info-box {
  max-width: 100% !important;
}