/* ============================================================
   NextStep Seniors - Shared Lesson Styles
   Used by every lesson page. Replaces the duplicated inline
   <style> blocks that used to live in each lesson file.
   ============================================================ */

/* Lesson page base */
.lesson-body {
  font-family: 'Figtree', sans-serif;
  background-color: #ffffff;
  color: #0f172a;
  overflow-x: hidden;
  scroll-behavior: smooth;
}

/* Scroll progress bar (top of page) */
#progress {
  position: fixed;
  top: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, #1d4ed8, #2563eb);
  width: 0%;
  z-index: 100;
  transition: width 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

/* Hide the generic progress bar injected by main.js on lesson pages */
#progress-bar {
  display: none !important;
}

/* Utility to keep content above fixed backgrounds */
.relative-z-10 {
  z-index: 10;
  position: relative;
}

/* Lesson content card */
.lesson-card {
  background: #ffffff;
  border-radius: 1rem;
  padding: 2rem;
  box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06);
  border: 1px solid #e2e8f0;
  min-height: 450px;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.4s ease, transform 0.4s ease;
}

.lesson-card.active {
  opacity: 1;
  transform: translateY(0);
}

/* Headings inside lesson content */
.lesson-content h2 {
  color: #2563eb;
  font-size: 1.6rem;
  font-weight: 700;
  border-bottom: 2px solid #e2e8f0;
  padding-bottom: 0.5rem;
  margin-bottom: 1rem;
}

.lesson-content h3 {
  color: #1d4ed8;
  font-size: 1.3rem;
  font-weight: 600;
  margin-top: 1.5rem;
  margin-bottom: 0.5rem;
}

.lesson-content h4 {
  font-size: 1.05rem;
  font-weight: 700;
  margin-top: 1rem;
  margin-bottom: 0.4rem;
}

/* Lists */
.lesson-content ul {
  margin: 0.75rem 0 0.75rem 1.25rem;
  list-style: disc;
  color: #334155;
}

.lesson-content ul li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.lesson-content ol {
  margin: 0.75rem 0 0.75rem 1.25rem;
  list-style: decimal;
  color: #334155;
}

.lesson-content ol li {
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

/* Callout boxes */
.callout {
  border-left: 4px solid #2563eb;
  background: #f0f7ff;
  border-radius: 0.5rem;
  padding: 1rem;
  margin-top: 1.5rem;
  color: #1e293b;
  line-height: 1.6;
}

.callout strong,
.callout b {
  color: #1d4ed8;
}

/* Interactive glossary tooltips */
.glossary-term {
  font-weight: 600;
  color: #1d4ed8;
  cursor: help;
  border-bottom: 1px dotted #1d4ed8;
  position: relative;
  display: inline-block;
}

.glossary-term .tooltip-text {
  visibility: hidden;
  width: 260px;
  background-color: #0f172a;
  color: #ffffff;
  text-align: center;
  border-radius: 6px;
  padding: 10px;
  position: absolute;
  z-index: 100;
  bottom: 130%;
  left: 50%;
  margin-left: -130px;
  opacity: 0;
  transition: opacity 0.3s;
  font-size: 0.85rem;
  font-weight: 400;
  line-height: 1.4;
}

.glossary-term:hover .tooltip-text,
.glossary-term:focus .tooltip-text {
  visibility: visible;
  opacity: 1;
}

/* Quiz */
.quiz-question {
  background: #f8fafc;
  border-radius: 0.75rem;
  padding: 1.5rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
}

.quiz-option {
  cursor: pointer;
  background: #ffffff;
  padding: 0.75rem;
  margin-top: 0.5rem;
  border-radius: 0.5rem;
  transition: background 0.2s, border 0.2s;
  border: 2px solid transparent;
  color: #1e293b;
}

.quiz-option:hover {
  background: #f1f5f9;
}

.quiz-option.selected {
  border: 2px solid #2563eb;
  background: #e0ecff;
}

.quiz-option.correct {
  background: #dcfce7;
  color: #14532d;
  font-weight: bold;
  border-color: #38a169;
}

.quiz-option.incorrect {
  background: #fee2e2;
  color: #7f1d1d;
  font-weight: bold;
  border-color: #e53e3e;
}

/* Calculators (shared) */
.calc-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  border-radius: 0.75rem;
  margin-top: 1rem;
}

.calc-input {
  background: #f8fafc;
  color: #0f172a;
  padding: 0.75rem;
  border-radius: 0.3rem;
  font-size: 1.05rem;
  border: 1px solid #cbd5e1;
  width: 100%;
}

.calc-label {
  color: #1d4ed8;
  padding: 0.75rem;
  font-weight: 600;
  align-self: center;
}

.calc-output {
  grid-column: 1 / span 2;
  background: #f0f7ff;
  color: #2563eb;
  padding: 0.75rem;
  border-radius: 0.3rem;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
  border: 1px dashed #e2e8f0;
}

