/* Playgate — a review docket, not a dashboard.
 *
 * Severity is ORDINAL, so it is one hue stepped by lightness (blocker darkest).
 * Verdict is STATUS, so it gets reserved hues that never appear as severities.
 * Both sets were checked with the palette validator against these exact
 * surfaces; the grey deliberately sits below the chroma floor, because for
 * "not applicable" reading recessive *is* the meaning.
 *
 * Colour never carries meaning alone: every mark is paired with its label.
 *
 * Layout: two columns. An earlier version put the gate rail in a third 92px
 * column, where its own heading and legend overflowed, and dumped all three
 * report sections into one 13,000px scroll. The rail is now a horizontal strip
 * inside the sticky report header, and the sections are panes.
 */

:root {
  --paper:      #eef1f4;
  --surface:    #f7f9fa;
  --surface-2:  #e7ebef;
  --ink:        #141a20;
  --ink-2:      #4d5763;
  --ink-3:      #78838f;
  --rule:       #d3dae0;
  --rule-firm:  #b9c2cb;

  /* Severity — ordinal ramp, blocker → info */
  --sev-blocker: #570814;
  --sev-high:    #8a1526;
  --sev-medium:  #b03a34;
  --sev-low:     #c96b5c;
  --sev-info:    #dc9a8e;

  /* Verdict — reserved status hues */
  --v-pass:   #1f6b3f;
  --v-fail:   #570814;
  --v-review: #5b4bc4;
  --v-na:     #6e767d;

  --focus: #1f5fbf;
  --measure: 74ch;
  --radius: 3px;
  --gutter: clamp(16px, 2vw, 28px);
}

@media (prefers-color-scheme: dark) {
  :root {
    --paper:     #0f1215;
    --surface:   #14171a;
    --surface-2: #1c2126;
    --ink:       #eef1f4;
    --ink-2:     #b3bcc5;
    --ink-3:     #8b959f;
    --rule:      #2a3138;
    --rule-firm: #3b444d;

    --sev-blocker: #ff7f6e;
    --sev-high:    #e65a4a;
    --sev-medium:  #c4453b;
    --sev-low:     #a03a34;
    --sev-info:    #7d332f;

    --v-pass:   #4faa71;
    --v-fail:   #ff7f6e;
    --v-review: #8a78f2;
    --v-na:     #737d86;

    --focus: #7fb0ff;
  }
}

*, *::before, *::after { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  background: var(--paper);
  color: var(--ink);
  font-family: "Public Sans", ui-sans-serif, system-ui, sans-serif;
  font-size: 15px;
  line-height: 1.55;
  font-variant-numeric: tabular-nums;
}

.is-mono, code, textarea { font-family: "JetBrains Mono", ui-monospace, SFMono-Regular, monospace; }

.sr-only {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

.skip { position: absolute; left: -9999px; top: 0; z-index: 30; background: var(--ink); color: var(--paper); padding: 10px 16px; }
.skip:focus { left: 8px; top: 8px; }

:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* ── masthead ─────────────────────────────────────────────────────────── */

.masthead {
  display: flex; flex-wrap: wrap; gap: 16px 26px;
  align-items: baseline; justify-content: space-between;
  padding: 15px var(--gutter) 12px;
  border-bottom: 2px solid var(--ink);
  background: var(--surface);
}
.masthead-mark { display: flex; align-items: baseline; gap: 14px; flex-wrap: wrap; min-width: 0; }
.wordmark {
  font-family: "Archivo", sans-serif; font-weight: 700;
  font-size: clamp(18px, 2.2vw, 24px); letter-spacing: 0.15em; font-stretch: expanded;
}
.tagline { color: var(--ink-3); font-size: 13px; }

.masthead-stats { display: flex; flex-wrap: wrap; gap: 10px 24px; margin: 0; min-width: 0; }
.masthead-stats div { display: flex; flex-direction: column; min-width: 0; }
.masthead-stats dt { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); }
.masthead-stats dd { margin: 0; font-family: "Archivo", sans-serif; font-weight: 600; font-size: 16px; }
.masthead-stats dd[data-stat="model"] {
  font-size: 11.5px; font-weight: 500; color: var(--ink-2); overflow-wrap: anywhere;
}

