/* Changes: one scan against an earlier scan. Reference: frontend/DESIGN.md, "Changes".
   Loaded on every page after load.css (the headline shows on Overview and on a run page); only
   tokens from app.css are used, so both themes work. No text under 11px. */

/* --- The two scans being compared -------------------------------------------------------------- */
.chg-pick { display: grid; grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr); align-items: start; gap: var(--sp-3) var(--sp-5); padding: var(--sp-4) var(--sp-5); }
.chg-scan { display: grid; gap: var(--sp-2); min-width: 0; }
.chg-scan > .label { margin: 0; }
.chg-scan > .select { width: 100%; max-width: 100%; }
.chg-scan-facts { display: flex; flex-wrap: wrap; align-items: baseline; gap: 0 var(--sp-5); min-height: 18px; color: var(--ink-2); font-size: var(--fs-2); }
.chg-scan-facts > .mono { font-size: var(--fs-2); }
.chg-scan-facts > span > b { font: 600 var(--fs-2)/1 var(--font-mono); color: var(--ink); }
.chg-pick-arrow { display: grid; place-items: center; height: var(--ctl); margin-top: 17px; color: var(--ink-3); }
.chg-dots { color: var(--ink-3); margin: 0 1px; }
@media (max-width: 639.98px) {
  .chg-pick { grid-template-columns: minmax(0, 1fr); }
  .chg-pick-arrow { display: none; }
}

/* --- The counts that head the page: one tile per kind that happened ---------------------------- */
.chg-head { display: flex; flex-wrap: wrap; align-items: stretch; }
.chg-tally { display: flex; flex-wrap: wrap; flex: 1 1 24rem; min-width: 0; }
.chg-tile { display: grid; align-content: center; gap: var(--sp-1); min-width: 6.5rem; padding: var(--sp-4) var(--sp-6) var(--sp-4) var(--sp-5); color: var(--ink); box-shadow: 1px 0 0 var(--line), 0 1px 0 var(--line); }
.chg-tile:hover { background: var(--surface-2); text-decoration: none; }
.chg-tile-n { display: flex; align-items: center; gap: var(--sp-3); font: 500 var(--fs-6)/1.1 var(--font-mono); letter-spacing: -.01em; }
.chg-tile-l { color: var(--ink-2); font-size: var(--fs-2); white-space: nowrap; }
/* Differences that are not changes: hatched and dashed, the way a row "not in the latest run" is. */
.chg-tile.is-reach { margin-left: auto; background: repeating-linear-gradient(135deg, transparent 0 7px, var(--surface-2) 7px 14px); border-left: 1px dashed var(--line-strong); box-shadow: 0 1px 0 var(--line); }
.chg-tile.is-reach > .chg-tile-n { color: var(--ink-2); }
.chg-none { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); padding: var(--sp-4) var(--sp-5); min-height: 44px; }
.chg-none > .icon { color: var(--win); }
/* The rest of what changed (queries edited, moved, call sites, tables): one quieter line. */
.chg-also { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-5); flex: 1 1 100%; order: 3; padding: var(--sp-3) var(--sp-5); }
.chg-also > .label { margin: 0; }
.chg-also:first-child { order: 0; flex: 1 1 auto; align-self: center; }
.chg-fix { flex: none; font-size: var(--fs-2); }

/* The sign that leads a group and its count. The sign carries the meaning; the tone repeats it. */
.chg-mark { flex: none; display: inline-grid; place-items: center; width: 18px; height: 18px; border-radius: var(--r-1); background: var(--surface-3); color: var(--ink-2); font: 600 var(--fs-2)/1 var(--font-mono); }
.chg-mark.is-new { background: var(--accent-bg); color: var(--accent); }
.chg-mark.is-worse { background: var(--warn-bg); color: var(--warn); }
.chg-mark.is-fixed, .chg-mark.is-better { background: var(--win-bg); color: var(--win); }

/* --- Findings before and after: two bars on one scale ---------------------------------------- */
.chg-flow { display: grid; grid-template-columns: auto minmax(8rem, 1fr) auto; align-items: center; gap: var(--sp-2) var(--sp-4); flex: 0 1 22rem; min-width: 15rem; padding: var(--sp-4) var(--sp-5); border-left: 1px solid var(--line); }
.chg-flow > .label { grid-column: 1 / -1; margin: 0; }
.chg-flow-name { color: var(--ink-2); font-size: var(--fs-2); }
.chg-flow-n { font: 600 var(--fs-2)/1 var(--font-mono); text-align: right; }
.chg-flow-bar { display: flex; gap: 1px; height: 16px; min-width: 0; }
.chg-seg { display: grid; place-items: center; min-width: 16px; height: 100%; border-radius: 2px; background: var(--ink-3); color: var(--surface); font: 600 var(--fs-1)/1 var(--font-mono); overflow: hidden; }
.chg-seg.is-new { background: var(--accent); color: var(--accent-ink); }
.chg-seg.is-worse { background: var(--warn); }
.chg-seg.is-fixed, .chg-seg.is-better { background: var(--win); }
.chg-seg.is-reach { background: repeating-linear-gradient(135deg, var(--surface-3) 0 4px, var(--surface) 4px 7px); color: var(--ink-2); box-shadow: inset 0 0 0 1px var(--line-strong); }
/* The second half of the flow: examined queries by how they ended (outcomes.css gives the state fills). */
.chg-flow > .chg-flow-label { margin-top: var(--sp-3); }
.chg-seg.st-fixed { color: var(--surface); }
.chg-seg.st-blocked { color: var(--ink); }
.chg-seg.st-not_judged, .chg-seg.st-nothing_to_gain { color: var(--ink); }
@media (max-width: 1039.98px) { .chg-flow { flex-basis: 100%; border-left: 0; border-top: 1px solid var(--line); } }

