/* ===== CSS CUSTOM PROPERTIES ===== */
:root {
  --primary-color: #667eea;
  --primary-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  --success-color: #38a169;
  --warning-color: #d69e2e;
  --info-color: #3182ce;
  --text-color: #2c3e50;
  --bg-light: #f7fafc;
  --bg-gray: #ecf0f1;
  --border-color: #e2e8f0;
  --shadow: 0 4px 20px rgba(0,0,0,0.08);
}

/* ===== BASE STYLES ===== */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  line-height: 1.7;
  color: var(--text-color);
  background: var(--bg-gray);
}

/* ===== HEADER ===== */
header {
  background: var(--primary-gradient);
  color: white;
  padding: 4rem 2rem;
  text-align: center;
}

header h1 {
  font-size: clamp(2rem, 5vw, 3.5rem);
  margin-bottom: 1rem;
  font-weight: 800;
}

header p {
  font-size: clamp(1rem, 2.5vw, 1.3rem);
  max-width: 700px;
  margin: 0 auto 2rem;
  opacity: 0.95;
}

.goal-box {
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  border-radius: 12px;
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
  text-align: left;
}

.goal-box h2 {
  font-size: 1.5rem;
  margin-bottom: 1rem;
}

.goal-box ul {
  list-style: none;
  padding-left: 0;
}

.goal-box li {
  padding: 0.5rem 0;
  padding-left: 1.5rem;
  position: relative;
}

.goal-box li::before {
  content: "\2713";
  position: absolute;
  left: 0;
  color: #a8ff78;
  font-weight: bold;
}

/* ===== PROGRESS TRACKING ===== */
.progress-container {
  background: white;
  padding: 1.5rem 2rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.05);
  position: sticky;
  top: 0;
  z-index: 500;
}

.progress-bar {
  width: 100%;
  height: 12px;
  background: var(--bg-light);
  border-radius: 6px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.progress-fill {
  height: 100%;
  background: var(--primary-gradient);
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 6px;
}

.progress-text {
  text-align: center;
  font-size: 0.9rem;
  color: #718096;
  margin: 0;
}

/* ===== TUTORIAL LAYOUT ===== */
.tutorial-container {
  display: flex;
  gap: 0;
  max-width: 100%;
  margin: 0 auto;
  background: var(--bg-gray);
}

/* Tutorial Sections - Left side (scrollable) */
.tutorial-sections {
  flex: 1;
  padding: 2rem;
  overflow-y: auto;
}

/* CodePen Area - Right side (sticky, fills remaining space) */
.codepen-area {
  position: sticky;
  top: 0;
  width: 60%;
  min-width: 600px;
  height: 100vh;
  background: white;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: all 0.3s ease;
}

.codepen-header {
  padding: 1.5rem;
  border-bottom: 2px solid var(--bg-gray);
  background: var(--primary-gradient);
  color: white;
}

.codepen-header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.codepen-header h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.3rem;
  padding-left: 0;
  border: none;
  color: white;
}

.codepen-header p {
  margin: 0;
  font-size: 0.9rem;
  opacity: 0.95;
}

/* Toggle Focus Button */
.toggle-focus-btn {
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid rgba(255, 255, 255, 0.3);
  padding: 0.75rem 1.25rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.3s ease;
  white-space: nowrap;
}

.toggle-focus-btn:hover {
  background: rgba(255, 255, 255, 0.3);
  border-color: rgba(255, 255, 255, 0.5);
  transform: translateY(-2px);
}

.toggle-focus-btn .icon {
  font-size: 1.2rem;
  line-height: 1;
}

.codepen-area iframe {
  flex: 1;
  width: 100%;
  border: none;
  background: #1e1e1e;
}

/* Focus Mode - CodePen takes full width */
.codepen-area.focus-mode {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 2000;
}

.tutorial-sections.hidden {
  display: none;
}

.tutorial-sections {
  transition: opacity 0.3s ease;
}

/* ===== TUTORIAL SECTIONS ===== */
.tutorial-section {
  background: white;
  margin: 0 0 2rem 0;
  padding: 2.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow);
  max-width: 900px;
  scroll-margin-top: 6rem;
}

.tutorial-section h2 {
  font-size: clamp(1.8rem, 4vw, 2.5rem);
  color: var(--primary-color);
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1rem;
}

.tutorial-section .part-number {
  background: var(--primary-gradient);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: bold;
  flex-shrink: 0;
}

