/*
 * ToneGuard taskpane.
 *
 * Constraints this design answers to:
 *  - The pane is narrow (~320-400px) and tall. Single column, no side-by-side anything.
 *  - It appears next to a message the reader is already suspicious of, so the verdict has
 *    to be legible in about one second, before any detail.
 *  - Colour carries meaning, so it can never be the ONLY carrier: every risk level also
 *    has a word. Red/green alone fails for colour-blind readers and in high contrast mode.
 *  - Evidence is the product. Quotes and link comparisons get real visual weight rather
 *    than being footnotes under a score.
 */

:root {
  --bg: #ffffff;
  --fg: #1b1a19;
  --fg-muted: #605e5c;
  --line: #e1dfdd;
  --surface: #faf9f8;

  --critical: #a4262c;
  --critical-bg: #fdf3f4;
  --high: #c4314b;
  --high-bg: #fdf3f4;
  --caution: #986f0b;
  --caution-bg: #fffbf0;
  --low: #005a9e;
  --low-bg: #f3f9fd;
  --clear: #0b6a0b;
  --clear-bg: #f1faf1;

  --radius: 6px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #1f1e1d;
    --fg: #f3f2f1;
    --fg-muted: #a19f9d;
    --line: #3b3a39;
    --surface: #292827;

    --critical: #f1707b; --critical-bg: #2d1a1c;
    --high: #f1707b;     --high-bg: #2d1a1c;
    --caution: #f0c419;  --caution-bg: #2b2616;
    --low: #6cb8f6;      --low-bg: #16232d;
    --clear: #6ccb6c;    --clear-bg: #16250f;
  }
}

* { box-sizing: border-box; }

body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font: 14px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", system-ui, sans-serif;
  -webkit-font-smoothing: antialiased;
}

#pane { padding: 14px; max-width: 100%; }

/* --- loading / error --- */

.state { text-align: center; padding: 40px 16px; }
.state-text { margin: 12px 0 4px; font-weight: 600; }
.state-sub { margin: 0; color: var(--fg-muted); font-size: 13px; }

.spinner {
  width: 26px; height: 26px; margin: 0 auto;
  border: 2.5px solid var(--line);
  border-top-color: var(--low);
  border-radius: 50%;
  animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .spinner { animation-duration: 2.4s; } }

.btn {
  margin-top: 14px; padding: 7px 16px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--surface); color: var(--fg);
  font: inherit; font-weight: 600; cursor: pointer;
}
.btn:hover { background: var(--line); }

/* --- verdict --- */

.verdict {
  padding: 12px;
  border-radius: var(--radius);
  border-left: 4px solid var(--line);
  background: var(--surface);
}
.verdict-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.badge {
  font-size: 11px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 3px;
  border: 1px solid currentColor;
}

.verdict-headline { margin: 0; font-size: 15px; font-weight: 700; }
.verdict-summary { margin: 8px 0 0; font-size: 13px; }

/* Risk level drives the accent. The badge text carries the same meaning as the colour. */
.risk-critical { border-left-color: var(--critical); background: var(--critical-bg); }
.risk-critical .badge, .risk-critical .verdict-headline { color: var(--critical); }
.risk-high { border-left-color: var(--high); background: var(--high-bg); }
.risk-high .badge, .risk-high .verdict-headline { color: var(--high); }
.risk-caution { border-left-color: var(--caution); background: var(--caution-bg); }
.risk-caution .badge, .risk-caution .verdict-headline { color: var(--caution); }
.risk-low { border-left-color: var(--low); background: var(--low-bg); }
.risk-low .badge, .risk-low .verdict-headline { color: var(--low); }
.risk-clear { border-left-color: var(--clear); background: var(--clear-bg); }
.risk-clear .badge, .risk-clear .verdict-headline { color: var(--clear); }

/* --- advice --- */

.advice {
  margin-top: 12px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
}
.advice-title { margin: 0 0 4px; font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted); }
.advice p { margin: 0; font-size: 13px; }

/* --- findings --- */

.section-title {
  margin: 20px 0 8px; font-size: 12px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .04em; color: var(--fg-muted);
}

.findings, .links, .degraded-list { list-style: none; margin: 0; padding: 0; }

.finding { padding: 12px 0; border-top: 1px solid var(--line); }
.finding:first-child { border-top: none; padding-top: 0; }
.finding-title { margin: 0 0 4px; font-size: 13.5px; font-weight: 600; }
.finding-detail { margin: 0; font-size: 13px; color: var(--fg-muted); }

/* Evidence gets real weight — it is the reason the tool is believable. */
.evidence { margin-top: 8px; }

.evidence-quote {
  margin: 0; padding: 8px 10px;
  border-left: 3px solid var(--line);
  background: var(--surface);
  font-size: 13px; font-style: italic;
}
.evidence-quote-source { display: block; margin-top: 4px; font-style: normal; font-size: 11.5px; color: var(--fg-muted); }

.evidence-compare {
  display: flex; flex-direction: column; gap: 3px;
  padding: 8px 10px; background: var(--surface); border-radius: 4px;
  font-size: 12.5px;
}
.evidence-compare code {
  font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 12px; word-break: break-all;
}
.compare-label { color: var(--fg-muted); font-size: 11.5px; }
.compare-actual code { color: var(--high); font-weight: 600; }

