/* ─────────────────────────────────────────────────────────────
   ECONOMIC STATECRAFT TRACKER — "grid status" presentation layer
   (cloned from the AI Governance Tracker; .agt-* contract kept)
   plus the instrument × operator matrix (.esm-*, bottom of file).
   Status semantics run on the series two-accent system:
     solid red          = the clamp is live        (ACTIVE)
     solid amber        = the turn is coming       (APPROACHING)
     hollow/hatch amber = scheduled, not energized (FUTURE)
     severed dark red   = struck instruments       (REVOKED)
     gray               = unclassified             (OTHER)
   Scoped .agt-*. JS contract preserved exactly: .agt-table,
   .agt-hidden, tr[data-agt-status], chip classes agt-on-<key>.
   ───────────────────────────────────────────────────────────── */

[x-cloak] { display: none !important; }

.agt-wrap {
  --ground: #0C0C0F;
  --panel: #14141A;
  --panel2: #1B1B22;
  --line: #2A2A33;
  --tx: #E6E4DE;
  --mut: #84838F;
  --red: #CC0000;
  --red-dim: #881111;
  --amber: #E8A33D;
  --mono: ui-monospace, "JetBrains Mono", Consolas, monospace;
  color: var(--tx);
  margin: 1.6rem 0;
}

/* ─── Thesis lead — first paragraph of the body ──────────── */
.agt-wrap > p:first-of-type {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.5;
  color: var(--tx);
  margin: 2.1rem 0 1.1rem;
}

/* ─── Field labels — leading <strong> in prose notes ─────── */
.agt-wrap > p > strong:first-child {
  font-family: var(--mono);
  font-size: 0.72em;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--amber);
}

/* ─── Section headers — instrument panel labels ──────────── */
.agt-wrap h2 {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--mono);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--tx);
  border-bottom: none;
  padding-bottom: 0;
  position: static;
  margin: 3.2rem 0 0.9rem;
}
.agt-wrap h2::before {
  content: "";
  flex: none;
  width: 8px;
  height: 8px;
  background: var(--red);
  box-shadow: 0 0 8px rgba(204, 0, 0, 0.55);
}
.agt-wrap h2::after {
  content: "";
  position: static;
  flex: 1 1 auto;
  width: auto;
  height: 1px;
  background: var(--line);
}

/* ─── Grid-status console ────────────────────────────────── */
.agt-console {
  background-color: var(--panel);
  background-image: radial-gradient(rgba(230, 228, 222, 0.04) 1px, transparent 1px);
  background-size: 12px 12px;
  border: 1px solid var(--line);
  border-top: 2px solid var(--red);
  padding: 0.95rem 1.1rem 1rem;
}
.agt-console-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.5rem 1rem;
}
.agt-console-title {
  font-family: var(--mono);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--tx);
}
.agt-console-readout {
  font-family: var(--mono);
  font-size: 0.7rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mut);
  margin-left: auto;
}
.agt-console-readout strong { color: var(--tx); font-weight: 700; }

.agt-btn {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: var(--ground);
  color: var(--tx);
  border: 1px solid var(--line);
  padding: 0.3rem 0.7rem;
  cursor: pointer;
}
.agt-btn:hover { border-color: var(--mut); background: var(--panel2); }
.agt-btn:focus-visible,
.agt-chip:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }

/* ─── Energization bar — share of rows per status ────────── */
.agt-bar {
  display: flex;
  gap: 2px;
  height: 10px;
  margin: 0.8rem 0 0.85rem;
  transform-origin: left center;
  animation: agtEnergize 0.7s cubic-bezier(0.25, 0.8, 0.3, 1) both;
}
@keyframes agtEnergize {
  from { transform: scaleX(0); }
  to { transform: scaleX(1); }
}
.agt-seg { flex: 0 1 0%; min-width: 0; transition: opacity 0.2s; }
.agt-seg-active { background: var(--red); box-shadow: 0 0 8px rgba(204, 0, 0, 0.35); }
.agt-seg-approaching { background: var(--amber); }
.agt-seg-future {
  background: repeating-linear-gradient(45deg,
    rgba(232, 163, 61, 0.5) 0 3px, rgba(232, 163, 61, 0.12) 3px 6px);
}
.agt-seg-revoked {
  background: repeating-linear-gradient(-45deg,
    var(--red-dim) 0 2px, var(--panel2) 2px 6px);
}
.agt-seg-other { background: var(--line); }
.agt-seg-off { opacity: 0.15; }

/* ─── Status chips — labelled LEDs ───────────────────────── */
.agt-filterbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.5rem;
}
.agt-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: var(--ground);
  color: var(--mut);
  border: 1px solid var(--line);
  padding: 0.38rem 0.7rem;
  cursor: pointer;
  transition: color 0.15s, border-color 0.15s, background-color 0.15s;
}
.agt-chip:hover { color: var(--tx); border-color: var(--mut); }
.agt-chip-count { opacity: 0.55; }

