/* ============================================================
   Learn Mode — Paginated Content Experience (F-073)
   Reuses patterns from Quiz (stats bar, progress, chevrons)
   and Flashcards (glassmorphic card, peeking edges, thumbs)
   ============================================================ */

/* --- Layout Shell --- */
.learn-mode-shell {
  display: flex;
  flex-direction: column;
  height: calc(100vh - 48px); /* below unified header */
  overflow: hidden;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

@media (max-width: 480px) {
  .learn-mode-shell {
    max-width: 100%;
  }
}

/* --- Stats Bar (mirrors quiz compact stats) --- */
.learn-stats-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-primary);
  min-height: 40px;
  gap: 12px;
  flex-shrink: 0;
}

.learn-stats-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.learn-stats-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.learn-stat-item {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 14px;
  color: var(--text-secondary);
  white-space: nowrap;
}

.learn-stat-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
  flex-shrink: 0;
}

.learn-key-facts-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 200ms ease;
}

.learn-key-facts-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.learn-key-facts-btn.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.learn-key-facts-btn svg {
  width: 14px;
  height: 14px;
}

.learn-key-facts-label {
  display: inline;
}

.learn-page-counter {
  font-weight: 600;
  color: var(--text-primary);
}

/* XP Badge — matches quiz .quiz-nav-stat--xp */
.learn-xp-badge {
  background: rgba(234, 179, 8, 0.15);
  color: #eab308;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  min-height: 36px;
  font-size: 14px;
  box-sizing: border-box;
}

.learn-xp-badge svg {
  width: 20px;
  height: 20px;
  opacity: 1;
  flex-shrink: 0;
}

/* Mastery Badge — matches quiz .quiz-nav-stat--mastery */
.learn-mastery-badge {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: rgba(59, 130, 246, 0.15);
  color: #2563EB;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 8px;
  min-height: 36px;
  font-size: 14px;
  box-sizing: border-box;
}

.learn-mastery-badge svg {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.learn-mastery-num {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  font-size: 11px;
  font-weight: 800;
  line-height: 1;
  color: inherit;
  pointer-events: none;
}

/* Task-mode navigation links (Flashcards, Quiz) */
.learn-task-mode-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  background: none;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 200ms ease;
  text-decoration: none;
  width: 36px;
  height: 36px;
}

.learn-task-mode-link:hover {
  background: var(--bg-hover);
}

.learn-task-mode-link svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

/* Homepage-matching icon colors */
#learn-link-flashcards { color: #a855f7; }
#learn-link-quiz { color: #eab308; }

.learn-contents-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  background: none;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 200ms ease;
  flex-shrink: 0;
}

.learn-contents-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.learn-contents-btn svg {
  width: 22px;
  height: 22px;
}

/* --- Guidance Bar --- */
.learn-guidance-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 4px 16px;
  min-height: 28px;
  background: rgba(59, 130, 246, 0.06);
  border-bottom: 1px solid var(--border);
  font-size: 13px;
  color: var(--text-secondary);
  text-align: center;
  flex-shrink: 0;
  transition: opacity 200ms ease;
}

.learn-guidance-bar.collapsed {
  cursor: pointer;
}

.learn-guidance-bar.collapsed .learn-guidance-text {
  display: none;
}

.learn-guidance-icon {
  font-size: 14px;
  flex-shrink: 0;
}

/* --- Segmented Progress Bar (matches quiz-engagement.css) --- */
.learn-progress-bar {
  display: flex;
  align-items: stretch;
  gap: 2px;
  padding: 0 2px;
  margin: 4px 20px 6px;
  height: 8px;
  border-radius: 4px;
  background: var(--hud-divider, transparent);
  flex-shrink: 0;
}

@media (max-width: 480px) {
  .learn-progress-bar {
    margin: 2px 16px 4px;
    height: 6px;
  }
}

.learn-progress-seg {
  flex: 1;
  height: 100%;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  transition: background 300ms ease, transform 150ms ease;
  position: relative;
}

body.light-mode .learn-progress-seg {
  background: rgba(0, 0, 0, 0.08);
}