/* ── shell: two columns ───────────────────────────────────────────────── */

.shell {
  display: grid;
  grid-template-columns: minmax(340px, 30%) minmax(0, 1fr);
  align-items: start;
}

.panel { min-width: 0; }

.panel-input {
  padding: 18px var(--gutter) 32px;
  border-right: 1px solid var(--rule);
  position: sticky; top: 0;
  max-height: 100vh; overflow-y: auto;
}

.panel-report { background: var(--surface); min-height: 100vh; padding-bottom: 48px; }

.panel-head { display: flex; align-items: baseline; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.panel-head h2 {
  margin: 0; font-family: "Archivo", sans-serif;
  font-size: 11px; font-weight: 700; letter-spacing: 0.18em; text-transform: uppercase; color: var(--ink-2);
}

.field-label { font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--ink-3); margin-right: 6px; }
.example-switch { display: flex; align-items: center; min-width: 0; }

select, textarea, button, input { font: inherit; color: inherit; }
select { background: var(--surface); border: 1px solid var(--rule-firm); border-radius: var(--radius); padding: 3px 6px; font-size: 12px; max-width: 170px; }

textarea {
  width: 100%; height: clamp(260px, 46vh, 520px); resize: vertical;
  background: var(--surface); color: var(--ink);
  border: 1px solid var(--rule-firm); border-radius: var(--radius);
  padding: 12px; font-size: 12px; line-height: 1.6; tab-size: 2;
}

.hint { color: var(--ink-3); font-size: 12px; margin: 8px 0 0; }
.hint-quiet { font-size: 11px; }

.controls { display: flex; flex-wrap: wrap; gap: 8px 18px; margin-top: 14px; }
.toggle { display: flex; align-items: center; gap: 7px; font-size: 13px; cursor: pointer; }
.toggle input { width: 15px; height: 15px; accent-color: var(--ink); flex: none; }

