/* ==========================================================================
   Learn Section Styles
   Comprehensive styles for the Learn/Course section of the financial exam
   prep website. Uses CSS custom properties defined in variables.css.
   ========================================================================== */

/* ==========================================================================
   1. LESSON LAYOUT
   ========================================================================== */

/* Wrapper that holds the reading column + sidebar TOC */
.lesson-layout {
  display: grid;
  grid-template-columns: 1fr 250px;
  gap: var(--space-2xl);
  max-width: calc(760px + 250px + var(--space-2xl));
  margin: 0 auto;
  padding: var(--space-xl) var(--container-padding);
  align-items: start;
}

.lesson {
  max-width: 760px;
  width: 100%;
  font-size: 1.125rem;
  line-height: 1.7;
  color: var(--color-text);
}

.lesson__header {
  margin-bottom: var(--space-2xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border);
}

.lesson__header h1 {
  font-family: var(--font-sans);
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
  margin: 0 0 var(--space-md) 0;
}

.lesson__meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-sm);
  color: var(--color-text-muted);
}

.lesson__meta-item {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
}

.lesson__meta-item svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.lesson__meta-divider {
  width: 4px;
  height: 4px;
  border-radius: var(--radius-full);
  background: var(--color-border);
}

.lesson__section {
  margin-bottom: var(--space-2xl);
}

.lesson__section h2 {
  font-family: var(--font-sans);
  font-size: var(--text-2xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  color: var(--color-text);
  margin: 0 0 var(--space-lg) 0;
  padding-top: var(--space-lg);
  scroll-margin-top: calc(var(--header-height) + var(--space-lg));
}

.lesson__section h3 {
  font-family: var(--font-sans);
  font-size: var(--text-xl);
  font-weight: var(--weight-semibold);
  line-height: var(--leading-tight);
  color: var(--color-text);
  margin: var(--space-xl) 0 var(--space-md) 0;
  scroll-margin-top: calc(var(--header-height) + var(--space-lg));
}

.lesson__section p {
  margin: 0 0 var(--space-md) 0;
}

.lesson__section ul,
.lesson__section ol {
  margin: 0 0 var(--space-md) 0;
  padding-left: var(--space-xl);
}

.lesson__section li {
  margin-bottom: var(--space-xs);
}

.lesson__section li::marker {
  color: var(--color-primary);
}

.lesson__section strong {
  font-weight: var(--weight-semibold);
  color: var(--color-text);
}

.lesson__section code {
  font-family: var(--font-mono);
  font-size: 0.9em;
  background: var(--color-primary-bg);
  color: var(--color-primary-dark);
  padding: 0.15em 0.4em;
  border-radius: var(--radius-sm);
}

.lesson__section blockquote {
  margin: var(--space-lg) 0;
  padding: var(--space-md) var(--space-lg);
  border-left: 3px solid var(--color-border);
  color: var(--color-text-secondary);
  font-style: italic;
  background: var(--color-bg);
  border-radius: 0 var(--radius-md) var(--radius-md) 0;
}

.lesson__resources {
  margin-top: var(--space-2xl);
  padding: var(--space-xl);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
}

.lesson__resources h3 {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-md) 0;
  color: var(--color-text);
}

.lesson__resources ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lesson__resources li {
  margin-bottom: var(--space-sm);
}

.lesson__resources a {
  color: var(--color-primary);
  text-decoration: none;
  font-weight: var(--weight-medium);
  transition: color var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
}

.lesson__resources a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.lesson__resources a svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}


/* ==========================================================================
   2. STICKY TABLE OF CONTENTS
   ========================================================================== */

.lesson__toc {
  position: sticky;
  top: calc(var(--header-height) + var(--space-xl));
  max-height: calc(100vh - var(--header-height) - var(--space-2xl));
  max-height: calc(100dvh - var(--header-height) - var(--space-2xl));
  overflow-y: auto;
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  contain: layout style;
}

.lesson__toc-title {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin: 0 0 var(--space-md) 0;
}

.lesson__toc-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.lesson__toc-item {
  margin-bottom: 0;
}

.lesson__toc-link {
  display: block;
  padding: var(--space-xs) var(--space-sm);
  color: var(--color-text-secondary);
  text-decoration: none;
  border-left: 2px solid transparent;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  transition: all var(--transition-fast);
  line-height: var(--leading-normal);
}

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

.lesson__toc-link--active {
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border-left-color: var(--color-primary);
  font-weight: var(--weight-medium);
}

.lesson__toc-link--nested {
  padding-left: var(--space-lg);
  font-size: var(--text-xs);
}


