/* ============================================================
   Tamerix -- Issue 05: Context engineering
   Page-specific styles. Shared components (prose marks, form chrome,
   code, tables, panels, message cards, JSON blocks, the step trace,
   the comparison matrix) live in assets/issue.css. This file owns
   ONLY the accent and the components unique to this issue: the
   policy picker, the token meter, the context-window message stack,
   the verdict box, and the before/after compression bars.
   ============================================================ */

/* per-issue accent (kept in sync with data/issues.json; lives here so adding
   an issue never touches the shared assets/core.css) */
body[data-essay="context-engineering"] { --accent:#9f1239; --accent-soft:#f8e6ea; }

/* ============================================================
   policy picker
   ============================================================ */

.policy-picker { display: flex; flex-wrap: wrap; gap: 8px; margin: 4px 0 12px; }
.policy-picker .opt {
  font-family: var(--font-ui);
  font-size: 13px;
  font-weight: 500;
  background: var(--bg);
  color: var(--ink);
  border: 1px solid var(--hairline-cool);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius);
  padding: 8px 14px;
  cursor: pointer;
}
.policy-picker .opt:hover { background: var(--accent-soft); filter: none; }
.policy-picker .opt.active { background: var(--accent); color: var(--accent-ink); }

/* ============================================================
   the token meter
   ============================================================ */

.token-meter {
  display: grid;
  grid-template-columns: 130px 1fr 96px;
  align-items: center;
  gap: 12px;
  font-family: var(--font-ui);
  font-size: 12.5px;
  color: var(--muted);
  margin: 6px 0 12px;
}
.token-meter .tm-name { text-align: right; }
.token-meter .tm-track {
  height: 18px;
  background: var(--bg);
  border: 1px solid var(--hairline-cool);
  border-radius: 2px;
  overflow: hidden;
  position: relative;
}
.token-meter .tm-fill { height: 100%; background: var(--accent); }
.token-meter .tm-fill.over { background: #b91c1c; }
.token-meter .tm-limit { position: absolute; top: 0; bottom: 0; width: 2px; background: var(--ink); }
.token-meter .tm-val { font-family: var(--font-mono); color: var(--accent); font-weight: 600; text-align: right; font-variant-numeric: tabular-nums; }
.token-meter .tm-val.over { color: #b91c1c; }

/* ============================================================
   the context-window message stack
   ============================================================ */

.ctx-window { display: flex; flex-direction: column; gap: 5px; margin: 10px 0; }
.ctx-msg {
  display: grid;
  grid-template-columns: 64px 1fr 54px;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--hairline-cool);
  border-left: 3px solid var(--muted);
  border-radius: var(--radius);
  padding: 7px 12px;
  background: var(--surface);
  transition: opacity 160ms ease;
}
.ctx-msg .role { font-family: var(--font-ui); font-size: 10px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--muted); }
.ctx-msg .label { font-family: var(--font-mono); font-size: 12.5px; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ctx-msg .cost { font-family: var(--font-mono); font-size: 12px; color: var(--muted); text-align: right; font-variant-numeric: tabular-nums; }

/* role left-border colours */
.ctx-msg.system { border-left-color: var(--ink); }
.ctx-msg.human  { border-left-color: var(--subtle); }
.ctx-msg.ai     { border-left-color: var(--accent); }
.ctx-msg.tool   { border-left-color: #b45309; }

/* states */
.ctx-msg.dropped { opacity: 0.34; }
.ctx-msg.dropped .label { text-decoration: line-through; }
.ctx-msg.pinned  { box-shadow: inset 0 0 0 1px var(--accent); }
.ctx-msg .pin { color: var(--accent); font-weight: 700; }
.ctx-msg.summary {
  border-left-color: var(--accent);
  background: var(--accent-soft);
  border-style: dashed;
}
.ctx-msg.summary .role { color: var(--accent); }
.ctx-msg.lost-important { box-shadow: inset 0 0 0 1px #b91c1c; }

/* the verdict box (the punchline) */
.verdict {
  margin: 12px 0 0;
  padding: 12px 16px;
  border-radius: 0 var(--radius) var(--radius) 0;
  font-family: var(--font-ui);
  font-size: 14px;
  border-left: 3px solid var(--accent);
  background: var(--accent-soft);
}
.verdict.good { border-left-color: #15803d; background: #e9f4ec; color: #14532d; }
.verdict.bad  { border-left-color: #b91c1c; background: #fbeaea; color: #7f1d1d; }
.verdict strong { font-weight: 700; }

/* ============================================================
   before/after compression bars
   ============================================================ */

.compress-bars { display: flex; flex-direction: column; gap: 12px; margin: 12px 0; }
.cb-row { display: grid; grid-template-columns: 90px 1fr 96px; align-items: center; gap: 10px; font-family: var(--font-ui); font-size: 13px; }
.cb-name { text-align: right; color: var(--muted); }
.cb-track { height: 22px; background: var(--bg); border: 1px solid var(--hairline-cool); border-radius: var(--radius); overflow: hidden; display: flex; }
.cb-seg { height: 100%; }
.cb-seg.sys { background: var(--ink); }
.cb-seg.summary { background: var(--accent); }
.cb-seg.recent { background: #b45309; }
.cb-seg.history { background: var(--accent); opacity: 0.5; }
.cb-val { font-family: var(--font-mono); font-size: 12px; text-align: right; font-variant-numeric: tabular-nums; color: var(--ink); }

/* ============================================================
   responsive (bespoke)
   ============================================================ */

@media (max-width: 700px) {
  .token-meter { grid-template-columns: 92px 1fr 84px; gap: 8px; }
  .ctx-msg { grid-template-columns: 52px 1fr 46px; gap: 7px; padding: 6px 10px; }
  .ctx-msg .label { font-size: 11.5px; }
  .cb-row { grid-template-columns: 66px 1fr 84px; gap: 7px; }
}
@media (max-width: 480px) {
  .ctx-msg { grid-template-columns: 44px 1fr 40px; }
  .ctx-msg .role { font-size: 9px; }
}
