/* ============ Phase 3: learning modules ============ */

/* ---------- Sticky section navigation ---------- */

.subnav {
  position: sticky;
  top: 72px;
  z-index: 18;
  display: flex;
  gap: 4px;
  padding: 8px 0;
  margin: 4px 0 8px;
  overflow-x: auto;
  scrollbar-width: none;
  background: linear-gradient(var(--bg) 70%, transparent);
}

.subnav::-webkit-scrollbar {
  display: none;
}

.subnav a {
  flex: none;
  padding: 6px 12px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.subnav a:hover {
  background: var(--surface);
  border-color: var(--line);
  color: var(--ink);
}

[id] {
  scroll-margin-top: 128px;
}

/* ---------- Section blocks ---------- */

.section-block {
  margin-top: 8px;
}

.content-section {
  margin-top: 24px;
  padding: 26px;
}

.section-title {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 8px;
}

.section-title h2 {
  margin-top: 6px;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.content-section .lead {
  font-size: 13px;
}

.subhead {
  margin: 24px 0 10px;
  font-size: 15px;
  letter-spacing: 0.01em;
}

/* ---------- Word toolbar ---------- */

.toolbar-card {
  padding: 16px;
  margin: 16px 0;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.search-field {
  flex: 1 1 280px;
  min-width: 0;
}

.search-field input {
  width: 100%;
  height: 44px;
  padding: 0 14px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 14px;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.search-field input::placeholder {
  color: var(--muted);
}

.search-field input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px rgba(47, 109, 163, 0.16);
}

.select {
  height: 44px;
  padding: 0 34px 0 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface-2);
  color: var(--ink);
  font-size: 13.5px;
  cursor: pointer;
}

.segmented {
  display: inline-flex;
  gap: 2px;
  padding: 4px;
  border-radius: var(--radius-sm);
  background: rgba(120, 125, 140, 0.1);
}

.segmented button {
  padding: 7px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--muted);
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
}

.segmented button.is-active {
  background: var(--surface);
  color: var(--ink);
  box-shadow: 0 1px 2px rgba(23, 26, 33, 0.1);
}

.toolbar-meta {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 12px;
  color: var(--muted);
  font-size: 12px;
}

/* ---------- Word list ---------- */

.word-list {
  display: grid;
  gap: 8px;
}

.word-item {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface);
  overflow: hidden;
}

.word-list .word-row {
  display: grid;
  grid-template-columns: 22px minmax(0, 1fr) auto auto auto;
  gap: 12px;
  align-items: center;
  padding: 11px 14px;
  border-top: 0;
}

.word-list .word-row:hover {
  background: var(--surface-2);
}

.word-list .word-row input[type="checkbox"] {
  width: 17px;
  height: 17px;
  accent-color: var(--green);
  cursor: pointer;
}

.word-main {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.word-en {
  font-size: 14px;
  font-weight: 650;
  overflow-wrap: anywhere;
}

.word-zh {
  color: var(--muted);
  font-size: 12.5px;
}

.word-chapter {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  white-space: nowrap;
}

.word-item.is-mastered .word-en {
  color: var(--muted);
  text-decoration: line-through;
  text-decoration-thickness: 1px;
}

.word-detail {
  padding: 12px 16px 14px 48px;
  border-top: 1px dashed var(--line);
  background: var(--surface-2);
}

.word-detail__en {
  margin: 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.7;
}

.word-detail__zh {
  margin: 3px 0 8px;
  color: var(--muted);
  font-size: 12.5px;
}

.word-detail .btn {
  margin-top: 2px;
}

.basic-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.basic-word {
  position: relative;
  display: block;
  padding: 10px 42px 10px 12px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.basic-word b {
  display: block;
  font-weight: 650;
  line-height: 1.4;
}

.basic-word span {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-size: 11.5px;
}

.basic-word .icon-btn {
  position: absolute;
  top: 50%;
  right: 8px;
  width: 28px;
  height: 28px;
  transform: translateY(-50%);
}

.empty-state {
  margin: 16px 0;
  padding: 44px 20px;
  border: 1px dashed var(--line);
  border-radius: var(--radius-md);
  color: var(--muted);
  text-align: center;
  font-size: 13.5px;
}

/* ---------- Flashcard dialog ---------- */

.modal {
  width: min(580px, calc(100% - 28px));
  max-height: calc(100dvh - 40px);
  padding: 0;
  border: 0;
  border-radius: 22px;
  background: transparent;
  color: var(--ink);
}

.modal::backdrop {
  background: rgba(6, 15, 26, 0.62);
  backdrop-filter: blur(4px);
}

.modal__panel {
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: var(--surface);
  box-shadow: var(--shadow);
}

.modal__head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 14px;
}

.modal__head h2 {
  margin-top: 6px;
  font-size: 19px;
}

.flashcard {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 270px;
  margin-top: 18px;
  padding: 26px 24px;
  border: 1px solid var(--line);
  border-radius: 16px;
  background:
    radial-gradient(420px 220px at 50% 0%, rgba(199, 137, 45, 0.12), transparent 70%),
    var(--surface-2);
  text-align: center;
  cursor: pointer;
}

.flashcard__word {
  font-size: clamp(26px, 5vw, 34px);
  font-weight: 760;
  letter-spacing: -0.02em;
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.flashcard__zh {
  font-size: 22px;
  font-weight: 700;
}

.flashcard__example {
  max-width: 460px;
  color: var(--ink-soft);
  font-size: 14px;
  line-height: 1.7;
}

.flashcard__translation {
  color: var(--muted);
  font-size: 12.5px;
}

.flashcard__hint {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
}

.flash-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 14px;
}

.flash-progress {
  margin-top: 12px;
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
  text-align: right;
}

/* ---------- Original Q&A / self-test ---------- */

.qa-list,
.selftest-list {
  display: grid;
  gap: 8px;
  margin-top: 16px;
}

.qa-item,
.selftest-item {
  border: 1px solid var(--line);
  border-radius: 11px;
  background: var(--surface-2);
  overflow: hidden;
}

.qa-item summary,
.selftest-item summary {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 13px 15px;
  cursor: pointer;
  list-style: none;
  font-size: 13.5px;
  font-weight: 600;
  line-height: 1.55;
}

.qa-item summary::-webkit-details-marker,
.selftest-item summary::-webkit-details-marker {
  display: none;
}

.qa-item summary::before,
.selftest-item summary::before {
  content: "+";
  flex: none;
  color: var(--accent);
  font-family: var(--mono);
  font-weight: 700;
}

.qa-item[open] summary::before,
.selftest-item[open] summary::before {
  content: "−";
}

.qa-answer,
.selftest-answer {
  padding: 0 15px 14px 35px;
  font-size: 13px;
  line-height: 1.7;
}

.qa-answer .en {
  color: var(--ink-soft);
  font-weight: 600;
}

.qa-answer .hint,
.selftest-answer {
  color: var(--muted);
}

.selftest-answer .answer {
  color: var(--ink-soft);
  font-weight: 600;
}

/* ---------- Process / patterns / tips ---------- */

.process-chain {
  display: grid;
  gap: 10px;
}

.process-chain p {
  margin: 0;
  padding: 11px 15px;
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.75;
}

.pattern-list {
  display: grid;
  gap: 8px;
}

.pattern-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
}