/* ==========================================================================
   3. CALLOUT BOXES
   ========================================================================== */

.callout {
  position: relative;
  margin: var(--space-xl) 0;
  padding: var(--space-lg);
  padding-left: calc(var(--space-lg) + 4px);
  border-left: 4px solid var(--color-border);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
  background: var(--color-bg);
}

.callout__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-sm);
  flex-shrink: 0;
}

.callout__icon svg {
  width: 16px;
  height: 16px;
}

.callout__header {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  margin-bottom: var(--space-sm);
}

.callout__title {
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  margin: 0;
  line-height: var(--leading-normal);
}

.callout__content {
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text-secondary);
}

.callout__content p:last-child {
  margin-bottom: 0;
}

/* Definition - Blue */
.callout--definition {
  border-left-color: #3b82f6;
  background: #eff6ff;
}

.callout--definition .callout__icon {
  background: rgba(59, 130, 246, 0.12);
  color: #3b82f6;
}

.callout--definition .callout__title {
  color: #1e40af;
}

/* Exam Tip - Amber */
.callout--exam-tip {
  border-left-color: #f59e0b;
  background: #fffbeb;
}

.callout--exam-tip .callout__icon {
  background: rgba(245, 158, 11, 0.12);
  color: #f59e0b;
}

.callout--exam-tip .callout__title {
  color: #92400e;
}

/* Takeaway - Green */
.callout--takeaway {
  border-left-color: #10b981;
  background: #ecfdf5;
}

.callout--takeaway .callout__icon {
  background: rgba(16, 185, 129, 0.12);
  color: #10b981;
}

.callout--takeaway .callout__title {
  color: #065f46;
}

/* Mnemonic - Purple */
.callout--mnemonic {
  border-left-color: #8b5cf6;
  background: #f5f3ff;
}

.callout--mnemonic .callout__icon {
  background: rgba(139, 92, 246, 0.12);
  color: #8b5cf6;
}

.callout--mnemonic .callout__title {
  color: #5b21b6;
}

/* Warning - Red */
.callout--warning {
  border-left-color: #ef4444;
  background: #fef2f2;
}

.callout--warning .callout__icon {
  background: rgba(239, 68, 68, 0.12);
  color: #ef4444;
}

.callout--warning .callout__title {
  color: #991b1b;
}

/* Example - Gray */
.callout--example {
  border-left-color: #94a3b8;
  background: #f8fafc;
}

.callout--example .callout__icon {
  background: rgba(148, 163, 184, 0.12);
  color: #64748b;
}

.callout--example .callout__title {
  color: #475569;
}


/* ==========================================================================
   4. COMPARE TABLES
   ========================================================================== */

.compare-table {
  width: 100%;
  margin: var(--space-xl) 0;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
}

.compare-table table {
  width: 100%;
  border-collapse: collapse;
  min-width: 500px;
  font-size: var(--text-sm);
}

.compare-table__header {
  background: var(--color-primary-bg);
}

.compare-table__header th {
  padding: var(--space-md) var(--space-lg);
  text-align: left;
  font-weight: var(--weight-semibold);
  font-size: var(--text-sm);
  color: var(--color-primary-dark);
  border-bottom: 2px solid var(--color-primary-light);
  white-space: nowrap;
}

.compare-table__row {
  transition: background-color var(--transition-fast);
}

.compare-table__row:nth-child(even) {
  background: var(--color-bg);
}

.compare-table__row:hover {
  background: var(--color-primary-bg);
}

.compare-table__row--highlight {
  background: rgba(59, 130, 246, 0.08) !important;
  box-shadow: inset 3px 0 0 var(--color-primary);
}

.compare-table__cell {
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--color-border-light, var(--color-border));
  color: var(--color-text-secondary);
  vertical-align: top;
  line-height: var(--leading-relaxed);
}

.compare-table__cell:first-child {
  font-weight: var(--weight-medium);
  color: var(--color-text);
}

.compare-table__col--highlight {
  background: rgba(59, 130, 246, 0.05);
}

.compare-table__footer {
  background: var(--color-bg);
}

.compare-table__footer td {
  padding: var(--space-sm) var(--space-lg);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  border-top: 2px solid var(--color-border);
}


/* ==========================================================================
   5. SVG DIAGRAMS
   ========================================================================== */

.diagram {
  margin: var(--space-2xl) 0;
  text-align: center;
}

.diagram__svg {
  display: block;
  max-width: 100%;
  height: auto;
  margin: 0 auto;
}