/* --- links ---
 *
 * Each link is a disclosure card: collapsed it answers "where does this actually go",
 * expanded it shows the page behind it. Pointing at a card opens it (taskpane.js), but the
 * open/closed state lives on a real <details> element, so the card is equally reachable by
 * tap and by keyboard — hover is an accelerant here, never the only way in.
 */

.link { padding: 0; border-top: 1px solid var(--line); }
.link:first-child { border-top: none; }

.link-details { padding: 10px 0; }

.link-summary {
  cursor: pointer;
  list-style: none;                 /* the default triangle sits badly beside a badge */
  padding-left: 16px;
  position: relative;
}
.link-summary::-webkit-details-marker { display: none; }

/* Our own marker: a caret that turns when the card opens. */
.link-summary::before {
  content: "";
  position: absolute; left: 2px; top: 6px;
  width: 5px; height: 5px;
  border-right: 1.5px solid var(--fg-muted);
  border-bottom: 1.5px solid var(--fg-muted);
  transform: rotate(-45deg);
  transition: transform .12s ease;
}
.link-details[open] > .link-summary::before { transform: rotate(45deg); }
@media (prefers-reduced-motion: reduce) {
  .link-summary::before { transition: none; }
}

.link-summary:focus-visible {
  outline: 2px solid var(--low);
  outline-offset: 2px;
  border-radius: 3px;
}

.link-head { display: flex; align-items: baseline; gap: 6px; flex-wrap: wrap; }
.link-label { font-size: 13px; font-weight: 600; margin: 0; }

.link-chip {
  flex: none;
  font-size: 10px; font-weight: 700; letter-spacing: .03em; text-transform: uppercase;
  padding: 1px 5px; border-radius: 3px;
  border: 1px solid currentColor;
}
.chip-critical { color: var(--critical); }
.chip-high { color: var(--high); }
.chip-caution { color: var(--caution); }
.chip-low { color: var(--low); }
.chip-clear { color: var(--clear); }

.link-url {
  margin: 2px 0 0; font-family: ui-monospace, SFMono-Regular, Consolas, monospace;
  font-size: 11.5px; color: var(--fg-muted); word-break: break-all;
}

/* The hint is a nudge for the first card the reader meets, not a permanent label. */
.link-hint { margin: 3px 0 0; font-size: 11px; color: var(--fg-muted); font-style: italic; }
.link-details[open] .link-hint { display: none; }

.link-body { padding: 8px 0 2px 16px; }
.link-note { margin: 0; font-size: 12.5px; color: var(--fg-muted); }
.link-body .finding:first-child { border-top: none; padding-top: 4px; }

/* Risk earns a visible edge on the card itself — the badge alone is easy to skim past.
 *
 * Only from `caution` up. A `low` or `clear` link is an ordinary link, and tinting it
 * would spend the reader's attention on the one thing that does not need it.
 */
.link-details.link-risk-critical,
.link-details.link-risk-high,
.link-details.link-risk-caution {
  border-left: 3px solid var(--line);
  padding-left: 8px;
}
.link-details.link-risk-critical { border-left-color: var(--critical); background: var(--critical-bg); }
.link-details.link-risk-high { border-left-color: var(--high); background: var(--high-bg); }
.link-details.link-risk-caution { border-left-color: var(--caution); background: var(--caution-bg); }

.shot { margin-top: 8px; }
.shot img {
  display: block; width: 100%; height: auto;
  border: 1px solid var(--line); border-radius: 4px;
}
.shot-caption { margin: 4px 0 0; font-size: 11.5px; color: var(--fg-muted); }

.link-blocked {
  margin-top: 8px; padding: 8px 10px;
  background: var(--surface); border-radius: 4px;
  font-size: 12.5px; color: var(--fg-muted);
}

/* --- degraded --- */

.degraded { margin-top: 20px; padding-top: 4px; }
.degraded-list li {
  font-size: 12.5px; color: var(--fg-muted);
  padding: 3px 0 3px 14px; position: relative;
}
.degraded-list li::before {
  content: "–"; position: absolute; left: 2px;
}

.footer {
  margin-top: 20px; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 11.5px; color: var(--fg-muted);
  display: flex; justify-content: space-between; align-items: baseline; gap: 12px;
}

/* Quiet by design: an administrator looks for this, a student never needs it. */
.linkish {
  border: 0; background: none; padding: 0;
  font: inherit; color: var(--low); cursor: pointer;
  text-decoration: underline; text-underline-offset: 2px;
}
.linkish:focus-visible { outline: 2px solid var(--low); outline-offset: 2px; border-radius: 2px; }

/* --- installation check --- */

.setup-title { margin: 0 0 12px; font-size: 15px; font-weight: 700; }
.setup-list { list-style: none; margin: 0; padding: 0; }

.setup-item {
  display: grid; grid-template-columns: 18px minmax(0, 1fr); gap: 0 8px;
  padding: 9px 0; border-top: 1px solid var(--line);
}
.setup-item:first-child { border-top: none; }
.setup-mark { font-weight: 700; line-height: 1.45; }
.setup-ok .setup-mark { color: var(--clear); }
.setup-fail .setup-mark { color: var(--critical); }
.setup-off .setup-mark { color: var(--fg-muted); }

.setup-item-title { margin: 0; font-size: 13px; font-weight: 600; }
.setup-item-detail { margin: 2px 0 0; font-size: 12.5px; color: var(--fg-muted); }

.setup-note {
  margin: 14px 0 0; padding-top: 10px;
  border-top: 1px solid var(--line);
  font-size: 12px; color: var(--fg-muted);
}