/* LED socket — dark when the status is filtered off */
.agt-led {
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--line);
}

/* Lit states (chip visible = status shown).
   Active label uses the site's --link-hover red: #CC0000 is too dark
   for 0.72rem text on near-black — the lit state must outshine the off state. */
.agt-chip.agt-on-active { color: #FF2222; border-color: rgba(204, 0, 0, 0.6); background: rgba(204, 0, 0, 0.09); }
.agt-chip.agt-on-approaching { color: var(--amber); border-color: rgba(232, 163, 61, 0.5); background: rgba(232, 163, 61, 0.07); }
.agt-chip.agt-on-future { color: var(--amber); border-color: rgba(232, 163, 61, 0.3); }
.agt-chip.agt-on-revoked { color: var(--tx); border-color: rgba(136, 17, 17, 0.65); }
.agt-chip.agt-on-other { color: var(--tx); border-color: var(--mut); }

.agt-on-active .agt-led { background: var(--red); border-color: transparent; box-shadow: 0 0 6px rgba(204, 0, 0, 0.7); }
.agt-on-approaching .agt-led { background: var(--amber); border-color: transparent; box-shadow: 0 0 6px rgba(232, 163, 61, 0.6); }
.agt-on-future .agt-led { background: transparent; border-color: rgba(232, 163, 61, 0.7); }
.agt-on-revoked .agt-led {
  border-color: var(--red-dim);
  background: linear-gradient(135deg,
    transparent 38%, var(--red-dim) 38%, var(--red-dim) 62%, transparent 62%);
}
.agt-on-other .agt-led { background: var(--mut); border-color: transparent; }

.agt-legend {
  font-family: var(--mono);
  font-size: 0.68rem;
  letter-spacing: 0.04em;
  line-height: 1.7;
  color: var(--mut);
  margin: 0.85rem 0 0;
}

/* ─── Tables — instrument readouts ───────────────────────── */
.agt-wrap table {
  width: 100%;
  border-collapse: collapse;
  background: var(--panel);
  border: 1px solid var(--line);
  margin: 1.1rem 0 2.4rem;
}
.agt-wrap th {
  background: var(--panel2);
  border: none;
  border-bottom: 1px solid var(--line);
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--mut);
  padding: 0.5rem 0.8rem;
  text-align: left;
}
.agt-wrap td {
  border: none;
  border-bottom: 1px solid var(--line);
  padding: 0.58rem 0.8rem;
  font-size: 0.88rem;
  line-height: 1.55;
  vertical-align: top;
}
.agt-wrap tbody tr:last-child td { border-bottom: none; }
.agt-wrap tbody tr:hover td { background: var(--panel2); }
.agt-wrap td:first-child { font-family: var(--mono); font-size: 0.78rem; color: var(--tx); white-space: nowrap; }

/* Table links: quiet steel with underline — red stays reserved
   for status. Prose links keep the site default. */
.agt-wrap td a {
  color: var(--tx);
  text-decoration: underline;
  text-decoration-color: rgba(230, 228, 222, 0.3);
  text-underline-offset: 2px;
}
.agt-wrap td a:hover { color: var(--red); text-decoration-color: var(--red); }

/* ─── Row status — left edge + LED (set by JS classifier) ── */
.agt-table tbody tr { transition: background-color 0.15s; }
.agt-table tbody tr td:first-child { border-left: 3px solid transparent; }
.agt-table tbody tr[data-agt-status="active"] td:first-child { border-left-color: var(--red); }
.agt-table tbody tr[data-agt-status="approaching"] td:first-child { border-left-color: var(--amber); }
.agt-table tbody tr[data-agt-status="future"] td:first-child { border-left-color: rgba(232, 163, 61, 0.35); }
.agt-table tbody tr[data-agt-status="revoked"] td:first-child { border-left-style: dashed; border-left-color: var(--red-dim); }
.agt-table tbody tr[data-agt-status="other"] td:first-child { border-left-color: var(--line); }

.agt-table tbody tr[data-agt-status="active"] {
  background: linear-gradient(90deg, rgba(204, 0, 0, 0.05), transparent 45%);
}
.agt-table tbody tr[data-agt-status="revoked"] td,
.agt-table tbody tr[data-agt-status="revoked"] td a { color: var(--mut); }

