/* ============================================
   CPTS Companion - Module Learning Flow Styles
   5-step boot.dev-style animated learning
   ============================================ */

/* ── Progress Steps Bar ── */
.learn-progress {
  background: var(--htb-dark);
  border: 1px solid var(--htb-border);
  border-radius: var(--border-radius);
  padding: 1rem 1.5rem;
  margin-bottom: 1.5rem;
}
.learn-progress-steps {
  display: flex;
  align-items: center;
  gap: 0;
  justify-content: center;
}
.learn-step {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem 0.5rem;
  transition: all 0.2s;
}
.step-num {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid var(--htb-border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 700;
  transition: all 0.3s;
}
.step-label {
  font-family: var(--font-mono);
  font-size: 0.65rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  transition: color 0.3s;
}
.learn-step.active .step-num {
  border-color: var(--htb-green);
  background: rgba(159, 239, 0, 0.1);
  color: var(--htb-green);
  box-shadow: 0 0 12px rgba(159, 239, 0, 0.2);
}
.learn-step.active .step-label {
  color: var(--htb-green);
}
.learn-step.completed .step-num {
  border-color: var(--htb-green);
  background: var(--htb-green);
  color: #000;
}
.learn-step.completed .step-label {
  color: var(--text-secondary);
}

.step-connector {
  flex: 1;
  max-width: 60px;
  height: 2px;
  background: var(--htb-border);
  position: relative;
  margin: 0 0.25rem;
  margin-bottom: 18px;
}
.step-connector-fill {
  position: absolute;
  left: 0;
  top: 0;
  height: 100%;
  width: 0%;
  background: var(--htb-green);
  transition: width 0.5s ease;
}

/* ── Panel Container ── */
.learn-steps-container {
  position: relative;
}
.learn-panel {
  display: none;
  animation: fadeSlideIn 0.3s ease;
}
.learn-panel.active {
  display: block;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ── Step Navigation ── */
.step-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid var(--htb-border);
}
.btn-arrow {
  font-family: var(--font-mono);
  font-weight: 700;
}

/* ============================================
   Step 1: Concept Animation
   ============================================ */
.concept-animation {
  margin-bottom: 2rem;
}
.anim-viewport {
  background: #0d1117;
  border: 1px solid var(--htb-border);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
}
.concept-svg {
  width: 100%;
  height: 350px;
  display: block;
}
.anim-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 1rem;
  background: rgba(13, 17, 23, 0.9);
  border-top: 1px solid var(--htb-border);
}
.anim-btn {
  background: none;
  border: 1px solid var(--htb-border);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.2s;
  min-width: 28px;
}
.anim-btn:hover {
  border-color: var(--htb-green);
  color: var(--htb-green);
}
.anim-progress-track {
  flex: 1;
  height: 4px;
  background: var(--htb-border);
  border-radius: 2px;
  overflow: hidden;
}
.anim-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--htb-green);
  transition: width 0.3s linear;
}

.anim-narration {
  padding: 1rem 1.25rem;
  background: var(--htb-dark);
  border: 1px solid var(--htb-border);
  border-top: none;
  border-radius: 0 0 8px 8px;
  min-height: 48px;
}
.anim-narration p {
  color: var(--text-secondary);
  font-size: 0.85rem;
  line-height: 1.6;
  margin: 0;
  font-style: italic;
}

.concept-text {
  margin-top: 1.5rem;
}
.concept-text p {
  color: var(--text-secondary);
  line-height: 1.7;
}

/* ============================================
   Step 2: Interactive Cheatsheet
   ============================================ */
.interactive-cheatsheet {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}
.cmd-block {
  background: #0d1117;
  border: 1px solid var(--htb-border);
  border-radius: 8px;
  overflow: hidden;
}
.cmd-block-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.5rem 1rem;
  background: #161b22;
  border-bottom: 1px solid var(--htb-border);
}
.cmd-block-title {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  font-weight: 600;
}
.cmd-block-actions {
  display: flex;
  gap: 0.4rem;
}
.cmd-action-btn {
  background: none;
  border: 1px solid var(--htb-border);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  padding: 2px 8px;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.2s;
}
.cmd-action-btn:hover {
  border-color: var(--htb-green);
  color: var(--htb-green);
}
.cmd-action-btn.copied {
  border-color: var(--htb-green);
  color: var(--htb-green);
}

