/* ─────────────────────────────────────────────────────────────
   CONVERGENCE TABLE — scoped styles, .ct-* / .ci-* prefixes
   Shared /tech demo tokens pinned on .ct-wrap.
   table.js binds: .ct-table  .ct-dim  .ct-row-focus  .ct-row-defocus
   .ct-th-country  [data-country] — those names are preserved exactly;
   everything else here is presentation-only.
   ───────────────────────────────────────────────────────────── */

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

.ct-wrap {
  /* shared /tech demo tokens — evilrobots identity */
  --ground: #0C0C0F;
  --panel:  #14141A;
  --panel2: #1B1B22;
  --line:   #2A2A33;
  --text:   #E6E4DE;
  --muted:  #84838F;
  --red:    #CC0000;
  --amber:  #E8A33D;
  --mono: ui-monospace, "Cascadia Code", "JetBrains Mono", Consolas, "SF Mono", Menlo, monospace;
  --muted-hi: color-mix(in srgb, var(--muted) 55%, var(--text));
  color: var(--text);
  margin: 1.5rem 0;
}

/* display voice inside the demo: mono, uppercase, tracked */
.ct-wrap h2 {
  font-family: var(--mono);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .14em;
  font-size: 1.15rem;
}

/* ─── Country card grid (the control deck) ──────────────── */
.ct-countries {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: .7rem;
  margin-bottom: .8rem;
}
@media (min-width: 860px) {
  .ct-countries { grid-template-columns: repeat(4, 1fr); }
}
.ct-country {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: .75rem .95rem;
  cursor: pointer;
  transition: border-color .15s, background-color .15s, opacity .3s;
}
.ct-country.ct-on  { border-left-color: var(--red); }
.ct-country.ct-off { opacity: .38; }
.ct-country:hover  { background: var(--panel2); }
.ct-country:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }

.ct-country-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: .35rem;
}
.ct-country-label {
  font-family: var(--mono);
  font-weight: 700;
  letter-spacing: .18em;
  font-size: .8rem;
  color: var(--text);
}
.ct-country-toggle {
  font-family: var(--mono);
  font-size: .62rem;
  letter-spacing: .12em;
  color: var(--muted);
}
.ct-country.ct-on .ct-country-toggle { color: var(--red); }

.ct-country-meter {
  height: 8px;
  background: var(--ground);
  border: 1px solid var(--line);
  margin-bottom: .4rem;
  position: relative;
  overflow: hidden;
}
.ct-country-meter-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--amber) 0%, var(--red) 85%);
  transition: width .25s;
}
.ct-country-score {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.35rem;
  font-variant-numeric: tabular-nums;
  color: var(--red);
}
.ct-country.ct-off .ct-country-score { color: var(--muted); }
.ct-country-gloss {
  font-size: .74rem;
  line-height: 1.55;
  color: var(--muted-hi);
}

/* ─── Aggregate readout + presets ───────────────────────── */
.ct-aggregate {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  padding: .7rem 1rem;
  margin-bottom: 1.4rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}
