/* ===================================================
   Homepage capabilities (side-scroll) visuals.
   Same language as the CMS diagram: neutral cards, sans labels,
   colour only where it means something. Motion: capabilities-viz.js
   Framework colours match the CMS diagram:
   ISO #8EC5FF · NCA #2DC882 · SAMA #F2C14E · NIST #B79CFF · PDPL #5EE0D0
   =================================================== */

.cap-run, .cap-heat, .cap-cycle, .cap-orbit {
  width: 100%;
  max-width: 500px;
  text-align: left;
}

/* shared card surface */
.cap-run, .cap-heat {
  padding: 20px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.03), rgba(255, 255, 255, 0.006)), #0B0B11;
  box-shadow: 0 40px 80px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.cap-run__who { display: grid; min-width: 0; }
.cap-run__who strong { font-size: 14px; font-weight: 600; color: var(--text-primary); line-height: 1.3; }
.cap-run__who small { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }

/* ---------- 1 · agent run ---------- */
.cap-run__head {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
}
.cap-run__avatar, .cap-run__doc {
  display: grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  color: var(--accent-primary);
  background: rgba(45, 200, 130, 0.09);
  border: 1px solid rgba(45, 200, 130, 0.22);
}
.cap-run__avatar svg, .cap-run__doc svg { width: 18px; height: 18px; }
.cap-run__state {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 4px 10px;
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
}
.cap-run__state i { width: 7px; height: 7px; border-radius: 50%; background: #FFB020; box-shadow: 0 0 8px rgba(255, 176, 32, 0.6); animation: cap-blink 1.2s ease-in-out infinite; }
.cap-run.is-done .cap-run__state i { background: var(--accent-primary); box-shadow: 0 0 8px rgba(45, 200, 130, 0.6); animation: none; }
@keyframes cap-blink { 50% { opacity: 0.35; } }

.cap-run__steps { list-style: none; margin: 0; padding: 18px 0 4px; display: grid; gap: 14px; }
.cap-step {
  position: relative;
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 12px;
}
/* rail between marks */
.cap-step:not(:last-child)::after {
  content: '';
  position: absolute;
  left: 11px;
  top: 26px;
  height: calc(100% - 12px);
  width: 1px;
  background: rgba(255, 255, 255, 0.08);
  transition: background 0.4s ease;
}
.cap-step.is-done:not(:last-child)::after { background: rgba(45, 200, 130, 0.45); }
.cap-step__mark {
  position: relative;
  display: grid;
  place-items: center;
  width: 23px;
  height: 23px;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #050508;
  transition: background 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}
.cap-step__mark svg { width: 11px; height: 11px; opacity: 0; transform: scale(0.5); transition: opacity 0.25s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1); }
.cap-step__spin {
  position: absolute;
  inset: -1px;
  border-radius: 50%;
  border: 1.5px solid transparent;
  border-top-color: var(--accent-primary);
  opacity: 0;
}
.cap-step.is-active .cap-step__spin { opacity: 1; animation: cap-spin 0.8s linear infinite; }
.cap-step.is-done .cap-step__mark { background: var(--accent-primary); border-color: transparent; box-shadow: 0 0 12px rgba(45, 200, 130, 0.35); }
.cap-step.is-done .cap-step__mark svg { opacity: 1; transform: none; }
@keyframes cap-spin { to { transform: rotate(360deg); } }

.cap-step__body { display: grid; min-width: 0; }
.cap-step__body strong { font-size: 13.5px; font-weight: 600; color: var(--text-tertiary); transition: color 0.3s ease; }
.cap-step__body small { font-size: 12px; color: var(--text-tertiary); opacity: 0.8; }
.cap-step.is-active .cap-step__body strong,
.cap-step.is-done .cap-step__body strong { color: var(--text-primary); }
.cap-step__out {
  font-size: 12px;
  color: var(--text-secondary);
  padding: 3px 9px;
  border-radius: var(--radius-pill);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.06);
  opacity: 0;
  transform: translateX(-6px);
  transition: opacity 0.35s ease, transform 0.35s ease;
  white-space: nowrap;
}
.cap-step.is-done .cap-step__out { opacity: 1; transform: none; }

