/* Result view: scorecard, report prose, and the source registry. */

/* ═══ Tabs ═════════════════════════════════════════════════════════════ */

.tabs {
  display: flex;
  gap: var(--space-1);
  border-bottom: 1px solid var(--border-subtle);
  margin-bottom: var(--space-6);
}

.tab {
  padding: var(--space-3) var(--space-4);
  color: var(--text-tertiary);
  font-size: var(--text-base);
  font-weight: 500;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color var(--duration-fast) var(--ease),
              border-color var(--duration-fast) var(--ease);
}
.tab:hover { color: var(--text-secondary); }
.tab[data-active="true"] {
  color: var(--text-primary);
  border-bottom-color: var(--accent);
}

/* Panels fill the pane. Only running prose needs a narrow measure, and it
   sets one itself — a shared 780px cap made the scorecard needlessly cramped
   on a wide screen. */
.panel { max-width: none; }

/* ═══ Scorecard ════════════════════════════════════════════════════════ */

.scorecard__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-4);
  margin-bottom: var(--space-8);
}

.scorecard__figure { display: flex; align-items: baseline; gap: var(--space-2); }
.scorecard__value {
  font-size: 48px;
  font-weight: 600;
  line-height: 1;
  letter-spacing: -0.03em;
}
.scorecard__figure[data-tone="success"] .scorecard__value { color: var(--success); }
.scorecard__figure[data-tone="accent"]  .scorecard__value { color: var(--accent); }
.scorecard__figure[data-tone="warning"] .scorecard__value { color: var(--warning); }
.scorecard__figure[data-tone="muted"]   .scorecard__value { color: var(--text-tertiary); }

.scorecard__denom { font-size: var(--text-md); color: var(--text-disabled); }

.scorecard__caption { display: flex; flex-direction: column; gap: 2px; }
.scorecard__band {
  font-size: var(--text-md);
  font-weight: 600;
  color: var(--text-primary);
}
.scorecard__label { font-size: var(--text-sm); color: var(--text-tertiary); }

/* ── Dimensions ── */
.dims { display: flex; flex-direction: column; gap: var(--space-3); }

.dim {
  display: grid;
  grid-template-columns: 200px 1fr 80px;
  align-items: center;
  gap: var(--space-4);
}
.dim__label { font-size: var(--text-base); color: var(--text-secondary); }
.dim__bar {
  height: 6px;
  border-radius: var(--radius-full);
  background: var(--bg-overlay);
  overflow: hidden;
}
.dim__fill {
  height: 100%;
  border-radius: var(--radius-full);
  background: var(--accent);
  /* Bars grow on first paint; the delay is enough to read as deliberate
     rather than as a slow render. */
  transition: width var(--duration-slow) var(--ease-out);
}
.dim__value {
  font-size: var(--text-sm);
  color: var(--text-tertiary);
  text-align: right;
}

/* ── Risks and opportunities ── */
.notes { margin-top: var(--space-8); }
.notes__title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: var(--space-3);
}
.notes__list { list-style: none; display: flex; flex-direction: column; gap: var(--space-3); }
.notes__list li {
  position: relative;
  padding-left: var(--space-4);
  font-size: var(--text-base);
  color: var(--text-secondary);
  line-height: var(--leading-relaxed);
}
.notes__list li::before {
  content: "";
  position: absolute;
  left: 0;
  top: 9px;
  width: 4px; height: 4px;
  border-radius: var(--radius-full);
  background: var(--text-disabled);
}

/* ═══ Report prose ═════════════════════════════════════════════════════ */

.prose {
  /* Full panel width, so the report's left edge lines up with the scorecard's
     and with the tabs above both. A narrower centred measure reads better for
     long English prose, but it put the report on a different vertical line
     from every other tab, which is more distracting than a long line.
     (Not `ch` either: that unit is the width of "0", and a CJK glyph is about
     twice that, so a ch-based measure is half as wide in Chinese.) */
  font-size: var(--text-md);
  line-height: var(--leading-relaxed);
  color: var(--text-secondary);
}

