/*
 * Structure for the shared result renderer.
 *
 * Hosts supply the palette by mapping their own tokens onto the `--fx-*` custom
 * properties below; nothing here hard-codes a colour except the verdict bands,
 * which are semantic and must stay recognisable across themes.
 *
 * `extension/shared/` mirrors this directory verbatim; see result-model.js.
 * Tap targets are 44px on coarse pointers — every surface can end up on a phone.
 */

.fx-result {
  --fx-bg: #ffffff;
  --fx-surface: #f6f8f7;
  --fx-line: #d7dedb;
  --fx-ink: #17211d;
  --fx-muted: #66746d;
  --fx-dim: #94a3b8;
  --fx-accent: #266d91;
  --fx-radius: 8px;
  --fx-gap: 16px;

  --fx-supported: #1f7a52;
  --fx-contradicted: #bd3b2f;
  --fx-mixed: #a96f12;
  --fx-unverifiable: #69727b;

  display: grid;
  gap: var(--fx-gap);
  min-width: 0;
  color: var(--fx-ink);
  font: inherit;
}

.fx-result[data-layout="panel"],
.fx-result[data-layout="sheet"] {
  --fx-gap: 14px;
}

/* Verdict semantics. Claim and stance keys share the palette on purpose: a
   supporting source and a supported claim mean the same thing to a reader. */
[data-claim-verdict="supported"],
[data-stance="supporting"] {
  --fx-verdict: var(--fx-supported);
}

[data-claim-verdict="contradicted"],
[data-stance="contradicting"] {
  --fx-verdict: var(--fx-contradicted);
}

[data-claim-verdict="mixed"] {
  --fx-verdict: var(--fx-mixed);
}

[data-claim-verdict="unverifiable"],
[data-stance="neutral"] {
  --fx-verdict: var(--fx-unverifiable);
}

.fx-result[data-band="strong"],
.fx-result[data-band="good"] {
  --fx-band: var(--fx-supported);
}

.fx-result[data-band="mixed"] {
  --fx-band: var(--fx-mixed);
}

.fx-result[data-band="poor"],
.fx-result[data-band="critical"] {
  --fx-band: var(--fx-contradicted);
}

.fx-result[data-band="unknown"] {
  --fx-band: var(--fx-unverifiable);
}

/* ── Quoted original text ─────────────────────────────────────────────── */

.fx-quote-wrap {
  display: grid;
  gap: 2px;
  justify-items: start;
}

.fx-quote {
  position: relative;
  margin: 0;
  padding: 8px 12px 8px 26px;
  border-radius: var(--fx-radius);
  color: var(--fx-muted);
  background: var(--fx-surface);
  font-size: 0.82rem;
  font-style: italic;
  line-height: 1.55;
}

.fx-quote::before {
  content: "\201C";
  position: absolute;
  top: 2px;
  left: 9px;
  color: var(--fx-accent);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 22px;
  font-style: normal;
  line-height: 1;
  opacity: 0.3;
}

.fx-clamped {
  display: -webkit-box;
  overflow: hidden;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 3;
}

.fx-text-toggle {
  padding: 4px 0;
  border: 0;
  color: var(--fx-accent);
  background: none;
  cursor: pointer;
  font: inherit;
  font-size: 0.76rem;
  font-weight: 700;
}

/* ── Verdict hero ─────────────────────────────────────────────────────── */

.fx-hero {
  display: flex;
  gap: 18px;
  align-items: flex-start;
  min-width: 0;
}

.fx-result[data-layout="sheet"] .fx-hero {
  gap: 14px;
}

.fx-donut {
  display: flex;
  position: relative;
  flex: 0 0 auto;
  flex-direction: column;
  align-items: center;
  width: 92px;
}

.fx-donut-svg {
  width: 92px;
  height: 92px;
  transform: rotate(-90deg);
}

.fx-donut-track {
  fill: none;
  stroke: var(--fx-line);
  stroke-width: 5;
}

.fx-donut-fill {
  fill: none;
  stroke: var(--fx-band);
  stroke-width: 5;
  stroke-linecap: round;
  transition: stroke-dashoffset 1s cubic-bezier(0.4, 0, 0.2, 1);
}

.fx-donut-value {
  display: flex;
  position: absolute;
  top: 0;
  left: 0;
  align-items: baseline;
  justify-content: center;
  width: 92px;
  height: 92px;
  padding-top: 33px;
  font-size: 1.6rem;
  font-weight: 800;
  letter-spacing: -1px;
}

.fx-donut-max {
  margin-left: 1px;
  color: var(--fx-dim);
  font-size: 0.68rem;
  font-weight: 500;
}