.learn-progress-seg:hover {
  transform: scaleY(1.8);
  filter: brightness(1.3);
}

/* Current page — blue fill only when unrated */
.learn-progress-seg.seg-current:not(.seg-gotit):not(.seg-hard):not(.seg-read) {
  background: #2563EB;
  box-shadow: 0 0 4px rgba(59, 130, 246, 0.4);
}

/* Current page outline ring (even when rated) */
.learn-progress-seg.seg-current {
  outline: 2px solid rgba(255, 255, 255, 0.8);
  outline-offset: -1px;
  z-index: 1;
}

body.light-mode .learn-progress-seg.seg-current {
  outline-color: rgba(59, 130, 246, 0.5);
}

.learn-progress-seg.seg-gotit,
body.light-mode .learn-progress-seg.seg-gotit {
  background: #22c55e;
}

.learn-progress-seg.seg-hard,
body.light-mode .learn-progress-seg.seg-hard {
  background: #eab308;
}

.learn-progress-seg.seg-read,
body.light-mode .learn-progress-seg.seg-read {
  background: #94a3b8;
}

.learn-progress-seg.seg-locked {
  opacity: 0.4;
}

/* Tooltip */
.learn-progress-seg::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: calc(100% + 8px);
  left: 50%;
  transform: translateX(-50%);
  padding: 4px 8px;
  background: rgba(0, 0, 0, 0.85);
  color: #fff;
  border-radius: 4px;
  font-size: 11px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease;
  z-index: 10;
}

.learn-progress-seg:hover::after {
  opacity: 1;
}

/* --- Card Area (main content region) --- */
.learn-card-area {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
  padding: 0;
  min-height: 0;
}

/* --- Card (matches quiz .question-display) --- */
.learn-card {
  position: relative;
  width: 100%;
  flex: 1;
  min-height: 0;
  border-radius: var(--radius-lg, 16px);
  overflow: hidden;
  display: flex;
  flex-direction: column;

  background: var(--bg-card);
  border: 1px solid var(--border);
  transition: all 0.3s ease;

  z-index: 1;
}

@media (max-width: 480px) {
  .learn-card {
    border-radius: 0;
    border-left: none;
    border-right: none;
  }
}

/* Peeking edges removed — matches quiz card style */

/* --- Card Header (page title) --- */
.learn-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg, 20px) var(--space-xl, 24px) var(--space-sm, 8px);
  flex-shrink: 0;
}

.learn-card-title {
  font-size: var(--font-lg, 18px);
  font-weight: 600;
  color: var(--text-primary);
  margin: 0 0 var(--space-sm, 8px);
  line-height: var(--line-height, 1.5);
}

/* --- Card Content (scrollable) --- */
.learn-card-content {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 0 var(--space-xl, 24px);
  position: relative;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
}

/* Scroll indicator fade */
.learn-card-scroll-indicator {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 40px;
  background: linear-gradient(transparent, var(--bg-card));
  pointer-events: none;
  z-index: 2;
  transition: opacity 200ms ease;
}

.learn-card-scroll-indicator.hidden {
  opacity: 0;
}

/* Content styling within card — override content.css !important borders */
.learn-card-content .content-box {
  background: transparent !important;
  border: none !important;
  border-left: none !important;
  border-radius: 0 !important;
  padding: 0 !important;
  margin-bottom: 16px;
}


.learn-card-content h3 {
  font-size: 16px;
  margin: 0 0 8px;
}

.learn-card-content h4 {
  font-size: 14px;
  margin: 12px 0 6px;
}

.learn-card-content p,
.learn-card-content li {
  font-size: 14px;
  line-height: 1.65;
  color: var(--text-primary);
}

.learn-card-content img,
.learn-card-content svg:not(button svg) {
  max-width: 100%;
  height: auto;
  border-radius: 8px;
}

.learn-card-content table {
  font-size: 13px;
  width: 100%;
  border-collapse: collapse;
}

.learn-card-content th,
.learn-card-content td {
  padding: 6px 8px;
  border: 1px solid var(--border);
  text-align: left;
}

/* Table horizontal scroll wrapper */
.learn-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin-bottom: 12px;
}

