/* =========================
   Topic Pages - Unified Enhanced Design
   ========================= */

* {
  box-sizing: border-box;
}

body {
  font-family: "Tajawal", sans-serif;
  margin: 0;
  background-color: #f6f8fa;
  overflow-x: hidden;
}

/* ===== Hero Section ===== */
.topic-hero {
  position: relative;
  background: linear-gradient(135deg, #062141, #0a4d4d);
  color: white;
  padding: 140px 25px 80px;
  text-align: center;
  overflow: hidden;
}

/* Animated Background Shapes */
.topic-hero::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: url('data:image/svg+xml,<svg width="60" height="60" xmlns="http://www.w3.org/2000/svg"><circle cx="30" cy="30" r="1.5" fill="rgba(255,255,255,0.1)"/></svg>');
  opacity: 0.4;
  animation: float 25s linear infinite;
}

@keyframes float {
  from { transform: translateY(0) translateX(0); }
  to { transform: translateY(-60px) translateX(-60px); }
}

/* Hero Shapes */
.hero-shapes {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  z-index: 0;
}

.shape {
  position: absolute;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.05);
  animation: floatShapes 20s infinite ease-in-out;
}

.shape-1 {
  width: 300px;
  height: 300px;
  top: -100px;
  right: -60px;
  animation-delay: 0s;
}

.shape-2 {
  width: 200px;
  height: 200px;
  bottom: -50px;
  left: 10%;
  animation-delay: 6s;
}

.shape-3 {
  width: 150px;
  height: 150px;
  top: 50%;
  left: -30px;
  animation-delay: 12s;
}

@keyframes floatShapes {
  0%, 100% {
    transform: translateY(0) rotate(0deg);
    opacity: 0.3;
  }
  50% {
    transform: translateY(-30px) rotate(180deg);
    opacity: 0.6;
  }
}

.topic-hero-inner {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
}

/* Topic Icons */
.topic-icon,
.python-icon {
  font-size: 75px;
  margin-bottom: 22px;
  display: inline-block;
  animation: bounce 2s ease-in-out infinite;
  filter: drop-shadow(0 10px 20px rgba(0, 0, 0, 0.3));
}

@keyframes bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-15px); }
}

.topic-hero h1 {
  font-size: 48px;
  margin-bottom: 20px;
  font-weight: 800;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.25);
  letter-spacing: -0.5px;
}

.topic-hero p {
  font-size: 19px;
  max-width: 750px;
  margin: auto;
  line-height: 1.9;
  color: rgba(255, 255, 255, 0.92);
}

/* ===== Scroll Progress Bar ===== */
.scroll-progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(to right, #062141, #0a3a5c);
  width: 0%;
  z-index: 9999;
  transition: width 0.1s ease;
}

/* ===== Content Section ===== */
.topic-content {
  padding: 80px 20px;
  max-width: 1200px;
  margin: auto;
}

.topic-content h2 {
  text-align: center;
  font-size: 40px;
  color: #062141;
  margin-bottom: 20px;
  font-weight: 800;
  position: relative;
  display: inline-block;
  width: 100%;
}

.topic-content h2::after {
  content: '';
  position: absolute;
  bottom: -12px;
  left: 50%;
  transform: translateX(-50%);
  width: 100px;
  height: 4px;
  background: linear-gradient(to right, #062141, #0a3a5c);
  border-radius: 2px;
}

.section-subtitle {
  text-align: center;
  font-size: 17px;
  color: #666;
  margin-bottom: 50px;
  max-width: 700px;
  margin-left: auto;
  margin-right: auto;
  line-height: 1.7;
}

/* ===== Stats Section ===== */
.stats-section {
  background: linear-gradient(135deg, #f0f8f9, #e6f1f4);
  padding: 60px 20px;
  margin: 60px 0;
  border-radius: 20px;
  text-align: center;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.06);
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 30px;
  max-width: 900px;
  margin: 40px auto 0;
}

.stat-item {
  padding: 30px;
  background: white;
  border-radius: 16px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.08);
  transition: all 0.3s ease;
}

.stat-item:hover {
  transform: translateY(-5px);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.12);
}

.stat-number {
  font-size: 46px;
  font-weight: 800;
  color: #062141;
  margin-bottom: 10px;
  display: block;
}

.stat-label {
  font-size: 17px;
  color: #666;
  font-weight: 600;
}

/* ===== Features Section ===== */
.features-section {
  padding: 40px 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 28px;
  margin-top: 40px;
}

.feature-card {
  background: white;
  padding: 32px;
  border-radius: 18px;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.08);
  text-align: center;
  transition: all 0.4s ease;
  border: 1px solid rgba(6, 33, 65, 0.08);
  opacity: 0;
  transform: translateY(20px);
}

.feature-card.visible {
  opacity: 1;
  transform: translateY(0);
}

