/* school-article-reader.css
   Styling for ArticleReader.mount() container.
   All rules scoped to .sar-shell so they can't bleed into lesson/runner CSS. */

.sar-shell {
  display: flex;
  flex-direction: column;
  background: #fff;
  color: #1a1a1a;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  max-height: 88vh;
}

.sar-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid #e6e6e6;
  background: #fafafa;
  flex-shrink: 0;
}

.sar-title-block { flex: 1; min-width: 0; }
.sar-title { margin: 0 0 4px 0; font-size: 22px; line-height: 1.25; font-weight: 700; color: #1a1a1a; }
.sar-author { font-size: 13px; color: #666; }

.sar-controls {
  display: flex;
  align-items: flex-start;
  gap: 18px;
  flex-shrink: 0;
  flex-wrap: wrap;
}
.sar-control-group { display: flex; flex-direction: column; gap: 5px; }
.sar-ctl-label, .sar-depth-label { font-size: 12px; color: #555; }
.sar-depth-heading, .sar-bias-heading {
  font-weight: 600;
  color: #1a1a1a;
  margin-left: 4px;
}

.sar-depth-btns, .sar-bias-btns { display: flex; gap: 4px; }

/* Bias slider: cool (left) → neutral → warm (right). Active = filled. */
.sar-bias-btn {
  width: 34px; height: 30px;
  border: 1px solid #ccc; background: #fff; border-radius: 6px;
  font-weight: 600; font-size: 12px; color: #555; cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sar-bias-btn:hover { border-color: #888; }
.sar-bias-btn[data-bias="L1"].active, .sar-bias-btn[data-bias="L2"].active { background: #2563eb; color: #fff; border-color: #2563eb; }
.sar-bias-btn[data-bias="C"].active { background: #555; color: #fff; border-color: #555; }
.sar-bias-btn[data-bias="R1"].active, .sar-bias-btn[data-bias="R2"].active { background: #b91c1c; color: #fff; border-color: #b91c1c; }

.sar-truth-toggle {
  border: 1px solid #ccc; background: #fff; border-radius: 6px;
  padding: 6px 12px; font-weight: 600; font-size: 12px; color: #555;
  cursor: pointer; transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sar-truth-toggle:hover { border-color: #888; }
.sar-truth-toggle.active { background: #047857; color: #fff; border-color: #047857; }
.sar-level-btn {
  width: 30px;
  height: 30px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  color: #555;
  cursor: pointer;
  transition: background 0.12s, color 0.12s, border-color 0.12s;
}
.sar-level-btn:hover { border-color: #888; }
.sar-level-btn.active {
  background: #2563eb;
  color: #fff;
  border-color: #2563eb;
}

.sar-close {
  width: 32px;
  height: 32px;
  border: 1px solid #ccc;
  background: #fff;
  border-radius: 6px;
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  color: #555;
}
.sar-close:hover { background: #f1f1f1; color: #000; }

.sar-body {
  flex: 1;
  overflow-y: auto;
  padding: 24px 28px 32px 28px;
  font-size: 16px;
  line-height: 1.65;
  color: #222;
}

.sar-body h2 { font-size: 20px; margin: 28px 0 10px; }
.sar-body h3 { font-size: 17px; margin: 22px 0 8px; }
.sar-body h4 { font-size: 15px; margin: 18px 0 6px; }
.sar-body p { margin: 0 0 14px 0; }
.sar-body ul, .sar-body ol { margin: 0 0 14px 22px; }
.sar-body li { margin-bottom: 6px; }
.sar-body code { background: #f1f1f1; padding: 1px 5px; border-radius: 3px; font-size: 0.92em; }
.sar-body strong { font-weight: 700; }
.sar-body em { font-style: italic; }

.sar-body .article-img,
.sar-body .img-float img {
  max-width: 100%;
  height: auto;
  border-radius: 6px;
}
.sar-body .img-float { margin: 10px 14px 10px 0; max-width: 45%; }
.sar-body .img-float-right { float: right; margin: 10px 0 10px 14px; }
.sar-body .img-float-left { float: left; }
.sar-body .img-float-caption { font-size: 12px; color: #777; padding: 4px 0; }

.sar-body .wiki-link { color: #2563eb; text-decoration: underline; cursor: pointer; }
.sar-body .wiki-link:hover { color: #1d4ed8; }
.sar-body .cite-ref a { color: #6366f1; text-decoration: none; padding: 0 2px; }
.sar-body .cite-ref a:hover { text-decoration: underline; }

.sar-body .references-section {
  margin-top: 32px;
  padding-top: 16px;
  border-top: 1px solid #e6e6e6;
  font-size: 14px;
  color: #555;
}
.sar-body .ref-list { margin-left: 22px; }
.sar-body .ref-item .ref-back {
  font-weight: 700;
  color: #6366f1;
  text-decoration: none;
  margin-right: 4px;
}

.sar-body .depth-tag.hidden,
.sar-body .bias-tag.hidden,
.sar-body .combo-tag.hidden,
.sar-body .depth-meta {
  display: none !important;
}

/* Truth tags: claim text renders plain by default. When Truth View is on,
   each tagged claim gets a tier-colored underline so facts/claims/opinions
   are visually distinct, and the span becomes clickable for its citations. */
.sar-body .truth-tag { cursor: default; }
.sar-body.truth-view .truth-tag {
  cursor: pointer;
  border-bottom: 2px solid #9ca3af;
  padding-bottom: 1px;
}
.sar-body.truth-view .truth-tag[data-tier="verified"] { border-bottom-color: #047857; }
.sar-body.truth-view .truth-tag[data-tier="proposed"] { border-bottom-color: #2563eb; border-bottom-style: dashed; }
.sar-body.truth-view .truth-tag[data-tier="claim"]    { border-bottom-color: #d97706; border-bottom-style: dashed; }
.sar-body.truth-view .truth-tag[data-tier="opinion"]  { border-bottom-color: #7c3aed; border-bottom-style: dotted; }
.sar-body.truth-view .truth-tag[data-cite-count]::after {
  content: " \1F517";
  font-size: 0.7em; opacity: 0.55; vertical-align: super;
}

/* Citation popover (appended to <body>, fixed-position near the clicked tag) */
.sar-truth-popover {
  position: absolute;
  z-index: 9500;
  max-width: 340px;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.18);
  padding: 10px 12px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 13px;
  color: #1a1a1a;
}
.sar-tp-header { font-size: 12px; color: #555; margin-bottom: 6px; padding-bottom: 6px; border-bottom: 1px solid #eee; }
.sar-tp-body { display: flex; flex-direction: column; gap: 5px; }
.sar-tp-empty { color: #777; font-style: italic; }
.sar-cite-row { display: flex; align-items: center; gap: 6px; }
.sar-cite-row a { color: #2563eb; text-decoration: none; }
.sar-cite-row a:hover { text-decoration: underline; }
.sar-cite-broken { color: #9ca3af; }
.sar-cite-tier {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 4px;
  font-size: 11px; font-weight: 700; color: #fff; flex-shrink: 0;
}
.sar-cite-tier-A { background: #047857; }
.sar-cite-tier-B { background: #2563eb; }
.sar-cite-tier-C { background: #d97706; }
.sar-cite-tier-D { background: #7c3aed; }
.sar-cite-tier-E { background: #6b7280; }
.sar-cite-tier-F { background: #0891b2; }
.sar-cite-tier-\? { background: #9ca3af; }

.sar-loading, .sar-error {
  padding: 28px;
  text-align: center;
  color: #666;
  font-size: 15px;
}
.sar-error { color: #b91c1c; }

@media (max-width: 600px) {
  .sar-header { flex-direction: column; gap: 10px; padding: 14px 16px; }
  .sar-controls { width: 100%; justify-content: space-between; }
  .sar-body { padding: 16px 18px 24px 18px; font-size: 15px; }
  .sar-title { font-size: 18px; }
}

/* Companion-reading cards on the lesson finish screen */
.lesson-companion {
  margin: 24px 0;
  padding: 16px;
  background: #f8f6f0;
  border: 1px solid #e0d9c2;
  border-radius: 10px;
}
.lesson-companion-label {
  font-family: 'Inter', sans-serif;
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: #6b5d3a;
  margin-bottom: 10px;
}
.lesson-companion-card {
  display: block;
  width: 100%;
  text-align: left;
  background: #fff;
  border: 1px solid #d8cfa9;
  border-radius: 8px;
  padding: 14px 18px;
  margin-bottom: 8px;
  cursor: pointer;
  font-family: inherit;
  transition: border-color 0.12s, box-shadow 0.12s;
}
.lesson-companion-card:hover {
  border-color: #b9a967;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}
.lesson-companion-card .lcc-title {
  display: block;
  font-weight: 600;
  font-size: 16px;
  color: #1a1a1a;
}
.lesson-companion-card .lcc-summary {
  display: block;
  font-size: 13px;
  color: #555;
  margin-top: 4px;
  line-height: 1.5;
}
.lesson-companion-card .lcc-cta {
  display: inline-block;
  margin-top: 8px;
  font-size: 13px;
  font-weight: 600;
  color: #2563eb;
}

/* Article reader overlay (lesson-runner mounts ArticleReader inside this) */
.sar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 30, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9000;
  padding: 16px;
}
.sar-overlay-inner {
  width: 100%;
  max-width: 880px;
  max-height: 92vh;
}
