/* ===========================================================================
   story.css—the pieces this write-up adds to the shared CAC shell.
   =========================================================================== */

:root {
  /* Highlight + link colours, validated with the dataviz palette validator
     against both surfaces. Dark: blue #3f97d6, red #d9645a, purple #9b7be0,
     green #3aa37d. Light: #1f78c1, #c4473d, #7d55c7, #1f8a63. Work ties are
     a dashed neutral, so they never rely on colour alone. */
  --hl: #5a91ea;
  --hl-soft: oklch(0.66 0.146 259.792 / 0.16);
  --lk-clue: #5a91ea;
  /* The portfolio's .btn--blue treatment */
  --btn-blue: oklch(0.718 0.146 259.792 / 0.12);
  --btn-blue-text: oklch(0.8 0.161 259.792);
  --btn-blue-border: oklch(1 0 0 / 0.10);
  --btn-sheen: inset 0 1px 0 oklch(1 0 0 / 0.06);
  --lk-grudge: #d9645a;
  --lk-secret: #9b7be0;
  --lk-close: #3aa37d;
  --lk-work: #8a8a8a;
  --open-track: oklch(1 0 0 / 0.07);
  --warn: var(--grade-assumed-text);
  --warn-bg: var(--grade-assumed-bg);
  --ok: var(--grade-measured-text);
  --ok-bg: var(--grade-measured-bg);
  --add: var(--grade-measured-text);
  --del: var(--grade-assumed-text);
  --redact-bg: oklch(0.08 0 0);
  --redact-fg: oklch(0.62 0 0);
  --wide-out: 9rem;
  --tg-on: oklch(0.52 0 0);
  --tg-victim: oklch(0.88 0 0);
  --tg-warn: oklch(0.63 0.2 27);
}
:root[data-theme="light"] {
  --hl: #336ecd;
  --hl-soft: oklch(0.55 0.16 259.792 / 0.12);
  --lk-clue: #336ecd;
  --btn-blue: oklch(0.55 0.16 259.792 / 0.10);
  --btn-blue-text: oklch(0.5 0.18 259.792);
  --btn-blue-border: oklch(0 0 0 / 0.07);
  --lk-grudge: #c4473d;
  --lk-secret: #7d55c7;
  --lk-close: #1f8a63;
  --lk-work: #8a8a8a;
  --open-track: oklch(0 0 0 / 0.06);
  --redact-bg: oklch(0.2 0 0);
  --redact-fg: oklch(0.78 0 0);
  --tg-on: oklch(0.62 0 0);
  --tg-victim: oklch(0.3 0 0);
  --tg-warn: oklch(0.55 0.21 27);
}

.section > ul.rulelist { margin-bottom: var(--s4); }
.section > ul.rulelist li { font-size: 15px; }
.section--flush { padding-top: 0; }
.section > h3:first-child { margin-top: var(--s2); }

.table-scroll { overflow-x: auto; margin: var(--s5) 0; -webkit-overflow-scrolling: touch; }
.table-scroll > table { margin: 0; }
.rules-table td.num, .rules-table th.num { white-space: nowrap; text-align: right; font-variant-numeric: tabular-nums; }
.targets-table td:first-child, .profiles-table td:last-child { white-space: normal; }
.targets-table td:last-child { white-space: nowrap; }
.profiles-table td:nth-child(2) { color: var(--text-secondary); font-weight: 400; }

.pf { display: inline-block; font-size: 10.5px; font-weight: 600; padding: 2px 6px; border-radius: var(--radius-sm); margin-right: 6px; border: 1px solid var(--grade-border); }
.pf--pass { background: var(--ok-bg); color: var(--ok); }
.pf--fail { background: var(--warn-bg); color: var(--warn); }

/* ── Wide figures ──────────────────────────────────────────── */
.module.wide { margin: var(--s5) 0 var(--s6); }
@media (min-width: 1240px) {
  .wide { margin-left: calc(-1 * var(--wide-out)) !important; margin-right: calc(-1 * var(--wide-out)) !important; }
}
.fig-cap { font-size: 12.5px; line-height: 1.5; color: var(--text-tertiary); margin-top: var(--s4); }
.fig-cap strong { color: var(--text); }
.fig-top { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: var(--s3) var(--s5); margin-bottom: var(--s4); }
.fig-top .module-head { margin-bottom: 0; }