.run {
  display: flex; align-items: center; justify-content: center; gap: 9px;
  width: 100%; margin-top: 14px;
  background: var(--ink); color: var(--paper);
  border: none; border-radius: var(--radius); padding: 11px 20px; cursor: pointer;
  font-family: "Archivo", sans-serif; font-weight: 600;
  font-size: 12px; letter-spacing: 0.12em; text-transform: uppercase;
}
.run:hover { background: var(--ink-2); }
.run[disabled] { opacity: 0.55; cursor: progress; }
.run-spinner { display: none; width: 11px; height: 11px; border: 2px solid currentColor; border-right-color: transparent; border-radius: 50%; }
.run[data-busy="true"] .run-spinner { display: inline-block; animation: spin 0.7s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── report header: sticky context ────────────────────────────────────── */

.report-top {
  position: sticky; top: 0; z-index: 10;
  background: var(--surface);
  padding: 16px var(--gutter) 0;
  border-bottom: 1px solid var(--rule-firm);
}

.verdict-banner {
  border: 2px solid var(--ink); border-left-width: 5px;
  border-radius: var(--radius); padding: 12px 15px; background: var(--surface-2);
}
.verdict-banner[data-state="blocked"] { border-color: var(--sev-blocker); }
.verdict-banner[data-state="open"]    { border-color: var(--v-review); }
.verdict-banner[data-state="clear"]   { border-color: var(--v-pass); }

.verdict-word {
  font-family: "Archivo", sans-serif; font-weight: 700;
  font-size: clamp(19px, 2.4vw, 27px); line-height: 1.1; margin: 0 0 3px;
}
.verdict-banner[data-state="blocked"] .verdict-word { color: var(--sev-blocker); }
.verdict-banner[data-state="open"]    .verdict-word { color: var(--v-review); }
.verdict-banner[data-state="clear"]   .verdict-word { color: var(--v-pass); }

.verdict-sub { margin: 0; color: var(--ink-2); font-size: 12.5px; overflow-wrap: anywhere; }
.verdict-app { font-weight: 600; color: var(--ink); }

.tally { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
.tally-item {
  display: inline-flex; align-items: center; gap: 5px;
  border: 1px solid var(--rule-firm); border-radius: var(--radius);
  padding: 2px 8px; font-size: 11px; background: var(--surface);
}
.tally-item b { font-family: "Archivo", sans-serif; font-size: 13px; }
.tally-item i { width: 8px; height: 8px; border-radius: 1px; flex: none; }

/* ── the gate rail: horizontal, full width ────────────────────────────── */

.rail-block { margin-top: 14px; }

.rail-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 10px; margin-bottom: 5px; }
.rail-title {
  font-family: "Archivo", sans-serif; font-size: 9.5px; font-weight: 700;
  letter-spacing: 0.16em; text-transform: uppercase; color: var(--ink-2); flex: none;
}
.rail-note { font-size: 11px; color: var(--ink-3); min-width: 0; overflow-wrap: anywhere; }

.rail {
  display: flex; align-items: flex-end; gap: 1px;
  height: 30px; padding: 0 0 2px;
  border-bottom: 1px solid var(--rule-firm);
}

/* Hierarchy is inverted on purpose: a passing gate is a hairline, a blocker has
 * weight. A rail where sixty passing gates shout in green buries the five that
 * stop the release. */
.tick {
  flex: 1 1 0; min-width: 2px; height: 3px;
  border: none; padding: 0; cursor: pointer;
  background: var(--rule); border-radius: 1px 1px 0 0;
  transition: opacity 0.12s ease;
}
.tick:hover, .tick:focus-visible { opacity: 1 !important; outline-offset: 1px; }
.tick-idle { cursor: default; opacity: 0.3; }

.tick[data-verdict="pass"]           { background: var(--v-pass); opacity: 0.32; }
.tick[data-verdict="not_applicable"] { background: var(--v-na);   opacity: 0.16; }
.tick[data-verdict="needs_review"],
.tick[data-verdict="insufficient_data"] { background: var(--v-review); height: 9px; opacity: 0.85; }

.tick[data-severity="blocker"] { background: var(--sev-blocker); height: 26px; opacity: 1; }
.tick[data-severity="high"]    { background: var(--sev-high);    height: 20px; opacity: 1; }
.tick[data-severity="medium"]  { background: var(--sev-medium);  height: 15px; opacity: 1; }
.tick[data-severity="low"]     { background: var(--sev-low);     height: 11px; opacity: 1; }

.key { list-style: none; margin: 7px 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 5px 14px; }
.key li { display: flex; align-items: center; gap: 5px; font-size: 10.5px; color: var(--ink-2); white-space: nowrap; }
.key i { width: 10px; height: 5px; border-radius: 1px; flex: none; }

/* ── panes ────────────────────────────────────────────────────────────── */

.tabs { display: flex; flex-wrap: wrap; gap: 2px; margin-top: 14px; }
.tab {
  background: none; border: none; border-bottom: 2px solid transparent;
  padding: 8px 12px; cursor: pointer;
  font-family: "Archivo", sans-serif; font-weight: 600;
  font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--ink-3);
}
.tab:hover { color: var(--ink); }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--ink); }
.tab-count {
  display: inline-block; margin-left: 5px; padding: 0 5px;
  border-radius: 8px; background: var(--surface-2); color: var(--ink-2);
  font-size: 10px; letter-spacing: 0;
}
.tab[aria-selected="true"] .tab-count { background: var(--ink); color: var(--surface); }

.panes { padding: 20px var(--gutter) 0; }
.pane-empty { color: var(--ink-3); font-size: 13px; padding: 8px 0 20px; }

/* ── findings ─────────────────────────────────────────────────────────── */

