/* Learn: lesson browser (progress, subject filter, lesson list) and reader. */

i[data-icon] { display: inline-flex; font-style: normal; }

/* ---------- Progress ---------- */

.progress-block { margin-bottom: 24px; max-width: 560px; }

.progress-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
  font-weight: 600;
  font-size: 0.95rem;
}

.progress-head .muted { font-variant-numeric: tabular-nums; }

.progress-track {
  height: 8px;
  border-radius: 999px;
  background: var(--plate-2);
  border: 1px solid var(--rule);
  overflow: hidden;
}

.progress-fill {
  width: 0;
  height: 100%;
  border-radius: inherit;
  background: var(--correct);
}

/* ---------- Subject filter ---------- */

.subject-tabs {
  width: fit-content;
  max-width: 100%;
  margin-bottom: 28px;
  overflow-x: auto;
  scrollbar-width: none;
}

.subject-tabs::-webkit-scrollbar { display: none; }

.subject-tabs .tab {
  flex: none;
  padding: 0 14px;
  white-space: nowrap;
  transition: color var(--fast) var(--ease), background-color var(--fast) var(--ease);
}

/* ---------- Lesson list ---------- */

.lesson-grid { display: grid; gap: 36px; }

.subject-head {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  justify-content: space-between;
  gap: 4px 16px;
  padding-bottom: 10px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--rule);
}

.subject-head h2 {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.9rem;
  line-height: 1;
}

.subject-head .muted { font-size: 0.9rem; }

.lesson-list {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(100%, 300px), 1fr));
  gap: 12px;
}

.lesson-card {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 6px;
  width: 100%;
  padding: 16px 18px;
  border: 1px solid var(--rule);
  border-radius: var(--r-panel);
  background: var(--plate);
  color: var(--text);
  font: inherit;
  text-align: left;
  cursor: pointer;
  transition: background-color var(--fast) var(--ease), border-color var(--fast) var(--ease);
}

.lesson-card:hover { background: var(--plate-2); border-color: var(--rule-strong); }

.lesson-card.completed { border-color: color-mix(in srgb, var(--correct) 40%, var(--rule)); }

.lesson-num { color: var(--muted); font-size: 0.82rem; font-weight: 500; }

.lesson-card-title { font-weight: 700; font-size: 1.05rem; line-height: 1.3; }

.lesson-card-desc { color: var(--muted); font-size: 0.92rem; line-height: 1.45; }

.lesson-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
  margin-top: auto;
  padding-top: 8px;
}

.lesson-status { font-size: 0.85rem; }
.lesson-status .icon-svg { width: 14px; height: 14px; }

.lesson-open {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  color: var(--signal);
  font-weight: 600;
  font-size: 0.9rem;
}

.lesson-open .icon-svg { width: 16px; height: 16px; }

/* ---------- States ---------- */

.state-msg { padding: 40px 0; color: var(--muted); }

.state-panel {
  display: flex;
  gap: 12px;
  align-items: flex-start;
  padding: 18px;
  border: 1px solid color-mix(in srgb, var(--buzz) 45%, var(--rule));
  border-radius: var(--r-panel);
  background: var(--plate);
}

.state-panel > .icon-svg { width: 22px; height: 22px; color: var(--buzz); margin-top: 1px; }
.state-panel p { margin-bottom: 12px; max-width: 60ch; }
.state-panel .icon-svg { width: 18px; height: 18px; }

/* ---------- Reader ---------- */

.back-btn { margin: -8px 0 14px -12px; }
.back-btn .icon-svg { width: 18px; height: 18px; }

.reader {
  position: relative;
  max-width: 760px;
  padding: 28px 32px 24px;
  border: 1px solid var(--rule);
  border-radius: var(--r-panel);
  background: var(--plate);
}

.reader-header {
  padding-bottom: 18px;
  margin-bottom: 22px;
  border-bottom: 1px solid var(--rule);
}

.reader-subject { color: var(--signal); font-weight: 600; font-size: 0.92rem; margin-bottom: 6px; }

.reader-title {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(2.2rem, 4.5vw, 3rem);
  line-height: 0.98;
}

.reader-title:focus { outline: none; }

.section-meter {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 14px;
  margin-top: 14px;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

.section-meter span:empty { display: none; }

.section-steps { display: inline-flex; gap: 4px; }

.section-steps span {
  display: block;
  width: 22px;
  height: 4px;
  border-radius: 999px;
  background: var(--rule-strong);
}

.section-steps span.seen { background: color-mix(in srgb, var(--signal) 50%, var(--rule)); }
.section-steps span.current { background: var(--signal); }

.lesson-content { min-height: 200px; }

.section-heading { font-size: 1.3rem; font-weight: 700; margin-bottom: 14px; }

.lesson-body {
  max-width: 65ch;
  font-size: 1.15rem;
  line-height: 1.65;
  -webkit-user-select: none;
  user-select: none;
}

/* Key terms inside the text */
.key-term {
  background: transparent;
  color: inherit;
  font-weight: 600;
  border-radius: 3px;
  box-shadow: inset 0 -0.42em 0 var(--signal-soft);
}

.key-term.has-def {
  cursor: help;
  text-decoration: underline dotted var(--signal);
  text-decoration-thickness: 2px;
  text-underline-offset: 4px;
  transition: background-color var(--fast) var(--ease);
}

.key-term.has-def:hover,
.key-term.has-def[aria-expanded="true"] { background: var(--signal-soft); }

.key-terms {
  margin-top: 26px;
  padding-top: 18px;
  border-top: 1px solid var(--rule);
}

.key-terms h3 { font-size: 0.95rem; font-weight: 600; color: var(--muted); margin-bottom: 10px; }

.key-terms-list { display: flex; flex-wrap: wrap; gap: 8px; }

.key-term-pill { color: var(--text); height: 30px; font-size: 0.88rem; }

.key-term-pill.has-def {
  cursor: help;
  border-color: color-mix(in srgb, var(--signal) 45%, var(--rule));
  background: var(--signal-soft);
  transition: border-color var(--fast) var(--ease);
}

.key-term-pill.has-def:hover,
.key-term-pill.has-def[aria-expanded="true"] { border-color: var(--signal); }

.key-terms-hint { margin-top: 10px; font-size: 0.85rem; }

.key-term-tooltip {
  position: absolute;
  z-index: 20;
  width: max-content;
  max-width: min(320px, 100%);
  padding: 10px 14px;
  border: 1px solid var(--rule-strong);
  border-radius: var(--r-control);
  background: var(--plate-2);
  box-shadow: var(--shadow-pop);
  color: var(--text);
  font-size: 0.92rem;
  line-height: 1.45;
  pointer-events: none;
}

.key-term-tooltip strong { display: block; margin-bottom: 2px; font-weight: 700; }

/* Section nav and completion */
.section-nav {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-top: 28px;
}

.section-nav .icon-svg,
.complete-section .icon-svg { width: 18px; height: 18px; }

.complete-section {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px 16px;
  margin-top: 20px;
  padding-top: 20px;
  border-top: 1px solid var(--rule);
}

.complete-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--correct);
  font-weight: 600;
  font-size: 0.95rem;
}

/* ---------- Narrow ---------- */

@media (max-width: 620px) {
  .reader { padding: 20px 16px 18px; }
  .lesson-body { font-size: 1.08rem; }
  .section-nav .btn { flex: 1; }
  .complete-section .btn { width: 100%; }
  .back-btn { margin-left: -8px; }
}
