/**
 * ZivType Phase 4: Learn & Code Stylesheet
 * Touch Typing Curriculum & Code Syntax Typing Engine
 */

/* --- Curriculum Overview (/learn) --- */
.curriculum-hero {
  margin-bottom: 2.5rem;
  text-align: center;
}

.curriculum-hero h1 {
  font-size: 2.4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
  letter-spacing: -0.03em;
}

.curriculum-hero p {
  color: var(--text-muted);
  max-width: 680px;
  margin: 0 auto;
  font-size: 1.05rem;
}

.module-card {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg, 14px);
  padding: 0;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-card);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  overflow: hidden;
}

.module-card:hover {
  border-color: var(--accent-primary);
}

.module-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.module-title-wrap h2 {
  font-size: 1.35rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.module-title-wrap p {
  color: var(--text-muted);
  font-size: 0.92rem;
  max-width: 600px;
}

.module-stats {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.star-counter {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 20px;
  padding: 0.35rem 0.85rem;
  font-size: 0.9rem;
  font-weight: 700;
  color: #ffc107;
}

.progress-bar-wrap {
  width: 100%;
  height: 6px;
  background: var(--bg-base);
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.progress-bar-fill {
  height: 100%;
  background: var(--brand-primary);
  border-radius: 3px;
  transition: width 0.4s ease;
}

.lesson-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 1rem;
}

.lesson-card {
  display: block;
  text-decoration: none;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1.1rem;
  transition: all 0.2s ease;
  color: inherit;
  position: relative;
}

.lesson-card:hover:not(.locked) {
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

/* --- Stage Accordions & Pagination (Phase 7.4b.1) --- */
.stage-accordion-btn {
  width: 100%;
  display: block;
  background: transparent;
  border: none;
  padding: 1.5rem 1.75rem;
  margin: 0;
  cursor: pointer;
  text-align: left;
  color: var(--text-primary);
  font: inherit;
  transition: background-color var(--transition-fast);
  -webkit-appearance: none;
  appearance: none;
}

.stage-accordion-btn:hover {
  background-color: var(--bg-card-hover);
}

.stage-accordion-btn:focus-visible {
  outline: 2px solid var(--accent-primary);
  outline-offset: -2px;
}

.stage-header-inner {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 1.25rem;
}

.stage-title-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 0.4rem;
}

.stage-title-row h2 {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-primary);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin: 0;
}

.stage-num-badge {
  color: var(--accent-primary);
  font-family: var(--font-mono);
  font-size: 1.2rem;
}

.stage-badges-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.stage-desc {
  color: var(--text-secondary);
  font-size: 0.95rem;
  line-height: 1.55;
  margin: 0;
  max-width: 680px;
}

.stage-chevron {
  display: inline-block;
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-left: 0.25rem;
}

[aria-expanded="true"] .stage-chevron {
  transform: rotate(180deg);
}

.stage-status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.25rem 0.65rem;
  border-radius: var(--radius-full, 9999px);
}

.stage-status-pill.pill-unlocked {
  background: var(--accent-subtle);
  color: var(--accent-primary);
  border: 1px solid var(--accent-glow);
}

.stage-status-pill.pill-locked {
  background: var(--bg-subtle);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
}

.stage-status-pill.pill-completed {
  background: rgba(34, 197, 94, 0.14);
  color: var(--color-success);
  border: 1px solid rgba(34, 197, 94, 0.3);
}

.stage-lessons-body {
  padding: 0 1.75rem 1.75rem 1.75rem;
}

.stage-accordion-btn .progress-bar-wrap {
  margin-top: 1.25rem;
  margin-bottom: 0;
}

@media (max-width: 768px) {
  .stage-accordion-btn {
    padding: 1.25rem 1rem;
  }
  .stage-lessons-body {
    padding: 0 1rem 1.25rem 1rem;
  }
  .stage-title-row h2 {
    font-size: 1.15rem;
  }
}

.curriculum-filter-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 2rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 10px;
}