.feature-card:hover {
  transform: translateY(-8px);
  box-shadow: 0 15px 40px rgba(6, 33, 65, 0.15);
  border-color: rgba(6, 33, 65, 0.15);
}

.feature-icon {
  font-size: 52px;
  margin-bottom: 20px;
  display: inline-block;
  transition: transform 0.3s ease;
}

.feature-card:hover .feature-icon {
  transform: scale(1.1) rotate(5deg);
}

.feature-card h3 {
  font-size: 21px;
  color: #062141;
  margin-bottom: 12px;
  font-weight: 800;
}

.feature-card p {
  font-size: 15px;
  color: #666;
  line-height: 1.8;
  margin: 0;
}

/* ===== Videos Grid ===== */
.videos-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(340px, 1fr));
  gap: 32px;
  margin-top: 50px;
}

.video-card {
  background: white;
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08);
  transition: all 0.4s ease;
  opacity: 0;
  transform: translateY(30px) scale(0.98);
  position: relative;
  border: 1px solid rgba(6, 33, 65, 0.06);
}

.video-card.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.video-card:hover {
  transform: translateY(-8px) scale(1.02);
  box-shadow: 0 20px 45px rgba(6, 33, 65, 0.15);
}

/* Video Thumbnail */
.video-thumbnail {
  position: relative;
  width: 100%;
  padding-top: 56.25%;
  background: #000;
  overflow: hidden;
}

.video-card iframe {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  border: none;
}

/* Play Overlay */
.play-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(6, 33, 65, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}

.video-card:hover .play-overlay {
  opacity: 1;
}

.play-icon {
  width: 70px;
  height: 70px;
  background: rgba(255, 255, 255, 0.95);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
  color: #062141;
  transform: scale(0.9);
  transition: transform 0.3s ease;
  padding-right: 5px;
}

.video-card:hover .play-icon {
  transform: scale(1.1);
}

/* Video Duration Badge */
.video-duration {
  position: absolute;
  bottom: 12px;
  right: 12px;
  background: rgba(0, 0, 0, 0.85);
  color: white;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 700;
  z-index: 2;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}

/* Video Info */
.video-info {
  padding: 26px;
  background: white;
}

.video-card h3 {
  font-size: 20px;
  color: #062141;
  margin: 0 0 12px 0;
  font-weight: 800;
  line-height: 1.5;
  transition: color 0.3s ease;
}

.video-card:hover h3 {
  color: #0a3a5c;
}

.video-card p {
  font-size: 15px;
  color: #666;
  margin: 0;
  line-height: 1.7;
}

/* ===== CTA Button ===== */
.cta-button {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  background: linear-gradient(135deg, #062141, #0a3a5c);
  color: white;
  padding: 16px 40px;
  border-radius: 50px;
  text-decoration: none;
  font-size: 17px;
  font-weight: 700;
  transition: all 0.3s ease;
  box-shadow: 0 10px 25px rgba(6, 33, 65, 0.3);
}

.cta-button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 15px 35px rgba(6, 33, 65, 0.4);
  gap: 14px;
}

/* ===== Responsive Design ===== */
@media (max-width: 768px) {
  .topic-hero {
    padding: 110px 20px 65px;
  }

  .topic-hero h1 {
    font-size: 34px;
  }

  .topic-hero p {
    font-size: 17px;
  }

  .topic-icon,
  .python-icon {
    font-size: 60px;
  }

  .topic-content h2 {
    font-size: 32px;
  }

  .videos-grid {
    grid-template-columns: 1fr;
    gap: 25px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }

  .stat-number {
    font-size: 40px;
  }

  .features-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 480px) {
  .topic-hero {
    padding: 100px 18px 60px;
  }

  .topic-hero h1 {
    font-size: 28px;
  }

  .topic-hero p {
    font-size: 16px;
  }

  .topic-content {
    padding: 60px 18px;
  }

  .topic-content h2 {
    font-size: 28px;
  }

  .video-info {
    padding: 22px;
  }

  .video-card h3 {
    font-size: 18px;
  }
}

/* ===== Animation Delays ===== */
.video-card:nth-child(1) { transition-delay: 0.1s; }
.video-card:nth-child(2) { transition-delay: 0.2s; }
.video-card:nth-child(3) { transition-delay: 0.3s; }
.video-card:nth-child(4) { transition-delay: 0.4s; }
.video-card:nth-child(5) { transition-delay: 0.5s; }
.video-card:nth-child(6) { transition-delay: 0.6s; }

.feature-card:nth-child(1) { transition-delay: 0.1s; }
.feature-card:nth-child(2) { transition-delay: 0.2s; }
.feature-card:nth-child(3) { transition-delay: 0.3s; }
.feature-card:nth-child(4) { transition-delay: 0.4s; }

/* Loading State */
.loading {
  opacity: 0;
}