/* ==========================================================================
   Interactive demo
   --------------------------------------------------------------------------
   Page-specific; `.demo-*` and `.app-frame` appear on no other page, verified
   against the built output. Nothing data-driven is a style attribute -- the
   CSP is `style-src 'self'` -- so the score bar is SVG geometry the script
   rewrites by attribute.
   ========================================================================== */

.demo-hero { padding-bottom: 8px; }
.demo-hero-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 0.95fr);
  gap: 40px;
  align-items: start;
}

/* -- the two orderings, which are the argument ------------------------- */

.demo-order {
  margin: 0;
  padding: 20px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: linear-gradient(180deg, #131c36, var(--bg-card));
}
.demo-order-caption { font-weight: 600; margin-bottom: 14px; font-size: 0.95rem; }
.demo-order-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.demo-order-col { min-width: 0; }
.demo-order-label {
  margin: 0 0 8px;
  font-size: 0.74rem;
  letter-spacing: 0.07em;
  text-transform: uppercase;
  color: var(--muted);
}
.demo-order-cvss .demo-order-label { color: #ffb37e; }
.demo-order-score .demo-order-label { color: var(--accent); }
.demo-order-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.demo-order-list li {
  display: grid;
  grid-template-columns: 20px 1fr auto;
  align-items: center;
  gap: 8px;
  padding: 9px 10px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: var(--bg);
  font-size: 0.82rem;
}
.demo-order-rank { color: var(--muted); font-variant-numeric: tabular-nums; }
.demo-order-name { min-width: 0; overflow-wrap: anywhere; }
.demo-order-value { font-weight: 700; font-variant-numeric: tabular-nums; }
.demo-move { grid-column: 3; font-size: 0.72rem; font-weight: 700; }
.demo-move-up { color: var(--ok); }
.demo-move-down { color: #ffb37e; }
.demo-order-note { margin: 14px 0 0; font-size: 0.84rem; color: var(--muted); }

/* -- layout ------------------------------------------------------------- */

.demo-intro { color: var(--muted); max-width: 62ch; }
.demo-grid {
  display: grid;
  grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr);
  gap: 24px;
  align-items: start;
  margin-top: 22px;
}
/* Grid items default to min-width:auto, so a column cannot shrink below its
   content and the single-column rule below has no effect. Both children opt
   out explicitly. */
.demo-list-col, .demo-detail-col, .demo-hero-visual { min-width: 0; }
.demo-item-title { overflow-wrap: anywhere; }

/* -- the ranked list ----------------------------------------------------- */

.demo-list { list-style: none; margin: 0; padding: 0; display: grid; gap: 10px; }
.demo-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 44px;
  padding: 14px;
  text-align: left;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: inherit;
  font: inherit;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.demo-item:hover { border-color: var(--accent); }
.demo-item:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }
.demo-item.is-active {
  border-color: var(--accent);
  background: linear-gradient(180deg, rgba(79, 140, 255, 0.16), var(--bg-card));
}
.demo-rank {
  flex: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 50%;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  font-size: 0.8rem;
  font-variant-numeric: tabular-nums;
}
.demo-item-main { flex: 1 1 auto; min-width: 0; }
.demo-item-title { display: block; font-size: 0.95rem; font-weight: 600; }
.demo-item-sub {
  display: block; margin-top: 3px;
  font-size: 0.78rem; color: var(--muted);
  overflow-wrap: anywhere;
}
.demo-score { flex: none; text-align: right; }
.demo-score-value { display: block; font-size: 1.25rem; font-weight: 700; line-height: 1.1; }
.demo-score-band { display: block; font-size: 0.72rem; color: var(--muted); }

/* -- what-if ------------------------------------------------------------- */

.demo-whatif {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
}
.demo-whatif-note { margin: 0 0 12px; font-size: 0.8rem; color: var(--muted); }
.demo-switch {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  font-size: 0.88rem;
  cursor: pointer;
}
.demo-switch input { width: 18px; height: 18px; accent-color: var(--accent); flex: 0 0 auto; }
.demo-switch:focus-within { outline: 3px solid var(--accent); outline-offset: 3px; border-radius: 8px; }
.demo-switch.is-disabled { opacity: 0.5; cursor: not-allowed; }
/* The controls assert propositions, so each one says what its proposition
   means. Laid out as a column so the help text sits under the label rather
   than pushing it off a narrow screen. */
.demo-switch { flex-wrap: wrap; align-items: flex-start; padding: 6px 0; }
.demo-switch > span:first-of-type { flex: 1 1 auto; align-self: center; }
.demo-switch-help {
  flex: 1 0 100%;
  margin-left: 28px;
  font-size: 0.76rem;
  line-height: 1.45;
  color: var(--muted);
}
.demo-whatif-status { margin: 8px 0 0; font-size: 0.82rem; color: var(--ok); min-height: 1.2em; }
.demo-reset { margin-top: 10px; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
/* A finding shown under conditions the visitor changed is marked, so a score
   on screen is never mistaken for the one the scenario records. */
.demo-item.is-modified .demo-score-value::after,
.demo-detail.is-modified .demo-detail-value::after {
  content: "*";
  margin-left: 2px;
  color: var(--accent);
}

/* -- detail panel -------------------------------------------------------- */

.demo-detail-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.demo-detail-title { margin: 0; font-size: 1.02rem; }
.demo-detail-sub { margin: 4px 0 0; font-size: 0.8rem; color: var(--muted); overflow-wrap: anywhere; }
.demo-detail-score { margin: 0; text-align: right; flex: none; }
.demo-detail-value { display: block; font-size: 2rem; font-weight: 700; line-height: 1; }
.demo-detail-band { display: block; font-size: 0.76rem; color: var(--muted); }

.demo-bar-wrap { margin: 16px 0 6px; }
.demo-bar { width: 100%; height: 16px; display: block; border-radius: 3px; }

.demo-factors {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  font-size: 0.88rem;
  /* Fixed, so the table honours its container rather than being sized by its
     longest description. */
  table-layout: fixed;
  /* The global `table` rule sets min-width: 640px for the site's wide
     scrollable tables. Inside a 543px panel that pushed the points column past
     the frame, which clips -- so the numbers were rendered and invisible, the
     worst of both. Opted out explicitly. */
  min-width: 0;
}
/* Column widths come from the colgroup, so a fixed layout has something
   definite to work from. There is no header row: the caption names the table,
   every row carries a row header, and the total is in the footer. */
.demo-col-points { width: 76px; }
.demo-factors th, .demo-factors td {
  padding: 10px 0;
  border-bottom: 1px solid rgba(36, 50, 90, 0.7);
  text-align: left;
  vertical-align: top;
  font-weight: 400;
}
.demo-factors tfoot th, .demo-factors tfoot td {
  border-bottom: 0; border-top: 2px solid var(--line); font-weight: 700; padding-top: 12px;
}
.demo-key { width: 10px; height: 10px; margin-right: 8px; vertical-align: 1px; }
.demo-factor-label { font-weight: 600; }
.demo-factor-detail { display: block; margin-top: 2px; font-size: 0.79rem; color: var(--muted); }
.demo-factor-points {
  width: 76px;
  text-align: right;
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
  font-weight: 600;
}
.demo-factors th { overflow-wrap: anywhere; }

.demo-sub { margin: 20px 0 8px; font-size: 0.8rem; letter-spacing: 0.06em; text-transform: uppercase; color: var(--muted); }

.demo-chain { list-style: none; margin: 0; padding: 0; display: grid; gap: 0; }
.demo-hop {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0 7px 4px;
  font-size: 0.86rem;
}
.demo-hop + .demo-hop::before {
  content: "";
  position: absolute;
  left: 9px; top: -8px; height: 16px;
  border-left: 2px dotted var(--line);
}
.demo-hop-dot {
  flex: none; width: 11px; height: 11px; border-radius: 50%;
  background: var(--bg); border: 2px solid var(--accent);
}
.demo-hop.is-origin .demo-hop-dot { border-color: #ffb37e; }
.demo-hop.is-target .demo-hop-dot { background: var(--danger); border-color: var(--danger); }
.demo-hop-name { overflow-wrap: anywhere; }
.demo-fix { margin: 0; font-size: 0.9rem; }
/* The sentence that stops a low rank reading as "harmless". Deliberately not
   muted: it carries the caveat, and muting a caveat is how it stops being
   read. */
.demo-caveat {
  margin: 10px 0 0;
  padding: 10px 12px;
  border-left: 3px solid var(--accent);
  background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem;
  line-height: 1.5;
}
.demo-model-note {
  margin: 24px 0 0;
  padding: 14px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--bg-soft);
  font-size: 0.84rem;
  line-height: 1.6;
  color: var(--muted);
}
.demo-model-note strong { color: var(--fg); }

@media (max-width: 900px) {
  .demo-hero-grid { grid-template-columns: 1fr; gap: 26px; }
  .demo-grid { grid-template-columns: 1fr; }
}

@media (max-width: 560px) {
  .demo-order-grid { grid-template-columns: 1fr; }
  .demo-detail-head { flex-direction: column; }
  .demo-detail-score { text-align: left; }
}

/* ---------- guided walkthrough ----------
   Five panels, one visible at a time once the script runs. Every panel says
   "Simulated" in its own markup: a disclaimer at the top of the page is not
   attached to the picture of a ticket three screens down. */
.wk { margin-top: 20px; }
.wk-dots { display: flex; gap: 8px; list-style: none; margin: 0 0 16px; padding: 0; }
.wk-dot {
  flex: 1 1 0; height: 4px; border-radius: 999px;
  background: var(--line);
}
.wk-dot.is-done { background: var(--accent-soft); }
.wk-dot.is-current { background: var(--accent); }

.wk-stage {
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg-card); padding: 20px;
}
.wk-eyebrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  margin: 0 0 6px;
  font-size: 0.74rem; letter-spacing: 0.06em; text-transform: uppercase;
  color: var(--muted);
}
.wk-sim {
  padding: 1px 8px; border-radius: 999px;
  background: var(--warn); color: #1b1200; font-weight: 700;
  letter-spacing: 0.04em;
}
.wk-title { margin: 0 0 8px; font-size: 1.2rem; }
.wk-title:focus-visible { outline: 3px solid var(--accent); outline-offset: 4px; }
.wk-lead { margin: 0 0 16px; color: var(--muted); line-height: 1.6; }