/* SVG internal element styles */
.diagram__svg .node {
  fill: var(--color-surface);
  stroke: var(--color-primary);
  stroke-width: 2;
}

.diagram__svg .node--accent {
  fill: var(--color-accent-bg);
  stroke: var(--color-accent);
}

.diagram__svg .node--purple {
  fill: var(--color-purple-bg);
  stroke: var(--color-purple);
}

.diagram__svg .node--warning {
  fill: var(--color-warning-bg, #fffbeb);
  stroke: var(--color-warning);
}

.diagram__svg .node--danger {
  fill: var(--color-danger-bg, #fef2f2);
  stroke: var(--color-danger);
}

.diagram__svg .edge {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 2;
}

.diagram__svg .edge--primary {
  stroke: var(--color-primary-light);
}

.diagram__svg .edge--accent {
  stroke: var(--color-accent);
}

.diagram__svg .edge--dashed {
  stroke-dasharray: 6, 4;
}

.diagram__svg .label {
  font-family: var(--font-sans);
  font-size: 13px;
  fill: var(--color-text);
  text-anchor: middle;
  dominant-baseline: central;
}

.diagram__svg .label--small {
  font-size: 11px;
  fill: var(--color-text-muted);
}

.diagram__svg .label--bold {
  font-weight: var(--weight-semibold);
}

.diagram__svg .arrow {
  fill: var(--color-border);
}

.diagram__svg .arrow--primary {
  fill: var(--color-primary-light);
}

.diagram figcaption {
  margin-top: var(--space-md);
  font-size: var(--text-sm);
  font-style: italic;
  color: var(--color-text-muted);
  line-height: var(--leading-normal);
}


/* ==========================================================================
   6. PROCESS STEPS
   ========================================================================== */

.process-steps {
  position: relative;
  margin: var(--space-2xl) 0;
  padding-left: var(--space-lg);
}

.process-steps__track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: calc(var(--space-lg) + 17px);
  width: 2px;
  background: var(--color-border);
}

.process-step {
  position: relative;
  display: flex;
  gap: var(--space-lg);
  margin-bottom: var(--space-xl);
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.5s ease, transform 0.5s ease;
}

.process-step--visible {
  opacity: 1;
  transform: translateY(0);
}

/* Staggered animation delays */
.process-step:nth-child(1) { transition-delay: 0s; }
.process-step:nth-child(2) { transition-delay: 0.1s; }
.process-step:nth-child(3) { transition-delay: 0.2s; }
.process-step:nth-child(4) { transition-delay: 0.3s; }
.process-step:nth-child(5) { transition-delay: 0.4s; }
.process-step:nth-child(6) { transition-delay: 0.5s; }
.process-step:nth-child(7) { transition-delay: 0.6s; }
.process-step:nth-child(8) { transition-delay: 0.7s; }
.process-step:nth-child(9) { transition-delay: 0.8s; }
.process-step:nth-child(10) { transition-delay: 0.9s; }

.process-step__marker {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-primary);
  color: var(--color-primary);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
  z-index: 1;
  transition: all var(--transition-base);
}

.process-step--visible .process-step__marker {
  background: var(--color-primary);
  color: var(--color-surface);
}

.process-step--completed .process-step__marker {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-surface);
}

.process-step__content {
  flex: 1;
  padding-top: var(--space-xs);
}

.process-step__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0 0 var(--space-xs) 0;
  line-height: var(--leading-tight);
}

.process-step__description {
  font-size: var(--text-base);
  color: var(--color-text-secondary);
  line-height: 1.6;
  margin: 0;
}


/* ==========================================================================
   7. DEEP DIVE / DETAILS
   ========================================================================== */

.deep-dive {
  margin: var(--space-xl) 0;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-surface);
  overflow: hidden;
  transition: background-color var(--transition-base);
}

.deep-dive[open] {
  background: var(--color-bg);
}

.deep-dive summary {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  cursor: pointer;
  list-style: none;
  user-select: none;
  transition: background-color var(--transition-fast);
}

.deep-dive summary::-webkit-details-marker {
  display: none;
}

.deep-dive summary::marker {
  display: none;
  content: "";
}

.deep-dive summary:hover {
  background: var(--color-bg);
}

.deep-dive summary::before {
  content: "";
  display: inline-block;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
  background-image: 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='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='9 18 15 12 9 6'%3E%3C/polyline%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  transition: transform var(--transition-fast);
}

.deep-dive[open] summary::before {
  transform: rotate(90deg);
}

