/*
 * CertaRounds — Teach Me (sheet + #/teach/:qid) and the shared read-only question view (qv-)
 * · src/screens/teach.js. Semantic tokens only. The sheet lives in <body>, so everything is
 * scoped by its own teach- / qv- classes.
 */

/* ============ Header (inside the sheet title) ============ */
.teach-head { display: flex; align-items: center; gap: var(--sp-3); min-width: 0; }
.teach-head__text { display: flex; flex-direction: column; gap: 1px; min-width: 0; }
.teach-head__over {
  font-size: var(--fs-12); font-weight: var(--fw-semibold); line-height: 1.3;
  letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-accent);
}
.teach-head__title { font-size: 16px; font-weight: var(--fw-bold); line-height: 1.3; letter-spacing: var(--tracking-snug); color: var(--text-strong); text-wrap: balance; }   /* phones 16px + balanced lines (R4 P2) */
@media (min-width: 768px) { .teach-head__title { font-size: var(--fs-20); letter-spacing: var(--tracking-tight); } }

.teach-metarow { --cluster: var(--sp-2) var(--sp-3); }
.teach-metarow__text { font-size: var(--fs-13); line-height: 1.4; color: var(--text-3); white-space: nowrap; }

/* ============ Sections ============ */
.teach-body { min-height: 120px; }
.teach-sec { display: flex; flex-direction: column; gap: var(--sp-3); }
.teach-sec__head { display: flex; align-items: baseline; justify-content: space-between; gap: var(--sp-3); }
.teach-sec__title { font-size: var(--fs-15); font-weight: var(--fw-bold); line-height: 1.3; letter-spacing: var(--tracking-snug); color: var(--text-strong); }
.teach-sec__meta { font-size: var(--fs-13); color: var(--text-3); white-space: nowrap; }
.teach-empty { font-size: var(--fs-15); line-height: 1.5; color: var(--text-2); }
@media (min-width: 768px) { .teach-sec__title { font-size: var(--fs-17); } }

/* The concept: this question's own explanation, never generated text */
.teach-concept__label { font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--text-accent); }
.teach-concept {
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
}
.teach-concept__p { font-size: var(--fs-15); line-height: 1.6; color: var(--text); }
.teach-concept__p + .teach-concept__p { margin-top: var(--sp-3); }
/* The question this explanation belongs to (its stem, two lines, the rest one tap away) — gives
   "this man" in the explanation its antecedent */
.teach-qctx { display: flex; flex-direction: column; gap: 4px; padding-left: var(--sp-3); border-left: 3px solid var(--border-strong); }
.teach-qctx__label { font-size: var(--fs-12); font-weight: var(--fw-semibold); line-height: 1.3; letter-spacing: var(--tracking-wide); text-transform: uppercase; color: var(--text-3); }
.teach-qctx__stem { max-width: var(--measure); font-size: var(--fs-15); line-height: 1.5; color: var(--text-2); }
.teach-qctx__stem.is-clamped { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.teach-qctx__more { align-self: flex-start; margin: -2px 0 -4px -12px; }
/* Go deeper / Board pearl: divided rows, as in the answer panel */
.teach-more { margin-top: calc(-1 * var(--sp-1)); border-top: 1px solid var(--divider); }
.teach-concept__more { align-self: flex-start; margin: calc(-1 * var(--sp-2)) 0 0 -12px; }
@media (min-width: 768px) { .teach-concept__p { font-size: 1rem; } }

.teach-gate {
  display: flex; align-items: center; gap: var(--sp-3);
  padding: 14px var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-2);
  box-shadow: inset 0 0 0 1px var(--border);
  font-size: var(--fs-13); line-height: 1.45; color: var(--text-2);
}
.teach-gate > .icon { color: var(--accent); }
.teach-gate__title { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--text-strong); }