.tip-list {
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--ink-soft);
  font-size: 13px;
  line-height: 1.8;
}

.closing-note {
  margin: 18px 0 0;
  padding-top: 14px;
  border-top: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12.5px;
}

/* ---------- Quiz ---------- */

.quiz-panel {
  margin-top: 14px;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface-2);
}

.quiz-question {
  font-size: 16px;
  font-weight: 650;
  line-height: 1.6;
}

.quiz-options {
  display: grid;
  gap: 8px;
  margin: 14px 0;
}

.quiz-option {
  width: 100%;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface);
  color: var(--ink);
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.quiz-option:hover {
  border-color: var(--line-strong);
}

.quiz-option.is-correct {
  border-color: rgba(29, 122, 95, 0.55);
  background: rgba(29, 122, 95, 0.1);
}

.quiz-option.is-wrong {
  border-color: rgba(181, 59, 49, 0.5);
  background: rgba(181, 59, 49, 0.08);
}

.quiz-option:disabled {
  cursor: default;
  opacity: 0.85;
}

.quiz-feedback {
  min-height: 22px;
  color: var(--muted);
  font-size: 12.5px;
}

.quiz-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
}

.quiz-progress {
  color: var(--muted);
  font-family: var(--mono);
  font-size: 11px;
}

.quiz-result {
  margin-top: 14px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--surface);
}

.quiz-result h3 {
  font-size: 18px;
  margin-bottom: 4px;
}

.quiz-result .score {
  color: var(--accent);
  font-family: var(--mono);
  font-size: 28px;
}

.quiz-result-list {
  display: grid;
  gap: 6px;
  margin-top: 12px;
  padding: 0;
  list-style: none;
  font-size: 12.5px;
}

.quiz-result-list li {
  display: flex;
  gap: 8px;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
}

.quiz-result-list .ok {
  color: var(--green);
}

.quiz-result-list .bad {
  color: var(--red);
}

.quiz-history {
  margin-top: 20px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

.quiz-history h3 {
  font-size: 14px;
  margin-bottom: 8px;
}

.attempt {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 5px 0;
  border-bottom: 1px dashed var(--line);
  color: var(--muted);
  font-size: 12px;
}

.attempt:last-child {
  border-bottom: 0;
}

.attempt b {
  color: var(--ink);
  font-family: var(--mono);
}

/* ---------- Communication content ---------- */

.module-section .section-title {
  margin-bottom: 4px;
}

.module-blocks {
  margin-top: 6px;
}

.module-blocks h3 {
  margin: 22px 0 8px;
  font-size: 16px;
  letter-spacing: -0.01em;
}

.module-blocks h4 {
  margin: 18px 0 6px;
  color: var(--ink-soft);
  font-size: 14px;
  font-weight: 650;
}

.module-blocks > p {
  margin: 8px 0;
  color: var(--ink-soft);
  font-size: 13.5px;
  line-height: 1.8;
}

.phrase-list {
  display: grid;
  gap: 8px;
  margin: 10px 0;
  padding: 0;
  list-style: none;
}

.phrase-card {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 13px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--surface-2);
  font-size: 13px;
  line-height: 1.65;
}