/* Quick-check within card */
/* Glossary-style definitions — clean, no overlapping backgrounds */
.learn-card-content .must-memorise {
  display: block;
  background: none !important;
  border: none !important;
  border-bottom: 1px solid var(--border) !important;
  border-radius: 0 !important;
  padding: 10px 4px !important;
  margin: 0 !important;
}

.learn-card-content .must-memorise:last-child {
  border-bottom: none !important;
}

/* Color the term (bold part) red so it stands out */
.learn-card-content .must-memorise strong {
  color: #dc2626;
  font-weight: 700;
}

.learn-card-content .quick-check {
  background: rgba(59, 130, 246, 0.06);
  border: 1px solid rgba(59, 130, 246, 0.15);
  border-radius: 8px;
  padding: 10px 12px;
  margin: 12px 0;
}

/* --- Card Footer (thumbs) --- */
.learn-card-footer {
  flex-shrink: 0;
  padding: 0 20px 16px;
}

.learn-card-divider {
  height: 1px;
  background: var(--border);
  margin-bottom: 12px;
}

.learn-thumbs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
}

.learn-thumb {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: 12px;
  background: none;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
  transition: all 200ms ease;
  min-width: 110px;
  justify-content: center;
}

.learn-thumb svg {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
}

.learn-thumb--hard {
  color: #ef4444;
}

.learn-thumb--hard:hover {
  background: rgba(239, 68, 68, 0.1);
  border-color: #ef4444;
}

.learn-thumb--hard.selected {
  background: rgba(239, 68, 68, 0.15);
  border-color: #ef4444;
}

.learn-thumb--gotit {
  color: #22c55e;
}

.learn-thumb--gotit:hover {
  background: rgba(34, 197, 94, 0.1);
  border-color: #22c55e;
}

.learn-thumb--gotit.selected {
  background: rgba(34, 197, 94, 0.15);
  border-color: #22c55e;
}

.learn-thumb:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* --- Navigation Arrows (absolute within card area) --- */
.learn-nav-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 100;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.15);
  background: var(--bg-card, rgba(255, 255, 255, 0.95));
  color: var(--text-secondary, #4b5563);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0.85;
  transition: opacity 150ms, transform 150ms, background 150ms;
  padding: 0;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.learn-nav-btn:hover:not(:disabled) {
  opacity: 1;
  transform: translateY(-50%) scale(1.1);
  background: var(--bg-hover, rgba(245, 245, 250, 1));
}

.learn-nav-btn:active:not(:disabled) {
  transform: translateY(-50%) scale(0.95);
}

.learn-nav-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2.5;
}

.learn-nav-prev { left: 4px; }
.learn-nav-next { right: 4px; }

@media (max-width: 480px) {
  .learn-nav-btn {
    width: 28px;
    height: 28px;
    opacity: 0.5;
    background: var(--bg-card, rgba(255, 255, 255, 0.85));
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  }
  .learn-nav-btn:active:not(:disabled) {
    opacity: 0.9;
  }
  .learn-nav-btn svg {
    width: 14px;
    height: 14px;
  }
  .learn-nav-prev { left: 2px; }
  .learn-nav-next { right: 2px; }
}

.learn-nav-btn.hidden {
  opacity: 0;
  pointer-events: none;
}

.learn-nav-btn:disabled {
  opacity: 0.3;
  cursor: not-allowed;
}

/* --- Key Facts Panel (roll-down) --- */
.learn-key-facts-panel {
  max-height: 0;
  overflow: hidden;
  transition: max-height 300ms ease, opacity 200ms ease;
  opacity: 0;
  background: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

body.light-mode .learn-key-facts-panel {
  background: var(--bg-secondary);
  border-bottom-color: var(--border);
}

.learn-key-facts-panel.open {
  max-height: 300px;
  opacity: 1;
}

.learn-key-facts-inner {
  padding: 12px 16px;
}

.learn-key-facts-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}

.learn-key-facts-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.learn-key-facts-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  padding: 4px;
  font-size: 16px;
  line-height: 1;
}