.cmd-block-body {
  padding: 1rem;
}
.cmd-line {
  display: flex;
  align-items: flex-start;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.5;
}
.cmd-line:last-child { margin-bottom: 0; }
.cmd-prompt {
  color: var(--htb-green);
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
.cmd-text {
  color: #e6edf3;
  word-break: break-all;
}
.cmd-flag {
  color: var(--htb-cyan);
  cursor: help;
  position: relative;
}
.cmd-flag-tooltip {
  display: none;
  position: absolute;
  bottom: calc(100% + 6px);
  left: 50%;
  transform: translateX(-50%);
  background: #1f2937;
  border: 1px solid var(--htb-border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  font-size: 0.75rem;
  color: var(--text-secondary);
  white-space: nowrap;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}
.cmd-flag:hover .cmd-flag-tooltip {
  display: block;
}

/* "Try in context" modal */
.context-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}
.context-modal {
  background: var(--htb-dark);
  border: 1px solid var(--htb-border);
  border-radius: 10px;
  width: min(700px, 90vw);
  max-height: 80vh;
  overflow-y: auto;
}
.context-modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  border-bottom: 1px solid var(--htb-border);
}
.context-modal-header h4 {
  margin: 0;
  font-size: 0.9rem;
}
.context-modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
}
.context-modal-body {
  padding: 1.5rem;
}
.context-terminal {
  background: #0d1117;
  border: 1px solid var(--htb-border);
  border-radius: 6px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: #e6edf3;
  white-space: pre-wrap;
}

/* ============================================
   Step 3: Terminal Emulator
   ============================================ */
.scenario-box {
  background: var(--htb-card);
  border: 1px solid var(--htb-border);
  border-radius: 8px;
  padding: 1.25rem;
  margin-bottom: 1.5rem;
}
.scenario-text {
  color: var(--text-secondary);
  line-height: 1.7;
  margin: 0;
}

.exercise-bar {
  height: 6px;
  background: var(--htb-border);
  border-radius: 3px;
  margin-bottom: 1.5rem;
  overflow: hidden;
}
.exercise-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--htb-green), #b4ff1a);
  border-radius: 3px;
  transition: width 0.5s ease;
}