/* Your record on this topic (engine mastery node) */
.teach-record {
  display: flex; flex-direction: column; gap: 10px;
  padding: var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface);
  box-shadow: inset 0 0 0 1px var(--border);
}
.teach-record__top { display: flex; align-items: center; justify-content: space-between; gap: var(--sp-3); }
.teach-record__value { display: flex; align-items: baseline; gap: 6px; }
.teach-record__value .tnum { font-size: var(--fs-30); font-weight: var(--fw-bold); line-height: 1; letter-spacing: -0.02em; color: var(--text-strong); }
.teach-record__unit { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-3); }
.teach-record__empty { font-size: var(--fs-15); font-weight: var(--fw-semibold); color: var(--text-strong); }
.teach-record__meta { font-size: var(--fs-13); line-height: 1.45; color: var(--text-3); text-wrap: pretty; }
.teach-record--empty { gap: 4px; background: var(--surface-2); }

/* Related questions (same chapter) */
.teach-rel { display: flex; flex-direction: column; border-radius: var(--r-md); box-shadow: inset 0 0 0 1px var(--border); overflow: hidden; }
.teach-rel > li + li { border-top: 1px solid var(--divider); }
.teach-rel__row {
  display: grid;
  grid-template-columns: 28px minmax(0, 1fr) 18px;
  align-items: center;
  gap: var(--sp-3);
  width: 100%;
  min-height: 64px;
  padding: 12px var(--sp-3) 12px 14px;
  text-align: left;
  color: var(--text);
  transition: background var(--dur-1) var(--ease-out);
}
.teach-rel__row:hover { background: var(--surface-hover); }
.teach-rel__row:active { background: var(--surface-pressed); }
.teach-rel__row:focus-visible { outline: none; box-shadow: inset 0 0 0 2px var(--focus); }
.teach-rel > li:first-child .teach-rel__row { border-radius: var(--r-md) var(--r-md) 0 0; }
.teach-rel > li:last-child .teach-rel__row { border-radius: 0 0 var(--r-md) var(--r-md); }
.teach-rel > li:only-child .teach-rel__row { border-radius: var(--r-md); }
.teach-rel__mark { display: grid; place-items: center; width: 28px; height: 28px; border-radius: 50%; }
/* not seen yet: a small accent dot (an empty ring read as an unchecked radio — R4 P2) */
.teach-rel__row--new .teach-rel__mark { width: 8px; height: 8px; margin: 10px; background: var(--accent); box-shadow: none; }
.teach-rel__row--ok .teach-rel__mark { background: var(--success-bg); color: var(--success); }
.teach-rel__row--bad .teach-rel__mark { background: var(--danger-bg); color: var(--danger); }
.teach-rel__body { display: flex; flex-direction: column; gap: 4px; min-width: 0; }
.teach-rel__stem {
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  font-size: var(--fs-15); line-height: 1.4; color: var(--text);
}
.teach-rel__meta { display: flex; flex-wrap: wrap; align-items: center; font-size: var(--fs-12); font-weight: var(--fw-medium); color: var(--text-3); }
.teach-rel__meta > span + span::before { content: "·"; margin: 0 6px; color: var(--text-3); font-weight: var(--fw-regular); }
.teach-rel__row--new .teach-rel__st { color: var(--text-accent); font-weight: var(--fw-semibold); }
.teach-rel__row--bad .teach-rel__st { color: var(--danger); font-weight: var(--fw-semibold); }
.teach-rel__row--ok .teach-rel__st { color: var(--success); font-weight: var(--fw-semibold); }
.teach-rel__chev { color: var(--text-3); }
.teach-rel__row:hover .teach-rel__chev { color: var(--link); }

/* Source + honesty line */
.teach-source { gap: var(--sp-2); padding-top: var(--sp-4); border-top: 1px solid var(--divider); }
.teach-honest { display: flex; align-items: flex-start; gap: var(--sp-2); font-size: var(--fs-12); line-height: 1.45; color: var(--text-3); }
.teach-honest .icon { color: var(--success); margin-top: 1px; }

/* Footer: Quiz me on this */
.teach-foot { flex: 1 1 auto; min-width: 0; }
.teach-quizwrap { display: flex; flex-direction: column; gap: 6px; }
.teach-quiz__note { font-size: var(--fs-12); line-height: 1.4; color: var(--text-3); text-align: center; }
/* desktop panel: content-width button with its one-line note beside it */
.teach-quizwrap--inline { flex-direction: row; align-items: center; gap: var(--sp-4); }
.teach-quizwrap--inline .teach-quiz__note { text-align: left; }