.ct-aggregate-num {
  font-family: var(--mono);
  font-size: .82rem;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.ct-aggregate-actions {
  display: flex;
  gap: .5rem;
  flex-wrap: wrap;
}
.ct-btn {
  font-family: var(--mono);
  font-size: .72rem;
  letter-spacing: .14em;
  background: var(--panel2);
  color: var(--text);
  border: 1px solid var(--line);
  padding: .45rem 1rem;
  cursor: pointer;
  text-transform: uppercase;
  transition: border-color .15s, background-color .15s, box-shadow .15s;
}
.ct-btn:hover { border-color: var(--muted); background: #232330; }
.ct-btn:focus-visible { outline: 2px solid var(--text); outline-offset: 2px; }
.ct-btn-reset { color: var(--muted-hi); }
.ct-btn.ct-live { color: #fff; }
.ct-btn-china.ct-live {
  border-color: var(--red);
  background: color-mix(in srgb, var(--red) 24%, var(--panel));
  box-shadow: inset 3px 0 0 var(--red);
}
.ct-btn-dem.ct-live {
  border-color: var(--amber);
  background: color-mix(in srgb, var(--amber) 18%, var(--panel));
  box-shadow: inset 3px 0 0 var(--amber);
}

/* ─── Sourced-table augmentation ────────────────────────── */
/* Hugo renders the markdown table; table.js applies the classes. */
.ct-table { border-collapse: collapse; font-size: .85rem; line-height: 1.6; }
.ct-table th, .ct-table td {
  transition: opacity .2s, background-color .15s;
}
.ct-table th {
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .1em;
  font-size: .7rem;
}
.ct-th-country {
  user-select: none;
  position: relative;
}
.ct-th-country:hover { background-color: rgba(204, 0, 0, .08); }
.ct-dim { opacity: .18; }
.ct-table tbody tr { cursor: pointer; }
.ct-table tbody tr.ct-row-focus {
  background-color: rgba(204, 0, 0, .06);
  outline: 1px solid rgba(204, 0, 0, .4);
}
.ct-table tbody tr.ct-row-defocus { opacity: .35; }
.ct-table tbody tr.ct-row-defocus:hover { opacity: .8; }

/* ─── Help strip ─────────────────────────────────────────── */
.ct-help {
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--line);
  padding: .75rem 1rem;
  margin: 0 0 1.2rem;
  font-size: .76rem;
  color: var(--muted-hi);
  line-height: 1.6;
}
.ct-help strong { color: var(--text); }

/* ─── CONVERGENCE INDEX HEATMAP (the hero) ──────────────── */
.ci { margin: 1.6rem 0 2.2rem; }
.ci-head { margin-bottom: 1rem; }
.ci-eyebrow {
  font-family: var(--mono);
  font-size: .68rem; letter-spacing: .26em; text-transform: uppercase;
  color: var(--muted);
  display: flex; align-items: center; gap: .55rem; margin-bottom: .55rem;
}
/* one blinking LED per page (the header's); this one holds steady */
.ci-led {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--red); box-shadow: 0 0 8px var(--red);
}
.ci-title { color: var(--text); font-size: 1.25rem; margin: 0 0 .4rem; }

/* the thesis, in numerals */
.ci-verdict {
  display: flex; align-items: flex-end; gap: 1.4rem; flex-wrap: wrap;
  background: var(--panel);
  border: 1px solid var(--line);
  border-left: 3px solid var(--red);
  padding: 1rem 1.2rem .9rem;
  margin: .95rem 0;
}
.ci-v { display: flex; align-items: baseline; gap: .55rem; }
.ci-v-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: clamp(2.1rem, 5vw, 3rem);
  line-height: .9;
  font-variant-numeric: tabular-nums;
  color: var(--text);
}
.ci-v-china { color: var(--red); text-shadow: 0 0 22px rgba(204, 0, 0, .45); }
.ci-v-gap   { color: var(--amber); }
.ci-v-label {
  font-family: var(--mono);
  font-size: .62rem; letter-spacing: .18em; text-transform: uppercase;
  line-height: 1.5;
  color: var(--muted-hi);
}
.ci-v-sep { color: var(--line); font-size: 1.7rem; align-self: center; }

