/* =============================================================
   QMerse demonstrator pages: the live panels.
   Smart Agent: coordinator + five agents, a run you can play, and a log.
   Stability Potential: pick a technology, see what one unit offers, set the target.
   Built on the case-study page system (case.css).
   ============================================================= */
.dm { margin-top: clamp(30px, 4vw, 48px); border: 1px solid rgba(255,255,255,0.1); border-radius: 18px; background: #0d141c; overflow: hidden; }
.dm-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 12px 18px; border-bottom: 1px solid rgba(255,255,255,0.08);
  font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.1em; text-transform: uppercase; color: var(--text-dim); }
.dm-live { display: inline-flex; align-items: center; gap: 8px; padding: 4px 10px; border: 1px solid rgba(255,255,255,0.16); border-radius: 999px; color: var(--text-mute); }
.dm-live::before { content: ''; width: 7px; height: 7px; border-radius: 50%; background: currentColor; opacity: 0.6; }
.dm-live.on { color: var(--copper-hi); border-color: rgba(233,165,102,0.5); }
.dm-live.done { color: var(--signal); border-color: rgba(93,210,166,0.5); }
.dm-foot { padding: 12px 18px; border-top: 1px solid rgba(255,255,255,0.08); font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }

/* ---- Smart Agent ---- */
.sg { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 0.95fr); }
.sg-stage { padding: clamp(10px, 2vw, 22px); border-inline-end: 1px solid rgba(255,255,255,0.08); display: grid; place-items: center; }
.sg-stage svg { display: block; width: 100%; max-width: 560px; height: auto; direction: ltr; }
.sg-spoke { stroke: rgba(232,229,223,0.16); stroke-width: 1.4; stroke-dasharray: 3 6; transition: stroke 0.3s, stroke-width 0.3s; }
.sg-spoke.on { stroke: var(--c); stroke-width: 2.2; stroke-dasharray: none; }
.sg-core circle { fill: #1b1610; stroke: rgba(201,123,61,0.6); stroke-width: 1.6; transition: stroke 0.3s, stroke-width 0.3s; }
.sg-core.on circle { stroke: #e9a566; stroke-width: 2.6; }
.sg-node { cursor: pointer; outline: none; }
.sg-node circle { fill: #0f1720; stroke: var(--c); stroke-width: 1.6; transition: fill 0.3s, stroke-width 0.3s; }
.sg-node:hover circle, .sg-node:focus-visible circle, .sg-node.on circle { stroke-width: 3; }
.sg-node.on circle, .sg-node.busy circle { fill: color-mix(in srgb, var(--c) 18%, #0f1720); }
.sg-node:focus-visible circle { stroke-dasharray: 4 3; }
.sg-k { font-family: var(--font-mono); font-size: 10px; letter-spacing: 0.08em; fill: var(--c); }
.sg-n { font-family: var(--font-display); font-size: 16px; font-weight: 500; fill: #f3efe7; }
.sg-core .sg-k { fill: #e9a566; }
.sg-pk { fill: var(--c); }
.sg-side { display: flex; flex-direction: column; gap: 16px; padding: clamp(18px, 2.4vw, 28px); min-width: 0; }
.sg-tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--copper-hi); }
.sg-side h3 { margin-top: 8px; font-family: var(--font-display); font-weight: 500; font-size: clamp(22px, 2.2vw, 28px); line-height: 1.15; letter-spacing: -0.015em; color: var(--text); }
.sg-side p { margin-top: 10px; font-size: 15px; line-height: 1.6; color: var(--text-mute); }
.sg-io { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; margin-top: 14px; }
.sg-io[hidden] { display: none; }
.sg-io h4 { font-family: var(--font-mono); font-weight: 400; font-size: 10.5px; letter-spacing: 0.14em; text-transform: uppercase; color: var(--text-dim); }
.sg-io ul { list-style: none; margin: 8px 0 0; padding: 0; display: grid; gap: 6px; }
.sg-io li { font-size: 13.5px; line-height: 1.4; color: var(--text); padding-inline-start: 14px; position: relative; }
.sg-io li::before { content: ''; position: absolute; inset-inline-start: 0; top: 0.55em; width: 6px; height: 6px; border-radius: 50%; background: var(--copper); }
.sg-io .out li::before { background: var(--signal); }
.sg-play { align-self: flex-start; display: inline-flex; align-items: center; gap: 10px; padding: 12px 20px; border-radius: 999px; border: 1px solid var(--copper); background: var(--copper);
  color: var(--ink); font-family: var(--font-mono); font-size: 12px; letter-spacing: 0.14em; text-transform: uppercase; cursor: pointer; transition: background 0.25s, color 0.25s; }
.sg-play:hover { background: var(--copper-hi); }
.sg-play.on { background: transparent; color: var(--copper-hi); }
.sg-play:focus-visible { outline: 2px solid var(--copper-hi); outline-offset: 3px; }
.sg-log { min-height: 152px; display: grid; align-content: start; gap: 6px; padding: 12px 14px; border: 1px solid rgba(255,255,255,0.08); border-radius: 12px; background: rgba(255,255,255,0.02);
  font-family: var(--font-mono); font-size: 12px; line-height: 1.45; color: var(--text-mute); }
.sg-log:empty::before { content: attr(data-empty); color: var(--text-dim); }
.sg-ln { animation: dmIn 0.35s ease both; }
.sg-ln b { color: var(--text); font-weight: 500; }
.sg-ln.amber { color: var(--copper-hi); }
.sg-ln.ok { color: var(--signal); }
@keyframes dmIn { from { opacity: 0; transform: translateY(3px); } }

/* ---- Stability Potential: the gap ---- */
.sp-gap { margin-top: clamp(30px, 4vw, 48px); display: grid; gap: 18px; max-width: 760px; }
.sp-b .bl { display: flex; justify-content: space-between; gap: 12px; font-family: var(--font-mono); font-size: 12px; color: var(--text-mute); margin-bottom: 8px; }
.sp-b .bl b { font-weight: 500; color: var(--copper-hi); }
.sp-b .bt { height: 14px; border-radius: 7px; background: rgba(255,255,255,0.06); overflow: hidden; }
.sp-b .bf { display: block; height: 100%; border-radius: 7px; width: var(--w); background: #7fb4e6; transform-origin: left; }
html[dir="rtl"] .sp-b .bf { transform-origin: right; }
.sp-b.gap .bf { background: repeating-linear-gradient(135deg, #e9a566 0 8px, #c97b3d 8px 16px); }
.reveal:not(.in) .sp-b .bf { transform: scaleX(0); }
.reveal.in .sp-b .bf { animation: dmGrow 1.1s var(--ease) both; }
.reveal.in .sp-b.gap .bf { animation-delay: 0.25s; }
@keyframes dmGrow { from { transform: scaleX(0); } }
.sp-cap { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); line-height: 1.5; }

/* ---- Stability Potential: explorer ---- */
.sp { display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); }
.sp-pick { list-style: none; margin: 0; padding: clamp(14px, 2vw, 20px); display: grid; gap: 6px; border-inline-end: 1px solid rgba(255,255,255,0.08); align-content: start; }
.sp-pick button { width: 100%; display: grid; grid-template-columns: 10px minmax(0, 1fr); column-gap: 12px; align-items: center; text-align: start; padding: 11px 14px; border-radius: 12px;
  border: 1px solid transparent; background: none; color: var(--text-mute); font: inherit; cursor: pointer; transition: background 0.25s, border-color 0.25s, color 0.25s; }
.sp-pick button i { grid-row: span 2; width: 10px; height: 10px; border-radius: 50%; background: var(--c); }
.sp-pick button b { font-weight: 500; font-size: 15px; color: inherit; }
.sp-pick button span { font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.sp-pick button:hover { color: var(--text); background: rgba(255,255,255,0.03); }
.sp-pick button[aria-pressed="true"] { color: var(--text); background: rgba(255,255,255,0.05); border-color: color-mix(in srgb, var(--c) 55%, transparent); }
.sp-pick button:focus-visible { outline: 2px solid var(--copper-hi); outline-offset: 2px; }
.sp-view { padding: clamp(18px, 2.4vw, 28px); display: flex; flex-direction: column; gap: 18px; min-width: 0; }
.sp-view h3 { font-family: var(--font-display); font-weight: 500; font-size: clamp(22px, 2.2vw, 28px); line-height: 1.15; letter-spacing: -0.015em; }
.sp-view .sp-tag { font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--copper-hi); }
.sp-view p { font-size: 15px; line-height: 1.6; color: var(--text-mute); }
.sp-svc { display: grid; gap: 12px; }
.sp-row { display: grid; grid-template-columns: 150px minmax(0, 1fr) 42px; gap: 12px; align-items: center; font-size: 13.5px; color: var(--text); }
.sp-row .t { position: relative; height: 10px; border-radius: 5px; background: rgba(255,255,255,0.07); }
.sp-row .t i { position: absolute; inset-block: 0; inset-inline-start: 0; width: var(--v); border-radius: 5px; background: var(--c); transition: width 0.6s var(--ease); }
.sp-row .t u { position: absolute; top: -4px; bottom: -4px; inset-inline-start: var(--tg); width: 2px; background: rgba(232,229,223,0.85); transition: inset-inline-start 0.3s; }
.sp-row .v { font-family: var(--font-mono); font-size: 12px; color: var(--text-mute); text-align: end; }
.sp-key { display: flex; flex-wrap: wrap; gap: 6px 18px; font-family: var(--font-mono); font-size: 11px; color: var(--text-dim); }
.sp-key span { display: inline-flex; align-items: center; gap: 7px; }
.sp-key .k-t { width: 2px; height: 12px; background: rgba(232,229,223,0.85); }
.sp-plan { border-top: 1px solid rgba(255,255,255,0.08); padding: clamp(18px, 2.4vw, 26px); display: grid; grid-template-columns: minmax(0, 0.8fr) minmax(0, 1.2fr); gap: clamp(18px, 3vw, 40px); }
.sp-tgt label { display: block; font-family: var(--font-mono); font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); }
.sp-tgt .row { display: flex; align-items: center; gap: 14px; margin-top: 10px; }
.sp-tgt input { flex: 1; accent-color: #e9a566; }
.sp-tgt output { font-family: var(--font-mono); font-size: 18px; color: var(--copper-hi); min-width: 3.2em; text-align: end; }
.sp-ind { margin-top: 16px; display: flex; gap: 10px; align-items: flex-start; font-size: 14px; line-height: 1.5; color: var(--text-mute); }
.sp-ind::before { content: ''; flex: none; width: 10px; height: 10px; margin-top: 6px; border-radius: 50%; background: var(--copper-hi); }
.sp-ind.ok::before { background: var(--signal); }
.sp-ind b { color: var(--text); font-weight: 500; }
.sp-contrib h4 { font-family: var(--font-mono); font-weight: 400; font-size: 11px; letter-spacing: 0.12em; text-transform: uppercase; color: var(--text-dim); margin-bottom: 10px; }
.sp-crow { display: grid; grid-template-columns: 130px minmax(0, 1fr) 38px; gap: 10px; align-items: center; font-size: 13px; color: var(--text-mute); padding: 3px 0; }
.sp-crow .t { height: 8px; border-radius: 4px; background: rgba(255,255,255,0.06); overflow: hidden; }
.sp-crow .t i { display: block; height: 100%; width: var(--v); background: var(--c); border-radius: 4px; }
.sp-crow .v { font-family: var(--font-mono); font-size: 11.5px; text-align: end; }

/* ---- Arabic ---- */
html[dir="rtl"] :is(.dm-bar, .dm-live, .sg-tag, .sg-io h4, .sg-play, .sp-tgt label, .sp-view .sp-tag, .sp-contrib h4, .sp-key) { letter-spacing: 0; }
html[dir="rtl"] :is(.dm-bar, .sg-tag, .sg-io h4, .sp-tgt label, .sp-view .sp-tag, .sp-contrib h4) { font-size: 12px; }
html[dir="rtl"] .sp-pick button span { font-size: 12px; }

/* ---- Responsive ---- */
@media (max-width: 960px) {
  .sg, .sp, .sp-plan { grid-template-columns: minmax(0, 1fr); }
  .sg-stage, .sp-pick { border-inline-end: 0; border-bottom: 1px solid rgba(255,255,255,0.08); }
  .sp-pick { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 560px) {
  .sg-io { grid-template-columns: minmax(0, 1fr); }
  .sg-n { font-size: 18px; }
  .sg-k { font-size: 12px; }
  .sp-row { grid-template-columns: 112px minmax(0, 1fr) 36px; gap: 8px; font-size: 12.5px; }
  .sp-crow { grid-template-columns: 104px minmax(0, 1fr) 34px; }
  .sp-pick button { padding: 9px 10px; column-gap: 9px; }
  .sp-pick button b { font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .sp-row .t i, .sp-row .t u, .sg-spoke, .sg-node circle { transition: none; }
  .sg-ln { animation: none; }
}