.cap-run__result {
  margin-top: 18px;
  padding: 14px;
  border-radius: 14px;
  border: 1px solid rgba(45, 200, 130, 0.22);
  background: linear-gradient(180deg, rgba(45, 200, 130, 0.06), rgba(45, 200, 130, 0.01));
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.45s ease, transform 0.5s cubic-bezier(0.2, 0.7, 0.2, 1);
}
.cap-run.is-done .cap-run__result { opacity: 1; transform: none; }
.cap-run__report { display: grid; grid-template-columns: auto 1fr auto; align-items: center; gap: 12px; }
.cap-run__review {
  font-size: 12.5px;
  font-weight: 600;
  color: #050508;
  background: var(--accent-primary);
  padding: 6px 14px;
  border-radius: var(--radius-pill);
}
.cap-run__bar { display: flex; gap: 3px; height: 6px; margin-top: 14px; }
.cap-run__bar i { width: var(--w); border-radius: 3px; background: var(--c); opacity: 0.85; }
.cap-run__legend { display: flex; gap: 16px; margin-top: 9px; font-size: 12px; color: var(--text-tertiary); }
.cap-run__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cap-run__legend i { width: 7px; height: 7px; border-radius: 50%; background: var(--c); }

/* ---------- 2 · risk heatmap ---------- */
.cap-heat__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.cap-heat__count { font-size: 12px; color: var(--text-tertiary); white-space: nowrap; }
.cap-heat__count b { color: var(--text-primary); font-weight: 600; }
.cap-heat__body {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 8px 10px;
}
.cap-heat__ylab { writing-mode: vertical-rl; transform: rotate(180deg); justify-self: center; align-self: center; font-size: 11.5px; color: var(--text-tertiary); }
.cap-heat__xlab { grid-column: 2; justify-self: center; font-size: 11.5px; color: var(--text-tertiary); }
.cap-heat__grid {
  position: relative;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 4px;
  aspect-ratio: 1.25;
}
/* Severity shows as a tinted outline on a near-neutral fill (tinted fills read muddy on black). */
.cap-heat__cell {
  border-radius: 7px;
  background: color-mix(in srgb, var(--cell) var(--fill, 4%), #0C0C12);
  border: 1px solid color-mix(in srgb, var(--cell) var(--edge, 22%), transparent);
}
.cap-heat__cell--low  { --cell: #2DC882; --fill: 3%; --edge: 16%; }
.cap-heat__cell--med  { --cell: #F2C14E; --fill: 3%; --edge: 20%; }
.cap-heat__cell--high { --cell: #FF8A3D; --fill: 5%; --edge: 28%; }
.cap-heat__cell--crit { --cell: #FF4D4F; --fill: 8%; --edge: 38%; }

.cap-heat__risk {
  --lc: #2DC882;
  position: absolute;
  left: calc((var(--i) - 0.5) * 20%);
  top: calc((5.5 - var(--l)) * 20%);
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  margin: -15px 0 0 -15px;
  border-radius: 50%;
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-primary);
  background: color-mix(in srgb, var(--lc) 22%, #0B0B11);
  border: 1px solid color-mix(in srgb, var(--lc) 60%, transparent);
  box-shadow: 0 0 14px color-mix(in srgb, var(--lc) 30%, transparent);
  transition: left 1.1s cubic-bezier(0.65, 0, 0.35, 1), top 1.1s cubic-bezier(0.65, 0, 0.35, 1), background 0.6s ease, border-color 0.6s ease, box-shadow 0.6s ease, transform 0.45s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
}
.cap-heat__risk--med  { --lc: #F2C14E; }
.cap-heat__risk--high { --lc: #FF8A3D; }
.cap-heat__risk--crit { --lc: #FF4D4F; }
.cap-heat__risk.is-key { z-index: 2; }
.cap-heat__risk.is-key::after {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 1px solid color-mix(in srgb, var(--lc) 55%, transparent);
  animation: cap-ring 1.8s ease-out infinite;
}
@keyframes cap-ring { from { transform: scale(0.8); opacity: 1; } to { transform: scale(1.5); opacity: 0; } }
.cap-heat.is-reset .cap-heat__risk { transform: scale(0); opacity: 0; transition: none; }

.cap-heat__tip {
  position: absolute;
  left: calc((var(--i, 4) - 0.5) * 20%);
  top: calc((5.5 - var(--l, 5)) * 20%);
  z-index: 3;
  width: 150px;
  margin: -12px 0 0 -172px;
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(14, 14, 20, 0.92);
  backdrop-filter: blur(8px);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.5);
  opacity: 0;
  transform: translateY(6px);
  transition: left 1.1s cubic-bezier(0.65, 0, 0.35, 1), top 1.1s cubic-bezier(0.65, 0, 0.35, 1), margin 1.1s cubic-bezier(0.65, 0, 0.35, 1), opacity 0.35s ease, transform 0.35s ease;
}
.cap-heat__tip.is-on { opacity: 1; transform: none; }
.cap-heat__tip.is-treated { margin-top: -48px; }
.cap-heat__tip strong { display: block; font-size: 12.5px; font-weight: 600; color: var(--text-primary); }
.cap-heat__tip span { display: flex; justify-content: space-between; gap: 8px; margin-top: 4px; font-size: 11.5px; }
.cap-heat__tip b { font-weight: 500; color: var(--text-secondary); }
.cap-heat__tip em { font-style: normal; color: #FF4D4F; transition: color 0.4s ease; }
.cap-heat__tip.is-treated em { color: var(--accent-primary); }

.cap-heat__legend { display: flex; flex-wrap: wrap; gap: 14px; margin-top: 16px; padding-left: 22px; font-size: 12px; color: var(--text-tertiary); }
.cap-heat__legend span { display: inline-flex; align-items: center; gap: 6px; }
.cap-heat__legend i { width: 8px; height: 8px; border-radius: 3px; }
.lv-low  { background: #2DC882; }
.lv-med  { background: #F2C14E; }
.lv-high { background: #FF8A3D; }
.lv-crit { background: #FF4D4F; }

/* ---------- 3 · lifecycle ring ---------- */
.cap-cycle { position: relative; aspect-ratio: 600 / 440; max-width: 560px; }
.cap-cycle::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 50%;
  width: 46%;
  aspect-ratio: 1;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  background: radial-gradient(closest-side, rgba(45, 200, 130, 0.12), transparent);
  pointer-events: none;
}
.cap-cycle__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cap-cycle__track { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 1.2; }
/* glowing trail behind the pulse: two arcs, rotated by the script (circumference 880) */
.cap-cycle__trail { fill: none; stroke: #2DC882; stroke-width: 2; stroke-linecap: round; stroke-dasharray: 70 942; opacity: 0.9; filter: drop-shadow(0 0 4px rgba(45, 200, 130, 0.6)); }
.cap-cycle:not(.is-live) .cap-cycle__trail { visibility: hidden; }
.cap-cycle__trail--long { stroke-dasharray: 190 942; stroke-width: 1.5; opacity: 0.28; filter: none; }
.cap-cycle__gauge-bg { fill: rgba(11, 11, 17, 0.9); stroke: rgba(255, 255, 255, 0.06); stroke-width: 6; }
.cap-cycle__gauge {
  fill: none;
  stroke: var(--accent-primary);
  stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 465;
  stroke-dashoffset: 18.6;
  filter: drop-shadow(0 0 6px rgba(45, 200, 130, 0.45));
  transition: stroke-dashoffset 0.8s ease;
}
.cap-cycle__core {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  display: grid;
  justify-items: center;
  text-align: center;
}
.cap-cycle__core b { font-family: var(--font-display); font-size: clamp(26px, 3vw, 34px); font-weight: 700; letter-spacing: -0.02em; color: var(--text-primary); line-height: 1; }
.cap-cycle__core span { margin-top: 6px; font-size: 12px; color: var(--text-tertiary); }

.cap-cycle__stage { position: absolute; left: var(--x); top: var(--y); width: 0; height: 0; }
.cap-cycle__stage i {
  position: absolute;
  left: -7px;
  top: -7px;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: #0B0B11;
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  transition: border-color 0.4s ease, background 0.4s ease, box-shadow 0.4s ease;
}
.cap-cycle__stage > span { position: absolute; display: grid; width: 156px; gap: 2px; }
.cap-cycle__stage strong { font-size: 13px; font-weight: 600; color: var(--text-secondary); transition: color 0.4s ease; }
.cap-cycle__stage small { font-size: 11.5px; color: var(--text-tertiary); }
.cap-cycle__stage--t > span { left: -78px; bottom: 16px; text-align: center; }
.cap-cycle__stage--b > span { left: -78px; top: 16px; text-align: center; }
.cap-cycle__stage--r > span { left: 16px; top: -10px; width: 124px; }
.cap-cycle__stage--l > span { right: 16px; top: -10px; width: 124px; text-align: right; }
.cap-cycle__stage.is-hit i { border-color: var(--accent-primary); background: var(--accent-primary); box-shadow: 0 0 0 5px rgba(45, 200, 130, 0.15), 0 0 16px rgba(45, 200, 130, 0.6); }
.cap-cycle__stage.is-hit strong { color: var(--text-primary); }

/* ---------- 4 · Saudi core orbit ---------- */
.cap-orbit { position: relative; aspect-ratio: 480 / 440; }
.cap-orbit__svg { position: absolute; inset: 0; width: 100%; height: 100%; overflow: visible; }
.cap-orbit__core {
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 2;
  width: 38%;
  transform: translate(-50%, -50%);
  display: grid;
  gap: 7px;
  padding: 14px;
  border-radius: 18px;
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.035), rgba(255, 255, 255, 0.008)), #0B0B11;
  box-shadow: 0 30px 70px rgba(0, 0, 0, 0.55), 0 0 60px rgba(45, 200, 130, 0.06);
}
.cap-orbit__title { font-size: 12px; color: var(--text-tertiary); margin-bottom: 2px; }
.cap-orbit__fw {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  border-radius: 10px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(255, 255, 255, 0.02);
  transition: border-color 0.5s ease, box-shadow 0.5s ease;
}
.cap-orbit__fw > i { width: 8px; height: 8px; border-radius: 50%; background: var(--fw); box-shadow: 0 0 10px color-mix(in srgb, var(--fw) 55%, transparent); }
.cap-orbit__fw strong { font-size: 13px; font-weight: 600; color: var(--text-primary); }
.cap-orbit__fw.is-flash {
  border-color: color-mix(in srgb, var(--fw) 45%, transparent);
  box-shadow: 0 0 20px color-mix(in srgb, var(--fw) 14%, transparent);
  transition-duration: 0.15s;
}

.cap-orbit__node {
  --fw: rgba(234, 234, 240, 0.55);
  position: absolute;
  left: 50%;
  top: 50%;
  z-index: 1;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  transform: translate(-50%, -50%);
  border-radius: var(--radius-pill);
  border: 1px solid rgba(255, 255, 255, 0.09);
  background: #0D0D13;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-secondary);
  white-space: nowrap;
  transition: border-color 0.4s ease, color 0.4s ease;
}
.cap-orbit__node i { width: 6px; height: 6px; border-radius: 50%; background: var(--fw); }
.cap-orbit__node.is-send { border-color: rgba(255, 255, 255, 0.22); color: var(--text-primary); }

/* ---------- reduced motion: final states, no loops ---------- */
@media (prefers-reduced-motion: reduce) {
  .cap-run__state i, .cap-step__spin, .cap-heat__risk.is-key::after { animation: none !important; }
}

/* ---------- narrow visual column (phones, and tablets in the side-scroll) ----------
   Responds to the visual column's own width, not the screen's. */
.h-panel__visual { container: capviz / inline-size; }

@container capviz (max-width: 420px) {
  .cap-run, .cap-heat { padding: 16px; }
  .cap-cycle__stage > span { width: 112px; }
  .cap-cycle__stage--t > span, .cap-cycle__stage--b > span { left: -56px; }
  .cap-cycle__stage small { display: none; }
  .cap-cycle__stage strong { font-size: 11.5px; line-height: 1.3; }
  .cap-cycle__core b { font-size: 21px; }
  .cap-cycle__core span { font-size: 10px; margin-top: 3px; }
  .cap-cycle__stage--r > span { left: 10px; width: 72px; top: -8px; }
  .cap-cycle__stage--l > span { right: 10px; width: 72px; top: -8px; }
  .cap-orbit__core { width: 46%; padding: 12px; gap: 6px; }
  .cap-orbit__fw { padding: 6px 8px; gap: 8px; }
  .cap-orbit__node { font-size: 11px; padding: 4px 9px; }
  .cap-heat__tip { width: 128px; margin-left: -144px; padding: 7px 9px; }
  .cap-heat__tip.is-treated { margin-top: -40px; }
  .cap-heat__tip strong { font-size: 11px; white-space: nowrap; }
  .cap-heat__tip span { margin-top: 2px; font-size: 10.5px; gap: 4px; white-space: nowrap; }
}