.fx-donut-label {
  margin-top: 2px;
  color: var(--fx-dim);
  font-size: 0.62rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.fx-summary {
  display: grid;
  flex: 1 1 auto;
  gap: 8px;
  min-width: 0;
}

.fx-verdict-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.fx-action {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-height: 28px;
  padding: 4px 12px;
  border: 1px solid;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 700;
}

.fx-action[data-action="safe"] {
  border-color: color-mix(in srgb, var(--fx-supported) 34%, transparent);
  color: var(--fx-supported);
  background: color-mix(in srgb, var(--fx-supported) 10%, transparent);
}

.fx-action[data-action="caution"] {
  border-color: color-mix(in srgb, var(--fx-mixed) 34%, transparent);
  color: var(--fx-mixed);
  background: color-mix(in srgb, var(--fx-mixed) 10%, transparent);
}

.fx-action[data-action="false"] {
  border-color: color-mix(in srgb, var(--fx-contradicted) 34%, transparent);
  color: var(--fx-contradicted);
  background: color-mix(in srgb, var(--fx-contradicted) 10%, transparent);
}

.fx-action[data-action="unknown"] {
  border-color: color-mix(in srgb, var(--fx-unverifiable) 34%, transparent);
  color: var(--fx-unverifiable);
  background: color-mix(in srgb, var(--fx-unverifiable) 10%, transparent);
}

.fx-action-icon {
  flex: 0 0 14px;
  width: 14px;
  height: 14px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2.4;
}

.fx-confidence {
  padding: 3px 8px;
  border: 1px solid var(--fx-line);
  border-radius: 999px;
  color: var(--fx-muted);
  background: var(--fx-surface);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.fx-confidence[data-confidence="high"] {
  color: var(--fx-supported);
}

.fx-confidence[data-confidence="medium"] {
  color: var(--fx-mixed);
}

.fx-confidence[data-confidence="low"] {
  color: var(--fx-contradicted);
}

.fx-completion {
  color: var(--fx-dim);
  font-size: 0.74rem;
  font-weight: 600;
}

.fx-tldr {
  margin: 0;
  font-size: 0.98rem;
  font-weight: 700;
  line-height: 1.5;
}

.fx-explanation-wrap {
  display: grid;
  gap: 2px;
  justify-items: start;
}

.fx-explanation,
.fx-prose {
  margin: 0;
  color: var(--fx-muted);
  font-size: 0.88rem;
  line-height: 1.6;
}

/* ── Actions ──────────────────────────────────────────────────────────── */

.fx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 2px;
}

.fx-button {
  min-height: 36px;
  padding: 0 14px;
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  color: var(--fx-accent);
  background: var(--fx-surface);
  cursor: pointer;
  font: inherit;
  font-size: 0.84rem;
  font-weight: 700;
}

.fx-button:disabled {
  cursor: wait;
  opacity: 0.6;
}

.fx-share {
  color: var(--fx-supported);
}

/* ── Claim distribution bar ───────────────────────────────────────────── */

.fx-claim-bar-wrap {
  display: grid;
  gap: 6px;
}

.fx-claim-bar {
  display: flex;
  gap: 2px;
  overflow: hidden;
  height: 6px;
  border-radius: 999px;
  background: var(--fx-surface);
}

.fx-claim-segment {
  border-radius: 999px;
  background: var(--fx-verdict);
}

.fx-claim-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 4px 10px;
  font-size: 0.72rem;
}

.fx-claim-legend-item {
  color: var(--fx-verdict);
  font-weight: 600;
}

/* ── Sections ─────────────────────────────────────────────────────────── */

.fx-section {
  display: grid;
  gap: 8px;
  min-width: 0;
}

.fx-section-title {
  margin: 0;
  color: var(--fx-muted);
  font-size: 0.74rem;
  font-weight: 800;
  letter-spacing: 0.4px;
  text-transform: uppercase;
}

.fx-section-summary {
  display: flex;
  gap: 8px;
  align-items: center;
  min-height: 32px;
  padding: 0;
  cursor: pointer;
  list-style: none;
}

.fx-section-summary::-webkit-details-marker {
  display: none;
}

.fx-section-summary:focus-visible {
  outline: 2px solid var(--fx-accent);
  outline-offset: 3px;
}

.fx-section-count {
  padding: 1px 7px;
  border-radius: 999px;
  color: var(--fx-muted);
  background: var(--fx-surface);
  font-size: 0.72rem;
  font-weight: 700;
}

.fx-chevron {
  width: 14px;
  height: 14px;
  margin-left: auto;
  fill: none;
  stroke: var(--fx-dim);
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 2;
  transition: transform 160ms ease;
}

.fx-collapsible[open] > .fx-section-summary .fx-chevron {
  transform: rotate(90deg);
}

.fx-section-body {
  min-width: 0;
}

/* ── Claims ───────────────────────────────────────────────────────────── */