/* ============ Deep-link page (#/teach/:qid) ============ */
.teach-page__head { display: flex; align-items: center; gap: var(--sp-4); }
.teach-page__back { align-self: flex-start; margin: calc(-1 * var(--sp-2)) 0 calc(-1 * var(--sp-3)) -12px; }
.teach-page__title { font-size: var(--fs-24); margin-top: 2px; }
.teach-page__quiz { width: 100%; }
@media (min-width: 768px) {
  .teach-page__head .teach-page__quiz { flex: 0 0 248px; width: auto; }
  .teach-page__head .teach-quiz__note { text-align: left; }
}
@media (min-width: 1024px) { .teach-page__title { font-size: var(--fs-30); } }
/* ≥1200: reading column (concept · related · source) + the shell's rail (record · Quiz me) */
.teach-page--wide .teach-concept__p { max-width: var(--measure); }
.teach-railcard { display: flex; flex-direction: column; gap: var(--sp-5); }
.teach-railcard .teach-record { padding: 0; box-shadow: none; background: none; }
.teach-railcard .teach-record--empty { padding: var(--sp-4); background: var(--surface-2); }
.teach-railcard .teach-quizwrap { padding-top: var(--sp-4); border-top: 1px solid var(--divider); }

/* ============ Read-only question view (results sheet · related question) ============ */
.qv { display: flex; flex-direction: column; gap: var(--sp-4); }
.qv-back { align-self: flex-start; margin: -4px 0 -6px -12px; }
.qv-chips { --cluster: var(--sp-2); }
/* Verdict meta: whole items wrap; each item's leading "·" sits in the 14px gutter, which the row
   clips at the left edge, so no line ever starts with a dangling separator */
.qv-meta { display: block; overflow: hidden; }
.qv-meta__row { display: flex; flex-wrap: wrap; margin-left: -14px; }
.qv-seg { white-space: nowrap; }
.qv-seg::before { content: "·"; display: inline-block; width: 14px; text-align: center; }
.qv-status { font-size: var(--fs-13); font-weight: var(--fw-medium); color: var(--text-3); }
.qv-key { display: flex; align-items: center; gap: var(--sp-2); font-size: var(--fs-13); font-weight: var(--fw-semibold); color: var(--success-strong); }
.qv-key .icon { color: var(--success); }
.qv-stem { max-width: var(--measure); font-size: var(--fs-stem); line-height: var(--lh-stem); color: var(--text); }
.qv-skipped {
  display: flex; align-items: flex-start; gap: var(--sp-3);
  padding: 14px var(--sp-4);
  border-radius: var(--r-md);
  background: var(--surface-sunken);
  font-size: var(--fs-15); line-height: 1.5; color: var(--text-2);
}
.qv-skipped strong { color: var(--text-strong); }
.qv-skipped .icon { margin-top: 1px; color: var(--text-3); }
.qv-checkrow { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-3); }
.qv-note { display: flex; align-items: flex-start; gap: var(--sp-2); margin-top: calc(-1 * var(--sp-2)); font-size: var(--fs-12); line-height: 1.45; color: var(--text-3); }
.qv-note .icon { color: var(--text-3); margin-top: 1px; }
.qv-explain { display: flex; flex-direction: column; gap: var(--sp-2); }
.qv-p + .qv-p { margin-top: var(--sp-3); }
.qv-cite { padding-top: var(--sp-3); border-top: 1px solid var(--divider); }

/* D7: 44px targets on phones */
@media (max-width: 767px) {
  .teach-concept__more, .qv-back, .teach-qctx__more { min-height: 44px; }
  /* "Hidden until you answer" on one line: Show moves under the text, aligned with it (R3 P2) */
  .teach-gate { flex-wrap: wrap; align-items: flex-start; row-gap: var(--sp-2); }
  .teach-gate > .icon { margin-top: 1px; }
  .teach-gate > .grow { flex: 1 1 calc(100% - 20px - var(--sp-3)); min-width: 0; }
  .teach-gate > .btn { margin-left: calc(20px + var(--sp-3)); min-height: 44px; }
  .teach-gate__title { white-space: nowrap; }
}