.agt-table tbody tr td:first-child::before {
  content: "";
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  margin-right: 0.55rem;
  vertical-align: 1px;
  background: var(--line);
}
.agt-table tbody tr[data-agt-status="active"] td:first-child::before {
  background: var(--red);
  box-shadow: 0 0 6px rgba(204, 0, 0, 0.6);
}
.agt-table tbody tr[data-agt-status="approaching"] td:first-child::before {
  background: var(--amber);
  box-shadow: 0 0 6px rgba(232, 163, 61, 0.5);
}
.agt-table tbody tr[data-agt-status="future"] td:first-child::before {
  background: transparent;
  border: 1px solid rgba(232, 163, 61, 0.65);
}
.agt-table tbody tr[data-agt-status="revoked"] td:first-child::before {
  border: 1px solid var(--red-dim);
  background: linear-gradient(135deg,
    transparent 38%, var(--red-dim) 38%, var(--red-dim) 62%, transparent 62%);
}

.agt-table tbody tr.agt-hidden { display: none; }

/* ─── Motion + small screens ─────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  .agt-bar { animation: none; }
  .agt-chip, .agt-seg, .agt-table tbody tr { transition: none; }
}

@media (max-width: 700px) {
  .agt-wrap table { display: block; overflow-x: auto; }
  .agt-wrap > p:first-of-type { font-size: 1.1rem; }
  .agt-console-readout { margin-left: 0; }
}

/* ═════════════════════════════════════════════════════════════
   THE INSTRUMENT × OPERATOR MATRIX (.esm-*)
   Server-rendered from data/economic_statecraft.json. Lives
   OUTSIDE .agt-wrap on purpose — tracker.js walks the wrap's
   tables, and the matrix must never be status-classified.
   Grammar borrowed from the convergence table's evidence matrix:
   a bounded panel that scrolls both axes inside its own window
   (the page body never scrolls sideways), sticky color-keyed
   operator headers, sticky instrument rubric, and the operators'
   three-channel color code — us #5B6CCC · china #CC0000 ·
   brics #B8860B — carried on --cc set inline by Hugo from the
   data file's `colors` map.
   ═════════════════════════════════════════════════════════════ */

/* .esm sits outside .agt-wrap, so it needs its own palette scope */
.esm,
.esm-cap {
  --ground: #0C0C0F;
  --panel: #14141A;
  --panel2: #1B1B22;
  --line: #2A2A33;
  --tx: #E6E4DE;
  --mut: #84838F;
  --red: #CC0000;
  --red-dim: #881111;
  --amber: #E8A33D;
  --mono: ui-monospace, "JetBrains Mono", Consolas, monospace;
}
.esm { margin: 1.7rem 0 0; color: var(--tx); }

/* ── Panel head — instrument nameplate + data stamp ─────────── */
.esm-head {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 0.4rem 1rem;
  margin: 0 0 0.6rem;
}
.esm-eyebrow {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: var(--mono);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--mut);
}
.esm-led {
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--red);
  box-shadow: 0 0 8px rgba(204, 0, 0, 0.55);
}
.esm-stamp {
  margin-left: auto;
  font-family: var(--mono);
  font-size: 0.64rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--mut);
  border: 1px solid var(--line);
  padding: 0.2rem 0.5rem;
  white-space: nowrap;
}