.deep-dive__label {
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-primary);
  background: var(--color-primary-bg);
  padding: 2px var(--space-sm);
  border-radius: var(--radius-sm);
  margin-right: var(--space-xs);
}

.deep-dive__content {
  padding: 0 var(--space-lg) var(--space-lg);
  font-size: var(--text-base);
  line-height: 1.7;
  color: var(--color-text-secondary);
  border-top: 1px solid var(--color-border-light, var(--color-border));
}

.deep-dive__content p:first-child {
  margin-top: var(--space-lg);
}

.deep-dive__content p:last-child {
  margin-bottom: 0;
}


/* ==========================================================================
   8. CALCULATORS
   ========================================================================== */

.calculator {
  margin: var(--space-xl) 0;
  padding: var(--space-xl);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-sm);
}

.calculator__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-xs) 0;
}

.calculator__description {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-lg) 0;
  line-height: var(--leading-relaxed);
}

.calculator__inputs {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-lg);
}

.calculator__field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.calculator__label {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
}

.calculator__input {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-family: var(--font-mono);
  font-size: var(--text-base);
  color: var(--color-text);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
  outline: none;
}

.calculator__input:focus {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(26, 86, 219, 0.1);
}

.calculator__input::placeholder {
  color: var(--color-text-muted);
  font-family: var(--font-sans);
}

.calculator__actions {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-lg);
}

.calculator__btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-surface);
  background: var(--color-primary);
  border: none;
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.calculator__btn:hover {
  background: var(--color-primary-dark);
}

.calculator__btn:active {
  transform: scale(0.98);
}

.calculator__btn--reset {
  color: var(--color-text-secondary);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
}

.calculator__btn--reset:hover {
  background: var(--color-border);
}

.calculator__result {
  padding: var(--space-lg);
  background: var(--color-primary-bg);
  border: 1px solid rgba(26, 86, 219, 0.15);
  border-radius: var(--radius-lg);
  text-align: center;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.calculator__result--visible {
  opacity: 1;
  transform: translateY(0);
}

.calculator__result-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}

.calculator__result-value {
  font-family: var(--font-mono);
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
  line-height: var(--leading-tight);
}

.calculator__result-detail {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}

.calculator__breakdown {
  margin-top: var(--space-lg);
  padding-top: var(--space-lg);
  border-top: 1px solid var(--color-border-light, var(--color-border));
}

.calculator__breakdown-row {
  display: flex;
  justify-content: space-between;
  padding: var(--space-xs) 0;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
}

.calculator__breakdown-row strong {
  color: var(--color-text);
  font-weight: var(--weight-medium);
}


/* ==========================================================================
   9. LESSON QUIZ
   ========================================================================== */

.lesson-quiz {
  margin: var(--space-2xl) 0;
  padding: var(--space-xl);
  background: var(--color-bg);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
}

.lesson-quiz__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-xs) 0;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
}

.lesson-quiz__title svg {
  width: 22px;
  height: 22px;
  color: var(--color-primary);
}

.lesson-quiz__subtitle {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin: 0 0 var(--space-xl) 0;
}

.lesson-quiz__item {
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-xl);
  border-bottom: 1px solid var(--color-border-light, var(--color-border));
}

.lesson-quiz__item:last-child {
  margin-bottom: 0;
  padding-bottom: 0;
  border-bottom: none;
}

.lesson-quiz__question {
  display: flex;
  gap: var(--space-sm);
  margin-bottom: var(--space-md);
}

.lesson-quiz__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--color-primary);
  color: var(--color-surface);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  flex-shrink: 0;
  margin-top: 2px;
}

.lesson-quiz__question-text {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  line-height: var(--leading-relaxed);
  margin: 0;
}

.lesson-quiz__options {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-left: calc(28px + var(--space-sm));
}

.lesson-quiz__option {
  display: flex;
  align-items: flex-start;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  transition: all var(--transition-fast);
}

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

.lesson-quiz__option--selected {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
  color: var(--color-text);
  font-weight: var(--weight-medium);
}

.lesson-quiz__option--correct {
  border-color: var(--color-accent);
  background: var(--color-accent-bg);
  color: var(--color-text);
}

