/* iq-live-progress · live round progress above the published Codex IQ board (降智雷达 / 模型智商).
   Scoped to .iqlp; consumes radar-ui tokens with console fallbacks and never styles anything outside
   the component. Motion is one CSS sweep loop (fresh running only) plus one-shot effects that the
   view adds on real events. Reduced motion and [data-view-hidden] on any ancestor create no motion. */

.iqlp {
  --iqlp-accent: var(--accent, #39ff88);
  --iqlp-signal: var(--accent-2, #22c76a);
  --iqlp-line: var(--line, #193a29);
  --iqlp-line-2: var(--line-2, #2a5a40);
  --iqlp-surface: var(--surface, #09110c);
  --iqlp-text: var(--text, #ddeae1);
  --iqlp-text-2: var(--text-2, #a2b8aa);
  --iqlp-text-3: var(--text-3, #6f8a79);
  --iqlp-warn: var(--warn, #f2c14e);
  --iqlp-alert: var(--alert, #ff7a6b);
  --iqlp-mono: var(--font-mono, ui-monospace, "SF Mono", Menlo, Consolas, monospace);
  --iqlp-ease: var(--ease, cubic-bezier(.2, .7, .2, 1));
  /* Tone = state colour for chip/scope/rail; text tone stays readable on light paper. */
  --iqlp-tone: var(--iqlp-text-3);
  --iqlp-tone-text: var(--iqlp-tone);
  --iqlp-rail: var(--iqlp-tone);
  --iqlp-fill-answered: color-mix(in srgb, var(--iqlp-signal) 48%, transparent);
  --iqlp-fill-graded: var(--iqlp-signal);
  container: iqlp / inline-size;
  position: relative;
  min-width: 0;
  margin: 8px 0 12px;
  padding: 12px 14px 11px 16px;
  border: 1px solid var(--iqlp-line);
  border-radius: var(--r-md, 4px);
  background: var(--iqlp-surface);
  box-shadow: inset 2px 0 0 var(--iqlp-rail);
  color: var(--iqlp-text);
  font: 400 13px/1.5 var(--font-sans, system-ui, sans-serif);
  font-variant-numeric: tabular-nums;
  letter-spacing: 0;
  overflow-wrap: break-word;
  text-align: left;
}
.iqlp *, .iqlp *::before, .iqlp *::after { box-sizing: border-box; }
.iqlp [hidden] { display: none !important; }
:where(.iqlp) p { margin: 0; } /* zero specificity: the class margins below win */

/* State tones */
.iqlp[data-state="running"],
.iqlp[data-state="waiting_publication"] { --iqlp-tone: var(--iqlp-signal); }
.iqlp[data-state="published"] { --iqlp-tone: var(--iqlp-accent); }
.iqlp[data-state="paused"] { --iqlp-tone: var(--iqlp-warn); }
.iqlp[data-state="failed"] { --iqlp-tone: var(--iqlp-alert); }
.iqlp[data-state="paused"], .iqlp[data-state="failed"] {
  --iqlp-fill-answered: color-mix(in srgb, var(--iqlp-text-3) 45%, transparent);
  --iqlp-fill-graded: color-mix(in srgb, var(--iqlp-text-3) 80%, transparent);
}
:root[data-theme="light"] .iqlp[data-state="running"],
:root[data-theme="light"] .iqlp[data-state="waiting_publication"] { --iqlp-tone-text: var(--iqlp-accent); }

/* Last verified data: dashed frame, muted rail and fills; the sweep is off (data-scan="off"). */
.iqlp[data-freshness="stale"] {
  border-style: dashed;
  --iqlp-rail: color-mix(in srgb, var(--iqlp-text-3) 60%, transparent);
  --iqlp-fill-answered: color-mix(in srgb, var(--iqlp-text-3) 40%, transparent);
  --iqlp-fill-graded: color-mix(in srgb, var(--iqlp-text-3) 75%, transparent);
}
.iqlp[data-state="unknown"] { border-style: dashed; }

/* ── Head ── */
.iqlp-head { display: flex; align-items: center; flex-wrap: wrap; gap: 6px 10px; min-width: 0; }
.iqlp-title { color: var(--iqlp-text); font-size: 13px; font-weight: 600; line-height: 1.4; }

.iqlp-chip {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 22px; padding: 0 8px;
  border: 1px solid color-mix(in srgb, var(--iqlp-tone) 45%, transparent);
  border-radius: var(--r-pill, 99px);
  background: color-mix(in srgb, var(--iqlp-tone) 9%, transparent);
  color: var(--iqlp-tone-text);
  font: 600 11px/1 var(--iqlp-mono); letter-spacing: .04em; white-space: nowrap;
}
.iqlp-chip::before { content: ""; flex: 0 0 auto; width: 6px; height: 6px; border-radius: 50%; background: currentColor; }
.iqlp[data-state="published"] .iqlp-chip::before { content: "✓"; width: auto; height: auto; border-radius: 0; background: none; font-size: 11px; }
.iqlp[data-state="paused"] .iqlp-chip::before { width: 6px; height: 7px; border-radius: 0; background: none; border-inline: 2px solid currentColor; }

.iqlp-tag {
  display: inline-flex; align-items: center; min-height: 22px; padding: 0 7px;
  border: 1px dashed var(--iqlp-line-2); border-radius: var(--r-sm, 3px);
  color: var(--iqlp-text-2);
  font: 600 10px/1 var(--iqlp-mono); letter-spacing: .06em; white-space: nowrap;
}
.iqlp-tag-live { border-style: solid; border-color: color-mix(in srgb, var(--iqlp-signal) 40%, transparent); color: var(--iqlp-text-2); }
.iqlp-tag-mode, .iqlp-tag-stale { border-color: color-mix(in srgb, var(--iqlp-warn) 55%, transparent); color: var(--iqlp-warn); }

/* Radar scope: rings + centre dot; a wedge sweeps only while fresh and running. */
.iqlp-scope {
  position: relative; flex: 0 0 auto; width: 18px; height: 18px;
  border: 1px solid color-mix(in srgb, var(--iqlp-tone) 55%, transparent);
  border-radius: 50%;
  background: radial-gradient(circle,
    var(--iqlp-tone) 0 1.4px, transparent 1.9px 4.2px,
    color-mix(in srgb, var(--iqlp-tone) 35%, transparent) 4.2px 5px, transparent 5.4px);
  overflow: hidden;
}
.iqlp-scope::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 0deg, transparent 0 250deg, color-mix(in srgb, var(--iqlp-tone) 55%, transparent) 360deg);
  opacity: 0;
}
.iqlp[data-scan="on"] .iqlp-scope::before { opacity: 1; animation: iqlp-sweep 3.6s linear infinite; }
/* Contact blip: only on a real count increase or publication arrival. */
.iqlp-scope::after {
  content: ""; position: absolute; top: 3px; right: 3px; width: 4px; height: 4px;
  border-radius: 50%; background: var(--iqlp-tone); opacity: 0;
}
.iqlp-scope.is-blip::after { animation: iqlp-blip 900ms ease-out; }

/* ── Notes ── */
.iqlp-flag { margin-top: 8px; color: var(--iqlp-warn); font-size: 12px; line-height: 1.55; }
.iqlp-flag + .iqlp-flag { margin-top: 2px; }

/* ── Meters: answered and graded are independent, each against the round total ── */
.iqlp-meters { display: grid; grid-template-columns: minmax(0, 1fr); gap: 8px 24px; margin-top: 10px; }
@container iqlp (min-width: 520px) { .iqlp-meters { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
.iqlp-meter { --iqlp-fill: var(--iqlp-fill-answered); min-width: 0; margin: 0 -6px; padding: 3px 6px 5px; border-radius: var(--r-sm, 3px); }
.iqlp-meter[data-kind="graded"] { --iqlp-fill: var(--iqlp-fill-graded); }
.iqlp-meter-top { display: flex; align-items: baseline; justify-content: space-between; flex-wrap: wrap; gap: 0 10px; min-width: 0; }
.iqlp-meter-label { color: var(--iqlp-text-2); font-size: 12px; }
.iqlp-meter-value { color: var(--iqlp-text-3); font: 500 12px/1.25 var(--iqlp-mono); white-space: nowrap; }
.iqlp-num-clip { display: inline-block; overflow: hidden; vertical-align: bottom; }
.iqlp-num { display: inline-block; color: var(--iqlp-text); font: 700 20px/1.25 var(--iqlp-mono); letter-spacing: -.02em; }
.iqlp[data-state="unknown"] .iqlp-num { color: var(--iqlp-text-3); }
.iqlp-pct { margin-left: 8px; }
.iqlp-track {
  position: relative; height: 4px; margin-top: 5px; border-radius: 2px;
  background:
    repeating-linear-gradient(90deg, transparent 0 calc(25% - 1px), color-mix(in srgb, var(--iqlp-text-3) 32%, transparent) calc(25% - 1px) 25%),
    color-mix(in srgb, var(--iqlp-text-3) 16%, transparent);
}
.iqlp-fill { position: absolute; inset: 0 auto 0 0; width: 0; border-radius: inherit; background: var(--iqlp-fill); }
/* Node at the bar head: steady while fresh-running, pulses once on a real increase. */
.iqlp-fill::after {
  content: ""; position: absolute; top: 50%; right: -3px; width: 6px; height: 6px; margin-top: -3px;
  border-radius: 50%; background: var(--iqlp-fill); opacity: 0;
}
.iqlp[data-scan="on"] .iqlp-meter:not([data-zero]) .iqlp-fill::after { opacity: 1; }
.iqlp-meter.is-grow { animation: iqlp-flash 900ms ease-out; }
.iqlp-meter.is-grow .iqlp-fill { transition: width 560ms var(--iqlp-ease); }
.iqlp-meter.is-grow .iqlp-fill::after { opacity: 1; animation: iqlp-node 900ms ease-out; }
.iqlp-num.is-new { animation: iqlp-flip 320ms var(--iqlp-ease) both; }

/* ── Board note and evidence times ── */
.iqlp-note { margin-top: 8px; color: var(--iqlp-text-2); font-size: 12px; line-height: 1.6; }
.iqlp-reload {
  min-height: 24px; margin: 0 0 0 6px; padding: 0; border: 0; background: none;
  color: var(--iqlp-accent); font: inherit; font-weight: 600;
  text-decoration: underline; text-underline-offset: 3px; text-decoration-thickness: 1px; cursor: pointer;
}
:root[data-theme="light"] .iqlp-reload { color: var(--accent-strong, #055a2f); }
.iqlp-reload:focus-visible { outline: 2px solid var(--focus, var(--iqlp-accent)); outline-offset: 2px; border-radius: var(--r-xs, 2px); }
.iqlp-meta { display: flex; flex-wrap: wrap; gap: 0 14px; margin-top: 6px; color: var(--iqlp-text-3); font: 11px/1.7 var(--iqlp-mono); }
.iqlp-meta-item { white-space: nowrap; }
.iqlp-meta-item:first-child { white-space: normal; min-width: 0; }
.iqlp-meta time, .iqlp-round { color: var(--iqlp-text-2); }
.iqlp-round { overflow-wrap: anywhere; }
.iqlp-sr {
  position: absolute !important; width: 1px !important; height: 1px !important; margin: -1px !important; padding: 0 !important;
  overflow: hidden !important; clip: rect(0 0 0 0) !important; clip-path: inset(50%) !important; white-space: nowrap !important; border: 0 !important;
}

/* Publication confirmation: one short ring on the chip. */
.iqlp-chip.is-confirm { animation: iqlp-confirm 900ms ease-out; }

@keyframes iqlp-sweep { to { transform: rotate(1turn); } }
@keyframes iqlp-blip { 0% { opacity: 1; transform: scale(.6); } 100% { opacity: 0; transform: scale(2.4); } }
@keyframes iqlp-flash {
  0% { background-color: color-mix(in srgb, var(--iqlp-signal) 13%, transparent); }
  100% { background-color: transparent; }
}
@keyframes iqlp-node {
  0% { transform: scale(1.5); box-shadow: 0 0 0 0 color-mix(in srgb, var(--iqlp-fill) 70%, transparent); }
  100% { transform: none; box-shadow: 0 0 0 7px transparent; }
}
@keyframes iqlp-flip { from { opacity: 0; transform: translateY(55%); } to { opacity: 1; transform: none; } }
@keyframes iqlp-confirm {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--iqlp-tone) 50%, transparent); }
  100% { box-shadow: 0 0 0 7px transparent; }
}

/* No motion is created under reduced motion or while the host marks the view hidden. A running
   scope keeps a still wedge so the state is visible without movement. */
@media (prefers-reduced-motion: reduce) {
  .iqlp, .iqlp *, .iqlp *::before, .iqlp *::after { animation: none !important; transition: none !important; }
}
[data-view-hidden] .iqlp, [data-view-hidden] .iqlp *, [data-view-hidden] .iqlp *::before, [data-view-hidden] .iqlp *::after,
.iqlp[data-view-hidden], .iqlp[data-view-hidden] *, .iqlp[data-view-hidden] *::before, .iqlp[data-view-hidden] *::after {
  animation: none !important; transition: none !important;
}

@container iqlp (max-width: 340px) {
  .iqlp-num { font-size: 18px; }
  .iqlp-meta { gap: 0 10px; }
}
@media print {
  .iqlp-scope::before, .iqlp-scope::after, .iqlp-fill::after { display: none; }
}