.prose h1 { font-size: var(--text-2xl); color: var(--text-primary); margin: 0 0 var(--space-6); }
.prose h2 {
  font-size: var(--text-lg);
  color: var(--text-primary);
  margin: var(--space-10) 0 var(--space-4);
  padding-bottom: var(--space-2);
  border-bottom: 1px solid var(--border-subtle);
}
.prose h3 { font-size: var(--text-md); color: var(--text-primary); margin: var(--space-6) 0 var(--space-3); }
.prose h4 { font-size: var(--text-base); color: var(--text-secondary); margin: var(--space-5) 0 var(--space-2); }

.prose p { margin-bottom: var(--space-4); }
.prose strong { color: var(--text-primary); font-weight: 600; }

.prose ul { margin: 0 0 var(--space-4) var(--space-5); }
.prose li { margin-bottom: var(--space-2); }

.prose code {
  padding: 1px 5px;
  border-radius: var(--radius-sm);
  background: var(--bg-overlay);
  color: var(--text-primary);
  font-size: 0.9em;
}

/* Citations are the reason the report can be audited, so they are given a
   distinct treatment rather than blending into the sentence. */
.cite {
  display: inline-block;
  padding: 0 4px;
  border-radius: var(--radius-sm);
  background: var(--accent-subtle);
  color: var(--accent);
  font-family: var(--font-mono);
  font-size: 0.82em;
  white-space: nowrap;
}

.table-wrap { overflow-x: auto; margin-bottom: var(--space-5); }
.prose table { width: 100%; border-collapse: collapse; font-size: var(--text-base); }
.prose th {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  background: var(--bg-raised);
  color: var(--text-primary);
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
}
.prose td {
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  vertical-align: top;
}

/* ═══ Sources ══════════════════════════════════════════════════════════ */

.sources__title {
  font-size: var(--text-sm);
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin: var(--space-8) 0 var(--space-3);
}
.sources__title:first-child { margin-top: 0; }

.sources__list { list-style: none; display: flex; flex-direction: column; gap: var(--space-1); }

.source {
  display: flex;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  transition: background var(--duration-fast) var(--ease);
}
.source:hover { background: var(--bg-raised); }

.source__id {
  flex-shrink: 0;
  width: 30px;
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--accent);
  padding-top: 2px;
}
.source__body { min-width: 0; }
.source__link {
  display: block;
  color: var(--text-primary);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
}
.source__link:hover { color: var(--accent); }

.source__meta {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  margin-top: var(--space-1);
  font-size: var(--text-sm);
  color: var(--text-disabled);
}

.tier {
  padding: 0 6px;
  border-radius: var(--radius-sm);
  font-size: var(--text-xs);
  font-weight: 500;
  text-transform: capitalize;
}
.tier[data-tier="high"]   { background: var(--success-subtle); color: var(--success); }
.tier[data-tier="medium"] { background: var(--warning-subtle); color: var(--warning); }
.tier[data-tier="low"]    { background: var(--bg-active);      color: var(--text-tertiary); }

/* ═══ Misc ═════════════════════════════════════════════════════════════ */

.empty-note {
  padding: var(--space-8);
  text-align: center;
  color: var(--text-tertiary);
  font-size: var(--text-base);
}

.skeleton {
  height: 180px;
  background: linear-gradient(90deg,
    var(--bg-raised) 25%, var(--bg-hover) 50%, var(--bg-raised) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite linear;
  border-radius: var(--radius-lg);
}
@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

@media (max-width: 720px) {
  .dim { grid-template-columns: 1fr; gap: var(--space-1); }
  .dim__value { text-align: left; }
  .scorecard__value { font-size: 38px; }
}

/* ── Citation check ────────────────────────────────────────────────────
 * The three counts sit side by side deliberately. "0 unsupported" on its own
 * reads as a clean bill of health; beside a large "could not be checked" it
 * means the screen mostly did not run, which is what a reader needs in order
 * to know what the first number is worth. So none of them is styled as a
 * headline the others hang off.
 */

.grounding__lede {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin: 0 0 var(--space-4);
}

.grounding__stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: var(--space-2);
  margin-bottom: var(--space-4);
}