.ci-sub { color: var(--text); font-size: .95rem; margin: 0; max-width: 64ch; }
.ci-sub a { color: var(--red); text-decoration: none; border-bottom: 1px dotted rgba(204, 0, 0, .5); }
.ci-sub a:hover { color: #ff3333; }

.ci-grid {
  display: grid;
  grid-template-columns: minmax(150px, 1.6fr) repeat(4, 1fr);
  gap: 2px;
  background: var(--line);
  border: 1px solid #3a3a44;
  border-radius: 3px;
  overflow: hidden;
  margin: 1rem 0 .8rem;
}
.ci-row { display: contents; }
.ci-cell {
  background: var(--panel);
  padding: .55em .6em;
  font-size: .85rem;
  display: flex; align-items: center;
  transition: opacity .38s ease var(--d, 0s), filter .38s ease var(--d, 0s), background-color .15s;
}
/* preset toggle = the one motion moment: a power-down sweep, top to bottom */
.ci-row:nth-child(2)  .ci-cell { --d: .00s; }
.ci-row:nth-child(3)  .ci-cell { --d: .03s; }
.ci-row:nth-child(4)  .ci-cell { --d: .06s; }
.ci-row:nth-child(5)  .ci-cell { --d: .09s; }
.ci-row:nth-child(6)  .ci-cell { --d: .12s; }
.ci-row:nth-child(7)  .ci-cell { --d: .15s; }
.ci-row:nth-child(8)  .ci-cell { --d: .18s; }
.ci-row:nth-child(9)  .ci-cell { --d: .21s; }
.ci-row:nth-child(10) .ci-cell { --d: .24s; }
.ci-row:nth-child(11) .ci-cell { --d: .27s; }
.ci-row:nth-child(12) .ci-cell { --d: .30s; }
.ci-cell.ci-dim { opacity: .13; filter: saturate(.2); }

.ci-head-row .ci-cell { background: linear-gradient(180deg, var(--panel2), var(--panel)); }
.ci-corner {
  color: var(--muted); font-family: var(--mono);
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
}
.ci-chead {
  justify-content: center;
  font-family: var(--mono);
  font-size: .74rem; letter-spacing: .1em; text-transform: uppercase;
  font-weight: 700;
  color: var(--c);
  cursor: pointer;
  user-select: none;
}
.ci-chead:hover { background: var(--panel2); }
.ci-chead:focus-visible { outline: 2px solid var(--text); outline-offset: -2px; }
.ci-comp { color: var(--text); }
a.ci-comp { color: var(--text); text-decoration: none; border-bottom: 1px dotted #3a3a44; }
a.ci-comp:hover { color: #fff; border-color: var(--red); }

.ci-score {
  position: relative;
  flex-direction: column;
  justify-content: center;
  gap: .12rem;
  padding: .5em .4em;
  text-decoration: none;
  background: color-mix(in srgb, var(--c) var(--pct), var(--panel));
}
.ci-num {
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.05rem;
  font-variant-numeric: tabular-nums;
  color: #F4F3EF;
  text-shadow: 0 1px 2px rgba(0, 0, 0, .6);
}
.ci-csu {
  font-family: var(--mono);
  font-size: .56rem;
  letter-spacing: .07em;
  color: rgba(255, 255, 255, .62);
  text-shadow: 0 1px 2px rgba(0, 0, 0, .5);
}
.ci-csu b { font-weight: 700; color: inherit; }
.ci-u3 .ci-csu b { color: var(--amber); }
/* no enforced limit at all — flagged in amber */
.ci-u3::after {
  content: "";
  position: absolute;
  top: 0; right: 0;
  border-top: 10px solid var(--amber);
  border-left: 10px solid transparent;
}
.ci-score:hover { box-shadow: inset 0 0 0 2px rgba(255, 255, 255, .5); }
.ci-score:hover .ci-num { color: #fff; }
.ci-score:focus-visible { outline: 2px solid #fff; outline-offset: -2px; }

.ci-mean-row .ci-cell { background: var(--ground); border-top: 1px solid #3a3a44; }
.ci-mean-row .ci-comp {
  color: var(--muted); font-family: var(--mono);
  font-size: .68rem; letter-spacing: .1em; text-transform: uppercase;
}
.ci-mean {
  justify-content: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 1.5rem;
  font-variant-numeric: tabular-nums;
  color: var(--c);
}

.ci-legend {
  display: flex; flex-wrap: wrap; gap: 1.1rem;
  font-family: var(--mono); font-size: .68rem;
  color: var(--muted); align-items: center;
  margin: .2rem 0 .8rem;
}
.ci-legend i {
  display: inline-block; width: 10px; height: 10px; border-radius: 2px;
  margin-right: .4rem; vertical-align: -1px;
}
.ci-ramp { display: inline-flex; align-items: center; }
.ci-ramp i {
  width: 50px; height: 8px; border-radius: 2px; margin: 0 .35rem;
  background: linear-gradient(90deg, rgba(190, 190, 200, .14), rgba(225, 225, 235, .92));
}
.ci-leg-u3 i {
  background: linear-gradient(225deg, var(--amber) 0 42%, var(--panel2) 42%);
  border: 1px solid var(--line);
  border-radius: 0;
}

.ci-method {
  border: 1px solid var(--line); border-radius: 3px;
  background: #101015; padding: .3rem .9rem;
  font-size: .85rem; color: var(--text);
}
.ci-method summary { cursor: pointer; color: var(--text); font-weight: 600; padding: .5rem 0; }
.ci-method code { font-family: var(--mono); color: #ff6666; font-size: .82rem; }
.ci-method ul { margin: .4rem 0; padding-left: 1.1rem; }
.ci-method li { margin: .25rem 0; }
.ci-method b { color: var(--red); }

/* ─── Responsive ─────────────────────────────────────────── */
@media (max-width: 700px) {
  .ct-aggregate { flex-direction: column; align-items: flex-start; }
  .ci-verdict { gap: 1rem; }
  .ci-v-sep { display: none; }
}
@media (max-width: 640px) {
  .ci-grid { grid-template-columns: minmax(96px, 1.3fr) repeat(4, 1fr); font-size: .8rem; }
  .ci-cell { padding: .45em .3em; }
  .ci-csu { display: none; }
  .ci-num { font-size: .85rem; }
  .ci-chead { font-size: .64rem; letter-spacing: .05em; }
  .ci-mean { font-size: 1.1rem; }
}

/* ─── deep-link landing: flash the row a score links to ─────── */
html { scroll-behavior: smooth; }
.ct-table tbody tr:target { box-shadow: inset 3px 0 0 var(--red, #CC0000); }
.ct-table tbody tr:target td { background: rgba(204, 0, 0, .10); }
.ct-table tbody tr:target td:first-child { color: #fff; }
@keyframes ctTargetFlash { 0% { background: rgba(204, 0, 0, .30); } 100% { background: rgba(204, 0, 0, .10); } }
.ct-table tbody tr:target td { animation: ctTargetFlash 1.6s ease-out; }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .ci-cell { transition: none; }
  .ct-country, .ct-country-meter-bar, .ct-table th, .ct-table td { transition: none; }
  .ct-table tbody tr:target td { animation: none; }
}

.ci-hasdoc { color: var(--red); font-size: .75em; vertical-align: 1px; }
a.ci-comp:hover .ci-hasdoc { color: #fff; }