.curriculum-search-wrap {
  position: relative;
  flex: 1;
  min-width: 240px;
}

.curriculum-search-input {
  width: 100%;
  padding: 0.55rem 0.85rem;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  color: var(--text-base);
  font-size: 0.9rem;
}

.curriculum-search-input:focus {
  outline: none;
  border-color: var(--brand-primary);
  box-shadow: 0 0 0 2px rgba(82, 230, 0, 0.2);
}

.pagination-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
}

.pagination-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.4rem 0.85rem;
  font-size: 0.85rem;
  font-weight: 600;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  background: var(--bg-base);
  color: var(--text-base);
  text-decoration: none;
  cursor: pointer;
  transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
  border-color: var(--brand-primary);
  color: var(--brand-primary);
}

.pagination-btn.active {
  background: var(--brand-primary);
  color: #000;
  border-color: var(--brand-primary);
  font-weight: 700;
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.stage-locked-message {
  padding: 1.5rem;
  background: rgba(0, 0, 0, 0.2);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.92rem;
}

.lesson-card.locked {
  opacity: 0.5;
  cursor: not-allowed;
  border-style: dashed;
}

.lesson-num {
  font-size: 0.75rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  margin-bottom: 0.4rem;
}

.lesson-card h3 {
  font-size: 1rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.lesson-card p {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 0.75rem;
}

.lesson-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 0.82rem;
  font-weight: 600;
  padding-top: 0.5rem;
  border-top: 1px solid var(--border-color);
}

.stars-awarded {
  color: #ffc107;
  letter-spacing: 2px;
}

.lock-badge {
  color: var(--text-muted);
  font-size: 0.8rem;
}

/* --- Touch Typing Workspace (/learn/{module}/{lesson}) --- */
.lesson-workspace-wrap {
  max-width: 1060px;
  margin: 1rem auto 3rem auto;
  width: 100%;
}

.lesson-nav-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.lesson-nav-bar a {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

.lesson-nav-bar a:hover {
  color: var(--text-base);
}

.lesson-meta-strip {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.lesson-target-box {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 2.75rem 3.25rem;
  min-height: 190px;
  font-family: var(--font-mono);
  font-size: clamp(1.65rem, 2.8vw, 2.15rem);
  line-height: 2.4;
  letter-spacing: 0.04em;
  cursor: text;
  position: relative;
  user-select: none;
  margin-bottom: 2rem;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.25);
}

.target-char {
  position: relative;
  transition: color 0.08s, background-color 0.08s;
  color: var(--text-muted);
}

.target-char.correct {
  color: var(--text-base);
}

.target-char.incorrect {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.2);
  border-radius: 3px;
}

.target-char.current {
  color: var(--brand-primary);
  background: var(--accent-subtle);
  border-bottom: 3.5px solid var(--brand-primary);
  border-radius: 3px;
  font-weight: 700;
  box-shadow: 0 0 12px var(--accent-glow);
  padding: 0 2px;
}

/* Virtual Keyboard Visualizer */
.keyboard-guide-wrap {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 1.75rem 2rem;
  margin-top: 2rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.keyboard-guide-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.25rem;
}

.finger-indicator {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--brand-primary);
}

.virtual-keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  user-select: none;
  width: 100%;
}

.v-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 920px;
}

.v-key {
  flex: 1;
  height: 52px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-base);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-family: var(--font-mono);
  font-size: 1.05rem;
  font-weight: 600;
  color: var(--text-muted);
  transition: all 0.12s ease;
}

.v-key.key-wide { flex: 1.5; }
.v-key.key-wider { flex: 1.8; }
.v-key.key-space { flex: 6; }

.v-key.active-target {
  background: var(--brand-primary);
  color: #0b0f0c;
  border-color: var(--brand-primary);
  transform: translateY(-2px);
  box-shadow: 0 0 16px rgba(82, 230, 0, 0.5);
  font-weight: 700;
}

.v-key.home-anchor {
  border-bottom: 3px solid var(--text-muted);
}

