/* ===== Reset & Base Styles ===== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --primary-color: #3b82f6;
  --primary-dark: #2563eb;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --bg-primary: #ffffff;
  --bg-secondary: #f8fafc;
  --bg-tertiary: #f1f5f9;
  --border-color: #e2e8f0;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Helvetica', 'Arial', sans-serif;
  line-height: 1.6;
  color: var(--text-primary);
  background: var(--bg-secondary);
}

code {
  font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
  background: var(--bg-tertiary);
  padding: 0.125rem 0.375rem;
  border-radius: 4px;
  font-size: 0.9em;
  color: #c7254e;
}

pre {
  margin: 1rem 0;
  padding: 1rem;
  background: #1e293b;
  color: #e2e8f0;
  border-radius: 8px;
  overflow-x: auto;
  font-size: 0.875rem;
  line-height: 1.5;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
}

/* ===== Tutorial Header ===== */
.tutorial-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 2rem 1.5rem 1.5rem;
  box-shadow: var(--shadow-md);
  position: sticky;
  top: 0;
  z-index: 100;
}

.tutorial-header h1 {
  font-size: 1.875rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.tutorial-header > p {
  font-size: 1rem;
  opacity: 0.95;
  margin-bottom: 1rem;
}

.progress-bar {
  background: rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  height: 24px;
  position: relative;
  overflow: hidden;
  backdrop-filter: blur(10px);
}

.progress-fill {
  background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
  height: 100%;
  width: 0%;
  transition: width 0.5s ease;
  border-radius: 12px;
}

.progress-text {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 0.75rem;
  font-weight: 600;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* ===== Two-Column Split View Container ===== */
.tutorial-container {
  display: flex;
  gap: 0;
  max-width: 1800px;
  margin: 0 auto;
  min-height: calc(100vh - 140px);
}

/* ===== Left Column: Tutorial Steps (Scrollable) ===== */
.tutorial-steps {
  flex: 0 0 45%;
  max-width: 45%;
  padding: 2rem 1.5rem;
  overflow-y: auto;
  height: calc(100vh - 140px);
  border-right: 1px solid var(--border-color);
  background: var(--bg-secondary);
}

/* ===== Right Column: CodePen Workspace (Sticky) ===== */
.codepen-workspace {
  flex: 1;
  position: relative;
  background: white;
}

.codepen-sticky {
  position: sticky;
  top: 140px;
  height: calc(100vh - 140px);
  display: flex;
  flex-direction: column;
  padding: 1.5rem;
}

.codepen-sticky h2 {
  font-size: 1.25rem;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.codepen-hint {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}

.codepen-embed {
  flex: 1;
  border-radius: 8px;
  overflow: hidden;
  border: 2px solid var(--border-color);
  box-shadow: var(--shadow-md);
  min-height: 0;
}

.codepen-embed iframe {
  display: block;
  height: 100%;
}

/* ===== Tutorial Introduction ===== */
.tutorial-intro {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  margin-bottom: 2rem;
}

.tutorial-intro h2 {
  font-size: 1.75rem;
  margin-bottom: 1rem;
  color: var(--text-primary);
}

.tutorial-intro ul {
  margin-left: 1.5rem;
  margin-top: 0.75rem;
}

.tutorial-intro li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* ===== Tutorial Sections ===== */
.tutorial-section {
  background: white;
  border-radius: 12px;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  overflow: hidden;
  scroll-margin-top: 120px;
}

.section-header {
  background: var(--bg-tertiary);
  padding: 1.5rem 2rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.section-header h2 {
  font-size: 1.5rem;
  font-weight: 600;
  margin: 0;
  flex: 1;
}

.section-progress {
  display: flex;
  align-items: center;
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  font-size: 0.9375rem;
  color: var(--text-secondary);
  user-select: none;
}

.checkbox-label input[type="checkbox"] {
  cursor: pointer;
  width: 18px;
  height: 18px;
}

.section-checkbox:checked + span {
  color: var(--success-color);
  font-weight: 600;
}

/* ===== Step Cards ===== */
.step-card {
  padding: 2rem;
  border-bottom: 1px solid var(--border-color);
}

.step-card:last-child {
  border-bottom: none;
}

.step-card h3 {
  font-size: 1.25rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.step-card h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.step-card p {
  margin-bottom: 1rem;
  color: var(--text-secondary);
}

.step-card ul {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.step-card li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

.step-card ol {
  margin-left: 1.5rem;
  margin-bottom: 1rem;
}

.step-card ol li {
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}

/* ===== Tip & Warning Boxes ===== */
.tip-box {
  background: #dbeafe;
  border-left: 4px solid var(--primary-color);
  padding: 1rem;
  border-radius: 6px;
  margin: 1rem 0;
}

.tip-box strong {
  color: var(--primary-dark);
  display: block;
  margin-bottom: 0.5rem;
}

.warning-box {
  background: #fef3c7;
  border-left: 4px solid var(--warning-color);
  padding: 1rem;
  border-radius: 6px;
  margin: 1rem 0;
}

.warning-box strong {
  color: #d97706;
  display: block;
  margin-bottom: 0.5rem;
}

/* ===== Solution Boxes ===== */
.solution-box {
  background: #f8fafc;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
  transition: all 0.3s;
}

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

.solution-box h4 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

/* ===== Resource Links ===== */
.resource-links {
  margin-top: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 6px;
  border: 1px solid var(--border-color);
}

.resource-links strong {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--text-primary);
}

.resource-links ul {
  list-style: none;
  margin-left: 0;
}

.resource-links li {
  margin-bottom: 0.375rem;
}

.resource-links a {
  color: var(--primary-color);
  text-decoration: none;
  font-size: 0.9375rem;
}

.resource-links a:hover {
  text-decoration: underline;
}

/* ===== Checkpoints ===== */
.checkpoint {
  background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
  border: 2px solid var(--primary-color);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 2rem;
}

.checkpoint h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.checklist {
  list-style: none;
  margin-left: 0;
  margin-bottom: 0;
}

.checklist li {
  padding: 0.5rem 0;
  color: var(--text-secondary);
  line-height: 1.8;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 0.75rem;
  align-items: start;
}

.checklist input[type="checkbox"] {
  margin-top: 0.3rem;
  cursor: pointer;
  flex-shrink: 0;
}

.checklist li code {
  white-space: nowrap;
  display: inline-block;
}

/* ===== Reflection Cards ===== */
.reflection-card {
  background: #faf5ff;
  border: 2px solid #e9d5ff;
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 2rem 2rem;
}

.reflection-card h4 {
  font-size: 1.125rem;
  font-weight: 600;
  margin-bottom: 0.75rem;
  color: var(--text-primary);
}

.reflection-card p {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
  font-style: italic;
}

.reflection-input {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e9d5ff;
  border-radius: 6px;
  font-family: inherit;
  font-size: 0.9375rem;
  line-height: 1.6;
  resize: vertical;
  transition: border-color 0.2s;
  margin-bottom: 0.75rem;
}

.reflection-input:focus {
  outline: none;
  border-color: #a78bfa;
}

.reflection-input.saved {
  border-color: var(--success-color);
  background: #f0fdf4;
}

/* ===== Buttons ===== */
.btn-primary,
.btn-secondary,
.btn-toggle-solution,
.btn-save-reflection {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 6px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-family: inherit;
  display: inline-block;
}

.btn-primary {
  background: var(--primary-color);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-toggle-solution {
  background: #fef3c7;
  color: #d97706;
  margin: 1rem 0;
}

.btn-toggle-solution:hover {
  background: #fde68a;
}

.btn-save-reflection {
  background: #e9d5ff;
  color: #7c3aed;
}

.btn-save-reflection:hover {
  background: #ddd6fe;
}

.btn-primary:focus-visible,
.btn-secondary:focus-visible,
.btn-toggle-solution:focus-visible,
.btn-save-reflection:focus-visible {
  outline: 2px solid var(--primary-color);
  outline-offset: 2px;
}

/* ===== Submission Section ===== */
#submission {
  background: linear-gradient(135deg, #f0fdf4 0%, #dbeafe 100%);
}

#submission h2 {
  padding: 1.5rem 2rem;
  font-size: 1.75rem;
  margin: 0;
}

.reflection-export {
  display: flex;
  gap: 1rem;
  margin: 1.5rem 0;
  flex-wrap: wrap;
}

/* ===== Responsive Design ===== */
@media (max-width: 1024px) {
  /* Stack columns vertically on tablets and below */
  .tutorial-container {
    flex-direction: column;
  }

  .tutorial-steps {
    flex: none;
    max-width: 100%;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    padding: 1.5rem 1rem;
  }

  .codepen-workspace {
    flex: none;
  }

  .codepen-sticky {
    position: relative;
    top: 0;
    height: 600px;
    padding: 1rem;
  }
}

@media (max-width: 768px) {
  .tutorial-header {
    padding: 1.5rem 1rem;
  }

  .tutorial-header h1 {
    font-size: 1.5rem;
  }

  .tutorial-intro,
  .step-card {
    padding: 1.5rem;
  }

  .checkpoint,
  .reflection-card {
    margin-left: 1.5rem;
    margin-right: 1.5rem;
    padding: 1rem;
  }

  .section-header {
    padding: 1rem 1.5rem;
  }

  .section-header h2 {
    font-size: 1.25rem;
  }

  pre {
    font-size: 0.75rem;
  }

  .reflection-export {
    flex-direction: column;
  }

  .reflection-export button {
    width: 100%;
  }

  .codepen-sticky {
    height: 500px;
  }
}

@media (max-width: 480px) {
  .tutorial-header h1 {
    font-size: 1.25rem;
  }

  .tutorial-header > p {
    font-size: 0.875rem;
  }

  .tutorial-steps {
    padding: 1rem;
  }

  .tutorial-intro,
  .step-card {
    padding: 1rem;
  }

  .checkpoint,
  .reflection-card {
    margin-left: 1rem;
    margin-right: 1rem;
  }

  .section-header {
    padding: 1rem;
  }

  .codepen-sticky {
    height: 400px;
  }
}

/* ===== Utility Classes ===== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}