.lesson-quiz__option--incorrect {
  border-color: var(--color-danger);
  background: var(--color-danger-bg, #fef2f2);
  color: var(--color-text);
}

.lesson-quiz__option-letter {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  border-radius: var(--radius-full);
  background: var(--color-bg);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
  flex-shrink: 0;
  margin-top: 1px;
  transition: all var(--transition-fast);
}

.lesson-quiz__option--selected .lesson-quiz__option-letter {
  background: var(--color-primary);
  color: var(--color-surface);
}

.lesson-quiz__option--correct .lesson-quiz__option-letter {
  background: var(--color-accent);
  color: var(--color-surface);
}

.lesson-quiz__option--incorrect .lesson-quiz__option-letter {
  background: var(--color-danger);
  color: var(--color-surface);
}

.lesson-quiz__feedback {
  margin-top: var(--space-md);
  margin-left: calc(28px + var(--space-sm));
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  line-height: var(--leading-relaxed);
  opacity: 0;
  transform: translateY(-4px);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.lesson-quiz__feedback--visible {
  opacity: 1;
  transform: translateY(0);
}

.lesson-quiz__feedback--correct {
  background: var(--color-accent-bg);
  color: #065f46;
  border: 1px solid rgba(16, 185, 129, 0.2);
}

.lesson-quiz__feedback--incorrect {
  background: var(--color-danger-bg, #fef2f2);
  color: #991b1b;
  border: 1px solid rgba(239, 68, 68, 0.2);
}

.lesson-quiz__explanation {
  margin-top: var(--space-sm);
  padding-top: var(--space-sm);
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  opacity: 0;
  max-height: 0;
  overflow: hidden;
  transition: opacity 0.3s ease, max-height 0.4s ease;
}

.lesson-quiz__explanation--visible {
  opacity: 1;
  max-height: 500px;
}

.lesson-quiz__score {
  text-align: center;
  padding: var(--space-xl);
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  margin-top: var(--space-xl);
}

.lesson-quiz__score-value {
  font-size: var(--text-4xl);
  font-weight: var(--weight-bold);
  color: var(--color-primary);
}

.lesson-quiz__score-label {
  font-size: var(--text-sm);
  color: var(--color-text-muted);
  margin-top: var(--space-xs);
}


/* ==========================================================================
   10. COURSE CATALOG PAGE
   ========================================================================== */

.course-catalog {
  padding: var(--space-xl) 0;
}

.course-catalog__grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: var(--space-xl);
}

.course-card {
  position: relative;
  display: flex;
  flex-direction: column;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: var(--space-xl);
  transition: transform var(--transition-base), box-shadow var(--transition-base);
  cursor: pointer;
  text-decoration: none;
  color: inherit;
}

.course-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}

.course-card__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: var(--space-md);
}

.course-card__progress {
  position: relative;
  width: 48px;
  height: 48px;
  flex-shrink: 0;
}

.course-card__progress-ring {
  transform: rotate(-90deg);
}

.course-card__progress-track {
  fill: none;
  stroke: var(--color-border);
  stroke-width: 3;
}

.course-card__progress-fill {
  fill: none;
  stroke: var(--color-primary);
  stroke-width: 3;
  stroke-linecap: round;
  transition: stroke-dashoffset var(--transition-slow);
}

.course-card__progress-fill--complete {
  stroke: var(--color-accent);
}

.course-card__progress-text {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  color: var(--color-text);
}

.course-card__badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px var(--space-sm);
  font-size: var(--text-xs);
  font-weight: var(--weight-bold);
  border-radius: var(--radius-full);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.course-card__badge--cfa {
  background: var(--color-primary-bg);
  color: var(--color-primary);
}

.course-card__badge--frm {
  background: var(--color-accent-bg);
  color: var(--color-accent-dark, #059669);
}

.course-card__badge--cpa {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}

.course-card__title {
  font-size: var(--text-lg);
  font-weight: var(--weight-bold);
  color: var(--color-text);
  margin: 0 0 var(--space-sm) 0;
  line-height: var(--leading-tight);
}

.course-card__description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-lg) 0;
  flex-grow: 1;
}

.course-card__meta {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
  margin-bottom: var(--space-lg);
}

.course-card__meta-item {
  display: flex;
  align-items: center;
  gap: 4px;
}

.course-card__meta-item svg {
  width: 14px;
  height: 14px;
}

.course-card__cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: var(--space-sm) var(--space-lg);
  font-family: var(--font-sans);
  font-size: var(--text-sm);
  font-weight: var(--weight-semibold);
  color: var(--color-primary);
  background: var(--color-primary-bg);
  border: 1px solid rgba(26, 86, 219, 0.15);
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  text-decoration: none;
  cursor: pointer;
}

.course-card__cta:hover {
  background: var(--color-primary);
  color: var(--color-surface);
}

.course-card__cta svg {
  width: 16px;
  height: 16px;
}