.grounding__stat {
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border: 1px solid var(--border-subtle);
}

.grounding__stat--warn  { border-color: var(--warning); background: var(--warning-subtle); }
.grounding__stat--muted { color: var(--text-tertiary); }

.grounding__value {
  font-family: var(--font-mono);
  font-size: var(--text-xl);
  color: var(--text-primary);
}

.grounding__stat--muted .grounding__value { color: var(--text-secondary); }

.grounding__label {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
  margin-top: var(--space-1);
}

.grounding__domains {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-3);
  font-size: var(--text-sm);
  color: var(--text-secondary);
  margin: 0 0 var(--space-4);
}

.grounding__list { list-style: none; display: flex; flex-direction: column; gap: var(--space-2); }

.grounding__item {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: var(--space-1) var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  border-left: 2px solid var(--border-default);
}

.grounding__item--ungrounded { border-left-color: var(--warning); }

.grounding__id {
  font-family: var(--font-mono);
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

.grounding__claim { font-size: var(--text-sm); color: var(--text-primary); }

.grounding__why {
  grid-column: 2;
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}

/* ── Automated checks ──────────────────────────────────────────────────
 * Above the tabs, so the flags are read before the number they qualify.
 * Every figure here was already being computed and stored; what was missing
 * was any place on screen for it.
 *
 * The verdict tints the border, not the whole panel. A red block over a
 * finished assessment reads as "this run failed", which is not what any of
 * these findings mean — the run succeeded and something about its output is
 * worth a second look.
 */
.reliability {
  border: 1px solid var(--border-default);
  border-left-width: 3px;
  border-radius: var(--radius-lg);
  background: var(--bg-raised);
  padding: var(--space-4);
  margin-bottom: var(--space-5);
}
.reliability[data-tone="risk"]  { border-left-color: var(--danger); }
.reliability[data-tone="warn"]  { border-left-color: var(--warning); }
.reliability[data-tone="ok"]    { border-left-color: var(--success); }
.reliability[data-tone="muted"] { border-left-color: var(--border-strong); }

.reliability__head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.reliability__title {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.reliability__verdict {
  color: var(--text-primary);
  font-size: var(--text-base);
}

.reliability__note {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  margin: var(--space-2) 0 0;
}

.reliability__rows {
  list-style: none;
  margin: var(--space-3) 0 0;
  padding: 0;
  display: grid;
  gap: var(--space-2);
}

.reliability__row {
  display: grid;
  grid-template-columns: minmax(110px, max-content) 1fr;
  gap: var(--space-3);
  align-items: baseline;
  font-size: var(--text-sm);
}

.reliability__label { color: var(--text-tertiary); }
.reliability__detail { color: var(--text-secondary); }
.reliability__row[data-tone="risk"] .reliability__detail { color: var(--danger); }
.reliability__row[data-tone="warn"] .reliability__detail { color: var(--warning); }

@media (max-width: 640px) {
  .reliability__row { grid-template-columns: 1fr; gap: var(--space-1); }
}

/* ── Report vs scorecard ─────────────────────────────────────────────── */

.consistency__clear {
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.consistency__list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: var(--space-3);
}

.consistency__item {
  border-left: 2px solid var(--border-strong);
  padding-left: var(--space-3);
}
.consistency__item--blocker { border-left-color: var(--danger); }
.consistency__item--warning { border-left-color: var(--warning); }

.consistency__detail {
  margin: 0;
  color: var(--text-primary);
  font-size: var(--text-sm);
}

/* The quoted sentence is the point of the finding: a phrase table decided
 * this, and a reader has to be able to overrule it by reading the words. */
.consistency__excerpt {
  margin: var(--space-2) 0 0;
  color: var(--text-secondary);
  font-size: var(--text-sm);
}

.consistency__excerpt-label {
  display: block;
  color: var(--text-tertiary);
  font-size: var(--text-xs);
  margin-bottom: var(--space-1);
}

.gate__sub--retention {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}