@media (max-width: 768px) {
  .lesson-target-box {
    padding: 1.75rem 1.5rem;
    min-height: 150px;
    font-size: 1.45rem;
    line-height: 2.1;
  }
  .keyboard-guide-wrap {
    padding: 1.25rem 0.75rem;
  }
  .v-row {
    gap: 4px;
  }
  .v-key {
    height: 40px;
    font-size: 0.85rem;
    border-radius: 6px;
  }
}

@media (max-width: 480px) {
  .lesson-target-box {
    padding: 1.25rem 0.9rem;
    min-height: 130px;
    font-size: 1.25rem;
    line-height: 1.95;
    letter-spacing: 0.02em;
  }
  .keyboard-guide-wrap {
    padding: 0.75rem 0.4rem;
  }
  .v-row {
    gap: 2px;
  }
  .v-key {
    height: 32px;
    font-size: 0.72rem;
    border-radius: 4px;
    padding: 0;
  }
}

/* --- Programming Code Workspace (/learn/code) --- */
.code-practice-header {
  margin-bottom: 2rem;
}

.code-lang-selector {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.lang-tab {
  padding: 0.5rem 1.1rem;
  border-radius: 6px;
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  white-space: nowrap;
  transition: all 0.15s ease;
}

.lang-tab:hover {
  color: var(--text-base);
  background: var(--bg-surface);
}

.lang-tab.active {
  background: var(--bg-surface);
  color: var(--brand-primary);
  border-color: var(--border-color);
}

.code-layout-grid {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 1.75rem;
  align-items: start;
  max-width: 1080px;
  margin: 0 auto;
}

@media (max-width: 900px) {
  .code-layout-grid {
    grid-template-columns: 1fr;
  }
}

.snippet-sidebar {
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 1rem;
}

.snippet-item {
  display: block;
  padding: 0.75rem 0.9rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--text-base);
  margin-bottom: 0.4rem;
  border: 1px solid transparent;
  transition: all 0.15s ease;
}

.snippet-item:hover {
  background: var(--bg-base);
  border-color: var(--border-color);
}

.snippet-item.active {
  background: var(--bg-base);
  border-color: var(--brand-primary);
}

.snippet-item h4 {
  font-size: 0.92rem;
  font-weight: 600;
  margin-bottom: 0.2rem;
}

.snippet-difficulty {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-muted);
}

/* Code Editor */
.code-editor-container {
  background: #0d110e;
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
}

.code-editor-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: var(--bg-surface);
  padding: 0.75rem 1.25rem;
  border-bottom: 1px solid var(--border-color);
}

.code-editor-body {
  display: flex;
  min-height: 340px;
  font-family: var(--font-mono);
  font-size: clamp(1.15rem, 1.8vw, 1.35rem);
  line-height: 1.95;
  position: relative;
  cursor: text;
}

.code-line-numbers {
  padding: 1.25rem 0.75rem;
  color: #4a5d4e;
  text-align: right;
  user-select: none;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(0, 0, 0, 0.15);
}

.code-text-canvas {
  flex: 1;
  padding: 1.25rem 1.5rem;
  white-space: pre-wrap;
  word-break: break-all;
  position: relative;
  outline: none;
}

.code-char {
  color: #647b68;
}

.code-char.correct {
  color: #d6e2d8;
}

.code-char.incorrect {
  color: #ff4757;
  background: rgba(255, 71, 87, 0.25);
  border-radius: 2px;
}

.code-char.auto-indent {
  color: #3b493e;
  opacity: 0.6;
}

.code-char.current {
  color: var(--brand-primary);
  background: var(--accent-subtle);
  border-left: 3px solid var(--brand-primary);
  box-shadow: 0 0 10px var(--accent-glow);
}

/* Code Live Metrics */
.code-metrics-bar {
  display: flex;
  gap: 2rem;
  background: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  padding: 0.75rem 1.25rem;
  font-size: 0.88rem;
  color: var(--text-muted);
}

.code-metrics-bar strong {
  color: var(--text-base);
}