.learn-key-facts-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.learn-key-facts-list li {
  padding: 4px 0;
  font-size: 13px;
  color: var(--text-primary);
  line-height: 1.5;
  display: flex;
  gap: 6px;
}

.learn-key-facts-list li::before {
  content: '\1F4CC'; /* pin emoji */
  flex-shrink: 0;
}

/* --- Summary Button (HUD) --- */
.learn-summary-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: none;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 4px 10px;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-secondary);
  cursor: pointer;
  transition: all 200ms ease;
}

.learn-summary-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
  border-color: var(--accent);
}

.learn-summary-btn.active {
  background: rgba(59, 130, 246, 0.1);
  border-color: var(--accent);
  color: var(--accent);
}

.learn-summary-btn svg {
  width: 14px;
  height: 14px;
}

.learn-summary-label {
  display: inline;
}

@media (max-width: 480px) {
  .learn-summary-label { display: none; }
}

/* --- Summary Panel (full card replacement) --- */
.learn-summary-panel {
  display: none;
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px 20px;
  -webkit-overflow-scrolling: touch;
}

.learn-summary-panel.open {
  display: block;
}

/* When summary is open, hide card content and footer */
.learn-summary-panel.open ~ .learn-card-content,
.learn-summary-panel.open ~ .learn-card-scroll-indicator,
.learn-summary-panel.open ~ .learn-card-footer {
  display: none;
}

/* Close X button in card header when summary is open */
.learn-summary-close {
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  padding: 4px;
  color: var(--text-secondary);
  cursor: pointer;
  border-radius: 6px;
  transition: color 200ms, background 200ms;
}

.learn-summary-close:hover {
  color: var(--text-primary);
  background: var(--bg-hover, rgba(0,0,0,0.06));
}

.learn-summary-close svg {
  width: 18px;
  height: 18px;
}

.learn-summary-content {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-primary);
}

/* Fix: CSS Grid items default to min-width:auto which prevents
   shrinking below content width, causing text to overflow the
   narrow summary panel. min-width:0 allows proper wrapping. */
.learn-summary-content .ko-grid {
  min-width: 0;
}

.learn-summary-content .ko-section {
  min-width: 0;
  overflow: hidden;
}

/* Scroll wrapper added by JS around tables */
.summary-table-scroll {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

/* Compact tables for narrow summary panel */
.learn-summary-content table {
  width: 100%;
  font-size: 11px;
  border-collapse: collapse;
}

.learn-summary-content th,
.learn-summary-content td {
  padding: 3px 4px !important;
  text-align: center;
  border: 1px solid var(--border) !important;
}

.learn-summary-content th:first-child,
.learn-summary-content td:first-child {
  text-align: left;
}

.learn-summary-content h4,
.learn-summary-content h5 {
  font-size: 14px;
  font-weight: 700;
  margin: 14px 0 6px;
  color: var(--text-primary);
}

.learn-summary-content ul {
  margin: 0 0 8px;
  padding-left: 20px;
}

.learn-summary-content li {
  margin-bottom: 4px;
}

/* --- Contents Overlay --- */
.learn-contents-overlay {
  position: absolute;
  top: 0;
  right: 0;
  width: 260px;
  max-height: 80%;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 0;
  z-index: 20;
  overflow-y: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
  transform: translateY(-8px);
  opacity: 0;
  pointer-events: none;
  transition: all 200ms ease;
}

.learn-contents-overlay.open {
  transform: translateY(0);
  opacity: 1;
  pointer-events: auto;
}

.learn-contents-title {
  padding: 0 16px 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  border-bottom: 1px solid var(--border);
  margin-bottom: 4px;
}

.learn-contents-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  font-size: 13px;
  color: var(--text-primary);
  cursor: pointer;
  transition: background 150ms ease;
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}

.learn-contents-item:hover {
  background: rgba(59, 130, 246, 0.08);
}

.learn-contents-item.current {
  color: var(--accent);
  font-weight: 600;
}

.learn-contents-item.locked {
  opacity: 0.4;
  cursor: not-allowed;
}

.learn-contents-status {
  flex-shrink: 0;
  width: 16px;
  text-align: center;
  font-size: 12px;
}