/* --- Not like for like -------------------------------------------------------------------------- */
.chg-note-list { display: grid; gap: var(--sp-2); margin: 0; }
.chg-note-list > div { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-4); min-width: 0; }
.chg-note-list dt { flex: 0 0 8.5rem; color: var(--ink-2); font-size: var(--fs-2); }
.chg-note-list dd { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-5); margin: 0; min-width: 0; }
.chg-note-list dd > .mono { font-size: var(--fs-2); font-weight: 500; }
.chg-effect { color: var(--ink-2); font-size: var(--fs-2); }

/* --- The list ------------------------------------------------------------------------------------- */
.tbl.chg-list { min-width: 54rem; }
.chg-n { font: 600 var(--fs-2)/1 var(--font-mono); }
.chg-fact { color: var(--ink-2); font-weight: 400; }
.chg-fact::before { content: "·"; margin-right: var(--sp-4); color: var(--line-strong); }
.chg-move { font: 500 var(--fs-2)/1.2 var(--font-mono); white-space: nowrap; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.chg-move > b { font-weight: 600; }
.chg-arrow { margin: 0 5px; color: var(--ink-3); }
.chg-pct { flex: none; font: 600 var(--fs-2)/1.2 var(--font-mono); color: var(--ink-2); white-space: nowrap; }
.chg-pct.is-worse { color: var(--warn); }
.chg-pct.is-better, .chg-pct.is-fixed { color: var(--win); }
/* What sits under a row and belongs to it: the diff of the query, a changed sorting key. */
.tbl.chg-list tr.chg-under > td { padding-top: 0; padding-bottom: var(--sp-4); overflow: visible; border-top: 0; }
.tbl.chg-list tr.chg-under:hover > td { background: none; }
.chg-diff { max-height: 16rem; }
.chg-diff .diff-line { white-space: pre-wrap; overflow-wrap: anywhere; min-width: 0; }
.chg-diff .diff-line.is-del > code { text-decoration: none; }
.chg-word { padding: 0 1px; border-radius: 2px; background: color-mix(in srgb, currentColor 16%, transparent); color: inherit; font-weight: 600; }
.diff-line.is-del .chg-word { background: color-mix(in srgb, var(--fail) 24%, transparent); text-decoration: line-through; text-decoration-color: color-mix(in srgb, var(--fail) 60%, transparent); }
.diff-line.is-add .chg-word { background: color-mix(in srgb, var(--win) 26%, transparent); }
.chg-key { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-2) var(--sp-4); min-width: 0; }
.chg-key > .label { margin: 0; flex: none; }
.chg-key > .keyrow { margin: 0; }
.chg-key .keybox.is-idle > .mono { text-decoration: line-through; }
.chg-unchanged { display: flex; flex-wrap: wrap; align-items: baseline; gap: var(--sp-1) var(--sp-5); font-size: var(--fs-2); }
.chg-unchanged.is-alone { padding: 0 var(--sp-5); }
.chg-more > td { color: var(--ink-3); font-size: var(--fs-2); }
/* The second list: hatched like a finding "not in the latest run". Nothing in it is a change. */
.tbl.chg-list.is-reach tbody > tr:not(.group-row):not(.site-detail) > td { background: repeating-linear-gradient(135deg, transparent 0 7px, var(--surface-2) 7px 14px); }
.tbl.chg-list.is-reach a.row-link { color: var(--ink-2); font-weight: 400; }
.chg-reach > .panel-head { border-bottom-style: dashed; }

/* --- The one-line headline on Overview and on a run page ------------------------------------------ */
.chg-headline { display: grid; border: 1px solid var(--line); border-radius: var(--r-3); background: var(--surface); }
.chg-headline-row { display: flex; flex-wrap: wrap; align-items: center; gap: var(--sp-1) var(--sp-4); min-height: 32px; padding: var(--sp-2) var(--sp-5); min-width: 0; }
.chg-headline-row + .chg-headline-row { border-top: 1px solid var(--line); }
.chg-line { gap: var(--sp-4); }
.chg-part { display: inline-flex; align-items: baseline; gap: var(--sp-2); color: var(--ink); font-size: var(--fs-3); white-space: nowrap; }
.chg-part > b { font: 600 var(--fs-3)/1 var(--font-mono); }
.chg-part + .chg-part::before { content: "·"; margin-right: var(--sp-4); color: var(--line-strong); }
.chg-part.is-new > b { color: var(--accent); }
.chg-part.is-worse > b { color: var(--warn); }
.chg-part.is-fixed > b, .chg-part.is-better > b { color: var(--win); }
.chg-part.is-reach, .chg-part.is-none { color: var(--ink-2); }
.chg-part.is-reach > b { color: var(--ink-2); }
.chg-since { color: var(--ink-2); font-size: var(--fs-2); white-space: nowrap; }
.chg-open { margin-left: auto; font-size: var(--fs-2); white-space: nowrap; }