/* Segmented control, from the CAC site */
.segmented { display: inline-flex; flex-wrap: wrap; gap: 2px; padding: 2px; background: var(--bg); border: 1px solid var(--border); border-radius: var(--radius-md); }
.seg-btn { position: relative; border: none; background: none; cursor: pointer; font: 500 12.5px var(--font); color: var(--text-tertiary); padding: 7px 12px; border-radius: var(--radius-sm); white-space: nowrap; line-height: 1.4; transition: color var(--transition), background var(--transition); }
.seg-btn:hover { color: var(--text); }
.seg-btn.is-active { color: var(--text); background: var(--pill-active-bg); }
.seg-btn:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }

/* Redaction: a black bar, sometimes with a placeholder label */
.redact {
  background: var(--redact-bg); color: var(--redact-fg);
  padding: 0 5px; border-radius: 2px; font-style: normal;
  font-size: 0.86em; letter-spacing: 0.01em;
  -webkit-box-decoration-break: clone; box-decoration-break: clone;
}
.redact--bar { display: inline-block; height: 14px; padding: 0; vertical-align: middle; }

.mini-diff {
  font: 12.5px/1.6 var(--font-mono); white-space: pre-wrap; word-break: break-word;
  background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: var(--s3); margin-top: var(--s2); color: var(--text-secondary);
}
.mini-diff .add { color: var(--add); }
.mini-diff .del { color: var(--del); }

/* ── Desktop screenshot at the top ─────────────────────────── */
.desk { margin: 0 0 var(--s6); }
.desk-frame { border-radius: var(--radius-lg); overflow: hidden; box-shadow: 0 0 0 1px var(--border), 0 16px 40px oklch(0 0 0 / 0.3); }
.desk-frame img { display: block; width: 100%; height: auto; }
.desk-cap { font-size: 12.5px; color: var(--text-tertiary); text-align: center; margin-top: var(--s3); }

/* ── Phone screenshots ─────────────────────────────────────── */
.phones { margin: var(--s5) 0 var(--s6); }
.phones-track {
  display: grid; grid-auto-flow: column; grid-auto-columns: 200px;
  gap: var(--s4); overflow-x: auto; scroll-snap-type: x mandatory;
  padding: var(--s1) 0 var(--s3); -webkit-overflow-scrolling: touch; scrollbar-width: thin;
}
.phone { scroll-snap-align: start; margin: 0; }
.phone-frame { border-radius: 26px; padding: 7px; background: var(--bg-elevated); box-shadow: 0 0 0 1px var(--border), 0 10px 30px oklch(0 0 0 / 0.25); }
.phone-frame img { display: block; width: 100%; height: auto; border-radius: 20px; }
.phone-cap { margin-top: var(--s3); font-size: 12.5px; line-height: 1.4; color: var(--text-tertiary); text-align: center; }
@media (min-width: 1240px) {
  .phones-track { grid-auto-flow: row; grid-template-columns: repeat(5, 1fr); grid-auto-columns: auto; overflow: visible; }
}

/* ── Who links to whom ─────────────────────────────────────── */
.web-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 12rem; gap: var(--s5); align-items: center; }
.web { display: block; width: 100%; max-width: 460px; height: auto; margin: 0 auto; }
.wl { fill: none; stroke-width: 1.6; transition: opacity 200ms ease, stroke-width 200ms ease; }
.wl--clue { stroke: var(--lk-clue); opacity: 0.45; stroke-width: 1.2; }
.wl--grudge { stroke: var(--lk-grudge); opacity: 0.85; }
.wl--secret { stroke: var(--lk-secret); opacity: 0.85; }
.wl--close { stroke: var(--lk-close); opacity: 0.85; }
.wl--work { stroke: var(--lk-work); opacity: 0.8; stroke-dasharray: 4 4; }
.wl.is-off { opacity: 0 !important; }
.wl.is-dim { opacity: 0.08; }
.wl.is-hot { opacity: 1; stroke-width: 2.2; }
.wn { cursor: pointer; outline: none; transition: opacity 200ms ease; }
.wn circle { fill: var(--bg); stroke: var(--border); stroke-width: 1; }
.wn text { fill: var(--text-secondary); font: 500 11px var(--font); text-anchor: middle; pointer-events: none; }
.wn--victim circle { fill: var(--text); stroke: var(--text); }
.wn--victim text { fill: var(--bg); font-weight: 600; }
.wn.is-self circle { stroke: var(--text); stroke-width: 2; }
.wn.is-dim { opacity: 0.35; }
.wn:focus-visible circle { stroke: var(--text); stroke-width: 2.5; }
.web-legend { list-style: none; display: flex; flex-direction: column; gap: var(--s2); font-size: 12.5px; color: var(--text-secondary); }
.web-legend li { display: flex; align-items: center; gap: var(--s2); transition: opacity 200ms ease; }
.web-legend li.is-off { opacity: 0.3; }
.lk { display: inline-block; width: 22px; height: 0; border-top: 2.5px solid; flex-shrink: 0; }
.lk--clue { border-color: var(--lk-clue); }
.lk--grudge { border-color: var(--lk-grudge); }
.lk--secret { border-color: var(--lk-secret); }
.lk--close { border-color: var(--lk-close); }
.lk--work { border-color: var(--lk-work); border-top-style: dashed; }