.course-card--completed .course-card__cta {
  background: var(--color-accent-bg);
  color: var(--color-accent);
  border-color: rgba(16, 185, 129, 0.15);
}

.course-card--completed .course-card__cta:hover {
  background: var(--color-accent);
  color: var(--color-surface);
}


/* ==========================================================================
   11. COURSE OVERVIEW PAGE — CHAPTER LIST
   ========================================================================== */

.chapter-list {
  position: relative;
  padding: var(--space-xl) 0;
  list-style: none;
  margin: 0;
}

/* The vertical timeline connector */
.chapter-list::before {
  content: "";
  position: absolute;
  top: var(--space-xl);
  bottom: var(--space-xl);
  left: 23px;
  width: 2px;
  background: var(--color-border);
}

.chapter-item {
  position: relative;
  display: flex;
  gap: var(--space-lg);
  padding: var(--space-md) 0;
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
}

.chapter-item + .chapter-item {
  margin-top: var(--space-sm);
}

.chapter-item__number {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border-radius: var(--radius-full);
  background: var(--color-surface);
  border: 2px solid var(--color-border);
  font-size: var(--text-sm);
  font-weight: var(--weight-bold);
  color: var(--color-text-muted);
  flex-shrink: 0;
  z-index: 1;
  transition: all var(--transition-base);
}

.chapter-item__body {
  flex: 1;
  padding: var(--space-md) var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: all var(--transition-fast);
}

.chapter-item:hover .chapter-item__body {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-sm);
}

.chapter-item__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--color-text);
  margin: 0 0 var(--space-xs) 0;
  line-height: var(--leading-tight);
}

.chapter-item__description {
  font-size: var(--text-sm);
  color: var(--color-text-secondary);
  line-height: var(--leading-relaxed);
  margin: 0 0 var(--space-sm) 0;
}

.chapter-item__footer {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  font-size: var(--text-xs);
  color: var(--color-text-muted);
}

.chapter-item__read-time {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chapter-item__read-time svg {
  width: 14px;
  height: 14px;
}

.chapter-item__status {
  display: flex;
  align-items: center;
  gap: 4px;
  font-weight: var(--weight-medium);
}

.chapter-item__status svg {
  width: 14px;
  height: 14px;
}

/* Current chapter */
.chapter-item--current .chapter-item__number {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: var(--color-surface);
  box-shadow: 0 0 0 4px rgba(26, 86, 219, 0.15);
}

.chapter-item--current .chapter-item__body {
  border-color: var(--color-primary);
  background: var(--color-primary-bg);
}

.chapter-item--current .chapter-item__status {
  color: var(--color-primary);
}

/* Completed chapter */
.chapter-item--completed .chapter-item__number {
  background: var(--color-accent);
  border-color: var(--color-accent);
  color: var(--color-surface);
}

.chapter-item--completed .chapter-item__status {
  color: var(--color-accent);
}

/* Locked chapter */
.chapter-item--locked {
  opacity: 0.55;
  pointer-events: none;
}

.chapter-item--locked .chapter-item__number {
  background: var(--color-bg);
  border-color: var(--color-border);
  color: var(--color-text-muted);
}


/* ==========================================================================
   12. LEARN HERO
   ========================================================================== */

.learn-hero {
  background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 50%, var(--color-primary-light) 100%);
  color: var(--color-surface);
  padding: var(--space-3xl) var(--container-padding);
  text-align: center;
}

.learn-hero__container {
  max-width: var(--container-max);
  margin: 0 auto;
}

.learn-hero__badge {
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  padding: var(--space-xs) var(--space-md);
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius-full);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: var(--space-lg);
  backdrop-filter: blur(4px);
}