.phrase-card .phrase-text {
  min-width: 0;
  overflow-wrap: anywhere;
}

.phrase-card .icon-btn {
  flex: none;
  width: 30px;
  height: 30px;
}

.table-wrap {
  margin: 12px 0;
  border: 1px solid var(--line);
  border-radius: 12px;
  overflow-x: auto;
}

.table-wrap table {
  width: 100%;
  min-width: 520px;
  border-collapse: collapse;
  font-size: 12.8px;
  line-height: 1.6;
}

.table-wrap th,
.table-wrap td {
  padding: 9px 12px;
  border-bottom: 1px solid var(--line);
  text-align: left;
  vertical-align: top;
}

.table-wrap th {
  background: var(--surface-2);
  color: var(--ink);
  font-weight: 650;
}

.table-wrap td {
  color: var(--ink-soft);
  white-space: pre-line;
}

.table-wrap tr:last-child td {
  border-bottom: 0;
}

.framework-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-top: 16px;
}

.framework-card {
  padding: 15px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.framework-card h3 {
  margin: 0 0 8px;
  font-size: 14px;
}

.framework-flow {
  margin: 0 0 8px;
  padding: 8px 10px;
  border: 1px dashed var(--line);
  border-radius: 8px;
  background: var(--surface);
  color: var(--ink-soft);
  font-family: var(--mono);
  font-size: 11.5px;
  line-height: 1.65;
  overflow-wrap: anywhere;
}

.framework-card p {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
}

.module-toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 10px;
  padding-top: 12px;
  border-top: 1px dashed var(--line);
}

.status-pill.is-done {
  color: var(--green);
}

.term-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 8px;
  margin-top: 14px;
}

.term {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 11px;
  border: 1px solid var(--line);
  border-radius: 9px;
  background: var(--surface-2);
  font-size: 12.5px;
}

.term b {
  font-weight: 650;
}

.term span {
  color: var(--muted);
  white-space: nowrap;
}

.scenario-note {
  margin: 14px 0;
  padding: 12px 15px;
  border: 1px solid var(--line);
  border-left: 3px solid var(--accent);
  border-radius: 0 10px 10px 0;
  background: var(--surface-2);
  color: var(--ink-soft);
  font-size: 12.5px;
}

.plan-table td:first-child {
  white-space: nowrap;
  color: var(--ink);
  font-family: var(--mono);
  font-size: 12px;
}

.chapter-card {
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.chapter-card:hover {
  transform: translateY(-2px);
  border-color: var(--line-strong);
  box-shadow: 0 16px 30px -22px rgba(15, 34, 54, 0.45);
}

.quiz-form {
  display: grid;
  gap: 12px;
  margin-top: 16px;
}

.quiz-block {
  min-width: 0;
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--surface-2);
}

.quiz-block h3 {
  margin: 0 0 8px;
  font-size: 13.5px;
  font-weight: 650;
  line-height: 1.6;
}

.quiz-block label {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: 13px;
  line-height: 1.55;
  cursor: pointer;
}

.quiz-block input[type="radio"] {
  margin-top: 3px;
  accent-color: var(--brand);
}

/* ---------- Responsive additions ---------- */

@media (max-width: 720px) {
  .subnav {
    position: static;
    flex-wrap: wrap;
    overflow: visible;
    background: none;
  }

  [id] {
    scroll-margin-top: 150px;
  }

  .table-wrap table {
    min-width: 0;
  }

  .table-wrap th,
  .table-wrap td {
    padding: 8px 9px;
    font-size: 12px;
  }

  .content-section,
  .panel {
    padding: 18px;
  }

  .toolbar-row {
    flex-direction: column;
    align-items: stretch;
  }

  .segmented {
    justify-content: space-between;
  }

  .segmented button {
    flex: 1;
  }

  .word-list .word-row {
    grid-template-columns: 22px minmax(0, 1fr) auto;
    row-gap: 5px;
  }

  .word-chapter {
    grid-column: 2;
    grid-row: 2;
  }

  .word-list .word-row .speak {
    grid-column: 3;
    grid-row: 1;
  }

  .word-list .word-row .detail-toggle {
    grid-column: 3;
    grid-row: 2;
  }

  .word-detail {
    padding-left: 16px;
  }

  .section-title {
    align-items: flex-start;
  }

  .framework-grid {
    grid-template-columns: 1fr;
  }

  .term-grid {
    grid-template-columns: 1fr 1fr;
  }
}

@media (max-width: 480px) {
  .subnav {
    top: 104px;
  }

  .term-grid {
    grid-template-columns: 1fr;
  }

  .flash-actions .btn {
    flex: 1 1 40%;
  }

  .quiz-footer {
    flex-direction: column;
    align-items: stretch;
  }

  .quiz-footer .btn {
    width: 100%;
  }
}