.exercise-progress-mini {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.fake-terminal {
  background: #0d1117;
  border: 1px solid var(--htb-border);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1rem;
}
.fake-terminal .terminal-chrome {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  background: #161b22;
  border-bottom: 1px solid #21262d;
}
.fake-terminal .terminal-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
}
.fake-terminal .terminal-dot.red { background: #ff5f56; }
.fake-terminal .terminal-dot.yellow { background: #ffbd2e; }
.fake-terminal .terminal-dot.green { background: #27c93f; }
.fake-terminal .terminal-title {
  margin-left: auto;
  font-size: 0.7rem;
  color: #484f58;
}

.terminal-output {
  padding: 1rem;
  max-height: 300px;
  overflow-y: auto;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.5;
}
.term-line {
  margin-bottom: 0.25rem;
  color: #e6edf3;
}
.term-prompt {
  color: var(--htb-green);
  font-weight: 700;
  margin-right: 0.5rem;
}
.term-comment {
  color: #484f58;
}
.term-error {
  color: #ff4444;
}
.term-success {
  color: var(--htb-green);
}
.term-output {
  color: #8b949e;
}

.terminal-input-row {
  display: flex;
  align-items: center;
  padding: 0.5rem 1rem 1rem;
  gap: 0.5rem;
}
.terminal-input {
  flex: 1;
  background: none;
  border: none;
  color: #e6edf3;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  outline: none;
  caret-color: var(--htb-green);
}
.terminal-input::placeholder {
  color: #30363d;
}

.hint-area {
  margin-top: 0.75rem;
}
.hint-btn {
  color: var(--htb-amber) !important;
  border-color: rgba(186, 117, 23, 0.3) !important;
}
.hint-text {
  margin-top: 0.5rem;
  color: var(--htb-amber);
  font-size: 0.85rem;
  font-style: italic;
}
.solution-area {
  margin-top: 0.5rem;
}
.solution-content {
  margin-top: 0.75rem;
  background: var(--htb-card);
  border: 1px solid var(--htb-border);
  border-radius: 6px;
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ============================================
   Step 4: Learn Flashcards
   ============================================ */
.flashcard-arena {
  text-align: center;
  padding: 1rem 0;
}
.flash-remaining {
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
}
.flash-counter {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
}

.learn-flashcard {
  width: min(500px, 90vw);
  height: 280px;
  margin: 0 auto;
  perspective: 1200px;
  cursor: pointer;
}
.learn-flashcard-inner {
  position: relative;
  width: 100%;
  height: 100%;
  transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  transform-style: preserve-3d;
}
.learn-flashcard.flipped .learn-flashcard-inner {
  transform: rotateY(180deg);
}

.learn-flashcard-front,
.learn-flashcard-back {
  position: absolute;
  inset: 0;
  backface-visibility: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  border-radius: 12px;
  border: 2px solid var(--htb-border);
}
.learn-flashcard-front {
  background: var(--htb-dark);
}
.learn-flashcard-front p {
  color: var(--text-primary);
  font-size: 1.1rem;
  line-height: 1.5;
  margin: 0;
}
.learn-flashcard-back {
  background: var(--htb-card);
  transform: rotateY(180deg);
  border-color: var(--htb-green);
}
.learn-flashcard-back p {
  color: var(--htb-green);
  font-size: 1rem;
  font-family: var(--font-mono);
  line-height: 1.5;
  margin: 0;
}

.flash-instruction {
  color: var(--text-muted);
  font-size: 0.8rem;
  margin-top: 1rem;
}

.flash-ratings {
  display: flex;
  justify-content: center;
  gap: 0.75rem;
  margin-top: 1.5rem;
}
.flash-rate-btn {
  padding: 0.5rem 1.25rem;
  border-radius: 6px;
  border: 1px solid var(--htb-border);
  background: var(--htb-card);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}
.flash-rate-btn:hover {
  transform: translateY(-2px);
}
.rate-again { border-color: rgba(231,76,60,0.4); }
.rate-again:hover { background: rgba(231,76,60,0.15); color: #ff4444; }
.rate-hard { border-color: rgba(186,117,23,0.4); }
.rate-hard:hover { background: rgba(186,117,23,0.15); color: #ffb800; }
.rate-good { border-color: rgba(29,158,117,0.4); }
.rate-good:hover { background: rgba(29,158,117,0.15); color: #1d9e75; }
.rate-easy { border-color: rgba(0,212,255,0.4); }
.rate-easy:hover { background: rgba(0,212,255,0.15); color: #00d4ff; }

.flash-done {
  text-align: center;
  padding: 3rem 1rem;
}
.flash-done-icon {
  font-size: 3rem;
  color: var(--htb-green);
  margin-bottom: 1rem;
  font-family: var(--font-mono);
  font-weight: 700;
}
.flash-done h3 { color: var(--htb-green); }
.flash-done p { color: var(--text-muted); }

/* ============================================
   Step 5: Completion Screen
   ============================================ */
.completion-screen {
  position: relative;
  text-align: center;
  padding: 2rem 1rem;
  min-height: 500px;
}
.confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}
.completion-content {
  position: relative;
  z-index: 2;
}

.completion-badge {
  margin-bottom: 1.5rem;
  opacity: 0;
  transform: scale(0.5);
}
.completion-badge svg {
  animation: badge-spin 15s linear infinite;
}
@keyframes badge-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.completion-terminal {
  max-width: 500px;
  margin: 0 auto 2rem;
  background: #0d1117;
  border: 1px solid var(--htb-border);
  border-radius: 8px;
  text-align: left;
  opacity: 0;
}
.completion-terminal .terminal-body {
  padding: 1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
}

.completion-title {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
  opacity: 0;
}
.completion-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  max-width: 500px;
  margin: 0 auto 2rem;
  opacity: 0;
}

.completion-stats {
  display: flex;
  justify-content: center;
  gap: 2.5rem;
  margin-bottom: 2.5rem;
  opacity: 0;
}
.comp-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
}
.comp-stat-val {
  font-size: 2rem;
  font-weight: 700;
  color: var(--htb-green);
  font-family: var(--font-mono);
}
.comp-stat-lbl {
  font-size: 0.7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.completion-actions {
  display: flex;
  gap: 1rem;
  justify-content: center;
  flex-wrap: wrap;
  opacity: 0;
}

/* ── Mobile ── */
@media (max-width: 768px) {
  .learn-progress-steps { gap: 0; }
  .step-label { display: none; }
  .step-connector { max-width: 30px; margin-bottom: 0; }
  .learn-flashcard { height: 220px; }
  .completion-stats { gap: 1.5rem; }
  .comp-stat-val { font-size: 1.5rem; }
  .flash-ratings { flex-wrap: wrap; }
}