.calc-btn-group {
  grid-column: 1 / span 2;
  display: flex;
  gap: 0.75rem;
}

.calc-btn {
  background: #f8fafc;
  color: #0f172a;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  cursor: pointer;
  transition: background 0.2s;
  text-align: center;
  font-weight: 600;
  border: 1px solid #cbd5e1;
  flex: 1;
}

.calc-btn:hover {
  background: #e0ecff;
}

.calc-btn.primary {
  background: #2563eb;
  color: #ffffff;
  border-color: #2563eb;
}

.calc-btn.primary:hover {
  background: #1d4ed8;
}

/* Inflation bar chart */
.bar-chart-container {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f0f7ff;
  border-radius: 0.5rem;
}

.bar-chart-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}

.bar-label {
  width: 150px;
  font-weight: 600;
  color: #0f172a;
  font-size: 0.9rem;
}

.bar-value {
  flex-grow: 1;
  height: 25px;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-size: 0.85rem;
  font-weight: bold;
  color: #ffffff;
  transition: width 0.5s ease;
}

.bar-value.start {
  background-color: #38a169;
}

.bar-value.end {
  background-color: #2563eb;
}

/* IRA tax flow comparison */
.tax-flow-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1.5rem;
  margin-top: 1.5rem;
}

.flow-box {
  background: #f8fafc;
  padding: 1.25rem;
  border-radius: 0.5rem;
  text-align: center;
  border: 2px solid #e2e8f0;
}

.flow-box h4 {
  font-size: 1.15rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.traditional-flow {
  border-color: #e53e3e;
}

.roth-flow {
  border-color: #38a169;
}

.tax-step {
  padding: 0.4rem;
  border-radius: 0.3rem;
  margin-bottom: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
}

.tax-step.in {
  background-color: #fee2e2;
  color: #7f1d1d;
}

.tax-step.out {
  background-color: #dcfce7;
  color: #14532d;
}

.tax-step.grow {
  background-color: #dbeafe;
  color: #1e3a8a;
}

/* Comparison toggle (IRAs) */
.comparison-area {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
  font-weight: 600;
  flex-wrap: wrap;
}

.toggle-btn {
  background: #f8fafc;
  color: #0f172a;
  padding: 1rem 1.25rem;
  border-radius: 0.75rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-align: center;
  border: 2px solid transparent;
  flex: 1;
}

.toggle-btn.active {
  border-color: #2563eb;
  background: #e0ecff;
  color: #1d4ed8;
  box-shadow: 0 0 12px rgba(37, 99, 235, 0.25);
}

.toggle-content {
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f0f7ff;
  border-radius: 0.5rem;
  min-height: 150px;
  color: #1e293b;
}

/* RMD checker */
.rmd-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  min-height: 120px;
  background: #f0f7ff;
  border: 4px solid #ffffff;
  color: #1e293b;
}

.rmd-result h4 {
  font-size: 1.4rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.rmd-result .age {
  font-size: 2.5rem;
  font-weight: 800;
  color: #1d4ed8;
  line-height: 1;
}

.account-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 1rem;
}

.account-selector button {
  background: #f8fafc;
  padding: 0.75rem 1.25rem;
  border-radius: 9999px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid #e2e8f0;
  cursor: pointer;
}

.account-selector button:hover {
  border-color: #2563eb;
}

.account-selector button.selected-account {
  border-color: #38a169;
  background: #dcfce7;
}

/* Roth conversion calculator */
.conversion-input-group {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 1.5rem;
  padding: 1rem;
  background: #f0f7ff;
  border-radius: 0.5rem;
}

.conversion-input-group label {
  font-weight: 600;
  color: #1e293b;
}

.conversion-input-group input,
.conversion-input-group select {
  background: #ffffff;
  border: 1px solid #cbd5e1;
  padding: 0.5rem;
  border-radius: 0.25rem;
  width: 100%;
  color: #0f172a;
}

#conversion-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 4px solid #2563eb;
  background: #ffffff;
  font-size: 1.05rem;
  color: #1e293b;
}

#conversion-result h4 {
  color: #1d4ed8;
  font-size: 1.5rem;
  margin-bottom: 0.75rem;
}

/* Roth conversion comparison cards */
.comparison-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.account-card {
  background: #f0f7ff;
  padding: 1.5rem;
  border-radius: 0.75rem;
  border: 2px solid #e2e8f0;
  min-height: 220px;
}

.account-card h4 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
}

.account-card.traditional {
  border-color: #4a90e2;
}

.account-card.roth {
  border-color: #e53e3e;
}

.account-card ul {
  margin: 0.5rem 0 0 1rem;
  list-style: disc;
}

/* Medicare part selector */
.medicare-parts-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.medicare-parts-selector button {
  background: #f8fafc;
  padding: 0.75rem 1.25rem;
  border-radius: 0.5rem;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid #e2e8f0;
  width: 23%;
  text-align: center;
  cursor: pointer;
  color: #0f172a;
}

