/* === MODULE PAGE — Design v2 === */

/* Hero */
.module-hero {
  padding: 140px 0 32px;
  text-align: center;
  position: relative;
  overflow: hidden;
}
.module-hero::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 500px;
  height: 500px;
  transform: translate(-50%, -50%);
  pointer-events: none;
  border-radius: 50%;
}
.module-hero h1 {
  font-family: var(--font-display);
  font-size: clamp(24px, 4vw, 42px);
  font-weight: 400;
  line-height: 1.15;
  letter-spacing: -0.01em;
  margin-bottom: 12px;
  opacity: 0;
  animation: heroFadeUp 0.6s ease 0.1s forwards;
}
.module-hero h1 span { color: var(--accent); }

/* Level badge — pill, colored per level */
.level-badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 700;
  padding: 5px 16px;
  border-radius: var(--radius-pill);
  letter-spacing: 1.5px;
  margin-bottom: 16px;
  opacity: 0;
  animation: heroFadeUp 0.6s ease forwards;
}

/* Level-specific colors */
.level-sapphire .level-badge { background: rgba(59, 130, 246, 0.15); color: #3B82F6; }
.level-sapphire .module-hero::before { background: radial-gradient(circle, rgba(59, 130, 246, 0.08) 0%, transparent 70%); }
.level-sapphire .module-hero h1 span { color: #3B82F6; }

.level-emerald .level-badge { background: rgba(34, 197, 94, 0.15); color: #22C55E; }
.level-emerald .module-hero::before { background: radial-gradient(circle, rgba(34, 197, 94, 0.08) 0%, transparent 70%); }
.level-emerald .module-hero h1 span { color: #22C55E; }

.level-amber .level-badge { background: rgba(245, 158, 11, 0.15); color: #F59E0B; }
.level-amber .module-hero::before { background: radial-gradient(circle, rgba(245, 158, 11, 0.08) 0%, transparent 70%); }
.level-amber .module-hero h1 span { color: #F59E0B; }

.level-ruby .level-badge { background: rgba(239, 68, 68, 0.15); color: #EF4444; }
.level-ruby .module-hero::before { background: radial-gradient(circle, rgba(239, 68, 68, 0.08) 0%, transparent 70%); }

.level-purple .level-badge { background: rgba(168, 85, 247, 0.15); color: #A855F7; }
.level-purple .module-hero::before { background: radial-gradient(circle, rgba(168, 85, 247, 0.08) 0%, transparent 70%); }
.level-purple .module-hero h1 span { color: #A855F7; }

.level-gold .level-badge { background: rgba(212, 175, 55, 0.15); color: #D4AF37; }
.level-gold .module-hero::before { background: radial-gradient(circle, rgba(212, 175, 55, 0.08) 0%, transparent 70%); }
.level-gold .module-hero h1 span { color: #D4AF37; }

/* Video section */
.video-section {
  max-width: 960px;
  margin: 0 auto;
  padding: 0 24px;
  opacity: 0;
  animation: heroFadeUp 0.6s ease 0.2s forwards;
}
.video-wrapper {
  position: relative;
  width: 100%;
  border-radius: var(--radius);
  overflow: hidden;
  background: #000;
  border: 1px solid var(--surface-alt);
  aspect-ratio: 16/9;
  box-shadow: var(--shadow-card);
}
.video-wrapper video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Action buttons — pill */
.module-actions {
  display: flex;
  gap: 16px;
  justify-content: center;
  margin-top: 28px;
  flex-wrap: wrap;
  opacity: 0;
  animation: heroFadeUp 0.6s ease 0.3s forwards;
}
.module-actions a {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 14px 28px;
  border-radius: var(--radius-pill);
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s;
}
.btn-pdf {
  background: var(--surface);
  border: 1px solid var(--surface-alt);
  color: var(--text);
}
.btn-pdf:hover {
  border-color: var(--accent);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  color: var(--text);
}
.btn-quiz {
  background: var(--accent);
  color: #fff;
  border: none;
}
.btn-quiz:hover {
  background: var(--accent-dark);
  box-shadow: var(--shadow-glow);
  transform: translateY(-2px);
  color: #fff;
}

/* Module navigation */
.module-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 960px;
  margin: 36px auto 0;
  padding: 28px 24px 0;
  border-top: 1px solid var(--surface-alt);
}
.module-nav-link {
  font-size: 14px;
  font-weight: 600;
  color: var(--accent);
  text-decoration: none;
  transition: all 0.2s;
  padding: 8px 0;
}
.module-nav-link:hover {
  text-decoration: underline;
  text-underline-offset: 3px;
}

/* Content article area */
.module-content {
  padding: 48px 0 64px;
}
.module-content .container {
  max-width: 760px;
}

/* Reveal on scroll */
.reveal {
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}
.reveal.visible {
  opacity: 1;
  transform: translateY(0);
}

/* Inline Checkpoints */
.checkpoint-box {
  margin: 32px 0;
  padding: 24px;
  background: rgba(239,68,68,0.04);
  border: 1px solid rgba(239,68,68,0.15);
  border-radius: 12px;
}
.checkpoint-header {
  font-size: 13px;
  font-weight: 700;
  color: #ef4444;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 12px;
}
.checkpoint-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  background: #ef4444;
  color: #fff;
  border-radius: 50%;
  font-size: 13px;
  font-weight: 800;
  margin-right: 8px;
}
.checkpoint-question {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
  color: #f1f1f1;
}
.checkpoint-options {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.checkpoint-opt {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 12px 16px;
  color: #f1f1f1;
  font-size: 14px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
}
.checkpoint-opt:hover:not(:disabled) {
  border-color: #ef4444;
  background: rgba(239,68,68,0.06);
}
.checkpoint-result {
  margin-top: 12px;
  padding: 12px 16px;
  background: rgba(255,255,255,0.03);
  border-radius: 8px;
  font-size: 14px;
  line-height: 1.6;
  color: #ccc;
}

/* Module Feedback Widget */
.module-feedback {
  margin: 32px 0;
}
.feedback-box {
  padding: 24px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
}
.feedback-box h4 {
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 12px;
  color: #f1f1f1;
}
.feedback-stars {
  display: flex;
  gap: 4px;
  margin-bottom: 8px;
}
.feedback-stars .star {
  font-size: 28px;
  color: #555;
  cursor: pointer;
  transition: color 0.15s;
}
.diff-btn {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.15);
  color: #888;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
  margin-left: 6px;
  transition: all 0.2s;
}
.diff-btn:hover {
  border-color: #ef4444;
  color: #f1f1f1;
}

/* === Quiz Gate === */
.btn-quiz {
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

/* Progress bar behind locked button */
.quiz-locked {
  background: rgba(255,255,255,0.04) !important;
  border: 1px solid rgba(255,255,255,0.1) !important;
  color: #888 !important;
  cursor: not-allowed;
  position: relative;
}
.quiz-locked::before {
  content: '';
  position: absolute;
  left: 0;
  bottom: 0;
  height: 3px;
  width: var(--progress, 0%);
  background: linear-gradient(90deg, #ef4444, #f59e0b);
  border-radius: 0 2px 2px 0;
  transition: width 0.3s ease;
}
.quiz-locked:hover {
  border-color: rgba(239,68,68,0.3) !important;
  color: #aaa !important;
}

/* Unlocked state */
.quiz-unlocked {
  background: #ef4444 !important;
  color: #fff !important;
  border: none !important;
}

/* Unlock animation */
.quiz-just-unlocked {
  animation: quizUnlock 0.6s ease;
  box-shadow: 0 0 20px rgba(239,68,68,0.5), 0 0 40px rgba(239,68,68,0.2);
}
@keyframes quizUnlock {
  0% { transform: scale(1); }
  30% { transform: scale(1.08); }
  60% { transform: scale(0.97); }
  100% { transform: scale(1); }
}

/* Toast on video */
.quiz-toast {
  position: absolute;
  top: 16px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(34, 197, 94, 0.95);
  color: #fff;
  padding: 10px 24px;
  border-radius: 10px;
  font-size: 15px;
  font-weight: 700;
  font-family: system-ui, -apple-system, sans-serif;
  z-index: 10;
  opacity: 0;
  transition: opacity 0.4s ease, transform 0.4s ease;
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(34, 197, 94, 0.3);
}
.quiz-toast-visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Responsive */
@media (max-width: 768px) {
  .module-hero { padding: 110px 0 24px; }
  .module-hero h1 { font-size: clamp(20px, 5vw, 32px); }
  .module-actions { gap: 12px; }
  .module-actions a { padding: 12px 20px; font-size: 13px; }
  .module-nav { flex-direction: column; gap: 12px; text-align: center; }
  .quiz-toast { font-size: 13px; padding: 8px 16px; }
}


/* === Study Guide + Related Modules === */
.study-guide {
  margin: 40px 0;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  overflow: hidden;
}
.study-guide summary {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 24px;
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: #f1f1f1;
  list-style: none;
  transition: background 0.2s;
}
.study-guide summary::-webkit-details-marker { display: none; }
.study-guide summary::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%233B82F6' stroke-width='2'%3E%3Cpath d='M2 3h6a4 4 0 0 1 4 4v14a3 3 0 0 0-3-3H2z'/%3E%3Cpath d='M22 3h-6a4 4 0 0 0-4 4v14a3 3 0 0 1 3-3h7z'/%3E%3C/svg%3E") no-repeat center;
  flex-shrink: 0;
}
.study-guide summary::after {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  margin-left: auto;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%23888' stroke-width='2'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E") no-repeat center;
  transition: transform 0.2s;
}
.study-guide[open] summary::after {
  transform: rotate(180deg);
}
.study-guide summary:hover {
  background: rgba(59, 130, 246, 0.1);
}
.study-guide-content {
  padding: 24px;
}
.study-guide-content h4 {
  font-size: 14px;
  font-weight: 700;
  color: #3B82F6;
  text-transform: uppercase;
  letter-spacing: 1px;
  margin: 0 0 12px;
}
.study-guide-content h4:not(:first-child) {
  margin-top: 24px;
}
.study-guide-content ul {
  margin: 0 0 8px;
  padding-left: 20px;
}
.study-guide-content li {
  font-size: 14px;
  line-height: 1.7;
  color: #ccc;
  margin-bottom: 4px;
}
.study-guide-content li strong {
  color: #f1f1f1;
}
.study-guide-content .sg-code {
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 6px;
  padding: 12px 16px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 12px;
  color: #a5b4fc;
  overflow-x: auto;
  margin: 8px 0 12px;
  white-space: pre;
}
.study-guide-content .sg-tip {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 12px 16px;
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid rgba(34, 197, 94, 0.15);
  border-radius: 8px;
  margin: 12px 0;
  font-size: 13px;
  color: #a7f3d0;
  line-height: 1.6;
}
.study-guide-content .sg-tip::before {
  content: '\1F4A1';
  flex-shrink: 0;
}

/* Related Modules */
.related-modules {
  margin: 32px 0;
}
.related-modules h3 {
  font-size: 16px;
  font-weight: 700;
  color: #f1f1f1;
  margin: 0 0 16px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.related-modules h3::before {
  content: '';
  display: inline-block;
  width: 20px;
  height: 20px;
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23A855F7' stroke-width='2'%3E%3Ccircle cx='12' cy='12' r='3'/%3E%3Cpath d='M12 1v4m0 14v4m-8.66-14.5 3.46 2m10.4 6 3.46 2m-17.32 0 3.46-2m10.4-6 3.46-2'/%3E%3C/svg%3E") no-repeat center;
  flex-shrink: 0;
}
.related-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px;
}
.related-card {
  display: block;
  padding: 16px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  text-decoration: none;
  transition: all 0.2s;
}
.related-card:hover {
  border-color: rgba(168, 85, 247, 0.4);
  background: rgba(168, 85, 247, 0.04);
  transform: translateY(-2px);
}
.related-card .rc-id {
  font-size: 11px;
  font-weight: 700;
  color: #A855F7;
  letter-spacing: 1px;
  margin-bottom: 4px;
}
.related-card .rc-title {
  font-size: 14px;
  font-weight: 600;
  color: #f1f1f1;
  line-height: 1.4;
  margin-bottom: 6px;
}
.related-card .rc-meta {
  font-size: 11px;
  color: #888;
}
.related-card .rc-badge {
  display: inline-block;
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 600;
  margin-right: 4px;
}
.rc-badge-same-track { background: rgba(168,85,247,0.15); color: #A855F7; }
.rc-badge-same-category { background: rgba(59,130,246,0.15); color: #3B82F6; }
.rc-badge-prereq { background: rgba(34,197,94,0.15); color: #22C55E; }

@media (max-width: 768px) {
  .study-guide summary { padding: 14px 16px; font-size: 15px; }
  .study-guide-content { padding: 16px; }
  .related-grid { grid-template-columns: 1fr; }
}