.tutorial-section h3 {
  font-size: 1.5rem;
  color: var(--text-color);
  margin-top: 2rem;
  margin-bottom: 1rem;
  padding-left: 1rem;
  border-left: 4px solid var(--primary-color);
}

.tutorial-section p {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.tutorial-section strong {
  color: var(--primary-color);
}

/* Checkpoint section */
.checkpoint-section {
  background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
  border: 3px solid var(--primary-color);
}

.checkpoint-section h2 {
  color: var(--primary-color);
}

/* Completion section special styling */
.completion-section {
  background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
  border: 3px solid var(--primary-color);
}

.completion-section h2 {
  color: var(--primary-color);
  font-size: 2.5rem;
}

/* ===== LISTS ===== */
ul, ol {
  margin: 1.5rem 0;
  padding-left: 2rem;
}

li {
  margin: 0.5rem 0;
  font-size: 1.05rem;
}

/* ===== CODE BLOCKS ===== */
.code-block-wrapper {
  position: relative;
  margin: 1.5rem 0;
}

pre {
  background: #2d3748;
  color: #e2e8f0;
  padding: 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  max-width: 100%;
}

/* Custom scrollbar for code blocks */
pre::-webkit-scrollbar {
  height: 8px;
}

pre::-webkit-scrollbar-track {
  background: #1a202c;
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb {
  background: #4a5568;
  border-radius: 4px;
}

pre::-webkit-scrollbar-thumb:hover {
  background: #718096;
}

code {
  font-family: "Fira Code", "Courier New", monospace;
}

.inline-code, .tutorial-section code:not(pre code) {
  background: #edf2f7;
  color: #d53f8c;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
  font-size: 0.9em;
  font-family: "Fira Code", monospace;
}

/* Copy Code Button */
.copy-code-btn {
  position: absolute;
  top: 0.75rem;
  right: 0.75rem;
  background: rgba(255, 255, 255, 0.1);
  color: #e2e8f0;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  z-index: 10;
}

.copy-code-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-1px);
}

.copy-code-btn.copied {
  background: var(--success-color);
  border-color: var(--success-color);
  color: white;
}

.copy-code-btn .icon {
  font-size: 1rem;
  line-height: 1;
}

/* ===== SOLUTION BOXES ===== */
.solution-box {
  margin: 1rem 0 1.5rem 0;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  overflow: hidden;
  transition: all 0.3s;
}

.solution-box.hidden {
  display: none;
}

.solution-box pre {
  margin: 0;
  border-radius: 0;
}

.show-solution {
  background: var(--primary-gradient);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
  margin: 0.5rem 0;
}

.show-solution:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.show-solution:active {
  transform: translateY(0);
}

/* ===== INFO BOXES ===== */
.info-box {
  background: #ebf8ff;
  border-left: 4px solid var(--info-color);
  padding: 1.5rem;
  margin: 1.5rem 0;
  border-radius: 4px;
}

.info-box.research {
  background: #faf089;
  border-left-color: var(--warning-color);
}

.info-box.warning {
  background: #fed7d7;
  border-left-color: #e53e3e;
}

.info-box.success {
  background: #c6f6d5;
  border-left-color: var(--success-color);
}

.info-box h4 {
  margin-bottom: 0.5rem;
  font-size: 1.2rem;
}

.info-box p {
  margin-bottom: 0.5rem;
}

.info-box ul {
  margin-top: 0.5rem;
}

/* ===== REFLECTION BOXES ===== */
.reflection-box {
  background: var(--bg-light);
  border: 2px dashed #a0aec0;
  padding: 1.5rem;
  margin: 2rem 0;
  border-radius: 8px;
}

.reflection-box h4 {
  color: var(--primary-color);
  margin-bottom: 1rem;
  font-size: 1.2rem;
}

.reflection-box p {
  font-style: italic;
  color: #718096;
  margin-bottom: 1rem;
}

/* Response Textarea */
.response-area {
  width: 100%;
  padding: 1rem;
  border: 2px solid var(--border-color);
  border-radius: 6px;
  font-family: inherit;
  font-size: 1rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
  min-height: 80px;
}

.response-area:focus {
  outline: none;
  border-color: var(--primary-color);
}

.save-indicator {
  font-size: 0.85rem;
  color: var(--success-color);
  margin-top: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s;
}

.save-indicator.visible {
  opacity: 1;
}