/* --- Slide Transitions --- */
.learn-card-content.slide-left-enter {
  animation: slideLeftIn 250ms ease-out forwards;
}

.learn-card-content.slide-right-enter {
  animation: slideRightIn 250ms ease-out forwards;
}

@keyframes slideLeftIn {
  from { transform: translateX(40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

@keyframes slideRightIn {
  from { transform: translateX(-40px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* --- Completion Screen (v3 — card CTAs + 2-row stats) --- */

/* Container */
.learn-completion {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 4px 24px 32px;
  min-height: 100%;
}

/* --- Keyframes --- */
@keyframes lc-icon-bounce {
  0%   { transform: scale(0); opacity: 0; }
  50%  { transform: scale(1.2); opacity: 1; }
  70%  { transform: scale(0.9); }
  100% { transform: scale(1); }
}

@keyframes lc-spark-burst {
  0%   { transform: translate(0, 0) scale(1); opacity: 1; }
  100% { transform: translate(var(--spark-dx), var(--spark-dy)) scale(0); opacity: 0; }
}

@keyframes lc-fade-up {
  from { transform: translateY(10px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes lc-tile-in {
  from { transform: translateY(12px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes lc-xp-pulse {
  0%, 100% { box-shadow: 0 0 0 rgba(234, 179, 8, 0); }
  50%      { box-shadow: 0 0 14px rgba(234, 179, 8, 0.35); }
}

@keyframes lc-btn-glow-purple {
  0%, 100% { box-shadow: 0 2px 8px rgba(168, 85, 247, 0.15); }
  50%      { box-shadow: 0 2px 16px rgba(168, 85, 247, 0.45); }
}

@keyframes lc-btn-glow-gold {
  0%, 100% { box-shadow: 0 2px 8px rgba(234, 179, 8, 0.15); }
  50%      { box-shadow: 0 2px 16px rgba(234, 179, 8, 0.45); }
}

@keyframes lc-action-slide {
  from { transform: translateY(16px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

@keyframes lc-confetti-fall {
  0%   { transform: translateY(-20px) rotate(0deg); opacity: 1; }
  80%  { opacity: 1; }
  100% { transform: translateY(calc(100vh + 40px)) rotate(720deg); opacity: 0; }
}

/* --- Hero icon with sparkles --- */
.lc-hero {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}

.lc-hero__icon {
  color: var(--color-success, #22c55e);
  filter: drop-shadow(0 0 12px rgba(34, 197, 94, 0.45));
  animation: lc-icon-bounce 500ms ease-out both;
}

.lc-hero__icon svg {
  width: 64px;
  height: 64px;
}

.lc-spark {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  top: 50%;
  left: 50%;
  margin: -3px 0 0 -3px;
  animation: lc-spark-burst 600ms ease-out 300ms both;
  pointer-events: none;
}

.lc-spark:nth-child(1) { --spark-dx: -28px; --spark-dy: -22px; background: #2563EB; }
.lc-spark:nth-child(2) { --spark-dx: 26px;  --spark-dy: -24px; background: #a855f7; }
.lc-spark:nth-child(3) { --spark-dx: 32px;  --spark-dy: 8px;   background: #22c55e; }
.lc-spark:nth-child(4) { --spark-dx: -30px; --spark-dy: 10px;  background: #eab308; }
.lc-spark:nth-child(5) { --spark-dx: 10px;  --spark-dy: 30px;  background: #ef4444; }
.lc-spark:nth-child(6) { --spark-dx: -12px; --spark-dy: 28px;  background: #ec4899; }

/* --- Title & topic --- */
.lc-title {
  font-size: 22px;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0 0 4px;
  animation: lc-fade-up 400ms ease-out 150ms both;
}

.lc-topic {
  font-size: 14px;
  color: var(--text-secondary);
  margin: 0 0 12px;
  animation: lc-fade-up 400ms ease-out 200ms both;
}

/* --- Motivational nudge --- */
.lc-nudge {
  font-size: 13px;
  color: var(--text-secondary, #64748b);
  line-height: 1.5;
  margin: 0 0 16px;
  max-width: 360px;
  animation: lc-fade-up 400ms ease-out 250ms both;
}

/* --- CTA cards (above stats — card style like homepage mini-cards) --- */
.lc-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin-bottom: 20px;
  animation: lc-action-slide 400ms ease-out 350ms both;
}

.lc-card {
  display: flex;
  align-items: center;
  gap: var(--space-sm, 8px);
  padding: 10px 14px;
  border-radius: 14px;
  border: 1px solid var(--border);
  background: var(--bg-card);
  text-decoration: none;
  cursor: pointer;
  transition: all 200ms ease;
  min-height: 44px;
}

.lc-card__icon {
  width: 44px;
  height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.lc-card__icon svg {
  width: 30px;
  height: 30px;
}

.lc-card__text {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.lc-card__label {
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.lc-card__sub {
  font-size: var(--font-xs, 11px);
  font-weight: 600;
  color: var(--text-secondary);
}

/* Flashcards card — purple (matches homepage .flow-mini-card--review) */
.lc-card--flashcards {
  border-color: rgba(168, 85, 247, 0.55);
  background: rgba(168, 85, 247, 0.12);
  box-shadow: 0 4px 14px rgba(168, 85, 247, 0.15);
  animation: lc-btn-glow-purple 2.5s ease-in-out infinite;
}

.lc-card--flashcards .lc-card__icon { color: #a855f7; }

.lc-card--flashcards:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(168, 85, 247, 0.25);
}

/* Quiz card — gold (matches homepage .flow-mini-card--quiz) */
.lc-card--quiz {
  border-color: rgba(234, 179, 8, 0.55);
  background: rgba(234, 179, 8, 0.12);
  box-shadow: 0 4px 14px rgba(234, 179, 8, 0.15);
  animation: lc-btn-glow-gold 2.5s ease-in-out 0.5s infinite;
}

.lc-card--quiz .lc-card__icon { color: #eab308; }

.lc-card--quiz:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(234, 179, 8, 0.25);
}

/* Revisit card — amber outline */
.lc-card--revisit {
  border-color: rgba(234, 179, 8, 0.45);
  background: rgba(234, 179, 8, 0.06);
}

.lc-card--revisit .lc-card__icon { color: var(--color-warning, #eab308); }
.lc-card--revisit .lc-card__label { color: var(--color-warning, #eab308); }

.lc-card--revisit:hover {
  background: rgba(234, 179, 8, 0.12);
}

/* Next topic card — green */
@keyframes lc-btn-glow-green {
  0%, 100% { box-shadow: 0 2px 8px rgba(34, 197, 94, 0.15); }
  50%      { box-shadow: 0 2px 16px rgba(34, 197, 94, 0.45); }
}

.lc-card--next {
  border-color: rgba(34, 197, 94, 0.55);
  background: rgba(34, 197, 94, 0.12);
  box-shadow: 0 4px 14px rgba(34, 197, 94, 0.15);
  animation: lc-btn-glow-green 2.5s ease-in-out 1s infinite;
}

.lc-card--next .lc-card__icon { color: #22c55e; }

.lc-card--next:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(34, 197, 94, 0.25);
}

/* --- Stats grid (2 rows: pages+XP, understood+revision) --- */
.lc-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  width: 100%;
  max-width: 380px;
  margin-bottom: 16px;
  animation: lc-fade-up 400ms ease-out 500ms both;
}

.lc-stat-tile {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.06);
  animation: lc-tile-in 400ms ease-out both;
}

.lc-stat-tile:nth-child(1) { animation-delay: 550ms; }
.lc-stat-tile:nth-child(2) { animation-delay: 600ms; }
.lc-stat-tile:nth-child(3) { animation-delay: 650ms; }
.lc-stat-tile:nth-child(4) { animation-delay: 700ms; }

body.light-mode .lc-stat-tile,
[data-theme="light"] .lc-stat-tile {
  background: rgba(0, 0, 0, 0.03);
  border-color: rgba(0, 0, 0, 0.06);
}

/* Stat icon — colored SVG, no circle border */
.lc-stat-tile__icon {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-muted, #64748b);
}

.lc-stat-tile__icon svg {
  width: 22px;
  height: 22px;
}

.lc-stat-tile__text {
  display: flex;
  flex-direction: column;
  gap: 0;
}

.lc-stat-tile__value {
  font-size: 18px;
  font-weight: 700;
  color: var(--text-primary);
  line-height: 1.2;
}

.lc-stat-tile__label {
  font-size: 11px;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.3px;
  line-height: 1.3;
}

/* --- Stat tile color modifiers (colored outlines) --- */

/* Pages read — blue icon */
.lc-stat-tile--pages .lc-stat-tile__icon { color: #2563EB; }

/* Understood — green icon (thumbs-up) */
.lc-stat-tile--success .lc-stat-tile__icon { color: var(--color-success, #22c55e); }
.lc-stat-tile--success .lc-stat-tile__value { color: var(--color-success, #22c55e); }

/* Need revision — red icon (thumbs-down) */
.lc-stat-tile--warning .lc-stat-tile__icon { color: #ef4444; }
.lc-stat-tile--warning .lc-stat-tile__value { color: #ef4444; }

/* XP — gold icon */
.lc-stat-tile--xp .lc-stat-tile__icon { color: #eab308; }
.lc-stat-tile--xp .lc-stat-tile__value { color: #eab308; }
.lc-stat-tile--xp.has-xp {
  animation: lc-tile-in 400ms ease-out 600ms both, lc-xp-pulse 1.5s ease-in-out 1.2s 2;
}

/* Muted tile (zero state) — gray icon */
.lc-stat-tile--muted .lc-stat-tile__icon { color: var(--text-muted, #64748b); opacity: 0.5; }
.lc-stat-tile--muted .lc-stat-tile__value { color: var(--text-muted, #64748b); }

/* --- Hard pages callout --- */
.lc-hard-callout {
  width: 100%;
  max-width: 380px;
  background: rgba(234, 179, 8, 0.08);
  border-left: 3px solid var(--color-warning, #eab308);
  border-radius: 8px;
  padding: 12px 16px;
  margin-bottom: 16px;
  text-align: left;
  animation: lc-fade-up 400ms ease-out 750ms both;
}

body.light-mode .lc-hard-callout,
[data-theme="light"] .lc-hard-callout {
  background: rgba(234, 179, 8, 0.06);
}

.lc-hard-callout__title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
  color: var(--color-warning, #eab308);
  margin-bottom: 6px;
}

.lc-hard-callout__title svg {
  width: 16px;
  height: 16px;
  flex-shrink: 0;
}

.lc-hard-callout__list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lc-hard-callout__list li {
  font-size: 13px;
  color: var(--text-secondary);
  padding: 5px 0;
}

.lc-hard-callout__list li::before {
  content: '\25CF ';
  color: var(--color-warning, #eab308);
}

/* --- Dashboard link (tertiary, de-emphasized) --- */
.lc-dashboard-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--text-muted, #64748b);
  text-decoration: none;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 8px;
  transition: all 200ms ease;
  animation: lc-fade-up 400ms ease-out 800ms both;
}

.lc-dashboard-link svg {
  width: 16px;
  height: 16px;
}

.lc-dashboard-link:hover {
  color: var(--text-secondary);
  background: var(--bg-hover);
}

/* --- Confetti pieces --- */
.lc-confetti {
  position: fixed;
  top: -10px;
  width: 8px;
  height: 8px;
  pointer-events: none;
  z-index: 9999;
  animation: lc-confetti-fall var(--lc-fall-dur, 1.2s) ease-in var(--lc-fall-delay, 0s) forwards;
}

.lc-confetti--circle { border-radius: 50%; }
.lc-confetti--square { border-radius: 2px; }

/* --- Reduced motion --- */
@media (prefers-reduced-motion: reduce) {
  .learn-completion,
  .learn-completion * {
    animation: none !important;
    transition: none !important;
  }
  .lc-hero__icon { filter: none; }
  .lc-spark { display: none; }
  .lc-confetti { display: none; }

  /* Ensure everything visible immediately */
  .lc-title, .lc-topic, .lc-nudge, .lc-actions,
  .lc-stats-grid, .lc-stat-tile, .lc-hard-callout,
  .lc-dashboard-link {
    opacity: 1 !important;
    transform: none !important;
  }
}

/* --- Mobile --- */
@media (max-width: 480px) {
  .learn-completion {
    padding: 4px 16px 28px;
  }

  .lc-hero__icon svg {
    width: 52px;
    height: 52px;
  }

  .lc-title { font-size: 20px; }

  .lc-stats-grid,
  .lc-actions,
  .lc-hard-callout {
    max-width: 100%;
  }

  .lc-stat-tile {
    padding: 8px 10px;
  }

  .lc-stat-tile__value {
    font-size: 16px;
  }

  .lc-stat-tile__icon {
    width: 32px;
    height: 32px;
  }

  .lc-stat-tile__icon svg {
    width: 16px;
    height: 16px;
  }

  .lc-card__icon svg {
    width: 26px;
    height: 26px;
  }
}

/* --- Loading Skeleton --- */
.learn-skeleton {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 20px;
}

.learn-skeleton-line {
  height: 14px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 6px;
  animation: skeletonPulse 1.5s ease-in-out infinite;
}

body.light-mode .learn-skeleton-line {
  background: rgba(0, 0, 0, 0.06);
}

.learn-skeleton-line:nth-child(1) { width: 60%; }
.learn-skeleton-line:nth-child(2) { width: 100%; height: 120px; }
.learn-skeleton-line:nth-child(3) { width: 90%; }
.learn-skeleton-line:nth-child(4) { width: 75%; }
.learn-skeleton-line:nth-child(5) { width: 85%; }

@keyframes skeletonPulse {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 0.8; }
}

/* --- Error State --- */
.learn-error {
  text-align: center;
  padding: 40px 24px;
  color: var(--text-secondary);
}

.learn-error h3 {
  color: var(--error, #ef4444);
  margin-bottom: 8px;
}

.learn-error-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 16px;
  padding: 10px 20px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: none;
  color: var(--text-primary);
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

/* --- Responsive --- */
@media (max-width: 480px) {
  .learn-stats-bar {
    padding: 4px 12px;
    min-height: 32px;
  }

  .learn-key-facts-label {
    display: none;
  }

  .learn-guidance-bar {
    font-size: 12px;
    padding: 3px 12px;
    min-height: 24px;
  }

  .learn-progress-bar {
    padding: 4px 12px;
  }

  .learn-progress-seg {
    height: 6px;
  }

  .learn-card {
    max-width: 100%;
    border-radius: 0;
    border-left: none;
    border-right: none;
  }

  .learn-card::before,
  .learn-card::after {
    display: none;
  }

  .learn-card-header {
    padding: 12px 12px 6px;
  }

  .learn-card-title {
    font-size: 16px;
  }

  .learn-card-content {
    padding: 6px 12px 0;
  }

  .learn-card-footer {
    padding: 0 12px 12px;
  }

  .learn-thumbs {
    gap: 16px;
  }

  .learn-thumb {
    padding: 8px 14px;
    font-size: 13px;
    min-width: 90px;
  }

  .learn-thumb svg {
    width: 18px;
    height: 18px;
  }

}

@media (min-width: 481px) and (max-width: 768px) {
  .learn-card {
    max-width: 100%;
  }

  .learn-nav-btn {
    width: 36px;
    height: 36px;
  }

  .learn-nav-prev { left: 8px; }
  .learn-nav-next { right: 8px; }
}

/* --- Reduced Motion --- */
@media (prefers-reduced-motion: reduce) {
  .learn-card-content.slide-left-enter,
  .learn-card-content.slide-right-enter {
    animation: none;
  }

  .learn-completion {
    animation: none;
  }

  .learn-skeleton-line {
    animation: none;
    opacity: 0.5;
  }

  .learn-progress-seg,
  .learn-thumb,
  .learn-nav-btn,
  .learn-key-facts-btn,
  .learn-guidance-bar {
    transition: none;
  }
}