.learn-hero__title {
  font-size: var(--text-5xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
  margin: 0 0 var(--space-md) 0;
  color: white;
}

.learn-hero__subtitle {
  font-size: var(--text-xl);
  line-height: var(--leading-relaxed);
  color: rgba(255, 255, 255, 0.9);
  max-width: 600px;
  margin: 0 auto var(--space-2xl);
}

.learn-hero__stats {
  display: flex;
  justify-content: center;
  gap: var(--space-2xl);
  padding-top: var(--space-xl);
  border-top: 1px solid rgba(255, 255, 255, 0.2);
}

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

.learn-hero__stat-value {
  display: block;
  font-size: var(--text-3xl);
  font-weight: var(--weight-bold);
  line-height: var(--leading-tight);
}

.learn-hero__stat-label {
  display: block;
  font-size: var(--text-sm);
  opacity: 0.8;
  margin-top: var(--space-xs);
}


/* ==========================================================================
   13. PREV/NEXT CHAPTER NAVIGATION
   ========================================================================== */

.lesson__nav {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: var(--space-lg);
  margin-top: var(--space-3xl);
  padding-top: var(--space-xl);
  border-top: 1px solid var(--color-border);
}

.lesson__nav-link {
  display: flex;
  align-items: center;
  gap: var(--space-md);
  padding: var(--space-lg);
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
}

.lesson__nav-link:hover {
  border-color: var(--color-primary-light);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.lesson__nav-link--prev {
  justify-content: flex-start;
}

.lesson__nav-link--next {
  justify-content: flex-end;
  text-align: right;
  grid-column: 2;
}

/* When only next exists, push to right */
.lesson__nav-link--next:first-child {
  grid-column: 2;
}

.lesson__nav-arrow {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-full);
  background: var(--color-primary-bg);
  color: var(--color-primary);
  flex-shrink: 0;
  transition: all var(--transition-fast);
}

.lesson__nav-link:hover .lesson__nav-arrow {
  background: var(--color-primary);
  color: var(--color-surface);
}

.lesson__nav-arrow svg {
  width: 18px;
  height: 18px;
}

.lesson__nav-label {
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
  margin-bottom: 2px;
}

.lesson__nav-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--color-text);
  line-height: var(--leading-tight);
}


/* ==========================================================================
   14. MARK COMPLETE BUTTON
   ========================================================================== */

.lesson__complete {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-sm);
  width: 100%;
  padding: var(--space-md) var(--space-xl);
  margin: var(--space-2xl) 0;
  font-family: var(--font-sans);
  font-size: var(--text-base);
  font-weight: var(--weight-bold);
  color: var(--color-surface);
  background: var(--color-primary);
  border: 2px solid var(--color-primary);
  border-radius: var(--radius-lg);
  cursor: pointer;
  transition: all var(--transition-base);
  position: relative;
  overflow: hidden;
}

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

.lesson__complete:active {
  transform: translateY(0);
  box-shadow: none;
}

.lesson__complete svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Completed state */
.lesson__complete--done {
  background: var(--color-accent);
  border-color: var(--color-accent);
  cursor: default;
}

.lesson__complete--done:hover {
  background: var(--color-accent);
  border-color: var(--color-accent);
  transform: none;
  box-shadow: none;
}

/* Ripple effect on click */
.lesson__complete::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.25);
  border-radius: inherit;
  transform: scale(0);
  opacity: 0;
  transition: transform 0.4s ease, opacity 0.4s ease;
}

.lesson__complete:active::after {
  transform: scale(2.5);
  opacity: 0;
}

/* Confetti-like animation on completion */
@keyframes lesson-complete-pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

.lesson__complete--animating {
  animation: lesson-complete-pop 0.4s ease;
}


/* ==========================================================================
   15. RESPONSIVE DESIGN
   ========================================================================== */

/* Desktop / Large (above 1024px) handled by default styles above */

/* Tablet — below 1024px */
@media (max-width: 1024px) {
  .lesson-layout {
    grid-template-columns: 1fr;
    max-width: 760px;
  }

  .lesson__toc {
    display: none;
  }

  .learn-hero__title {
    font-size: var(--text-4xl);
  }

  .learn-hero__stats {
    gap: var(--space-xl);
  }
}