/* ===== CHECKPOINTS ===== */
.checkpoint {
  background: white;
  border: 2px solid var(--border-color);
  padding: 1rem 1.5rem;
  margin: 1.5rem 0;
  border-radius: 8px;
  transition: all 0.3s;
}

.checkpoint:hover {
  border-color: var(--primary-color);
  background: var(--bg-light);
}

.checkpoint label {
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  font-size: 1.05rem;
}

.checkpoint input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: var(--primary-color);
}

.checkpoint.completed {
  background: #c6f6d5;
  border-color: var(--success-color);
}

/* ===== EXPORT SECTION ===== */
.export-section {
  background: white;
  padding: 2rem;
  text-align: center;
  margin: 2rem 0;
}

#export-responses {
  background: var(--success-color);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 8px;
  font-size: 1.1rem;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}

#export-responses:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(56, 161, 105, 0.3);
}

#export-responses:active {
  transform: translateY(0);
}

/* ===== FOOTER ===== */
footer {
  background: #2c3e50;
  color: white;
  text-align: center;
  padding: 2rem;
  margin-top: 4rem;
}

footer p {
  margin: 0.5rem 0;
}

footer p:last-child {
  font-size: 0.9rem;
  opacity: 0.8;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .tutorial-container {
    flex-direction: column;
  }

  .codepen-area {
    width: 100%;
    height: 500px;
    position: relative;
    min-width: unset;
  }

  .tutorial-sections {
    padding: 1rem;
  }

  .tutorial-section {
    margin-bottom: 1.5rem;
    padding: 1.5rem;
  }

  header {
    padding: 2rem 1rem;
  }

  .goal-box {
    padding: 1.5rem;
  }

  .progress-container {
    padding: 1rem 1.5rem;
  }

  /* Hide focus toggle on mobile (layout already stacks) */
  .toggle-focus-btn {
    display: none;
  }
}

/* ===== CHALLENGE BLOCKS ===== */

/* Challenge tag badges */
.challenge-tag-fill,
.challenge-tag-write {
  display: inline-block;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.6rem;
  border-radius: 4px;
  vertical-align: middle;
  margin-left: 0.5rem;
}

.challenge-tag-fill {
  background: #ebf8ff;
  color: var(--info-color);
  border: 1px solid var(--info-color);
}

.challenge-tag-write {
  background: #faf5ff;
  color: #805ad5;
  border: 1px solid #805ad5;
}

/* Challenge block container */
.challenge-block {
  background: #1a202c;
  border-radius: 8px;
  margin: 1.5rem 0;
  overflow: hidden;
  border: 2px solid #4a5568;
}

.challenge-block.write-prompt {
  background: #faf5ff;
  border: 2px dashed #805ad5;
  padding: 1.5rem;
}

.challenge-block.write-prompt p {
  color: #553c9a;
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.challenge-block.write-prompt ol {
  color: #553c9a;
}

/* Challenge code (with blanks) */
.challenge-code {
  background: #1a202c;
  color: #e2e8f0;
  padding: 1.5rem;
  margin: 0;
  font-size: 0.85rem;
  line-height: 1.6;
  overflow-x: auto;
}

/* The blank highlight */
.blank {
  background: #4a5568;
  color: #fbd38d;
  padding: 0.15rem 0.3rem;
  border-radius: 3px;
  border-bottom: 2px solid #fbd38d;
  font-weight: bold;
  letter-spacing: 0.05em;
}

/* Hint box inside challenge blocks */
.challenge-hint-box {
  background: #2d3748;
  border-top: 1px solid #4a5568;
  padding: 1rem 1.5rem;
  font-size: 0.9rem;
  color: #cbd5e0;
}

.challenge-hint-box strong {
  color: #fbd38d;
}

.challenge-hint-box ul {
  margin: 0.5rem 0 0 1.5rem;
  padding: 0;
}

.challenge-hint-box li {
  font-size: 0.9rem;
  color: #cbd5e0;
  margin: 0.25rem 0;
}

/* Write-prompt hint box (lighter) */
.write-prompt .challenge-hint-box {
  background: #f0e6ff;
  border-top: 1px solid #d6bcfa;
  color: #553c9a;
}

.write-prompt .challenge-hint-box strong {
  color: #805ad5;
}

.write-prompt .challenge-hint-box li {
  color: #553c9a;
}

/* ===== REDUCED MOTION ===== */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}