.medicare-parts-selector button:hover {
  border-color: #2563eb;
}

.medicare-parts-selector button[data-part="A"].active-part {
  background: #e53e3e;
  color: #ffffff;
  border-color: #e53e3e;
}

.medicare-parts-selector button[data-part="B"].active-part {
  background: #4a90e2;
  color: #ffffff;
  border-color: #4a90e2;
}

.medicare-parts-selector button[data-part="C"].active-part {
  background: #38a169;
  color: #ffffff;
  border-color: #38a169;
}

.medicare-parts-selector button[data-part="D"].active-part {
  background: #f5a623;
  color: #ffffff;
  border-color: #f5a623;
}

#part-detail {
  background: #f0f7ff;
  padding: 1.5rem;
  border-radius: 0.75rem;
  min-height: 200px;
  border: 3px solid #4a90e2;
  color: #1e293b;
}

#part-detail h4 {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 0.75rem;
  color: #1d4ed8;
}

#part-detail ul {
  margin: 0.5rem 0 0 1.1rem;
  list-style: disc;
}

/* Debt prioritization */
.debt-selector {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.debt-selector button {
  background: #f8fafc;
  padding: 1rem;
  border-radius: 0.5rem;
  text-align: left;
  font-weight: 600;
  transition: all 0.3s ease;
  border: 2px solid #e2e8f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  color: #0f172a;
}

.debt-selector button:hover {
  border-color: #2563eb;
  background: #f1f5f9;
}

.debt-selector button.active {
  border-color: #1d4ed8;
  background: #e0ecff;
}

#priority-result {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 0.75rem;
  min-height: 120px;
  background: #f0f7ff;
  border: 1px solid #e2e8f0;
  color: #1e293b;
}

#priority-result h4 {
  font-size: 1.4rem;
  font-weight: 800;
  margin-bottom: 0.5rem;
}

/* Expense sorter (fixed-budget) */
.sorter-container {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-top: 1.5rem;
}

.sorter-zone {
  background: #f8fafc;
  min-height: 220px;
  padding: 1rem;
  border-radius: 0.75rem;
  border: 2px dashed #cbd5e1;
  transition: border-color 0.2s;
}

.sorter-zone.active {
  border-color: #2563eb;
  background: #f1f5f9;
}

.sorter-item {
  background: #ffffff;
  color: #0f172a;
  padding: 0.5rem 1rem;
  margin-bottom: 0.5rem;
  border-radius: 0.5rem;
  cursor: grab;
  border-left: 5px solid #cbd5e1;
  border: 1px solid #e2e8f0;
  transition: transform 0.1s, border-left-color 0.3s;
}

.sorter-item:hover {
  transform: translateY(-1px);
}

.sorter-item.correct-essential {
  border-left: 5px solid #38a169;
}

.sorter-item.correct-discretionary {
  border-left: 5px solid #1d4ed8;
}

.sorter-item.incorrect {
  border-left: 5px solid #e53e3e;
}

.unassigned-items {
  background: #f0f7ff;
  padding: 1rem;
  border-radius: 0.75rem;
  margin-bottom: 1rem;
  border: 1px solid #e2e8f0;
}

/* Social Security multiplier bars */
.multiplier-bar-container {
  display: flex;
  width: 100%;
  height: 25px;
  background-color: #e2e8f0;
  border-radius: 0.5rem;
  overflow: hidden;
  margin-top: 1rem;
}

.multiplier-bar {
  height: 100%;
  background-color: #2563eb;
  transition: width 0.5s ease;
  text-align: right;
  color: #ffffff;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 5px;
  font-size: 0.9rem;
  min-width: 0;
}

.age-label {
  text-align: center;
  font-weight: 600;
  color: #1d4ed8;
  margin-top: 0.5rem;
}

/* Success visual (perfect quiz score) */
#success-visual {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 90;
  opacity: 0;
  transition: opacity 0.3s;
}

@keyframes pulseGold {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.7; transform: scale(1.08); }
}

#success-visual .success-emoji {
  font-size: 5rem;
  animation: pulseGold 0.6s ease-out;
}

/* Lesson navigation bar */
.lesson-nav {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: #ffffff;
  border: 1px solid #e2e8f0;
  padding: 1rem;
  border-radius: 0.75rem;
  box-shadow: 0 4px 16px -2px rgba(15, 23, 42, 0.08);
}

/* Responsive tweaks */
@media (max-width: 640px) {
  .lesson-card {
    padding: 1.25rem;
    min-height: 0;
  }

  .lesson-content h2 {
    font-size: 1.3rem;
  }

  .lesson-content h3 {
    font-size: 1.1rem;
  }

  .calc-grid,
  .tax-flow-grid,
  .comparison-grid,
  .sorter-container {
    grid-template-columns: 1fr;
  }

  .medicare-parts-selector button {
    width: 48%;
  }

  .comparison-area {
    flex-direction: column;
  }

  .bar-label {
    width: 110px;
  }
}
