/* Theme tokens: every colour pair below is verified to WCAG AA by
 * viewer/test/a11y.test.mjs — text pairs at 4.5:1 or better on both `--bg`
 * and `--surface`, borders and focus outlines at 3:1 or better. Keep the
 * two dark blocks identical; the test asserts that too. */
:root {
  --bg: #ffffff;
  --surface: #f2f4f8;
  --fg: #1a1a1a;
  --muted: #555555;
  --border: #767b85;
  --accent: #1f4fbf;
  --pass: #1a7f37;
  --warning: #8a5900;
  --fail: #b42318;
  --invalid: #6e2fb3;
  /* High-contrast pair for the protocol-mismatch banner: white on #b42318
   * is 6.1:1, and the border stays visible against a white page. */
  --banner-bg: #b42318;
  --banner-fg: #ffffff;
  --banner-border: #7a1510;
  /* Shared with the dark media query; the palette test keeps them in
   * step. White on #b42318 is 6.1:1, above AA. */
  --schema-warning-bg: #b42318;
  --schema-warning-fg: #ffffff;
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #14161a;
    --surface: #1e2229;
    --fg: #ececec;
    --muted: #a8a8a8;
    --border: #6b7280;
    --accent: #7ea6ff;
    --pass: #56d364;
    --warning: #e3b341;
    --fail: #ff7b72;
    --invalid: #c297ff;
    /* Light red text on the dark page is illegible on a red field, so the
     * banner keeps a dark red field with near-white text (9.1:1) and a
     * light border to separate it from the page. */
    --banner-bg: #8c1d18;
    --banner-fg: #ffe9e6;
    --banner-border: #ff7b72;
    --schema-warning-bg: #b42318;
    --schema-warning-fg: #ffffff;
  }
}

:root[data-theme="dark"] {
  --bg: #14161a;
  --surface: #1e2229;
  --fg: #ececec;
  --muted: #a8a8a8;
  --border: #6b7280;
  --accent: #7ea6ff;
  --pass: #56d364;
  --warning: #e3b341;
  --fail: #ff7b72;
  --invalid: #c297ff;
  --banner-bg: #8c1d18;
  --banner-fg: #ffe9e6;
  --banner-border: #ff7b72;
  --schema-warning-bg: #b42318;
  --schema-warning-fg: #ffffff;
}

body {
  margin: 0 auto;
  max-width: 48rem;
  padding: 1rem;
  background: var(--bg);
  color: var(--fg);
  font: 16px/1.5 system-ui, sans-serif;
}

header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

h1 { font-size: 1.4rem; }
h2 { font-size: 1.15rem; }
h3 { font-size: 1.05rem; margin-bottom: 0.25rem; }
h4 { font-size: 1rem; margin: 0; }
p, dd { overflow-wrap: anywhere; }

button, input[type="file"] { font: inherit; color: inherit; }

button {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.75rem;
  cursor: pointer;
}

input {
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font: inherit;
}

/* Keyboard focus is always a 3px accent ring, in both themes (1.4.11 /
 * 2.4.7). `summary` and the focusable `<pre>` in the dialog need it in
 * addition to buttons and inputs. */
button:focus-visible,
input:focus-visible,
summary:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
}

.drop {
  border: 2px dashed var(--border);
  border-radius: 6px;
  padding: 1rem;
  background: var(--surface);
}

.drop[data-active="true"] { border-color: var(--accent); }
.drop label { display: block; margin-bottom: 0.5rem; }

#result { margin-top: 1.5rem; border-left: 6px solid var(--border); padding-left: 1rem; }
#result[data-state="pass"] { border-color: var(--pass); }
#result[data-state="warning"] { border-color: var(--warning); }
#result[data-state="fail"], #result[data-state="error"] { border-color: var(--fail); }
#result[data-state="invalid"] { border-color: var(--invalid); }

#warnings { color: var(--warning); }

/* The protocol-mismatch alert: high-contrast in both themes, and it does
 * not rely on colour alone — it is an always-labelled alert region. */
.mismatch-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--banner-border);
  border-radius: 6px;
  background: var(--banner-bg);
  color: var(--banner-fg);
  font-weight: 600;
}

/* The schema version warning banner: uses a distinct amber/orange palette
 * to differentiate it from the protocol-mismatch banner. */
.schema-warning-banner {
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  border: 2px solid var(--schema-warning-fg);
  border-radius: 6px;
  background: var(--schema-warning-bg);
  color: var(--schema-warning-fg);
  font-weight: 600;
}

dl { display: grid; grid-template-columns: max-content 1fr; gap: 0.25rem 1rem; }
dt { color: var(--muted); }
dd { margin: 0; }

/* Surface-filter tabs (findings). The selected tab is announced with
 * aria-selected; the roving tabindex keeps the Tab order short, and arrow
 * keys move between tabs (handled in app.js). */
.controls {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  margin: 0.5rem 0;
}

.tabs { display: flex; gap: 0.25rem; flex-wrap: wrap; }

[role="tab"][aria-selected="true"] {
  background: var(--surface);
  border-color: var(--accent);
  font-weight: 600;
}

.search label { display: block; margin-bottom: 0.25rem; }
.search input { min-width: 14rem; }

#search-status {
  margin: 0.25rem 0;
  color: var(--muted);
  overflow-wrap: anywhere;
}

/* Readiness groups (E-085): a heading carrying its live filtered count,
 * then the cards. A group with no visible cards is hidden by app.js, so
 * filtering never leaves empty headings behind. */