.finding { border-left: 3px solid var(--rule-firm); padding-left: 14px; margin: 0 0 24px; min-width: 0; }
.finding[data-severity="blocker"] { border-left-color: var(--sev-blocker); }
.finding[data-severity="high"]    { border-left-color: var(--sev-high); }
.finding[data-severity="medium"]  { border-left-color: var(--sev-medium); }
.finding[data-severity="low"]     { border-left-color: var(--sev-low); }
.finding[data-severity="info"]    { border-left-color: var(--sev-info); }

.finding-top { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; margin-bottom: 5px; }
.badge {
  font-family: "Archivo", sans-serif; font-weight: 700;
  font-size: 9px; letter-spacing: 0.15em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 2px; color: #fff; white-space: nowrap; flex: none;
}
.badge[data-severity="blocker"] { background: var(--sev-blocker); }
.badge[data-severity="high"]    { background: var(--sev-high); }
.badge[data-severity="medium"]  { background: var(--sev-medium); }
.badge[data-severity="low"]     { background: var(--sev-low); color: #21120f; }
.badge[data-severity="info"]    { background: var(--sev-info); color: #21120f; }
.finding-index { color: var(--ink-3); font-size: 11px; }

.finding-title { margin: 0; font-size: 16px; font-weight: 600; line-height: 1.35; overflow-wrap: anywhere; }
.finding-detail { margin: 6px 0 0; color: var(--ink-2); max-width: var(--measure); }

.finding-meta { margin: 8px 0 0; font-size: 11.5px; color: var(--ink-3); display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.finding-meta a { color: inherit; overflow-wrap: anywhere; }
.finding-meta .src {
  border: 1px solid var(--rule-firm); border-radius: 2px; padding: 0 5px;
  font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; flex: none;
}

.block-label { margin: 12px 0 4px; font-size: 9.5px; letter-spacing: 0.15em; text-transform: uppercase; color: var(--ink-3); }

.evidence { list-style: none; margin: 0; padding: 0; }
.evidence li {
  font-family: "JetBrains Mono", monospace; font-size: 11.5px;
  padding: 3px 0; color: var(--ink-2);
  border-bottom: 1px dotted var(--rule);
  overflow-wrap: anywhere;
}
.evidence .loc { color: var(--ink); font-weight: 500; }

.mitigations { margin: 0; padding: 0; list-style: none; counter-reset: fix; }
.mitigations li {
  counter-increment: fix; position: relative;
  padding-left: 25px; margin-bottom: 9px; max-width: var(--measure);
}
.mitigations li::before {
  content: counter(fix); position: absolute; left: 0; top: 2px;
  font-family: "Archivo", sans-serif; font-size: 9.5px; font-weight: 700;
  color: var(--v-pass); border: 1px solid var(--v-pass);
  width: 16px; height: 16px; border-radius: 50%;
  display: grid; place-items: center;
}
.mitigations .why { display: block; color: var(--ink-3); font-size: 12px; }
.mitigations .effort { font-size: 10px; color: var(--ink-3); white-space: nowrap; }
.mitigations .effort::before { content: " · "; }
.mitigations .by-model { color: var(--v-review); }

/* ── open questions ───────────────────────────────────────────────────── */

.question { border-left: 3px solid var(--v-review); padding-left: 14px; margin-bottom: 18px; }
.question h4 { margin: 0; font-size: 14px; font-weight: 600; overflow-wrap: anywhere; }
.question p { margin: 4px 0 0; color: var(--ink-2); font-size: 13px; max-width: var(--measure); }
.question ul { margin: 6px 0 0; padding-left: 18px; color: var(--ink-2); font-size: 12.5px; max-width: var(--measure); }

/* ── ledger ───────────────────────────────────────────────────────────── */

.ledger { width: 100%; border-collapse: collapse; font-size: 12px; table-layout: fixed; }
.ledger col.c-verdict { width: 108px; }
.ledger col.c-policy  { width: 26%; }
.ledger col.c-gate    { width: 26%; }
.ledger th {
  text-align: left; font-size: 9.5px; letter-spacing: 0.14em; text-transform: uppercase;
  color: var(--ink-3); font-weight: 600;
  border-bottom: 1px solid var(--rule-firm); padding: 0 10px 6px 0;
}
.ledger td { padding: 6px 10px 6px 0; border-bottom: 1px solid var(--rule); vertical-align: top; overflow-wrap: anywhere; }
.ledger tr.is-target td { background: var(--surface-2); }
.ledger .v { font-family: "Archivo", sans-serif; font-weight: 600; font-size: 9.5px; letter-spacing: 0.08em; text-transform: uppercase; }
.ledger .v[data-verdict="fail"]              { color: var(--v-fail); }
.ledger .v[data-verdict="pass"]              { color: var(--v-pass); }
.ledger .v[data-verdict="needs_review"]      { color: var(--v-review); }
.ledger .v[data-verdict="insufficient_data"] { color: var(--v-review); }
.ledger .v[data-verdict="not_applicable"]    { color: var(--v-na); }
.ledger .gate { font-family: "JetBrains Mono", monospace; font-size: 10.5px; color: var(--ink-3); }
.ledger .note { color: var(--ink-2); }

/* ── states ───────────────────────────────────────────────────────────── */

.empty { max-width: 48ch; padding: 26px var(--gutter); }
.empty-lead { font-family: "Archivo", sans-serif; font-weight: 600; font-size: 19px; margin: 0 0 8px; }
.empty-body { color: var(--ink-2); margin: 0; }

.problem {
  border: 1px solid var(--sev-high); border-left-width: 3px; border-radius: var(--radius);
  padding: 13px 15px; margin: 20px var(--gutter); background: var(--surface-2);
}
.problem h3 { margin: 0 0 5px; font-size: 14px; color: var(--sev-high); }
.problem p, .problem li { margin: 3px 0; font-size: 13px; color: var(--ink-2); overflow-wrap: anywhere; }
.problem ul { padding-left: 18px; }

.note-strip {
  border: 1px dashed var(--rule-firm); border-radius: var(--radius);
  padding: 7px 11px; margin-top: 12px; font-size: 12px; color: var(--ink-2);
}

.colophon { border-top: 1px solid var(--rule); padding: 14px var(--gutter) 26px; color: var(--ink-3); font-size: 11.5px; }
.colophon p { margin: 0; max-width: 78ch; }

.reveal { animation: rise 0.28s ease both; }
@keyframes rise { from { opacity: 0; transform: translateY(4px); } }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* ── narrow ───────────────────────────────────────────────────────────── */

@media (max-width: 960px) {
  .shell { grid-template-columns: 1fr; }
  .panel-input { position: static; max-height: none; border-right: none; border-bottom: 1px solid var(--rule); }
  .report-top { position: static; }
  .ledger col.c-verdict { width: 92px; }
  .ledger col.c-policy  { width: 34%; }
  .ledger .gate, .ledger col.c-gate { display: none; }
}

@media (max-width: 620px) {
  .masthead-stats { gap: 8px 16px; }
  .rail { height: 24px; }
  .tick[data-severity="blocker"] { height: 21px; }
  .tick[data-severity="high"]    { height: 16px; }

  /* A four-column table at 414px squeezes Notes into a column of single words.
   * Stack each row as a block instead: the verdict leads, the policy names it,
   * the note explains it. */
  .ledger, .ledger tbody, .ledger tr, .ledger td { display: block; width: auto; }
  .ledger colgroup, .ledger thead, .ledger th { display: none; }
  .ledger tr { padding: 9px 0; border-bottom: 1px solid var(--rule); }
  .ledger td { border: none; padding: 0; }
  .ledger td:nth-child(2) { font-weight: 600; margin-top: 1px; }
  .ledger .note { font-size: 12px; margin-top: 2px; }
  .ledger .gate { display: block; margin-top: 2px; }
}