.fx-claims,
.fx-sources {
  display: grid;
  gap: 8px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.fx-claim {
  display: flex;
  flex-wrap: wrap;
  gap: 6px 10px;
  align-items: flex-start;
  justify-content: space-between;
  padding: 10px 12px;
  border: 1px solid var(--fx-line);
  border-left: 3px solid var(--fx-verdict);
  border-radius: var(--fx-radius);
  background: var(--fx-surface);
}

.fx-claim-text {
  flex: 1 1 200px;
  font-size: 0.88rem;
  line-height: 1.5;
}

.fx-claim-verdict {
  color: var(--fx-verdict);
  font-size: 0.7rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
  white-space: nowrap;
}

.fx-empty {
  padding: 10px 12px;
  border: 1px dashed var(--fx-line);
  border-radius: var(--fx-radius);
  color: var(--fx-muted);
  font-size: 0.86rem;
}

/* ── Sources ──────────────────────────────────────────────────────────── */

.fx-source {
  border: 1px solid var(--fx-line);
  border-left: 3px solid var(--fx-verdict);
  border-radius: var(--fx-radius);
  background: var(--fx-surface);
}

.fx-source-link {
  display: grid;
  gap: 3px;
  padding: 10px 12px;
  color: inherit;
  text-decoration: none;
}

.fx-source-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.fx-source-host {
  overflow-wrap: anywhere;
  color: var(--fx-muted);
  font-size: 0.74rem;
  font-weight: 600;
}

.fx-source-stance {
  color: var(--fx-verdict);
  font-size: 0.66rem;
  font-weight: 800;
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

.fx-source-title {
  font-size: 0.88rem;
  font-weight: 650;
  line-height: 1.45;
}

.fx-source-link:focus-visible {
  outline: 2px solid var(--fx-accent);
  outline-offset: 2px;
}

/* ── Feedback ─────────────────────────────────────────────────────────── */

/* Duplicated rather than borrowed from a host: the module cannot assume the page
   defines a visually-hidden helper, and this label must never render. */
.fx-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.fx-feedback {
  display: grid;
  gap: 10px;
  padding-top: 14px;
  border-top: 1px solid var(--fx-line);
}

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

.fx-feedback-prompt {
  color: var(--fx-muted);
  font-size: 0.84rem;
  font-weight: 700;
}

.fx-feedback-thumbs {
  display: flex;
  gap: 6px;
}

.fx-thumb {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  padding: 0;
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  color: var(--fx-muted);
  background: var(--fx-surface);
  cursor: pointer;
  transition: color 120ms ease, border-color 120ms ease, background 120ms ease;
}

.fx-thumb svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.9;
}

.fx-thumb:hover {
  color: var(--fx-ink);
  border-color: var(--fx-muted);
}

/* An active thumb tints toward the verdict palette, which already reads as
   agree/disagree on every theme. */
.fx-thumb-up.fx-active {
  color: var(--fx-supported);
  border-color: color-mix(in srgb, var(--fx-supported) 42%, transparent);
  background: color-mix(in srgb, var(--fx-supported) 10%, var(--fx-bg));
}

.fx-thumb-down.fx-active {
  color: var(--fx-contradicted);
  border-color: color-mix(in srgb, var(--fx-contradicted) 42%, transparent);
  background: color-mix(in srgb, var(--fx-contradicted) 10%, var(--fx-bg));
}

.fx-feedback-status {
  color: var(--fx-muted);
  font-size: 0.82rem;
}

.fx-feedback-note {
  padding: 9px 11px;
  border: 1px solid var(--fx-line);
  border-radius: var(--fx-radius);
  color: var(--fx-ink);
  background: var(--fx-bg);
  font: inherit;
  font-size: 0.92rem;
  resize: none;
}

.fx-feedback-footer {
  display: flex;
  justify-content: flex-end;
}

.fx-feedback-send {
  min-height: 32px;
  padding: 0 14px;
  border: 1px solid color-mix(in srgb, var(--fx-supported) 28%, transparent);
  border-radius: var(--fx-radius);
  color: var(--fx-supported);
  background: color-mix(in srgb, var(--fx-supported) 8%, var(--fx-bg));
  cursor: pointer;
  font: inherit;
  font-size: 0.86rem;
  font-weight: 800;
}

.fx-feedback-send:hover:not(:disabled) {
  border-color: var(--fx-supported);
  background: color-mix(in srgb, var(--fx-supported) 14%, var(--fx-bg));
}

.fx-feedback-send:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

/* ── Footer ───────────────────────────────────────────────────────────── */

.fx-checked-at {
  margin: 0;
  color: var(--fx-dim);
  font-size: 0.72rem;
}

/* ── Touch and motion ─────────────────────────────────────────────────── */

@media (pointer: coarse) {
  .fx-button {
    min-height: 44px;
  }

  .fx-section-summary {
    min-height: 44px;
  }

  .fx-text-toggle {
    min-height: 36px;
  }

  .fx-thumb {
    width: 44px;
    height: 44px;
  }

  .fx-feedback-send {
    min-height: 44px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fx-donut-fill,
  .fx-chevron,
  .fx-thumb {
    transition: none;
  }
}