.readiness { margin-top: 0.75rem; }
.readiness-heading { color: var(--muted); margin-bottom: 0.25rem; }

/* Findings rows: status word is text, never colour alone. */
#ready-list, #attention-list, #incomplete-list, #skipped-list { list-style: none; padding: 0; margin: 0; }

.finding {
  margin: 0.5rem 0;
  padding: 0.5rem 0.75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 6px;
}

.finding .status { font-weight: 600; }
.finding .status[data-status="pass"] { color: var(--pass); }
.finding .status[data-status="warning"] { color: var(--warning); }
.finding .status[data-status="fail"], .finding .status[data-status="error"] { color: var(--fail); }
.finding .meta { color: var(--muted); }
/* The identity is a button, not a label: it opens the fixture detail
 * dialog. It keeps the monospace identity look and reads as a control
 * through the shared button border, padding and focus ring. */
.finding .identity {
  font-family: ui-monospace, monospace;
  color: var(--accent);
  background: var(--bg);
  padding: 0.1rem 0.4rem;
}
.finding .summary { display: block; }
.finding .timing {
  display: inline-block;
  color: var(--muted);
  font-family: ui-monospace, monospace;
  font-size: 0.85rem;
}
.finding details { margin-top: 0.35rem; }
.finding summary { cursor: pointer; margin: 0.25rem 0; }

#findings-empty { margin: 0.25rem 0; color: var(--muted); }

/* The report-source dialog. Native showModal() traps focus; ::backdrop
 * dims the page behind the modal in both themes. */
dialog {
  background: var(--surface);
  color: var(--fg);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  max-width: min(48rem, calc(100vw - 2rem));
}

dialog::backdrop { background: rgba(0, 0, 0, 0.6); }

dialog pre {
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem;
  overflow: auto;
  max-height: 60vh;
  font: 13px/1.45 ui-monospace, monospace;
  margin: 0.5rem 0;
}

.dialog-actions { display: flex; justify-content: flex-end; gap: 0.5rem; }

aside { margin-top: 2rem; color: var(--muted); }

/* --- Comparison view (CF-08 section 2.4) --- */

#compare { margin-top: 2rem; }

.compare-picks {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(16rem, 1fr));
  gap: 1rem;
}

#compare-status { color: var(--muted); overflow-wrap: anywhere; }

#compare-result {
  margin-top: 1rem;
  border-left: 6px solid var(--border);
  padding-left: 1rem;
}

/* The verdict banner's left edge carries the verdict, and the text names
 * it, so the meaning is never carried by colour alone. */
#compare-result[data-verdict="regression"] { border-color: var(--fail); }
#compare-result[data-verdict="coverage-lost"] { border-color: var(--warning); }
#compare-result[data-verdict="improved"] { border-color: var(--pass); }
#compare-result[data-verdict="no-change"] { border-color: var(--border); }

#compare-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.5rem;
}

#compare-table caption { text-align: left; color: var(--muted); padding: 0.25rem 0; }

#compare-table th,
#compare-table td {
  border: 1px solid var(--border);
  padding: 0.3rem 0.5rem;
  text-align: left;
  overflow-wrap: anywhere;
}

#compare-table th { color: var(--muted); font-weight: 600; }

/* Outcome cells are tinted, never coloured alone: the cell text always
 * names the classification, and regressions gain a text suffix. */
.outcome[data-classification="regressed"],
.outcome[data-classification="added-failing"],
.outcome[data-classification="skipped-failing"] { color: var(--fail); font-weight: 600; }

.outcome[data-classification="degraded"],
.outcome[data-classification="removed-failing"] { color: var(--warning); }

.outcome[data-classification="improved"],
.outcome[data-classification="resolved"],
.outcome[data-classification="added"] { color: var(--pass); }

.outcome[data-classification="removed"],
.outcome[data-classification="skipped"] { color: var(--muted); }

.outcome[data-classification="unchanged"],
.outcome[data-classification="unchanged-skip"] { color: var(--muted); }

/* --- Fixture detail (E-086) --- */

/* The inventory is optional, so its zone and its status line stay quiet
 * until a file is chosen. */
.drop-optional { margin-top: 0.5rem; }
#inventory-status { color: var(--muted); margin: 0.5rem 0 0; overflow-wrap: anywhere; }

.hint { color: var(--muted); font-size: 0.9rem; }

/* Every fixture shows the same rows, so an absent value is a sentence in
 * its own cell rather than a missing line that shifts the layout. A 64-hex
 * digest needs a value track that can shrink, and on a narrow screen the
 * label track would otherwise starve it, so the rows stack instead. */
#fixture-facts { margin: 0.5rem 0; grid-template-columns: minmax(0, 1fr); gap: 0.1rem 1rem; }
#fixture-facts dd { margin-bottom: 0.35rem; }

@media (min-width: 40rem) {
  #fixture-facts { grid-template-columns: max-content minmax(0, 1fr); gap: 0.25rem 1rem; }
  #fixture-facts dd { margin-bottom: 0; }
}

#fixture-facts .detail-value { overflow-wrap: anywhere; }

/* The verification line is text in both states; the colour only repeats
 * what the words already say. */
.verification-state { font-weight: 600; }
.verification-state[data-verification="verified"] { color: var(--pass); }
.verification-state[data-verification="unverified"] { color: var(--warning); }

#fixture-detail .copy { margin-left: 0.5rem; font-size: 0.85rem; white-space: nowrap; }
#copy-status { color: var(--muted); overflow-wrap: anywhere; }