/* ── Timeline grid ─────────────────────────────────────────── */
.tg-legend, .mem-legend { display: flex; flex-wrap: wrap; gap: var(--s2) var(--s4); font-size: 12px; color: var(--text-tertiary); margin-bottom: var(--s4); }
.tg-legend span, .mem-legend span { display: inline-flex; align-items: center; gap: var(--s2); }
.tg-key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--open-track); }
.tg-key--on { background: var(--tg-on); }
.tg-key--warn { background: var(--tg-warn); }
.tg-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.tg { display: grid; grid-template-columns: 4.6rem repeat(9, minmax(22px, 1fr)); gap: 3px; min-width: 330px; }
.tg-h { font-size: 11px; font-weight: 600; color: var(--text-tertiary); text-align: center; padding-bottom: 4px; white-space: nowrap; }
.tg-h--victim { color: var(--text); }
.tg-t { font-size: 11px; color: var(--text-tertiary); font-variant-numeric: tabular-nums; white-space: nowrap; display: flex; align-items: center; }
.tg-c { height: 18px; border-radius: 2px; background: var(--open-track); position: relative; }
.tg-c.is-on { background: var(--tg-on); }
.tg-c.is-warn { background: var(--tg-warn); }
.tg-c.is-warn::after { content: "!"; position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font: 700 11px var(--font); color: #fff; }
.tg-c.is-victim.is-on { background: var(--tg-victim); }

/* ── The first game, turn by turn ──────────────────────────── */
.rp-btn {
  display: inline-flex; align-items: center; gap: 6px; cursor: pointer;
  font: 400 13px var(--font); color: var(--btn-blue-text); background: var(--btn-blue);
  padding: 7px 14px 7px 11px; border-radius: var(--radius-pill); border: 1px solid var(--btn-blue-border);
  box-shadow: var(--btn-sheen); transition: opacity 0.15s ease, scale 0.15s ease;
}
.rp-btn:hover { opacity: 0.85; }
.rp-btn:active { scale: 0.96; }
.rp-btn:focus-visible { outline: 1.5px solid var(--text-tertiary); outline-offset: 2px; }
.rp-btn svg { width: 14px; height: 14px; fill: currentColor; }
.rp-btn .ico-pause { display: none; }
.is-playing .rp-btn .ico-pause { display: block; }
.is-playing .rp-btn .ico-play { display: none; }
.tb-stage { display: grid; grid-template-columns: minmax(0, 1.1fr) minmax(0, 1fr); gap: var(--s5); align-items: center; }
.tb { display: block; width: 100%; max-width: 420px; height: auto; margin: 0 auto; }
.tb-table { fill: var(--bg); stroke: var(--border); stroke-width: 1; }
.tb-q { stroke: var(--text-tertiary); stroke-width: 1; opacity: 0; transition: opacity 300ms ease; }
.tb-q.is-on { opacity: 0.35; }
.tb-live { stroke: var(--hl); stroke-width: 2.5; opacity: 0; transition: opacity 200ms ease; }
.tb-live.is-on { opacity: 1; }
.tb-seat circle { fill: var(--bg); stroke: var(--border); stroke-width: 1; transition: fill 200ms ease, stroke 200ms ease; }
.tb-seat text { fill: var(--text-secondary); font: 500 10.5px var(--font); text-anchor: middle; }
.tb-seat.is-speaking circle { fill: var(--hl); stroke: var(--hl); }
.tb-seat.is-speaking text { fill: #fff; font-weight: 600; }
.tb-seat.is-target circle { stroke: var(--hl); stroke-width: 2; }
.tb-say { min-height: 9.5rem; background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: var(--s4); }
.tb-phase { font-size: 11px; font-weight: 600; color: var(--text-tertiary); font-variant-numeric: tabular-nums; }
.tb-who { font-size: 15px; font-weight: 600; color: var(--text); margin: var(--s1) 0 var(--s2); }
.tb-text { font-size: 14px; line-height: 1.5; color: var(--text-secondary); }
.tb-scrub { margin-top: var(--s4); }
.tb-scrub input[type="range"] { width: 100%; accent-color: var(--hl); cursor: pointer; }
.tb-scale { display: flex; font-size: 11px; color: var(--text-tertiary); margin-top: 2px; }
.tb-scale span { border-left: 1px solid var(--border); padding-left: 5px; white-space: nowrap; overflow: hidden; }

/* ── Shared card text ──────────────────────────────────────── */
.st-label { font-size: 11px; font-weight: 600; color: var(--text-tertiary); margin-bottom: var(--s2); }
.st-quote { font-size: 15px; line-height: 1.5; color: var(--text); }

/* ── What each player remembered ───────────────────────────── */
.mem-key { display: inline-block; width: 12px; height: 12px; border-radius: 2px; background: var(--open-track); box-shadow: inset 0 0 0 1px var(--border); }
.mem-key--kept { background: var(--hl); box-shadow: none; }
.mem-rows { display: flex; flex-direction: column; gap: var(--s3); }
.mem-row { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 9.5rem; gap: var(--s4); align-items: center; }
.mem-label { font-size: 13px; color: var(--text); line-height: 1.3; }
.mem-label small { display: block; font-size: 11.5px; color: var(--text-tertiary); }
.mem-strip { display: flex; gap: 1px; height: 22px; }
.mem-strip i { flex: 1 1 0; min-width: 1px; border-radius: 1px; background: var(--open-track); }
.mem-strip i.k { background: var(--hl); }
.mem-strip i.r2 { margin-left: 5px; }
.mem-val { font-size: 12.5px; line-height: 1.3; text-align: right; }
.mem-val strong { display: block; color: var(--text); font-variant-numeric: tabular-nums; }
.mem-verdict { font-size: 11.5px; font-weight: 600; white-space: nowrap; }
.mem-verdict.is-right { color: var(--ok); }
.mem-verdict.is-wrong { color: var(--warn); }
.mem-axis { display: grid; grid-template-columns: 9.5rem minmax(0, 1fr) 9.5rem; gap: var(--s4); margin-top: var(--s2); font-size: 11px; color: var(--text-tertiary); }
.mem-axis-track { display: flex; }
.mem-axis-track span { border-top: 1px solid var(--border); padding-top: 4px; }

/* ── Bug report ────────────────────────────────────────────── */
.bugreport .module-title { margin-bottom: var(--s4); }
.br-cols { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: var(--s3); }
.br-card { background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-md); padding: var(--s4); min-width: 0; }
.br-card--private { border-style: dashed; }
.br-fix { margin-top: var(--s4); }

.mem-profiles { margin: 0 0 var(--s4); }
.mem-profiles .rules-table { background: var(--bg); }
.fig-divider { border: none; border-top: 1px solid var(--border-light); margin: var(--s5) 0; }

/* ── Prompt quotes, the added rule, the closing line ───────── */
.section > blockquote.pq {
  margin: var(--s3) 0 var(--s4); padding: var(--s2) 0 var(--s2) var(--s4);
  border-left: 2px solid var(--border); font: 13.5px/1.55 var(--font-mono); color: var(--text-secondary);
}
.rule-added {
  font: 13px/1.6 var(--font-mono); color: var(--add);
  background: var(--bg); border: 1px solid var(--border-light); border-radius: var(--radius-md);
  padding: var(--s3) var(--s4);
}
.closing { font-size: 17px; line-height: 1.55; color: var(--text); }
.section > h3 + p { margin-top: 0; }

/* ── Narrow screens ────────────────────────────────────────── */
@media (max-width: 720px) {
  .br-cols, .tb-stage { grid-template-columns: 1fr; }
  .web-wrap { grid-template-columns: 1fr; }
  .web-legend { flex-direction: row; flex-wrap: wrap; gap: var(--s2) var(--s4); }
  .mem-row, .mem-axis { grid-template-columns: minmax(0, 1fr) auto; row-gap: var(--s1); }
  .mem-label { grid-column: 1 / -1; }
  .mem-axis > :first-child { display: none; }
  .tb-say { min-height: 8rem; }
}
@media (max-width: 560px) {
  .module { padding: var(--s4); }
}