/* Tablet / Small — below 768px */
@media (max-width: 768px) {
  .lesson {
    font-size: 1rem;
  }

  .lesson__header h1 {
    font-size: var(--text-3xl);
  }

  .lesson__section h2 {
    font-size: var(--text-xl);
  }

  .lesson__section h3 {
    font-size: var(--text-lg);
  }

  /* Compare tables: horizontal scroll */
  .compare-table {
    margin-left: calc(-1 * var(--container-padding));
    margin-right: calc(-1 * var(--container-padding));
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  /* Calculator inputs stack */
  .calculator__inputs {
    grid-template-columns: 1fr;
  }

  .calculator {
    padding: var(--space-lg);
  }

  /* Course catalog 2-column */
  .course-catalog__grid {
    grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
    gap: var(--space-lg);
  }

  /* Chapter list adjustments */
  .chapter-item__body {
    padding: var(--space-sm) var(--space-md);
  }

  .chapter-item__description {
    display: none;
  }

  .chapter-item__number {
    width: 40px;
    height: 40px;
    font-size: var(--text-xs);
  }

  .chapter-list::before {
    left: 19px;
  }

  /* Lesson nav stacks on tablet */
  .lesson__nav {
    grid-template-columns: 1fr;
    gap: var(--space-md);
  }

  .lesson__nav-link--next {
    grid-column: 1;
    text-align: left;
    justify-content: flex-start;
    flex-direction: row-reverse;
  }

  /* Learn hero */
  .learn-hero {
    padding: var(--space-2xl) var(--container-padding);
  }

  .learn-hero__title {
    font-size: var(--text-3xl);
  }

  .learn-hero__subtitle {
    font-size: var(--text-base);
  }

  .learn-hero__stats {
    flex-wrap: wrap;
    gap: var(--space-lg);
  }

  .learn-hero__stat-value {
    font-size: var(--text-2xl);
  }

  /* Process steps */
  .process-steps {
    padding-left: 0;
  }

  .process-steps__track {
    left: 17px;
  }

  .process-step__marker {
    width: 32px;
    height: 32px;
    font-size: var(--text-xs);
  }

  /* Callout boxes */
  .callout {
    padding: var(--space-md);
    padding-left: calc(var(--space-md) + 4px);
  }

  /* Quiz option margins */
  .lesson-quiz__options {
    margin-left: 0;
  }

  .lesson-quiz__feedback {
    margin-left: 0;
  }
}

/* Mobile — below 640px */
@media (max-width: 640px) {
  .lesson-layout {
    padding: var(--space-md) var(--space-sm);
  }

  .lesson__header h1 {
    font-size: var(--text-2xl);
  }

  .lesson__meta {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-xs);
  }

  .lesson__meta-divider {
    display: none;
  }

  /* Course catalog single column */
  .course-catalog__grid {
    grid-template-columns: 1fr;
  }

  .course-card {
    padding: var(--space-lg);
  }

  /* Calculator */
  .calculator__result-value {
    font-size: var(--text-2xl);
  }

  .calculator__actions {
    flex-direction: column;
  }

  .calculator__btn {
    justify-content: center;
  }

  /* Learn hero */
  .learn-hero__title {
    font-size: var(--text-2xl);
  }

  .learn-hero__stats {
    flex-direction: column;
    align-items: center;
    gap: var(--space-md);
  }

  /* Quiz */
  .lesson-quiz {
    padding: var(--space-md);
    margin-left: calc(-1 * var(--space-sm));
    margin-right: calc(-1 * var(--space-sm));
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .lesson-quiz__question {
    flex-direction: column;
  }

  .lesson-quiz__option {
    padding: var(--space-sm);
  }

  /* Deep dive */
  .deep-dive summary {
    padding: var(--space-sm) var(--space-md);
    font-size: var(--text-sm);
  }

  .deep-dive__content {
    padding: 0 var(--space-md) var(--space-md);
    font-size: var(--text-sm);
  }

  /* Diagram */
  .diagram {
    margin-left: calc(-1 * var(--space-sm));
    margin-right: calc(-1 * var(--space-sm));
  }

  /* Lesson complete button */
  .lesson__complete {
    font-size: var(--text-sm);
    padding: var(--space-sm) var(--space-lg);
  }
}


/* ==========================================================================
   REDUCED MOTION
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .process-step {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .process-step--visible .process-step__marker {
    transition: none;
  }

  .calculator__result {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .calculator__result--visible {
    transition: none;
  }

  .lesson-quiz__feedback {
    opacity: 1;
    transform: none;
    transition: none;
  }

  .lesson-quiz__feedback--visible {
    transition: none;
  }

  .course-card {
    transition: none;
  }

  .course-card:hover {
    transform: none;
  }

  .lesson__nav-link {
    transition: none;
  }

  .lesson__nav-link:hover {
    transform: none;
  }

  .lesson__complete {
    transition: none;
  }

  .lesson__complete:hover {
    transform: none;
  }

  .lesson__complete--animating {
    animation: none;
  }

  .lesson__complete::after {
    transition: none;
  }

  .deep-dive summary::before {
    transition: none;
  }

  .lesson__toc-link {
    transition: none;
  }

  .lesson-quiz__option {
    transition: none;
  }

  .callout {
    transition: none;
  }

  .deep-dive {
    transition: none;
  }

  .chapter-item__number {
    transition: none;
  }

  .chapter-item__body {
    transition: none;
  }

  .calculator__btn {
    transition: none;
  }

  .calculator__input {
    transition: none;
  }

  .compare-table__row {
    transition: none;
  }

  .lesson__nav-arrow {
    transition: none;
  }

  .course-card__cta {
    transition: none;
  }

  .course-card__progress-fill {
    transition: none;
  }
}