.wk-rows { list-style: none; margin: 0 0 14px; padding: 0; display: grid; gap: 10px; }
.wk-row {
  display: grid; gap: 4px 12px; padding: 12px;
  border: 1px solid var(--line); border-left-width: 3px; border-radius: 10px;
  background: var(--bg-soft);
}
@media (min-width: 720px) {
  .wk-row { grid-template-columns: minmax(0, 15rem) auto; align-items: baseline; }
  .wk-detail { grid-column: 1 / -1; }
}
.wk-asset { font-family: var(--mono); font-size: 0.84rem; overflow-wrap: anywhere; }
.wk-state {
  justify-self: start; padding: 1px 9px; border-radius: 999px;
  font-size: 0.76rem; font-weight: 700; white-space: nowrap;
}
.wk-detail { font-size: 0.88rem; color: var(--muted); line-height: 1.55; }

/* State is never carried by colour alone: every one of these has its word in
   the pill beside it. */
.wk-row--fix-now, .wk-row--regressed { border-left-color: var(--danger); }
.wk-row--verified { border-left-color: var(--ok); }
.wk-row--still-affected { border-left-color: var(--warn); }
.wk-row--unverified, .wk-row--waiting { border-left-color: var(--muted); }
.wk-row--acting, .wk-row--moderate, .wk-row--low { border-left-color: var(--accent); }
.wk-state--fix-now, .wk-state--regressed { background: var(--danger); color: #2b0000; }
.wk-state--verified { background: var(--ok); color: #04220f; }
.wk-state--still-affected { background: var(--warn); color: #1b1200; }
.wk-state--unverified, .wk-state--waiting { background: var(--line); color: var(--text); }
.wk-state--acting, .wk-state--moderate, .wk-state--low { background: var(--accent-soft); color: var(--text); }

.wk-note {
  margin: 0; padding: 10px 12px;
  border-left: 3px solid var(--accent); background: var(--bg-soft);
  border-radius: 0 var(--radius) var(--radius) 0;
  font-size: 0.85rem; line-height: 1.55;
}
.wk-outcome { margin: 0 0 18px; padding-left: 1.2em; line-height: 1.7; }
.wk-outcome li { margin: 6px 0; }
.wk-cta { margin: 0; display: flex; gap: 10px; flex-wrap: wrap; }

.wk-controls {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  margin-top: 16px;
}
.wk-progress { margin: 0; font-size: 0.84rem; color: var(--muted); flex: 1 1 auto; }