/* ── The bounded panel — scrolls both axes in its own window ── */
.esm-matrix {
  border: 1px solid var(--line);
  border-radius: 3px;
  background: #101015;
  max-height: min(80vh, 860px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: thin;
  scrollbar-color: #2f2f3a #101015;
}
.esm-matrix::-webkit-scrollbar { width: 10px; height: 10px; }
.esm-matrix::-webkit-scrollbar-track,
.esm-matrix::-webkit-scrollbar-corner { background: #101015; }
.esm-matrix::-webkit-scrollbar-thumb {
  background: #2a2a33;
  border: 2px solid #101015;
  border-radius: 5px;
}
.esm-matrix::-webkit-scrollbar-thumb:hover { background: #3a3a44; }

.esm-matrix table {
  width: 100%;
  min-width: 860px;
  table-layout: fixed;
  margin: 0;
  border-collapse: separate;  /* collapse breaks sticky borders */
  border-spacing: 0;
  font-size: 0.82rem;
  line-height: 1.6;
}
.esm-matrix th:first-child { width: 21%; }
.esm-matrix th:not(:first-child) { width: 26.33%; }

/* operator headers — sticky, color-keyed swatch + rule + label */
.esm-matrix thead th {
  position: sticky;
  top: 0;
  z-index: 3;
  background: #1b1b22;
  border: none;
  border-bottom: 2px solid var(--cc, var(--line));
  font-family: var(--mono);
  font-size: 0.66rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  /* raw channel colors are too dark for 0.66rem text on near-black —
     lift them toward the page's bright text, keep the rule pure */
  color: color-mix(in srgb, var(--cc, var(--mut)) 62%, #E8E8F0);
  padding: 0.7rem 0.85rem;
  text-align: left;
  white-space: nowrap;
}
.esm-matrix thead th:not(:first-child)::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 0.5rem;
  background: var(--cc, var(--line));
  box-shadow: 0 0 6px color-mix(in srgb, var(--cc, transparent) 55%, transparent);
}

/* instrument rubric — sticky left, one shade up from the ground */
.esm-matrix th:first-child,
.esm-matrix td:first-child {
  position: sticky;
  left: 0;
  z-index: 2;
  background: #14141a;
  border-right: 1px solid var(--line);
}
.esm-matrix thead th:first-child { z-index: 4; background: #1b1b22; color: var(--mut); }
.esm-matrix td:first-child strong {
  color: #E8E8F0;
  font-size: 0.84rem;
  letter-spacing: 0.01em;
}

/* cells — row rules, faint column seams, a whisper of the
   operator's channel as a heatmap wash. font-size:inherit beats
   main.css's td{font-size:.9rem}; break-word keeps long tokens
   inside the fixed-layout columns. */
.esm-matrix td {
  border: none;
  border-bottom: 1px solid var(--line);
  border-left: 1px solid #1c1c23;
  padding: 0.7rem 0.85rem;
  vertical-align: top;
  font-size: inherit;
  overflow-wrap: break-word;
  background-color: color-mix(in srgb, var(--cc, transparent) 3%, transparent);
}
.esm-matrix td:first-child { border-left: none; }
.esm-matrix tbody tr:last-child td { border-bottom: none; }
/* hover deepens the column wash (and overrides main.css's global
   tr:hover td); the sticky rubric must stay opaque or scrolled
   columns ghost under it */
.esm-matrix tbody tr:hover td {
  background-color: color-mix(in srgb, var(--cc, #84838F) 8%, #14141a);
}
.esm-matrix tbody tr:hover td:first-child { background: #17171d; }

/* ── Status pill — a lit LED in the operator's channel ──────── */
.esm-status {
  display: inline-flex;
  align-items: center;
  gap: 0.42rem;
  font-family: var(--mono);
  font-size: 0.62rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: color-mix(in srgb, var(--cc, var(--red)) 62%, #E8E8F0);
  background: color-mix(in srgb, var(--cc, var(--red)) 11%, transparent);
  border: 1px solid color-mix(in srgb, var(--cc, var(--red)) 55%, transparent);
  padding: 0.2rem 0.5rem 0.18rem;
  margin-bottom: 0.45rem;
  white-space: nowrap;
}
.esm-status::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--cc, var(--red));
  box-shadow: 0 0 6px color-mix(in srgb, var(--cc, var(--red)) 70%, transparent);
}
/* receiving-end statuses (Target / Exposed / None documented) go
   hollow — the asymmetry between wielder and target IS the finding */
.esm-status-dim {
  color: var(--mut);
  background: transparent;
  border-color: var(--line);
}
.esm-status-dim::before {
  background: transparent;
  border: 1px solid color-mix(in srgb, var(--cc, var(--mut)) 60%, transparent);
  box-shadow: none;
}

/* cell prose + receipts — quiet dotted citations, red on hover */
.esm-note { color: var(--tx); }
.esm-note .esm-receipt {
  font-family: var(--mono);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  color: #a9a9b6;
  border-bottom: 1px dotted #4a4a56;
  white-space: nowrap;
}
.esm-note .esm-receipt:hover { color: #ff3333; border-bottom-color: #ff3333; }

/* ── Legend — the three channels, defined once ──────────────── */
.esm-legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem 1.3rem;
  margin: 0.65rem 0 0;
  font-family: var(--mono);
  font-size: 0.66rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--mut);
}
.esm-legend span { display: inline-flex; align-items: center; gap: 0.45rem; }
.esm-legend i { flex: none; width: 9px; height: 9px; background: var(--line); }
.esm-legend .esm-legend-dim i {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: transparent;
  border: 1px solid var(--mut);
}

/* ── The finding — same grammar as the convergence verdict ──── */
.esm-cap {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  padding: 0.95rem 1.15rem;
  margin: 1.1rem 0 1.4rem;
  font-size: 0.95rem;
  line-height: 1.7;
  color: #E8E8F0;
  max-width: none;
}

/* ── Small screens ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .esm-matrix { max-height: 76vh; }
  .esm-matrix table { min-width: 720px; font-size: 0.78rem; }
  .esm-matrix thead th, .esm-matrix td { padding: 0.55rem 0.6rem; }
  .esm-matrix th:first-child { width: 132px; }
  .esm-head { margin-top: 0; }
  .esm-stamp { margin-left: 0; }
  .esm-cap { font-size: 0.88rem; padding: 0.8rem 0.95rem; }
}
