/* ======================================
   topics.css — صفحة المواضيع والدروس
   هيرو على هيئة Terminal بتسلسل DNA/RNA متحرك،
   وشبكة بطاقات مواضيع مصدرها قاعدة البيانات.
   يعتمد على متغيرات :root المعرّفة في main.css
   (--primary, --secondary, --accent, --text-secondary, --text-muted)
====================================== */

* { box-sizing: border-box; }

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

/* ===========================
   PAGE WRAPPER
   نفس قيم التباعد المستخدمة في hero-topics-section
   على الصفحة الرئيسية، لتفادي تداخل الهيدر الثابت
=========================== */
.tp-page {
  padding: 40px 40px 70px;
  background: #ffffff;
}

/* ===========================
   HERO — نافذة طرفية (Terminal)
=========================== */
.tp-hero {
  background: linear-gradient(160deg, #041829, #062141 65%);
  border-radius: 18px;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,0.06);
  box-shadow: 0 10px 44px rgba(6,33,65,0.25);
  margin-top: 57px;
  margin-bottom: 22px;
}

.tp-chrome {
  height: 34px;
  background: rgba(255,255,255,0.03);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  direction: ltr; /* حتى تبقى الأحمر-أصفر-أخضر بترتيبها الصحيح دائماً */
}
.tp-dot { width: 9px; height: 9px; border-radius: 50%; }
.tp-dot-red   { background: #e2615a; }
.tp-dot-amber { background: #e2b35a; }
.tp-dot-green { background: #5dcaa5; }
.tp-chrome-title {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.35);
  margin-right: 6px;
}

.tp-hero-body { padding: 38px 42px; }

.tp-eyebrow {
  font-family: 'Courier New', monospace;
  font-size: 12.5px;
  color: #5dcaa5;
  margin-bottom: 14px;
}

.tp-title {
  font-size: 30px;
  font-weight: 800;
  color: #fff;
  margin-bottom: 10px;
  line-height: 1.35;
}

.tp-sub {
  font-size: 14.5px;
  color: rgba(255,255,255,0.6);
  line-height: 1.7;
  max-width: 520px;
  margin-bottom: 24px;
}

/* ===========================
   DNA / RNA sequence line
   يحل محل النص الثابت "$ ابدأ_التعلم"
=========================== */
.tp-seqline { display: flex; align-items: center; gap: 10px; }
.tp-sym {
  font-family: 'Courier New', monospace;
  color: #5dcaa5;
  font-size: 14px;
  flex-shrink: 0;
}

.tp-seq-track {
  direction: ltr;
  overflow: hidden;
  flex: 1;
  min-width: 0;
  max-width: 380px;
  height: 20px;
  position: relative;
}
.tp-seq-track::before,
.tp-seq-track::after {
  content: '';
  position: absolute;
  top: 0; bottom: 0;
  width: 26px;
  z-index: 2;
  pointer-events: none;
}
.tp-seq-track::before { left: 0;  background: linear-gradient(to right, #051d33, transparent); }
.tp-seq-track::after  { right: 0; background: linear-gradient(to left,  #0a2f48, transparent); }

.tp-seq-tape {
  display: inline-flex;
  white-space: nowrap;
  font-family: 'Courier New', monospace;
  font-size: 15px;
  letter-spacing: 2px;
  animation: tpSeqScroll 16s linear infinite;
}
@keyframes tpSeqScroll {
  from { transform: translateX(0); }
  to   { transform: translateX(-50%); }
}

.tp-base {
  display: inline-block;
  width: 1.4ch;
  text-align: center;
  transition: color .35s, transform .25s;
}
.tp-base.b-a { color: #5dcaa5; }
.tp-base.b-t { color: #9fe1cb; }
.tp-base.b-u { color: #ffffff; }
.tp-base.b-c { color: rgba(255,255,255,0.45); }
.tp-base.b-g { color: rgba(255,255,255,0.25); }
.tp-base.flip { transform: scale(1.4); }

.tp-seq-caption {
  font-family: 'Courier New', monospace;
  font-size: 11px;
  color: rgba(255,255,255,0.32);
  margin-top: 8px;
  margin-bottom: 26px;
}
.tp-seq-caption b { color: rgba(159,225,203,0.7); font-weight: 400; }

/* ===========================
   STAT — عدد المواضيع فقط
=========================== */
.tp-stats { display: flex; }
.tp-stat {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  padding: 11px 20px;
  font-family: 'Courier New', monospace;
  font-size: 13px;
  display: inline-flex;
  gap: 9px;
  align-items: center;
}
.tp-stat i { color: #5dcaa5; font-size: 13px; }
.tp-stat-k { color: #5dcaa5; }
.tp-stat-c { color: rgba(255,255,255,0.3); }
.tp-stat-v { color: #fff; font-weight: 700; }

/* Hero entrance animation (JS adds .tp-in to trigger) */
.tp-anim {
  opacity: 0;
  transform: translateY(14px);
}
.tp-anim.tp-in {
  animation: tpFadeUp .7s ease forwards;
  animation-delay: var(--d, 0s);
}
@keyframes tpFadeUp {
  to { opacity: 1; transform: translateY(0); }
}

/* ===========================
   TOPIC CARDS GRID — من قاعدة البيانات
=========================== */
.tp-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
}

.tp-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  background: #fff;
  border: 1px solid rgba(6,33,65,0.08);
  border-radius: 20px;
  padding: 30px 18px 24px;
  text-decoration: none;
  box-shadow: 0 4px 16px rgba(0,0,0,0.05);
  transition: all .3s cubic-bezier(0.68,-0.55,0.265,1.55);
  opacity: 0;
  transform: translateY(24px);
}
.tp-card.tp-in {
  opacity: 1;
  transform: translateY(0);
  transition: opacity .6s ease, transform .6s ease, box-shadow .3s, border-color .3s;
}
.tp-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 14px 36px rgba(6,33,65,0.13);
  border-color: rgba(10,77,77,0.25);
}

.tp-card-icon {
  width: 74px;
  height: 74px;
  border-radius: 50%;
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 6px 20px rgba(10,77,77,0.15);
}
.tp-card-icon img {
  width: 40px;
  height: 40px;
  object-fit: contain;
  transition: transform .4s cubic-bezier(0.68,-0.55,0.265,1.55);
}
.tp-card:hover .tp-card-icon img { transform: scale(1.15) rotate(-4deg); }

.tp-card-title {
  font-size: 15px;
  font-weight: 800;
  color: var(--primary, #062141);
  line-height: 1.4;
}
.tp-card-desc {
  font-size: 12.5px;
  color: var(--text-muted, #64748b);
  line-height: 1.7;
}
.tp-card-level {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--secondary, #0a4d4d);
  background: #e1f5ee;
  padding: 4px 12px;
  border-radius: 999px;
}
.tp-card-cta {
  margin-top: 4px;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--accent, #1a7a7a);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: gap .2s;
}
.tp-card:hover .tp-card-cta { gap: 10px; }
.tp-card-cta i { font-size: 10px; }

/* Empty state — لو ألغى المسؤول كل المواضيع */
.tp-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted, #94a3b8);
}
.tp-empty i { font-size: 34px; margin-bottom: 12px; display: block; }
.tp-empty p { font-size: 14px; }

/* ===========================
   RESPONSIVE
=========================== */
@media (max-width: 900px) {
  .tp-page { padding: 24px 24px 50px; }
}

@media (max-width: 760px) {
  .tp-hero-body { padding: 28px 22px; }
  .tp-title { font-size: 23px; }
  .tp-seq-track { max-width: none; }
}

@media (max-width: 480px) {
  .tp-page { padding: 18px 16px 40px; }
  .tp-hero { margin-top: 70px; }
  .tp-grid { grid-template-columns: repeat(2, 1fr); }
}
